From 9a0c2664b0ca5634aa557b0761139cccfb0fe753 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 26 Mar 2024 18:36:09 +0100 Subject: Kernel: Add NewFS support: initial commit. Signed-off-by: Amlal El Mahrouss --- Private/FSKit/NewFS.hxx | 33 ++--- Private/KernelKit/FileManager.hpp | 3 +- Private/Source/NewFS+IO.cxx | 13 +- Public/Developer/System.Core/Headers/Defines.hxx | 35 ++++-- Public/Developer/System.Core/Headers/Dialog.hxx | 9 ++ Public/Developer/System.Core/Headers/Image.hxx | 9 ++ Public/Developer/System.Core/Headers/Menu.hxx | 9 ++ Public/Developer/System.Core/Headers/Rsrc.hxx | 9 ++ Public/Developer/System.Core/Headers/TrueType.hxx | 19 +++ Public/Developer/System.Core/Headers/Window.hxx | 140 +++++++++++++++++++++ .../System.Core/Headers/Window/Dialog.hxx | 9 -- .../Developer/System.Core/Headers/Window/Image.hxx | 9 -- .../Developer/System.Core/Headers/Window/Menu.hxx | 9 -- .../Developer/System.Core/Headers/Window/Rsrc.hxx | 9 -- .../System.Core/Headers/Window/TrueType.hxx | 9 -- .../System.Core/Headers/Window/Window.hxx | 131 ------------------- Public/Developer/System.Core/Sources/CRT0.cxx | 4 +- 17 files changed, 238 insertions(+), 221 deletions(-) create mode 100644 Public/Developer/System.Core/Headers/Dialog.hxx create mode 100644 Public/Developer/System.Core/Headers/Image.hxx create mode 100644 Public/Developer/System.Core/Headers/Menu.hxx create mode 100644 Public/Developer/System.Core/Headers/Rsrc.hxx create mode 100644 Public/Developer/System.Core/Headers/TrueType.hxx create mode 100644 Public/Developer/System.Core/Headers/Window.hxx delete mode 100644 Public/Developer/System.Core/Headers/Window/Dialog.hxx delete mode 100644 Public/Developer/System.Core/Headers/Window/Image.hxx delete mode 100644 Public/Developer/System.Core/Headers/Window/Menu.hxx delete mode 100644 Public/Developer/System.Core/Headers/Window/Rsrc.hxx delete mode 100644 Public/Developer/System.Core/Headers/Window/TrueType.hxx delete mode 100644 Public/Developer/System.Core/Headers/Window/Window.hxx diff --git a/Private/FSKit/NewFS.hxx b/Private/FSKit/NewFS.hxx index 8e306180..9645d29c 100644 --- a/Private/FSKit/NewFS.hxx +++ b/Private/FSKit/NewFS.hxx @@ -21,7 +21,7 @@ #include /** - @brief New File System. + @brief New File System specification. @author Amlal EL Mahrouss */ @@ -89,34 +89,15 @@ typedef HCore::Char NewCharType; enum { - kNewFSHardDrive = 0xC0, // Hard Drive + kNewFSHardDrive = 0xC0, // Hard Drive (SSD, HDD) kNewFSOpticalDrive = 0x0C, // Blu-Ray/DVD kNewFSMassStorageDevice = 0xCC, // USB - kNewFSUnknown = 0xFF, // unknown device or unsupported (floppy) - kNewFSDriveCount = 4, + kNewFSScsi = 0xC4, // SCSI Hard Drive + kNewFSUnknown = 0xFF, // Unknown device. (floppy) + kNewFSDriveCount = 5, }; -/// @brief NewFS filesystem block. -/// @author Amlal El Mahrouss. -struct PACKED NewBootBlock final { - NewCharType Ident[kNewFSIdentLen]; - NewCharType Shell[kNewFSNodeNameLen]; - - HCore::Int64 NumParts; // number of sub-partitions. - HCore::Int64 FreeSectors; - HCore::Int64 SectorCount; - HCore::Int64 SectorSz; - - HCore::Int64 DiskSize; // size of media. - HCore::Int32 DiskKind; // kind of disk. - - HCore::Lba FirstPartBlock; - HCore::Lba LastPartBlock; - - NewCharType Pad[kNewFSPadLen]; -}; - -/// @brief File catalog type. +/// @brief Ccatalog type. struct PACKED NewCatalog final { NewCharType Name[kNewFSNodeNameLen]; @@ -130,7 +111,7 @@ struct PACKED NewCatalog final { HCore::Lba PrevSibling; }; -/// @brief File fork type. +/// @brief Fork type. struct PACKED NewFork final { NewCharType Name[kNewFSNodeNameLen]; diff --git a/Private/KernelKit/FileManager.hpp b/Private/KernelKit/FileManager.hpp index 7af1ab0d..d02c087c 100644 --- a/Private/KernelKit/FileManager.hpp +++ b/Private/KernelKit/FileManager.hpp @@ -27,8 +27,9 @@ /// Main filesystem abstraction manager. #define kBootFolder "/Boot" -#define kBinFolder "/Programs" +#define kBinFolder "/Applications" #define kShLibsFolder "/Library" +#define kMountFolder "/Mount" /// refer to first enum. #define kFileOpsCount 4 diff --git a/Private/Source/NewFS+IO.cxx b/Private/Source/NewFS+IO.cxx index a62970e7..1fd85dd8 100644 --- a/Private/Source/NewFS+IO.cxx +++ b/Private/Source/NewFS+IO.cxx @@ -7,11 +7,16 @@ #include #include -/** --------------------------------------------------- +/************************************************************* + * + * File: NewFS+IO.cxx + * Purpose: Filesystem to mountpoint interface. + * Date: 3/26/24 + * + * Copyright Mahrouss Logic, all rights reserved. + * + *************************************************************/ - * THIS FILE CONTAINS CODE FOR THE HCFS I/O DEVICES. - -------------------------------------------------------- */ #ifdef __FSKIT_NEWFS__ diff --git a/Public/Developer/System.Core/Headers/Defines.hxx b/Public/Developer/System.Core/Headers/Defines.hxx index 9d6d84ee..55810d9d 100644 --- a/Public/Developer/System.Core/Headers/Defines.hxx +++ b/Public/Developer/System.Core/Headers/Defines.hxx @@ -6,16 +6,12 @@ #pragma once -#ifndef __cplusplus -#error This API is meant to be used with C++. -#endif - #ifdef CA_MUST_PASS #undef CA_MUST_PASS #endif #ifdef _DEBUG -#define CA_MUST_PASS(e) { if (!e) { __assert_chk_fail() } } +#define CA_MUST_PASS(e) { if (!e) { MsgBox("Sorry, ssertion failed.\nFile: %s\nLine: %i", __FILE__, __LINE__) __assert_chk_fail() } } #else #define CA_MUST_PASS(e) CA_UNREFERENCED_PARAMETER(e) #endif @@ -153,7 +149,7 @@ enum { * @brief GUID type, something you can also find in CFKit. * @author AMlal El Mahrouss */ -typedef struct GUID final { +typedef struct GUID { DWordType Data1; WordType Data2; WordType Data3; @@ -162,23 +158,38 @@ typedef struct GUID final { /// \brief Object handle. /// \author Amlal El Mahrouss -typedef struct Object final { - CharacterTypeUTF8 ObjectName[255]; - DWordType ObjectType; - CharacterTypeUTF8 ObjectNamespace[255]; +typedef struct Object { + CharacterTypeUTF8 Name[255]; + DWordType Kind; + DWordType Flags; VoidType(*Release)(struct Object* Self); IntPtrType(*Invoke)(struct Object* Self, DWordType Sel, ...); VoidType(*Query)(struct Object* Self, PtrVoidType* Dst, SizeType SzDst, struct GUID* GuidOf); } *ObjectRef; +#ifdef __cplusplus + #define object_cast reinterpret_cast +template +using StrType = CharacterTypeUTF8[N]; + +#else + +#define object_cast (ObjectRef) + +#endif // ifdef C++ + CA_EXTERN_C ObjectRef HcGetAppObject(VoidType); CA_INLINE ObjectRef kApplicationObject; typedef CharacterTypeUTF8 Str255Type[255]; -template -using StrType = CharacterTypeUTF8[N]; +/// @brief Shows an message box with a formatting. +/// @param title the message box title +/// @param format the format +/// @param va_list the va args, that goes along with it. +/// @return void +CA_EXTERN_C VoidType MsgBox(CharacterTypeUTF8* title, CharacterTypeUTF8* format, ...); diff --git a/Public/Developer/System.Core/Headers/Dialog.hxx b/Public/Developer/System.Core/Headers/Dialog.hxx new file mode 100644 index 00000000..0fc4e738 --- /dev/null +++ b/Public/Developer/System.Core/Headers/Dialog.hxx @@ -0,0 +1,9 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include diff --git a/Public/Developer/System.Core/Headers/Image.hxx b/Public/Developer/System.Core/Headers/Image.hxx new file mode 100644 index 00000000..0fc4e738 --- /dev/null +++ b/Public/Developer/System.Core/Headers/Image.hxx @@ -0,0 +1,9 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include diff --git a/Public/Developer/System.Core/Headers/Menu.hxx b/Public/Developer/System.Core/Headers/Menu.hxx new file mode 100644 index 00000000..0fc4e738 --- /dev/null +++ b/Public/Developer/System.Core/Headers/Menu.hxx @@ -0,0 +1,9 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include diff --git a/Public/Developer/System.Core/Headers/Rsrc.hxx b/Public/Developer/System.Core/Headers/Rsrc.hxx new file mode 100644 index 00000000..0fc4e738 --- /dev/null +++ b/Public/Developer/System.Core/Headers/Rsrc.hxx @@ -0,0 +1,9 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include diff --git a/Public/Developer/System.Core/Headers/TrueType.hxx b/Public/Developer/System.Core/Headers/TrueType.hxx new file mode 100644 index 00000000..14a85823 --- /dev/null +++ b/Public/Developer/System.Core/Headers/TrueType.hxx @@ -0,0 +1,19 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include + +/************************************************************* + * + * File: TrueType.hxx + * Purpose: TrueType font implementation for System Software. + * Date: 3/26/24 + * + * Copyright Mahrouss Logic, all rights reserved. + * + *************************************************************/ diff --git a/Public/Developer/System.Core/Headers/Window.hxx b/Public/Developer/System.Core/Headers/Window.hxx new file mode 100644 index 00000000..02be0681 --- /dev/null +++ b/Public/Developer/System.Core/Headers/Window.hxx @@ -0,0 +1,140 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include + +/************************************************************* + * + * File: Window.hxx + * Purpose: Window Manager implementation for System Software. + * Date: 3/26/24 + * + * Copyright Mahrouss Logic, all rights reserved. + * + *************************************************************/ + +struct _GraphicsPoint; +struct _GraphicsPort; + +typedef float PositionType; + +/// @brief A point, can represent the size, position of a window. +typedef struct _GraphicsPoint { + PositionType X, Y; +} GraphicsPoint; + +/// @brief Tracker Graphics port. +typedef struct _GraphicsPort { + WordType windowPort; + WordType windowKind; + BooleanType windowVisible; + BooleanType windowMaximized; + BooleanType windowMinimized; + BooleanType windowMoving; + BooleanType windowDisableClose; + BooleanType windowDisableMinimize; + GraphicsPoint windowPosition; + GraphicsPoint windowSize; + BooleanType windowInvalidate; + DWordType windowClearColor; + WordType menuPort; + WordType parentPort; +} GraphicsPort; + +typedef UInt32Type ColorRef; + +/***********************************************************************************/ +/// Color utils. +/***********************************************************************************/ + +const ColorRef kRgbRed = 0x000000FF; +const ColorRef kRgbGreen = 0x0000FF00; +const ColorRef kRgbBlue = 0x00FF0000; +const ColorRef kRgbBlack = 0x00000000; +const ColorRef kRgbWhite = 0xFFFFFFFF; + +/***********************************************************************************/ +/// Color macro. +/***********************************************************************************/ + +#define RGB32(R, G, B) (ColorRef)(0x##R##G##B) + +#define kGraphicsKindWindow 0 +#define kGraphicsKindDialog 1 +#define kGraphicsKindMenu 2 +#define kGraphicsKindButton 3 +#define kGraphicsKindLabel 4 +#define kGraphicsKindDropdown 5 +#define kGraphicsKindIcon 6 +#define kGraphicsKindRadio 7 +#define kGraphicsKindCheck 7 + +typedef QWordType ControlRef; + +/// @brief Creates a new control +/// @param id the control rsrc fork. +/// @return +CA_EXTERN_C ControlRef CreateControl(const DWordType id); + +/// @brief Releases the control +/// @param id the control ref. +/// @return +CA_EXTERN_C VoidType ReleaseControl(const ControlRef id); + +/// @brief Moves a control inside a GraphicsPort. +/// @param id the control ref. +/// @param where where to move at. +/// @return +CA_EXTERN_C Int32Type SetControlPosition(const ControlRef id, GraphicsPoint where); + +/// @brief Enable control. +/// @param id +/// @param enabled +/// @return +CA_EXTERN_C Int32Type SetControlEnabled(const ControlRef id, BooleanType enabled); + +/// @brief Make control visible. +/// @param id +/// @param visible +/// @return +CA_EXTERN_C Int32Type MakeControlVisible(const ControlRef id, BooleanType visible); + +/// @brief Creates a new window. +/// @param name the window name +/// @param rsrcId the window fork rsrc id. +/// @return the window graphics port. +CA_EXTERN_C GraphicsPort* CreateWindow(const char* name, const DWordType rsrcId); + +/// @brief Creates a new menu +/// @param name the menu's name +/// @param rsrcId the menu fork rsrc id. +/// @return the menu graphics port. +CA_EXTERN_C GraphicsPort* CreateMenu(const char* name, const DWordType rsrcId); + +/// @brief Releases the window. +/// @param port the window port. +/// @return void +CA_EXTERN_C VoidType ReleaseWindow(GraphicsPort* port); + +/// @brief Releases the menu +/// @param port the menu port. +/// @return void +CA_EXTERN_C VoidType ReleaseMenu(GraphicsPort* port); + +/// @brief Moves a window on the desktop. (menu arent movable, will return kErrIncompatible is menu is provided.) +/// @param id the gfx port. +/// @param where to move. +/// @return error code. +CA_EXTERN_C Int32Type MoveWindow(const GraphicsPort* id, GraphicsPoint where); + +enum { + kWinErrIncompatible = 0x74, + kWinErrOutOfMemory, + kWinErrInvalidArg, + kWinErrNotImplemented, +}; diff --git a/Public/Developer/System.Core/Headers/Window/Dialog.hxx b/Public/Developer/System.Core/Headers/Window/Dialog.hxx deleted file mode 100644 index 3e445532..00000000 --- a/Public/Developer/System.Core/Headers/Window/Dialog.hxx +++ /dev/null @@ -1,9 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#include diff --git a/Public/Developer/System.Core/Headers/Window/Image.hxx b/Public/Developer/System.Core/Headers/Window/Image.hxx deleted file mode 100644 index 3e445532..00000000 --- a/Public/Developer/System.Core/Headers/Window/Image.hxx +++ /dev/null @@ -1,9 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#include diff --git a/Public/Developer/System.Core/Headers/Window/Menu.hxx b/Public/Developer/System.Core/Headers/Window/Menu.hxx deleted file mode 100644 index 3e445532..00000000 --- a/Public/Developer/System.Core/Headers/Window/Menu.hxx +++ /dev/null @@ -1,9 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#include diff --git a/Public/Developer/System.Core/Headers/Window/Rsrc.hxx b/Public/Developer/System.Core/Headers/Window/Rsrc.hxx deleted file mode 100644 index 3e445532..00000000 --- a/Public/Developer/System.Core/Headers/Window/Rsrc.hxx +++ /dev/null @@ -1,9 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#include diff --git a/Public/Developer/System.Core/Headers/Window/TrueType.hxx b/Public/Developer/System.Core/Headers/Window/TrueType.hxx deleted file mode 100644 index 3e445532..00000000 --- a/Public/Developer/System.Core/Headers/Window/TrueType.hxx +++ /dev/null @@ -1,9 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#include diff --git a/Public/Developer/System.Core/Headers/Window/Window.hxx b/Public/Developer/System.Core/Headers/Window/Window.hxx deleted file mode 100644 index 4c79d50b..00000000 --- a/Public/Developer/System.Core/Headers/Window/Window.hxx +++ /dev/null @@ -1,131 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#include - -/// @file Window.hxx -/// @brief Tracker window protocol. -/// @author Amlal El Mahrouss. - -typedef float PositionType; - -/// @brief A point, can represent the size, position of a window. -typedef struct _GraphicsPoint { - PositionType X, Y; -} GraphicsPoint; - -/// @brief Tracker Graphics port. -typedef struct _GraphicsPort { - WordType windowPort; - WordType windowKind; - BooleanType windowVisible; - BooleanType windowMaximized; - BooleanType windowMinimized; - BooleanType windowMoving; - BooleanType windowDisableClose; - BooleanType windowDisableMinimize; - GraphicsPoint windowPosition; - GraphicsPoint windowSize; - BooleanType windowInvalidate; - DWordType windowClearColor; - WordType menuPort; - WordType parentPort; -} GraphicsPort; - -typedef UInt32Type ColorRef; - -/***********************************************************************************/ -/// Color utils. -/***********************************************************************************/ - -const ColorRef kRgbRed = 0x000000FF; -const ColorRef kRgbGreen = 0x0000FF00; -const ColorRef kRgbBlue = 0x00FF0000; -const ColorRef kRgbBlack = 0x00000000; -const ColorRef kRgbWhite = 0xFFFFFFFF; - -/***********************************************************************************/ -/// Color macro. -/***********************************************************************************/ - -#define RGB32(R, G, B) (ColorRef)(0x##R##G##B) - -#define kGraphicsKindWindow 0 -#define kGraphicsKindDialog 1 -#define kGraphicsKindMenu 2 -#define kGraphicsKindButton 3 -#define kGraphicsKindLabel 4 -#define kGraphicsKindDropdown 5 -#define kGraphicsKindIcon 6 -#define kGraphicsKindRadio 7 -#define kGraphicsKindCheck 7 - -typedef QWordType ControlRef; - -/// @brief Creates a new control -/// @param id the control rsrc fork. -/// @return -CA_EXTERN_C ControlRef CreateControl(const DWordType id); - -/// @brief Releases the control -/// @param id the control ref. -/// @return -CA_EXTERN_C VoidType ReleaseControl(const ControlRef id); - -/// @brief Moves a control inside a GraphicsPort. -/// @param id the control ref. -/// @param where where to move at. -/// @return -CA_EXTERN_C Int32Type SetControlPosition(const ControlRef id, GraphicsPoint where); - -/// @brief Enable control. -/// @param id -/// @param enabled -/// @return -CA_EXTERN_C Int32Type SetControlEnabled(const ControlRef id, BooleanType enabled); - -/// @brief Make control visible. -/// @param id -/// @param visible -/// @return -CA_EXTERN_C Int32Type MakeControlVisible(const ControlRef id, BooleanType visible); - -/// @brief Creates a new window. -/// @param name the window name -/// @param rsrcId the window fork rsrc id. -/// @return the window graphics port. -CA_EXTERN_C GraphicsPort* CreateWindow(const char* name, const DWordType rsrcId); - -/// @brief Creates a new menu -/// @param name the menu's name -/// @param rsrcId the menu fork rsrc id. -/// @return the menu graphics port. -CA_EXTERN_C GraphicsPort* CreateMenu(const char* name, const DWordType rsrcId); - -/// @brief Releases the window. -/// @param port the window port. -/// @return void -CA_EXTERN_C VoidType ReleaseWindow(GraphicsPort* port); - -/// @brief Releases the menu -/// @param port the menu port. -/// @return void -CA_EXTERN_C VoidType ReleaseMenu(GraphicsPort* port); - -/// @brief Moves a window on the desktop. (menu arent movable, will return kErrIncompatible is menu is provided.) -/// @param id the gfx port. -/// @param where to move. -/// @return error code. -CA_EXTERN_C Int32Type MoveWindow(const GraphicsPort* id, GraphicsPoint where); - -enum { - kWinErrIncompatible = 0x74, - kWinErrOutOfMemory, - kWinErrInvalidArg, - kWinErrNotImplemented, -}; diff --git a/Public/Developer/System.Core/Sources/CRT0.cxx b/Public/Developer/System.Core/Sources/CRT0.cxx index a0235e68..b6fb9de1 100644 --- a/Public/Developer/System.Core/Sources/CRT0.cxx +++ b/Public/Developer/System.Core/Sources/CRT0.cxx @@ -4,9 +4,9 @@ #include -/// @brief Inits the DLL. +/// @brief Inits the library. /// @return if it was succesful or not. -CA_EXTERN_C DWordType __DllMain(VoidType) { +CA_EXTERN_C DWordType __start(VoidType) { kApplicationObject = HcGetAppObject(); CA_MUST_PASS(kApplicationObject); -- cgit v1.2.3