From 98b24c3a90d3c97a06cb553d08369943605efbe0 Mon Sep 17 00:00:00 2001 From: Amlal Date: Sat, 30 Nov 2024 19:48:33 +0100 Subject: META: Add new error code for CD trays. New Power mgmt and CD-ROM API. Also format code. Signed-off-by: Amlal --- dev/SCIKit/Foundation.h | 19 +++++++++++++++++++ dev/SCIKit/LPC.h | 1 + dev/SCIKit/src/Makefile | 2 +- dev/ZKAKit/FSKit/NeFS.h | 14 +++++++------- dev/ZKAKit/FirmwareKit/EFI/EFI.h | 18 +++++++++--------- dev/ZKAKit/HALKit/AMD64/Storage/AHCI-DMA.cc | 6 +++--- dev/ZKAKit/KernelKit/DriveMgr.h | 1 - dev/ZKAKit/KernelKit/LPC.h | 1 + dev/ZKAKit/KernelKit/LoaderInterface.h | 6 +++--- dev/ZKAKit/KernelKit/ThreadLocalStorage.h | 2 +- dev/ZKAKit/KernelKit/ThreadLocalStorage.inl | 2 +- dev/ZKAKit/KernelKit/UserProcessScheduler.h | 2 +- dev/ZKAKit/src/FS/NeFS.cc | 14 +++++++------- 13 files changed, 54 insertions(+), 34 deletions(-) (limited to 'dev') diff --git a/dev/SCIKit/Foundation.h b/dev/SCIKit/Foundation.h index ba186511..039fe6ce 100644 --- a/dev/SCIKit/Foundation.h +++ b/dev/SCIKit/Foundation.h @@ -208,4 +208,23 @@ IMPORT_C Void EvtRemoveListener(_Input const Char* event_name, _Input SCIObject /// @return the event data. IMPORT_C VoidPtr EvtDispatchEvent(_Input const Char* event_name, _Input VoidPtr event_data); +// ------------------------------------------------------------------------------------------ // +// Power API. +// ------------------------------------------------------------------------------------------ // + +IMPORT_C Void PwrShutdownMachine(const Char* _Input msg, _Input SInt32 code); +IMPORT_C Void PwrRebootMachine(const Char* _Input msg, _Input SInt32 code); +IMPORT_C Void PwrSleepMachine(const Char* _Input msg, _Input SInt32 code); + +IMPORT_C SInt32 PwrGetCode(_Output SInt32& code); + +// ------------------------------------------------------------------------------------------ // +// CD-ROM API. +// ------------------------------------------------------------------------------------------ // + +IMPORT_C SInt32 CdEjectDrive(_Input const Char drv_letter); + +IMPORT_C SInt32 CdOpenTray(Void); +IMPORT_C SInt32 CdCloseTray(Void); + #endif // ifndef SCIKIT_FOUNDATION_H diff --git a/dev/SCIKit/LPC.h b/dev/SCIKit/LPC.h index 918cab17..4f2a4e86 100644 --- a/dev/SCIKit/LPC.h +++ b/dev/SCIKit/LPC.h @@ -47,6 +47,7 @@ inline constexpr ErrObject kErrorNonBlocking = 58; inline constexpr ErrObject kErrorIPC = 59; inline constexpr ErrObject kErrorSign = 60; inline constexpr ErrObject kErrorInvalidCreds = 61; +inline constexpr ErrObject kErrorCDTrayBroken = 62; inline constexpr ErrObject kErrorUnimplemented = 0; /// @brief The last error reported by the system to the process. diff --git a/dev/SCIKit/src/Makefile b/dev/SCIKit/src/Makefile index e7daa038..588f233a 100644 --- a/dev/SCIKit/src/Makefile +++ b/dev/SCIKit/src/Makefile @@ -1,5 +1,5 @@ ################################################## -# (c) EL Mahrouss Logic, all rights reserved. +# (c) ELMH Group, all rights reserved. # This is the bootloader makefile. ################################################## diff --git a/dev/ZKAKit/FSKit/NeFS.h b/dev/ZKAKit/FSKit/NeFS.h index a0b70e00..efd42107 100644 --- a/dev/ZKAKit/FSKit/NeFS.h +++ b/dev/ZKAKit/FSKit/NeFS.h @@ -23,7 +23,7 @@ default. /** @brief New File System specification. - @author ELMH Group + @author ELMH Group (Amlal EL Mahrouss amlalelmahrouss at icloud dot com) */ #define kNeFSInvalidFork (-1) @@ -239,15 +239,15 @@ namespace Kernel /// @param theFork the fork itself. /// @return the fork _Output NFS_FORK_STRUCT* CreateFork(_Input NFS_CATALOG_STRUCT* catalog, - _Input NFS_FORK_STRUCT& theFork); + _Input NFS_FORK_STRUCT& theFork); /// @brief Find fork inside New filesystem. /// @param catalog the catalog. /// @param name the fork name. /// @return the fork. _Output NFS_FORK_STRUCT* FindFork(_Input NFS_CATALOG_STRUCT* catalog, - _Input const Char* name, - Boolean dataOrRsrc); + _Input const Char* name, + Boolean dataOrRsrc); _Output Void RemoveFork(_Input NFS_FORK_STRUCT* fork); @@ -257,7 +257,7 @@ namespace Kernel _Output NFS_CATALOG_STRUCT* GetCatalog(_Input const Char* name); - _Output NFS_CATALOG_STRUCT* CreateCatalog(_Input const Char* name, + _Output NFS_CATALOG_STRUCT* CreateCatalog(_Input const Char* name, _Input const Int32& flags, _Input const Int32& kind); @@ -267,12 +267,12 @@ namespace Kernel _Input Bool isRsrcFork, _Input VoidPtr data, _Input SizeT sizeOfData, - _Input const Char* forkName); + _Input const Char* forkName); VoidPtr ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, _Input Bool isRsrcFork, _Input SizeT dataSz, - _Input const Char* forkName); + _Input const Char* forkName); bool Seek(_Input _Output NFS_CATALOG_STRUCT* catalog, SizeT off); diff --git a/dev/ZKAKit/FirmwareKit/EFI/EFI.h b/dev/ZKAKit/FirmwareKit/EFI/EFI.h index 2905678a..523e2156 100644 --- a/dev/ZKAKit/FirmwareKit/EFI/EFI.h +++ b/dev/ZKAKit/FirmwareKit/EFI/EFI.h @@ -823,11 +823,11 @@ typedef struct _EfiProcessorInformation typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS)( IN struct _EfiMpServicesProtocol* Self, - OUT UInt32* NumberOfProcessors, - OUT UInt32* NumberOfEnabledProcessors); + OUT UInt32* NumberOfProcessors, + OUT UInt32* NumberOfEnabledProcessors); typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_GET_PROCESSOR_INFO)( - IN struct _EfiMpServicesProtocol* Self, + IN struct _EfiMpServicesProtocol* Self, IN UInt32* ProcessorNumber, OUT struct _EfiProcessorInformation* NumberOfEnabledProcessors); @@ -842,8 +842,8 @@ typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_STARTUP_ALL_APS)( IN Boolean SingleThread, IN VoidPtr WaitEvent OPTIONAL, // EFI_EVENT first, but unused here. IN UInt32 TimeoutInMicroSeconds, - IN Void* ProcedureArgument OPTIONAL, - OUT UInt32** FailedCpuList OPTIONAL); + IN Void* ProcedureArgument OPTIONAL, + OUT UInt32** FailedCpuList OPTIONAL); typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_SWITCH_BSP)( IN struct _EfiMpServicesProtocol* This, @@ -856,18 +856,18 @@ typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_STARTUP_THIS_AP)( IN UInt32 ProcessorNumber, IN VoidPtr WaitEvent OPTIONAL, IN UInt32 TimeoutInMicroseconds, - IN Void* ProcedureArgument OPTIONAL, - OUT Boolean* Finished OPTIONAL); + IN Void* ProcedureArgument OPTIONAL, + OUT Boolean* Finished OPTIONAL); typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_ENABLEDISABLEAP)( IN struct _EfiMpServicesProtocol* This, IN UInt32 ProcessorNumber, IN Boolean EnableAP, - IN UInt32* HealthFlag OPTIONAL); + IN UInt32* HealthFlag OPTIONAL); typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_WHOAMI)( IN struct _EfiMpServicesProtocol* This, - OUT UInt32* ProcessorNumber); + OUT UInt32* ProcessorNumber); typedef struct _EfiMpServicesProtocol { diff --git a/dev/ZKAKit/HALKit/AMD64/Storage/AHCI-DMA.cc b/dev/ZKAKit/HALKit/AMD64/Storage/AHCI-DMA.cc index 53944613..179bc593 100644 --- a/dev/ZKAKit/HALKit/AMD64/Storage/AHCI-DMA.cc +++ b/dev/ZKAKit/HALKit/AMD64/Storage/AHCI-DMA.cc @@ -49,7 +49,7 @@ enum }; STATIC Kernel::PCI::Device kAhciDevice; -STATIC HbaPort* kAhciPort = nullptr; +STATIC HbaPort* kAhciPort = nullptr; STATIC Kernel::Lba kCurrentDiskSectorCount = 0UL; Kernel::Void drv_calculate_disk_geometry() @@ -221,13 +221,13 @@ Kernel::Void drv_std_read(Kernel::UInt64 lba, Kernel::Char* buffer, Kernel::Size for (int i = 0; i < cmd_hdr->Prdtl - 1; i++) { cmd_tbl->PrdtEntries[i].Dba = (Kernel::UInt32)(Kernel::UInt64)buffer; - cmd_tbl->PrdtEntries[i].Dbau = (Kernel::UInt32)((Kernel::UInt64)(buffer) >> 32); + cmd_tbl->PrdtEntries[i].Dbau = (Kernel::UInt32)((Kernel::UInt64)(buffer) >> 32); cmd_tbl->PrdtEntries[i].Dbc = size_buffer - 1; // 8K bytes (this value should always be set to 1 less than the actual value) cmd_tbl->PrdtEntries[i].InterruptBit = 1; } cmd_tbl->PrdtEntries[i].Dba = (Kernel::UInt32)(Kernel::UInt64)buffer; - cmd_tbl->PrdtEntries[i].Dbau = (Kernel::UInt32)((Kernel::UInt64)(buffer) >> 32); + cmd_tbl->PrdtEntries[i].Dbau = (Kernel::UInt32)((Kernel::UInt64)(buffer) >> 32); cmd_tbl->PrdtEntries[i].Dbc = size_buffer - 1; // 8K bytes (this value should always be set to 1 less than the actual value) cmd_tbl->PrdtEntries[i].InterruptBit = 1; diff --git a/dev/ZKAKit/KernelKit/DriveMgr.h b/dev/ZKAKit/KernelKit/DriveMgr.h index ffad6feb..a8a410ba 100644 --- a/dev/ZKAKit/KernelKit/DriveMgr.h +++ b/dev/ZKAKit/KernelKit/DriveMgr.h @@ -145,7 +145,6 @@ namespace Kernel private: DriveTrait mA, mB, mC, mD; - }; /// @brief Unimplemented drive. diff --git a/dev/ZKAKit/KernelKit/LPC.h b/dev/ZKAKit/KernelKit/LPC.h index 2bf54dd7..68bc9196 100644 --- a/dev/ZKAKit/KernelKit/LPC.h +++ b/dev/ZKAKit/KernelKit/LPC.h @@ -55,6 +55,7 @@ namespace Kernel inline constexpr HError kErrorIPC = 59; inline constexpr HError kErrorSign = 60; inline constexpr HError kErrorInvalidCreds = 61; + inline constexpr HError kErrorCDTrayBroken = 62; inline constexpr HError kErrorUnimplemented = 0; /// @brief Raises a bug check stop code. diff --git a/dev/ZKAKit/KernelKit/LoaderInterface.h b/dev/ZKAKit/KernelKit/LoaderInterface.h index a95aae4e..dc9bc477 100644 --- a/dev/ZKAKit/KernelKit/LoaderInterface.h +++ b/dev/ZKAKit/KernelKit/LoaderInterface.h @@ -25,9 +25,9 @@ namespace Kernel public: virtual _Output ErrorOr GetBlob() = 0; - virtual _Output const Char* AsString() = 0; - virtual _Output const Char* MIME() = 0; - virtual _Output const Char* Path() = 0; + virtual _Output const Char* AsString() = 0; + virtual _Output const Char* MIME() = 0; + virtual _Output const Char* Path() = 0; virtual _Output ErrorOr FindStart() = 0; virtual _Output VoidPtr FindSymbol(_Input const Char* name, _Input Int32 kind) = 0; }; diff --git a/dev/ZKAKit/KernelKit/ThreadLocalStorage.h b/dev/ZKAKit/KernelKit/ThreadLocalStorage.h index 18cdbdd8..93e0a9a4 100644 --- a/dev/ZKAKit/KernelKit/ThreadLocalStorage.h +++ b/dev/ZKAKit/KernelKit/ThreadLocalStorage.h @@ -24,7 +24,7 @@ struct THREAD_INFORMATION_BLOCK; struct PACKED THREAD_INFORMATION_BLOCK final { Kernel::Char Cookie[kTLSCookieLen]{0}; //! Thread magic number. - Kernel::VoidPtr Record{nullptr}; //! Thread information record. + Kernel::VoidPtr Record{nullptr}; //! Thread information record. }; ///! @brief Cookie Sanity check. diff --git a/dev/ZKAKit/KernelKit/ThreadLocalStorage.inl b/dev/ZKAKit/KernelKit/ThreadLocalStorage.inl index 1ae3d5cd..d9850c01 100644 --- a/dev/ZKAKit/KernelKit/ThreadLocalStorage.inl +++ b/dev/ZKAKit/KernelKit/ThreadLocalStorage.inl @@ -72,7 +72,7 @@ template inline Kernel::Bool tls_delete_class(T* obj) { using namespace Kernel; - + if (!obj) return No; diff --git a/dev/ZKAKit/KernelKit/UserProcessScheduler.h b/dev/ZKAKit/KernelKit/UserProcessScheduler.h index e7b023ed..dbadc9d8 100644 --- a/dev/ZKAKit/KernelKit/UserProcessScheduler.h +++ b/dev/ZKAKit/KernelKit/UserProcessScheduler.h @@ -20,7 +20,7 @@ #define kSchedMaxStackSz mib_cast(8) #define kProcessInvalidID (-1) -#define kProcessNameLen (128U) +#define kProcessNameLen (128U) //////////////////////////////////////////////////// // The current date is: Thu 11/28/2024 // diff --git a/dev/ZKAKit/src/FS/NeFS.cc b/dev/ZKAKit/src/FS/NeFS.cc index 76b702bb..e1a844c6 100644 --- a/dev/ZKAKit/src/FS/NeFS.cc +++ b/dev/ZKAKit/src/FS/NeFS.cc @@ -7,6 +7,7 @@ #ifdef __FSKIT_INCLUDES_NEFS__ #include +#include #include #include @@ -16,7 +17,6 @@ #include #include #include -#include #include #include @@ -61,7 +61,7 @@ STATIC MountpointInterface kDiskMountpoint; /// @return the fork /***********************************************************************************/ _Output NFS_FORK_STRUCT* NeFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* catalog, - _Input NFS_FORK_STRUCT& the_fork) + _Input NFS_FORK_STRUCT& the_fork) { if (catalog && the_fork.ForkName[0] != 0 && the_fork.DataSize <= kNeFSForkDataSz) @@ -170,8 +170,8 @@ _Output NFS_FORK_STRUCT* NeFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* catal /// @return the fork. /***********************************************************************************/ _Output NFS_FORK_STRUCT* NeFSParser::FindFork(_Input NFS_CATALOG_STRUCT* catalog, - _Input const Char* name, - Boolean isDataFork) + _Input const Char* name, + Boolean isDataFork) { auto drv = kDiskMountpoint.A(); NFS_FORK_STRUCT* the_fork = nullptr; @@ -236,7 +236,7 @@ _Output NFS_CATALOG_STRUCT* NeFSParser::CreateCatalog(_Input const Char* name) /// @param kind the catalog kind. /// @return catalog pointer. /***********************************************************************************/ -_Output NFS_CATALOG_STRUCT* NeFSParser::CreateCatalog(_Input const Char* name, +_Output NFS_CATALOG_STRUCT* NeFSParser::CreateCatalog(_Input const Char* name, _Input const Int32& flags, _Input const Int32& kind) { @@ -244,7 +244,7 @@ _Output NFS_CATALOG_STRUCT* NeFSParser::CreateCatalog(_Input const Char* name, Lba out_lba = 0UL; - kcout << "Checking for extension...\r"; + kcout << "Checking for path separator...\r"; /// a directory should have a slash in the end. if (kind == kNeFSCatalogKindDir && @@ -936,7 +936,7 @@ Boolean NeFSParser::RemoveCatalog(_Input const Char* catalogName) VoidPtr NeFSParser::ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, _Input Bool is_rsrc_fork, _Input SizeT dataSz, - _Input const Char* forkName) + _Input const Char* forkName) { if (!catalog) { -- cgit v1.2.3