From 93079836948ce3832f3690167e4aa9b9bb8795fc Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 28 Jan 2024 11:04:21 +0100 Subject: Kernel: refactoring stuff. Signed-off-by: Amlal El Mahrouss --- Private/KernelKit/CodeManager.hpp | 102 +++++++++++++++---------------- Private/KernelKit/Defines.hpp | 4 +- Private/KernelKit/DriveManager.hpp | 121 ++++++++++++++++++------------------- 3 files changed, 113 insertions(+), 114 deletions(-) diff --git a/Private/KernelKit/CodeManager.hpp b/Private/KernelKit/CodeManager.hpp index f470bb01..5aa35a5b 100644 --- a/Private/KernelKit/CodeManager.hpp +++ b/Private/KernelKit/CodeManager.hpp @@ -1,11 +1,11 @@ /* -* ======================================================== -* -* hCore -* Copyright 2024 Mahrouss Logic, all rights reserved. -* -* ======================================================== -*/ + * ======================================================== + * + * hCore + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ #ifndef _INC_CODE_MANAGER_ #define _INC_CODE_MANAGER_ @@ -16,58 +16,58 @@ namespace hCore { - /// - /// \name PEFLoader - /// PEF container format implementation. - /// - class PEFLoader : public Loader - { - PEFLoader() = delete; - - public: - explicit PEFLoader(const char* path); - ~PEFLoader() override; +/// +/// \name PEFLoader +/// \brief PEF loader class. +/// +class PEFLoader : public Loader +{ + private: + explicit PEFLoader() = delete; - public: - HCORE_COPY_DEFAULT(PEFLoader); + public: + explicit PEFLoader(const char *path); + ~PEFLoader() override; - public: - typedef void(*MainKind)(void); + public: + HCORE_COPY_DEFAULT(PEFLoader); - public: - const char* Path() override; - const char* Format() override; - const char* MIME() override; + public: + typedef void (*MainKind)(void); - public: - ErrorOr LoadStart() override; - VoidPtr FindSymbol(const char* name, Int32 kind) override; + public: + const char *Path() override; + const char *Format() override; + const char *MIME() override; - public: - bool IsLoaded() noexcept; + public: + ErrorOr LoadStart() override; + VoidPtr FindSymbol(const char *name, Int32 kind) override; - private: - Ref fPath; - VoidPtr fCachedBlob; - bool fBad; + public: + bool IsLoaded() noexcept; - }; + private: + Ref fPath; + VoidPtr fCachedBlob; + bool fBad; +}; - namespace Utils - { - /// \brief Much like Mac OS's UPP. - /// This is read-only by design. - /// It handles different kind of code. - /// PowerPC <-> AMD64 for example. - typedef struct UniversalProcedureTable final - { - const Char NAME[kPefNameLen]; - const VoidPtr TRAP; - const SizeT ARCH; - } __attribute__((packed)) UniversalProcedureTableType; +namespace Utils +{ +/// \brief Much like Mac OS's UPP. +/// This is read-only by design. +/// It handles different kind of code. +/// PowerPC <-> AMD64 for example. +typedef struct UniversalProcedureTable final +{ + const Char NAME[kPefNameLen]; + const VoidPtr TRAP; + const SizeT ARCH; +} __attribute__((packed)) UniversalProcedureTableType; - bool execute_from_image(PEFLoader& exec) noexcept; - } -} +bool execute_from_image(PEFLoader &exec) noexcept; +} // namespace Utils +} // namespace hCore #endif // ifndef _INC_CODE_MANAGER_ diff --git a/Private/KernelKit/Defines.hpp b/Private/KernelKit/Defines.hpp index 9e00cf00..d87d2b28 100644 --- a/Private/KernelKit/Defines.hpp +++ b/Private/KernelKit/Defines.hpp @@ -11,5 +11,5 @@ #include -#define KERNELKIT_VERSION "1.0.0" -#define KERNELKIT_RELEASE "Baldur" \ No newline at end of file +#define KERNELKIT_VERSION "1.0.1" +#define KERNELKIT_RELEASE "Cairo" diff --git a/Private/KernelKit/DriveManager.hpp b/Private/KernelKit/DriveManager.hpp index 9951c9cf..b5c0ad0c 100644 --- a/Private/KernelKit/DriveManager.hpp +++ b/Private/KernelKit/DriveManager.hpp @@ -20,68 +20,67 @@ namespace hCore { - enum - { - kInvalidDrive = -1, - kBlockDevice = 0xAD, - kMassStorage = 0xDA, - kFloppyDisc = 0xCD, - kOpticalDisc = 0xDC, // CD-ROM/DVD-ROM/Blu-Ray - kReadOnly = 0x10, // Read only drive - kXPMDrive = 0x11, // eXplicit Partition Map. - kXPTDrive = 0x12, // GPT w/ XPM partition. - kMBRDrive = 0x13, // IBM PC classic partition scheme - }; - - typedef Int64 DriveID; - - // Mounted drive. - struct DriveTraits final +enum +{ + kInvalidDrive = -1, + kBlockDevice = 0xAD, + kMassStorage = 0xDA, + kFloppyDisc = 0xCD, + kOpticalDisc = 0xDC, // CD-ROM/DVD-ROM/Blu-Ray + kReadOnly = 0x10, // Read only drive + kXPMDrive = 0x11, // eXplicit Partition Map. + kXPTDrive = 0x12, // GPT w/ XPM partition. + kMBRDrive = 0x13, // IBM PC classic partition scheme +}; + +typedef Int64 DriveID; + +// Mounted drive. +struct DriveTraits final +{ + char fName[kDriveNameLen]; // /system, /boot... + Int32 fKind; // fMassStorage, fFloppy, fOpticalDisc. + DriveID fId; // Drive id. + Int32 fFlags; // fReadOnly, fXPMDrive, fXPTDrive + + //! disk mount, unmount operations + void (*fMount)(void); + void (*fUnmount)(void); + + bool (*fReady)(void); //! is drive ready? + + //! for StorageKit. + struct DrivePacket final { - char fName[kDriveNameLen]; // /system, /boot... - Int32 fKind; // fMassStorage, fFloppy, fOpticalDisc. - DriveID fId; // Drive id. - Int32 fFlags; // fReadOnly, fXPMDrive, fXPTDrive - - //! disk mount, unmount operations - void(*fMount)(void); - void(*fUnmount)(void); - - bool(*fReady)(void); //! is drive ready? - - //! for StorageKit. - struct - { - voidPtr fPacketContent; // packet body. - Char fPacketMime[32]; //! identify what we're sending. - SizeT fPacketSize; // packet size - } fPacket; - }; + voidPtr fPacketContent; // packet body. + Char fPacketMime[32]; //! identify what we're sending. + SizeT fPacketSize; // packet size + } fPacket; +}; #define kPacketBinary "file/x-binary" #define kPacketSource "file/x-source" -#define kPacketASCII "file/x-ascii" -#define kPacketZip "file/x-zip" - - //! drive as a device. - typedef DeviceInterface Drive; - typedef Drive* DrivePtr; - - class DriveSelector final - { - public: - explicit DriveSelector(); - ~DriveSelector(); - - public: - HCORE_COPY_DEFAULT(DriveSelector); - - DriveTraits& GetMounted(); - bool Mount(DriveTraits* drive); - DriveTraits* Unmount(); - - private: - DriveTraits* fDrive; - - }; -} +#define kPacketASCII "file/x-ascii" +#define kPacketZip "file/x-zip" + +//! drive as a device. +typedef DeviceInterface Drive; +typedef Drive *DrivePtr; + +class DriveSelector final +{ + public: + explicit DriveSelector(); + ~DriveSelector(); + + public: + HCORE_COPY_DEFAULT(DriveSelector); + + DriveTraits &GetMounted(); + bool Mount(DriveTraits *drive); + DriveTraits *Unmount(); + + private: + DriveTraits *fDrive; +}; +} // namespace hCore -- cgit v1.2.3