From 4c714f2c24c5df78bae2f35c42c73107de4c8c71 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 18 Mar 2024 12:35:19 +0100 Subject: unstable, unrelated: See below. - :boom: Breaking changes in System.Core.dll - Framebuffer, moved operator bool into c++ source file. - Remove zlib in favor of our own Zip API. Signed-off-by: Amlal El Mahrouss --- Private/KernelKit/DebugOutput.hpp | 2 +- Private/KernelKit/DriveManager.hpp | 108 -------------------------------- Private/KernelKit/DriveManager.hxx | 112 ++++++++++++++++++++++++++++++++++ Private/KernelKit/Framebuffer.hpp | 8 +-- Private/KernelKit/PEFSharedObject.hxx | 10 +-- 5 files changed, 121 insertions(+), 119 deletions(-) delete mode 100644 Private/KernelKit/DriveManager.hpp create mode 100644 Private/KernelKit/DriveManager.hxx (limited to 'Private/KernelKit') diff --git a/Private/KernelKit/DebugOutput.hpp b/Private/KernelKit/DebugOutput.hpp index a2355cd8..88ed2448 100644 --- a/Private/KernelKit/DebugOutput.hpp +++ b/Private/KernelKit/DebugOutput.hpp @@ -96,7 +96,7 @@ inline TerminalDevice get_console_in(Char* buf) { typedef Char rt_debug_type[255]; -class DebuggerPorts final { +class DebuggerPortHeader final { public: Int16 fPort[kDebugMaxPorts]; Int16 fBoundCnt; diff --git a/Private/KernelKit/DriveManager.hpp b/Private/KernelKit/DriveManager.hpp deleted file mode 100644 index 027c9391..00000000 --- a/Private/KernelKit/DriveManager.hpp +++ /dev/null @@ -1,108 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#ifndef __DRIVE_MANAGER__ -#define __DRIVE_MANAGER__ - -#include -#include -#include -#include -#include -#include - -#define kDriveInvalidID -1 -#define kDriveNameLen 32 - -namespace HCore { -enum { - kInvalidDrive = -1, - kBlockDevice = 0xAD, - kMassStorage = 0xDA, - kFloppyDisc = 0xCD, - kOpticalDisc = 0xDC, // CD-ROM/DVD-ROM/Blu-Ray - kReadOnly = 0x10, // Read only drive - kEPMDrive = 0x11, // Explicit Partition Map. - kEPTDrive = 0x12, // ESP w/ EPM partition. - kMBRDrive = 0x13, // IBM PC classic partition scheme - kDriveCnt = 9, -}; - -typedef Int64 rt_drive_id_type; - -/// @brief Mounted drive traits. -struct DriveTraits final { - Char fName[kDriveNameLen]; // /System, /Boot, //./Devices/USB... - Int32 fKind; // fMassStorage, fFloppy, fOpticalDisc. - rt_drive_id_type fId; // Drive id. - Int32 fFlags; // fReadOnly, fXPMDrive, fXPTDrive - - //! for StorageKit. - struct DrivePacket final { - voidPtr fPacketContent; // packet body. - Char fPacketMime[32]; //! identify what we're sending. - SizeT fPacketSize; // packet size - UInt32 fPacketCRC32; // sanity crc, in case if good is set to false - Boolean fPacketGood; - } 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 DriveDevice; -typedef DriveDevice* DriveDevicePtr; - -/** - * @brief Abstracted hard-drive container class. - * @note This class has all of it's drive set to nullptr, allocate them using - * GetAddressOf(index). - */ -class Mountpoint final { - public: - explicit Mountpoint() = default; - ~Mountpoint() = default; - - HCORE_COPY_DEFAULT(Mountpoint); - - public: - DriveDevicePtr A() { return mA; } - DriveDevicePtr B() { return mB; } - DriveDevicePtr C() { return mC; } - DriveDevicePtr D() { return mD; } - - DriveDevicePtr* GetAddressOf(int index) { - DbgLastError() = kErrorSuccess; - - switch (index) { - case 0: - return &mA; - case 1: - return &mB; - case 2: - return &mC; - case 3: - return &mD; - default: { - DbgLastError() = kErrorNoSuchDisk; - kcout << "HCoreKrnl\\Mountpoint: Check HError.\n"; - - break; - } - } - - return nullptr; - } - - private: - DriveDevicePtr mA, mB, mC, mD = nullptr; -}; -} // namespace HCore - -#endif /* ifndef __DRIVE_MANAGER__ */ diff --git a/Private/KernelKit/DriveManager.hxx b/Private/KernelKit/DriveManager.hxx new file mode 100644 index 00000000..abca0ad3 --- /dev/null +++ b/Private/KernelKit/DriveManager.hxx @@ -0,0 +1,112 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#ifndef __DRIVE_MANAGER__ +#define __DRIVE_MANAGER__ + +#include +#include +#include +#include +#include +#include + +#define kDriveInvalidID -1 +#define kDriveNameLen 32 + +namespace HCore { +enum { + kInvalidDrive = -1, + kBlockDevice = 0xAD, + kMassStorage = 0xDA, + kFloppyDisc = 0xCD, + kOpticalDisc = 0xDC, // CD-ROM/DVD-ROM/Blu-Ray + kReadOnly = 0x10, // Read only drive + kEPMDrive = 0x11, // Explicit Partition Map. + kEPTDrive = 0x12, // ESP w/ EPM partition. + kMBRDrive = 0x13, // IBM PC classic partition scheme + kDriveCnt = 9, +}; + +typedef Int64 rt_drive_id_type; + +/// @brief Media drive trait type. +struct DriveTrait final { + Char fName[kDriveNameLen]; // /System, /Boot, //./Devices/USB... + Int32 fKind; // fMassStorage, fFloppy, fOpticalDisc. + rt_drive_id_type fId; // Drive id. + Int32 fFlags; // fReadOnly, fXPMDrive, fXPTDrive + + /// @brief Packet drive (StorageKit compilant.) + struct DrivePacket final { + VoidPtr fPacketContent; // packet body. + Char fPacketMime[kDriveNameLen]; //! identify what we're sending. + SizeT fPacketSize; // packet size + UInt32 fPacketCRC32; // sanity crc, in case if good is set to false + Boolean fPacketGood; + } fPacket; + + Void (*fInput)(DrivePacket* packetPtr); + Void (*fOutput)(DrivePacket* packetPtr); + Void (*fVerify)(DrivePacket* packetPtr); +}; + +#define kDrivePacketBinary "file/x-binary" +#define kDrivePacketSource "file/x-source" +#define kDrivePacketASCII "file/x-ascii" +#define kDrivePacketZip "file/x-zip" + +//! drive as a device. +typedef DeviceInterface DriveDevice; +typedef DriveDevice* DriveDevicePtr; + +/** + * @brief Abstracted hard-drive container class. + * @note This class has all of it's drive set to nullptr, allocate them using + * GetAddressOf(index). + */ +class Mountpoint final { + public: + explicit Mountpoint() = default; + ~Mountpoint() = default; + + HCORE_COPY_DEFAULT(Mountpoint); + + public: + DriveDevicePtr A() { return mA; } + DriveDevicePtr B() { return mB; } + DriveDevicePtr C() { return mC; } + DriveDevicePtr D() { return mD; } + + DriveDevicePtr* GetAddressOf(int index) { + DbgLastError() = kErrorSuccess; + + switch (index) { + case 0: + return &mA; + case 1: + return &mB; + case 2: + return &mC; + case 3: + return &mD; + default: { + DbgLastError() = kErrorNoSuchDisk; + kcout << "HCoreKrnl\\Mountpoint: Check HError.\n"; + + break; + } + } + + return nullptr; + } + + private: + DriveDevicePtr mA, mB, mC, mD = nullptr; +}; +} // namespace HCore + +#endif /* ifndef __DRIVE_MANAGER__ */ diff --git a/Private/KernelKit/Framebuffer.hpp b/Private/KernelKit/Framebuffer.hpp index 2847efb0..daf95ed0 100644 --- a/Private/KernelKit/Framebuffer.hpp +++ b/Private/KernelKit/Framebuffer.hpp @@ -28,7 +28,7 @@ class FramebufferContext final { class Framebuffer final { public: - Framebuffer(Ref &addr) : m_FrameBufferAddr(addr) {} + explicit Framebuffer(Ref &addr) : m_FrameBufferAddr(addr) {} ~Framebuffer() {} Framebuffer &operator=(const Framebuffer &) = delete; @@ -36,10 +36,8 @@ class Framebuffer final { volatile UIntPtr *operator[](const UIntPtr &pos); - operator bool() { - return m_FrameBufferAddr && m_Colour != FramebufferColorKind::INVALID; - } - + operator bool(); + const FramebufferColorKind &Color( const FramebufferColorKind &colour = FramebufferColorKind::INVALID); diff --git a/Private/KernelKit/PEFSharedObject.hxx b/Private/KernelKit/PEFSharedObject.hxx index becac43e..0684b2a7 100644 --- a/Private/KernelKit/PEFSharedObject.hxx +++ b/Private/KernelKit/PEFSharedObject.hxx @@ -25,7 +25,7 @@ extern "C" void __mh_purecall(void); */ class SharedObject final { public: - struct SharedObjectTraits final { + struct SharedObjectTrait final { VoidPtr fImageObject; VoidPtr fImageEntrypointOffset; }; @@ -38,15 +38,15 @@ class SharedObject final { HCORE_COPY_DEFAULT(SharedObject); private: - SharedObjectTraits *fMounted{nullptr}; + SharedObjectTrait *fMounted{nullptr}; public: - SharedObjectTraits **GetAddressOf() { return &fMounted; } + SharedObjectTrait **GetAddressOf() { return &fMounted; } - SharedObjectTraits *Get() { return fMounted; } + SharedObjectTrait *Get() { return fMounted; } public: - void Mount(SharedObjectTraits *to_mount) { + void Mount(SharedObjectTrait *to_mount) { if (!to_mount || !to_mount->fImageObject) return; fMounted = to_mount; -- cgit v1.2.3