diff options
| author | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-01 17:08:13 +0000 |
|---|---|---|
| committer | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-01 17:08:13 +0000 |
| commit | 5c59cd35a2fa3e620542b73e8c3f66f0dccd241c (patch) | |
| tree | 985e7e39fd9657ceb45ab292f6a934e0e6d4571b /Private/KernelKit | |
| parent | 6c4cc0dba681fef1cef3c31877653a1d6413fc90 (diff) | |
| parent | 6ce7dffe92775f262384a028af233999a7d18048 (diff) | |
Merge branch 'HCR-9-add-support-for-file-load-hel-amd64' into 'trunk'
See below.
See merge request mahrouss-logic/micro-kernel!2
Diffstat (limited to 'Private/KernelKit')
| -rw-r--r-- | Private/KernelKit/DebugOutput.hpp | 48 | ||||
| -rw-r--r-- | Private/KernelKit/DriveManager.hpp | 3 | ||||
| -rw-r--r-- | Private/KernelKit/FileManager.hpp | 1 | ||||
| -rw-r--r-- | Private/KernelKit/Framebuffer.hpp | 82 | ||||
| -rw-r--r-- | Private/KernelKit/OSErr.hpp | 31 | ||||
| -rw-r--r-- | Private/KernelKit/PEF.hpp | 1 | ||||
| -rw-r--r-- | Private/KernelKit/PEFSharedObject.hxx | 39 |
7 files changed, 101 insertions, 104 deletions
diff --git a/Private/KernelKit/DebugOutput.hpp b/Private/KernelKit/DebugOutput.hpp index a651cb8b..875884ba 100644 --- a/Private/KernelKit/DebugOutput.hpp +++ b/Private/KernelKit/DebugOutput.hpp @@ -13,28 +13,26 @@ #include <NewKit/OwnPtr.hpp> #include <NewKit/Stream.hpp> -namespace HCore -{ - // @brief Emulates a VT100 terminal. - class TerminalDevice final : public DeviceInterface<const char*> - { - public: - TerminalDevice(void (*print)(const char *), void (*get)(const char *)) : DeviceInterface<const char*>(print, get) {} - virtual ~TerminalDevice() {} - - /// @brief returns device name (terminal name) - /// @return string type (const char*) - virtual const char* Name() const override { return ("TerminalDevice"); } - - TerminalDevice &operator=(const TerminalDevice &) = default; - TerminalDevice(const TerminalDevice &) = default; - - }; - - namespace Detail - { - bool serial_init(); - } - - extern TerminalDevice kcout; -} // namespace HCore +namespace HCore { +// @brief Emulates a VT100 terminal. +class TerminalDevice final : public DeviceInterface<const char *> { + public: + TerminalDevice(void (*print)(const char *), void (*get)(const char *)) + : DeviceInterface<const char *>(print, get) {} + + virtual ~TerminalDevice() {} + + /// @brief returns device name (terminal name) + /// @return string type (const char*) + virtual const char *Name() const override { return ("TerminalDevice"); } + + TerminalDevice &operator=(const TerminalDevice &) = default; + TerminalDevice(const TerminalDevice &) = default; +}; + +namespace Detail { +bool serial_init(); +} + +extern TerminalDevice kcout; +} // namespace HCore diff --git a/Private/KernelKit/DriveManager.hpp b/Private/KernelKit/DriveManager.hpp index da478a45..ac39c177 100644 --- a/Private/KernelKit/DriveManager.hpp +++ b/Private/KernelKit/DriveManager.hpp @@ -29,11 +29,12 @@ enum { kEPMDrive = 0x11, // Explicit Partition Map. kEPTDrive = 0x12, // ESP w/ EPM partition. kMBRDrive = 0x13, // IBM PC classic partition scheme + kDriveCnt = 9, }; typedef Int64 DriveID; -// Mounted drive. +/// @brief Mounted drive traits. struct DriveTraits final { char fName[kDriveNameLen]; // /System, /Boot, /USBDevice... Int32 fKind; // fMassStorage, fFloppy, fOpticalDisc. diff --git a/Private/KernelKit/FileManager.hpp b/Private/KernelKit/FileManager.hpp index 6ed713c4..b65bdfe1 100644 --- a/Private/KernelKit/FileManager.hpp +++ b/Private/KernelKit/FileManager.hpp @@ -39,6 +39,7 @@ enum { kFileReadAll = 101, kFileReadChunk = 102, kFileWriteChunk = 103, + kFileIOCnt = (kFileWriteChunk - kFileWriteAll) + 1, }; typedef VoidPtr NodePtr; diff --git a/Private/KernelKit/Framebuffer.hpp b/Private/KernelKit/Framebuffer.hpp index 6dc94a3b..8ad23571 100644 --- a/Private/KernelKit/Framebuffer.hpp +++ b/Private/KernelKit/Framebuffer.hpp @@ -13,47 +13,45 @@ #include <NewKit/Defines.hpp> #include <NewKit/Ref.hpp> -namespace HCore -{ - enum class FramebufferColorKind : UChar - { - RGB32, - RGB16, - RGB8, - INVALID, - }; - - class FramebufferContext final - { - public: - UIntPtr m_Base; - UIntPtr m_Bpp; - UInt m_Width; - UInt m_Height; - - }; - - class Framebuffer final - { - public: - Framebuffer(Ref<FramebufferContext*> &addr); - ~Framebuffer(); - - Framebuffer &operator=(const Framebuffer &) = delete; - Framebuffer(const Framebuffer &) = default; - - volatile UIntPtr* operator[](const UIntPtr &width_and_height); - operator bool(); - - const FramebufferColorKind& Color(const FramebufferColorKind &colour = FramebufferColorKind::INVALID); - - Ref<FramebufferContext*>& Leak(); - - private: - Ref<FramebufferContext*> m_FrameBufferAddr; - FramebufferColorKind m_Colour; - - }; -} // namespace HCore +namespace HCore { +enum class FramebufferColorKind : UChar { + RGB32, + RGB16, + RGB8, + INVALID, +}; + +class FramebufferContext final { + public: + UIntPtr m_Base; + UIntPtr m_Bpp; + UInt m_Width; + UInt m_Height; +}; + +class Framebuffer final { + public: + Framebuffer(Ref<FramebufferContext *> &addr) : m_FrameBufferAddr(addr) {} + ~Framebuffer() {} + + Framebuffer &operator=(const Framebuffer &) = delete; + Framebuffer(const Framebuffer &) = default; + + volatile UIntPtr *operator[](const UIntPtr &width_and_height); + + operator bool() { + return m_FrameBufferAddr && m_Colour != FramebufferColorKind::INVALID; + } + + const FramebufferColorKind &Color( + const FramebufferColorKind &colour = FramebufferColorKind::INVALID); + + Ref<FramebufferContext *> &Leak(); + + private: + Ref<FramebufferContext *> m_FrameBufferAddr; + FramebufferColorKind m_Colour; +}; +} // namespace HCore #endif /* ifndef __INC_FB_HPP__ */ diff --git a/Private/KernelKit/OSErr.hpp b/Private/KernelKit/OSErr.hpp index 975de898..62916959 100644 --- a/Private/KernelKit/OSErr.hpp +++ b/Private/KernelKit/OSErr.hpp @@ -11,20 +11,19 @@ #include <NewKit/Defines.hpp> -namespace HCore -{ - typedef Int32 OSErr; +namespace HCore { +typedef Int32 OSErr; - inline constexpr OSErr kErrorExecutable = 33; - inline constexpr OSErr kErrorExecutableLib = 34; - inline constexpr OSErr kErrorFileNotFound = 35; - inline constexpr OSErr kErrorDirectoryNotFound = 36; - inline constexpr OSErr kErrorDiskReadOnly = 37; - inline constexpr OSErr kErrorDiskIsFull = 38; - inline constexpr OSErr kErrorProcessFault = 39; - inline constexpr OSErr kErrorSocketHangUp = 40; - inline constexpr OSErr kErrorThreadLocalStorage = 41; - inline constexpr OSErr kErrorMath = 42; - inline constexpr OSErr kErrorNoNetwork = 43; - inline constexpr OSErr kErrorHeapOutOfMemory = 44; -}
\ No newline at end of file +inline constexpr OSErr kErrorExecutable = 33; +inline constexpr OSErr kErrorExecutableLib = 34; +inline constexpr OSErr kErrorFileNotFound = 35; +inline constexpr OSErr kErrorDirectoryNotFound = 36; +inline constexpr OSErr kErrorDiskReadOnly = 37; +inline constexpr OSErr kErrorDiskIsFull = 38; +inline constexpr OSErr kErrorProcessFault = 39; +inline constexpr OSErr kErrorSocketHangUp = 40; +inline constexpr OSErr kErrorThreadLocalStorage = 41; +inline constexpr OSErr kErrorMath = 42; +inline constexpr OSErr kErrorNoNetwork = 43; +inline constexpr OSErr kErrorHeapOutOfMemory = 44; +} // namespace HCore diff --git a/Private/KernelKit/PEF.hpp b/Private/KernelKit/PEF.hpp index afa43968..8c67c6ae 100644 --- a/Private/KernelKit/PEF.hpp +++ b/Private/KernelKit/PEF.hpp @@ -31,6 +31,7 @@ enum { kPefArchRISCV, kPefArch64x0, /* 64x000. */ kPefArch32x0, + kPefArchCount = (kPefArch32x0 - kPefArchIntel86S) + 1, kPefArchInvalid = 0xFF, }; diff --git a/Private/KernelKit/PEFSharedObject.hxx b/Private/KernelKit/PEFSharedObject.hxx index af90858e..263f08f4 100644 --- a/Private/KernelKit/PEFSharedObject.hxx +++ b/Private/KernelKit/PEFSharedObject.hxx @@ -16,10 +16,13 @@ #include <NewKit/Defines.hpp> namespace HCore { - /** - * @brief Shared Library class - * Load library from this class - */ +/// @brief Pure implementation, missing method/function handler. +extern "C" void __mh_purecall(void); + +/** + * @brief Shared Library class + * Load library from this class + */ class SharedObject final { public: struct SharedObjectTraits final { @@ -44,9 +47,7 @@ class SharedObject final { public: void Mount(SharedObjectTraits *to_mount) { - if (!to_mount || - !to_mount->fImageObject) - return; + if (!to_mount || !to_mount->fImageObject) return; fMounted = to_mount; @@ -65,17 +66,18 @@ class SharedObject final { }; template <typename SymbolType> - SymbolType Load(const char *symbol_name) { - auto ret = reinterpret_cast<SymbolType>( - fLoader->FindSymbol(symbol_name, kPefCode)); + SymbolType Load(const char *symbol_name, SizeT len, Int32 kind) { + if (symbol_name == nullptr || *symbol_name == 0) return nullptr; + if (len > kPathLen || len < 1) return nullptr; - if (!ret) - ret = reinterpret_cast<SymbolType>( - fLoader->FindSymbol(symbol_name, kPefData)); + auto ret = + reinterpret_cast<SymbolType>(fLoader->FindSymbol(symbol_name, kind)); - if (!ret) - ret = reinterpret_cast<SymbolType>( - fLoader->FindSymbol(symbol_name, kPefZero)); + if (!ret) { + if (kind == kPefCode) return (VoidPtr)__mh_purecall; + + return nullptr; + } return ret; } @@ -84,10 +86,7 @@ class SharedObject final { PEFLoader *fLoader{nullptr}; }; -inline void hcore_pure_call(void) { - // virtual placeholder. - return; -} +typedef SharedObject *SharedObjectPtr; } // namespace HCore #endif /* ifndef __KERNELKIT_SHARED_OBJECT_HXX__ */ |
