From af212d19d0b2f0fad608c78ca922d3db9cb326bd Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 9 Feb 2024 20:31:40 +0100 Subject: Kernel: See below. - Rework some bootloader modules, will work on some. - Rework GKit to look like the DOM on a browser. Signed-off-by: Amlal El Mahrouss --- .gitignore | 2 - Private/NewBoot/NetBoot/EfiModule.cxx | 15 +++ Private/NewBoot/NetBoot/manifest.json | 6 +- Private/NewBoot/NetBoot/module.cxx | 13 --- Private/NewBoot/Source/CDROM/MAHROUSS/.keep | 0 Private/Source/PermissionSelector.cxx | 2 +- Private/StorageKit/ATA.hpp | 165 +++++++++++++--------------- Private/StorageKit/NVME.hpp | 50 ++++----- Private/StorageKit/PRDT.hpp | 2 +- Public/Kits/GKit/Core.hpp | 57 +++++++++- Public/Kits/GKit/Makefile | 2 +- 11 files changed, 168 insertions(+), 146 deletions(-) create mode 100644 Private/NewBoot/NetBoot/EfiModule.cxx delete mode 100644 Private/NewBoot/NetBoot/module.cxx create mode 100644 Private/NewBoot/Source/CDROM/MAHROUSS/.keep diff --git a/.gitignore b/.gitignore index ba873061..3102b158 100644 --- a/.gitignore +++ b/.gitignore @@ -8,8 +8,6 @@ build.ninja cmake_install.cmake qtcsettings.cmake -MAHROUSS/ - x86_64/ *.epm diff --git a/Private/NewBoot/NetBoot/EfiModule.cxx b/Private/NewBoot/NetBoot/EfiModule.cxx new file mode 100644 index 00000000..a0ce13a5 --- /dev/null +++ b/Private/NewBoot/NetBoot/EfiModule.cxx @@ -0,0 +1,15 @@ +/* + * ======================================================== + * + * NetBoot + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include +#include + +extern "C" Int32 EfiMain(EfiHandlePtr handle, EfiSystemTable* SystemTable) { + return kEfiOk; +} diff --git a/Private/NewBoot/NetBoot/manifest.json b/Private/NewBoot/NetBoot/manifest.json index 1a177877..8486cfc1 100644 --- a/Private/NewBoot/NetBoot/manifest.json +++ b/Private/NewBoot/NetBoot/manifest.json @@ -1,4 +1,4 @@ { - "pluginName": "internetBoot", - "description": "internetBoot your device from the network." -} \ No newline at end of file + "pluginName": "interBoot", + "description": "Boot your device from your network infra." +} diff --git a/Private/NewBoot/NetBoot/module.cxx b/Private/NewBoot/NetBoot/module.cxx deleted file mode 100644 index b7e4727f..00000000 --- a/Private/NewBoot/NetBoot/module.cxx +++ /dev/null @@ -1,13 +0,0 @@ -/* - * ======================================================== - * - * NetBoot - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -extern "C" void __Module(const char* ip, long iplen) -{ - -} diff --git a/Private/NewBoot/Source/CDROM/MAHROUSS/.keep b/Private/NewBoot/Source/CDROM/MAHROUSS/.keep new file mode 100644 index 00000000..e69de29b diff --git a/Private/Source/PermissionSelector.cxx b/Private/Source/PermissionSelector.cxx index 1943a567..34760b8f 100644 --- a/Private/Source/PermissionSelector.cxx +++ b/Private/Source/PermissionSelector.cxx @@ -5,7 +5,7 @@ * Copyright Mahrouss Logic, all rights reserved. * * File: PermissionSelector.cpp - * Purpose: Permission primitive type. + * Purpose: Permission selectors. * * ======================================================== */ diff --git a/Private/StorageKit/ATA.hpp b/Private/StorageKit/ATA.hpp index 279258ca..33b976ae 100644 --- a/Private/StorageKit/ATA.hpp +++ b/Private/StorageKit/ATA.hpp @@ -1,104 +1,87 @@ /* -* ======================================================== -* -* HCore -* Copyright Mahrouss Logic, all rights reserved. -* -* ======================================================== -*/ + * ======================================================== + * + * HCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ #pragma once +#include #include #include #include #include -#include -namespace HCore -{ - enum class PATAType - { - kRead28, - kRead48, - kWrite28, - kWrite48, - kATAUnknown - }; - - const char* ata_read_28(ULong lba); - const char* ata_read_48(ULong lba); - - Int32 ata_write_48(ULong lba, const char *text = nullptr); - Int32 ata_write_28(ULong lba, const char *text = nullptr); - - class PATACommandManager final - { - public: - PATACommandManager() = default; - ~PATACommandManager() = default; - - PATACommandManager &operator=(const PATACommandManager &) = default; - PATACommandManager(const PATACommandManager &) = default; - - public: - static Ref Shared() - { - static Ref manager; - return manager; +namespace HCore { +enum class PATAType { kRead28, kRead48, kWrite28, kWrite48, kATAUnknown }; + +const char *ata_read_28(ULong lba); +const char *ata_read_48(ULong lba); + +Int32 ata_write_48(ULong lba, const char *text = nullptr); +Int32 ata_write_28(ULong lba, const char *text = nullptr); + +class PATACommandManager final { + public: + explicit PATACommandManager() = default; + ~PATACommandManager() = default; + + PATACommandManager &operator=(const PATACommandManager &) = default; + PATACommandManager(const PATACommandManager &) = default; + + public: + static Ref Shared() { + static Ref manager; + return manager; + } + + public: + template + ErrorOr operator()(ULong lba, + const char *text = nullptr) noexcept { + switch (Command) { + case PATAType::kRead28: + return ErrorOr(ata_read_28(lba)); + case PATAType::kRead48: + return ErrorOr(ata_read_48(lba)); + case PATAType::kWrite28: { + if (text) { + ata_write_28(lba, text); + kcout << "ErrorOr ata_read: Write ATA Command... " + "(Write28)\n"; + + return {}; } - public: - template - ErrorOr operator()(ULong lba, const char *text = nullptr) noexcept - { - switch (Command) - { - case PATAType::kRead28: - return ErrorOr(ata_read_28(lba)); - case PATAType::kRead48: - return ErrorOr(ata_read_48(lba)); - case PATAType::kWrite28: - { - if (text) - { - ata_write_28(lba, text); - kcout << "ErrorOr ata_read: Write ATA Command... " - "(Write28)\n"; - - return {}; - } - - kcout << "ErrorOr ata_read: Bad ATA Command... " - "(Write28)\n"; - - return {}; - } - case PATAType::kWrite48: - { - if (text) - { - ata_write_48(lba, text); - kcout << "ErrorOr ata_read: Write ATA Command... " - "(Write48)\n"; - - return {}; - } - - kcout << "ErrorOr ata_read: Bad ATA Command... " - "(Write48)\n"; - - return {}; - } - case PATAType::kATAUnknown: - { - kcout << "ErrorOr ata_read: Unknown ATA Command...\n"; - return {}; - } - } - - return ErrorOr(nullptr); + kcout << "ErrorOr ata_read: Bad ATA Command... " + "(Write28)\n"; + + return {}; + } + case PATAType::kWrite48: { + if (text) { + ata_write_48(lba, text); + kcout << "ErrorOr ata_read: Write ATA Command... " + "(Write48)\n"; + + return {}; } - }; -} // namespace HCore + kcout << "ErrorOr ata_read: Bad ATA Command... " + "(Write48)\n"; + + return {}; + } + case PATAType::kATAUnknown: { + kcout << "ErrorOr ata_read: Unknown ATA Command...\n"; + return {}; + } + } + + return ErrorOr(nullptr); + } +}; +} // namespace HCore diff --git a/Private/StorageKit/NVME.hpp b/Private/StorageKit/NVME.hpp index 0bfbef52..1b638989 100644 --- a/Private/StorageKit/NVME.hpp +++ b/Private/StorageKit/NVME.hpp @@ -6,43 +6,35 @@ * * ======================================================== */ - + #pragma once #include #include -namespace HCore -{ - class NVMEPacket; - - class NVMEDevice : public DeviceInterface - { - public: - NVMEDevice(void(*Out)(NVMEPacket outpacket), - void(*In)(NVMEPacket inpacket), - void(*Cleanup)(void)) - : DeviceInterface(Out, In), fCleanup(Cleanup) - {} - - virtual ~NVMEDevice() - { - if (fCleanup) - fCleanup(); - } +namespace HCore { +class NVMEPacket; - public: - NVMEDevice &operator=(const NVMEDevice &) = default; - NVMEDevice(const NVMEDevice &) = default; +class NVMEDevice : public DeviceInterface { + public: + explicit NVMEDevice(void (*Out)(NVMEPacket outpacket), + void (*In)(NVMEPacket inpacket), void (*Cleanup)(void)) + : DeviceInterface(Out, In), fCleanup(Cleanup) {} - virtual const char *Name() const; + virtual ~NVMEDevice() { + if (fCleanup) fCleanup(); + } - public: - OwnPtr operator()(UInt32 dmaLow, UInt32 dmaHigh, SizeT sz); + public: + NVMEDevice &operator=(const NVMEDevice &) = default; + NVMEDevice(const NVMEDevice &) = default; - private: - void(*fCleanup)(void); + virtual const char *Name() const; + public: + OwnPtr operator()(UInt32 dmaLow, UInt32 dmaHigh, SizeT sz); - }; -} // namespace HCore + private: + void (*fCleanup)(void); +}; +} // namespace HCore diff --git a/Private/StorageKit/PRDT.hpp b/Private/StorageKit/PRDT.hpp index d269ee3a..fb7d81ff 100644 --- a/Private/StorageKit/PRDT.hpp +++ b/Private/StorageKit/PRDT.hpp @@ -16,7 +16,7 @@ namespace HCore { class PRDT final { public: - PRDT() = delete; + explicit PRDT() = delete; explicit PRDT(const UIntPtr &physAddr); ~PRDT(); diff --git a/Public/Kits/GKit/Core.hpp b/Public/Kits/GKit/Core.hpp index 7059eb5e..00ae524e 100644 --- a/Public/Kits/GKit/Core.hpp +++ b/Public/Kits/GKit/Core.hpp @@ -14,11 +14,20 @@ #pragma once +#include #include #include #include #include +#define $() HCore::GApplication::Shared()->Document() + +#ifdef __EXPORT_LIB +#define G_API __attribute__((container(".EXPORT"))) +#else +#define G_API __attribute__((container(".IMPORT"))) +#endif // ifdef __EXPORT_LIB + namespace HCore { template class GAction; @@ -27,8 +36,11 @@ class GString; class GNumber; class GVector2; class GBoolean; +class GDocument; +class GApplication; +class GFrame; -class GBoolean { +class G_API GBoolean { private: explicit GBoolean() : m_Value(false) {} @@ -46,7 +58,7 @@ class GBoolean { }; template -class GAction { +class G_API GAction { explicit GAction(HCore::StringView& sw) { m_Name = sw; } HCore::StringView m_Name; @@ -64,7 +76,7 @@ class GAction { } }; -class GVector2 { +class G_API GVector2 { explicit GVector2(HCore::StringView& sw) : m_Vec2() {} HCore::Array m_Vec2; @@ -81,7 +93,7 @@ class GVector2 { } }; -class GNumber { +class G_API GNumber { HCore::Int m_Number{0}; friend class GForm; @@ -94,7 +106,7 @@ class GNumber { } }; -class GString { +class G_API GString { explicit GString(HCore::StringView& content) { m_Content = new HCore::StringView(); *m_Content = content; @@ -110,4 +122,39 @@ class GString { return str; } }; + +class G_API GApplication final { + public: + explicit GApplication() = default; + ~GApplication() = default; + + HCORE_COPY_DEFAULT(GApplication); + + GDocument* Document() noexcept { return nullptr; } + + GApplication* Shared() noexcept { + STATIC GApplication* gApp = nullptr; + + if (!gApp) gApp = new GApplication(); + + return gApp; + } +}; + +class G_API GDocument final { + public: + explicit GDocument(StringView& sv) : mString(GString::Construct(sv)) {} + ~GDocument() = default; + + HCORE_COPY_DEFAULT(GDocument); + + GFrame** GetAddressOf() noexcept { return &mFrame; } + GFrame* Get() noexcept { return mFrame; } + + GString& Name() { return mString; } + + private: + GFrame* mFrame{nullptr}; + GString mString; +}; } // namespace HCore diff --git a/Public/Kits/GKit/Makefile b/Public/Kits/GKit/Makefile index 95ab0ee2..d8228fca 100644 --- a/Public/Kits/GKit/Makefile +++ b/Public/Kits/GKit/Makefile @@ -10,7 +10,7 @@ ASMFLAGS=-f elf64 .PHONY: build-gkit build-gkit: - $(CC) -I../ -I../../../Private/ $(CCFLAGS) *.cxx + $(CC) -I../ -I$(HOME) -I../../../Private/ $(CCFLAGS) *.cxx .PHONY: all all: build-gkit -- cgit v1.2.3