From b038c3eff8c80be2e6e10bea16634523fff4a6b5 Mon Sep 17 00:00:00 2001 From: Amlal Date: Sun, 14 Jul 2024 00:37:06 +0200 Subject: [IMP] - IsUndefined returns const bool& now. - Replace kUndefined with kNull now. - Remove ML_ from macros in newstd.hxx. - Rename NSyscall to NSyscallInterface, which is a ref counted class now. - Rename MBCIType to PowerID - Update ToDos. - Update NewFS root catalog name. - Fix JSON 'null' initialization. - Add Json to variant object. - Replace kPointer with kBlob in variant kinds. - Add Leak() method to variant. Signed-off-by: Amlal --- Boot/Modules/.keep | 0 Boot/Modules/NetBoot/.hgkeep | 0 Boot/Modules/NetBoot/Module.cxx | 20 ++++++++++++++++++ Boot/Modules/NetBoot/NetBoot.hxx | 26 +++++++++++++++++++++++ Boot/Modules/NetBoot/compile_flags.txt | 8 +++++++ Boot/Modules/NetBoot/manifest.json | 4 ++++ Boot/NetBoot/.hgkeep | 0 Boot/NetBoot/Module.cxx | 20 ------------------ Boot/NetBoot/NetBoot.hxx | 26 ----------------------- Boot/NetBoot/compile_flags.txt | 8 ------- Boot/NetBoot/manifest.json | 4 ---- Boot/ReadMe.md | 4 ++-- Boot/download-ovmf.ps1 | 4 ---- Boot/ovmf.ps1 | 4 ++++ Comm/newstd.hxx | 38 +++++++++++++++------------------- Kernel/Docs/TODO-LIST.md | 10 +++++---- Kernel/FSKit/NewFS.hxx | 2 +- Kernel/KernelKit/DebugOutput.hpp | 2 +- Kernel/NewKit/Json.hxx | 18 +++++++++------- Kernel/NewKit/Variant.hpp | 20 +++++++++++++----- Kernel/Sources/FS/NewFS.cxx | 4 ++-- Kernel/Sources/Json.cxx | 2 +- Kernel/Sources/Main.cxx | 8 +++---- Kernel/Sources/Variant.cxx | 10 ++++++--- 24 files changed, 129 insertions(+), 113 deletions(-) create mode 100644 Boot/Modules/.keep create mode 100644 Boot/Modules/NetBoot/.hgkeep create mode 100644 Boot/Modules/NetBoot/Module.cxx create mode 100644 Boot/Modules/NetBoot/NetBoot.hxx create mode 100644 Boot/Modules/NetBoot/compile_flags.txt create mode 100644 Boot/Modules/NetBoot/manifest.json delete mode 100644 Boot/NetBoot/.hgkeep delete mode 100644 Boot/NetBoot/Module.cxx delete mode 100644 Boot/NetBoot/NetBoot.hxx delete mode 100644 Boot/NetBoot/compile_flags.txt delete mode 100644 Boot/NetBoot/manifest.json delete mode 100644 Boot/download-ovmf.ps1 create mode 100644 Boot/ovmf.ps1 diff --git a/Boot/Modules/.keep b/Boot/Modules/.keep new file mode 100644 index 00000000..e69de29b diff --git a/Boot/Modules/NetBoot/.hgkeep b/Boot/Modules/NetBoot/.hgkeep new file mode 100644 index 00000000..e69de29b diff --git a/Boot/Modules/NetBoot/Module.cxx b/Boot/Modules/NetBoot/Module.cxx new file mode 100644 index 00000000..3bc71d0e --- /dev/null +++ b/Boot/Modules/NetBoot/Module.cxx @@ -0,0 +1,20 @@ +/* + * ======================================================== + * + * NetBoot + * Copyright ZKA Technologies, all rights reserved. + * + * ======================================================== + */ + +#include +#include + +EXTERN_C Int32 ModuleMain(Void) +{ + /// - Find a network drive called "/Remote/newoskrnl" + /// - Download our image + /// - Boot from it. + + return kEfiOk; +} diff --git a/Boot/Modules/NetBoot/NetBoot.hxx b/Boot/Modules/NetBoot/NetBoot.hxx new file mode 100644 index 00000000..1a474501 --- /dev/null +++ b/Boot/Modules/NetBoot/NetBoot.hxx @@ -0,0 +1,26 @@ +/* + * ======================================================== + * + * NetBoot + * Copyright ZKA Technologies, all rights reserved. + * + * ======================================================== + */ + +#pragma once + +#include + +/// @brief the internet header is used to download updates OTA. +typedef struct NetBootInternetHeader +{ + Kernel::Char NB1; /// magic char 1 'N' + Kernel::Char NB2; /// magic char 2 'E' + Kernel::Char NB3; /// magic char 3 'T' + Kernel::Char NB4; /// magic char 4 'B' + + Kernel::Char PatchName[255]; /// example: ColdChoco + Kernel::Int32 PatchLength; /// the patch length. + Kernel::Char PatchTarget[255]; /// the target file. + Kernel::Boolean ImpliesROM; /// does it imply an EEPROM reprogram? +} NetBootInternetHeader; diff --git a/Boot/Modules/NetBoot/compile_flags.txt b/Boot/Modules/NetBoot/compile_flags.txt new file mode 100644 index 00000000..f9ca281f --- /dev/null +++ b/Boot/Modules/NetBoot/compile_flags.txt @@ -0,0 +1,8 @@ +-std=c++20 +-I../ +-I../../ +-I../../Kernel +-D__NEWOS_AMD64__ +-std=c++20 +-D__x86_64__ +-D__NEWOS_OTA__ diff --git a/Boot/Modules/NetBoot/manifest.json b/Boot/Modules/NetBoot/manifest.json new file mode 100644 index 00000000..5f94c677 --- /dev/null +++ b/Boot/Modules/NetBoot/manifest.json @@ -0,0 +1,4 @@ +{ + "pluginName": "iBoot", + "description": "OTA updates." +} diff --git a/Boot/NetBoot/.hgkeep b/Boot/NetBoot/.hgkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Boot/NetBoot/Module.cxx b/Boot/NetBoot/Module.cxx deleted file mode 100644 index 3bc71d0e..00000000 --- a/Boot/NetBoot/Module.cxx +++ /dev/null @@ -1,20 +0,0 @@ -/* - * ======================================================== - * - * NetBoot - * Copyright ZKA Technologies, all rights reserved. - * - * ======================================================== - */ - -#include -#include - -EXTERN_C Int32 ModuleMain(Void) -{ - /// - Find a network drive called "/Remote/newoskrnl" - /// - Download our image - /// - Boot from it. - - return kEfiOk; -} diff --git a/Boot/NetBoot/NetBoot.hxx b/Boot/NetBoot/NetBoot.hxx deleted file mode 100644 index 1a474501..00000000 --- a/Boot/NetBoot/NetBoot.hxx +++ /dev/null @@ -1,26 +0,0 @@ -/* - * ======================================================== - * - * NetBoot - * Copyright ZKA Technologies, all rights reserved. - * - * ======================================================== - */ - -#pragma once - -#include - -/// @brief the internet header is used to download updates OTA. -typedef struct NetBootInternetHeader -{ - Kernel::Char NB1; /// magic char 1 'N' - Kernel::Char NB2; /// magic char 2 'E' - Kernel::Char NB3; /// magic char 3 'T' - Kernel::Char NB4; /// magic char 4 'B' - - Kernel::Char PatchName[255]; /// example: ColdChoco - Kernel::Int32 PatchLength; /// the patch length. - Kernel::Char PatchTarget[255]; /// the target file. - Kernel::Boolean ImpliesROM; /// does it imply an EEPROM reprogram? -} NetBootInternetHeader; diff --git a/Boot/NetBoot/compile_flags.txt b/Boot/NetBoot/compile_flags.txt deleted file mode 100644 index f9ca281f..00000000 --- a/Boot/NetBoot/compile_flags.txt +++ /dev/null @@ -1,8 +0,0 @@ --std=c++20 --I../ --I../../ --I../../Kernel --D__NEWOS_AMD64__ --std=c++20 --D__x86_64__ --D__NEWOS_OTA__ diff --git a/Boot/NetBoot/manifest.json b/Boot/NetBoot/manifest.json deleted file mode 100644 index 825677f7..00000000 --- a/Boot/NetBoot/manifest.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "pluginName": "iBoot", - "description": "Boot your device from your network infrastructure." -} diff --git a/Boot/ReadMe.md b/Boot/ReadMe.md index 47e76793..1c2b95af 100644 --- a/Boot/ReadMe.md +++ b/Boot/ReadMe.md @@ -1,4 +1,4 @@ -# newosldr +# newosldr (Zeta Bootloader Architecture) You need: @@ -11,7 +11,7 @@ Start by cloning the repo: git clone git@bitbucket.org:mahrouss/microkernel.git ``` -And execute: +And then execute: ``` make all diff --git a/Boot/download-ovmf.ps1 b/Boot/download-ovmf.ps1 deleted file mode 100644 index 5a2c5f0e..00000000 --- a/Boot/download-ovmf.ps1 +++ /dev/null @@ -1,4 +0,0 @@ -$client = new-object System.Net.WebClient -$output = "$PSScriptRoot\OVMF.fd" - -$client.DownloadFile("https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd", $output) diff --git a/Boot/ovmf.ps1 b/Boot/ovmf.ps1 new file mode 100644 index 00000000..5a2c5f0e --- /dev/null +++ b/Boot/ovmf.ps1 @@ -0,0 +1,4 @@ +$client = new-object System.Net.WebClient +$output = "$PSScriptRoot\OVMF.fd" + +$client.DownloadFile("https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd", $output) diff --git a/Comm/newstd.hxx b/Comm/newstd.hxx index 65a28205..d8ef3123 100644 --- a/Comm/newstd.hxx +++ b/Comm/newstd.hxx @@ -14,15 +14,15 @@ Purpose: System Call Interface. #error !!! including header in kernel mode !!! #endif // __KERNEL__ -#define ML_IMPORT_CXX extern "C++" -#define ML_IMPORT_C extern "C" +#define IMPORT_CXX extern "C++" +#define IMPORT_C extern "C" #define cRestrictR "r" #define cRestrictRB "rb" #define cRestrictW "w" #define cRestrictRW "rw" -class NSyscall; /// @brief System call class. +class NSSyscallInterface; /// @brief System call class. typedef int OSType; typedef bool Bool; @@ -42,35 +42,35 @@ typedef __INT8_TYPE__ SInt8; typedef char UTFChar; -typedef UInt32 MBCIType; +typedef UInt32 PowerID; /** @brief System call class. */ -class NSyscall +class NSSyscallInterface { public: - explicit NSyscall() = default; - virtual ~NSyscall() = default; + explicit NSSyscallInterface() = default; + virtual ~NSSyscallInterface() = default; - NSyscall& operator=(const NSyscall&) = default; - NSyscall(const NSyscall&) = default; + NSSyscallInterface& operator=(const NSSyscallInterface&) = default; + NSSyscallInterface(const NSSyscallInterface&) = default; public: /// @brief disable device. - virtual UInt0 PowerOff(MBCIType) = 0; + virtual UInt0 PowerOff(PowerID) = 0; /// @brief enable device. - virtual UInt0 PowerOn(MBCIType) = 0; + virtual UInt0 PowerOn(PowerID) = 0; /// @brief reboot device. - virtual UInt0 PowerReboot(MBCIType) = 0; + virtual UInt0 PowerReboot(PowerID) = 0; /// @brief check if MBCI device is wokeup. - virtual Bool PowerIsWokeup(MBCIType) = 0; + virtual Bool PowerIsWokeup(PowerID) = 0; - /// @brief probe MBCI device from phone. - virtual MBCIType PowerProbeDevice(const char* namepace, const int index) = 0; + /// @brief probe MBCI/ACPI device from phone. + virtual PowerID PowerProbeDevice(const char* namepace, const int index) = 0; // THOSE DOESNT REQUIRE PERMISSIONS FROM THE USER. // @@ -116,12 +116,8 @@ public: virtual UInt0* WriteStorage(const UTFChar* cmdNameOrData, SizeT cmdSize, OSType descriptorType) = 0; }; -/// @brief Request syscall object. +/// @brief Get shared syscall object. /// @return Syscall implementation. -ML_IMPORT_C NSyscall* NRequestSyscall(UInt0); - -/// @brief Release syscall object. -/// @param syscall System call object. -ML_IMPORT_C UInt0 NReleaseSyscall(NSyscall* syscall); +IMPORT_C NSSyscallInterface* NSGetSharedSyscallInterface(UInt0); #endif // ifndef _INC_COMM_NEWSTD_HXX_ diff --git a/Kernel/Docs/TODO-LIST.md b/Kernel/Docs/TODO-LIST.md index ed7b1cf9..62cc886c 100644 --- a/Kernel/Docs/TODO-LIST.md +++ b/Kernel/Docs/TODO-LIST.md @@ -13,11 +13,13 @@ - AHCI driver [ WiP ] - Context switch x87/SSE/AVX registers [ X ] - Framebuffer [ X ] -- AHCI support [ ] -- Make installer [ ] +- ATA support [ X ] +- Make installer [ X ] Status: -newosldr: Need to boot from EPM partition. +newosldr: Need to boot from EPM partition. [ X ]
-NewKernel: New Filesystem in progress. +NewKernel: New Filesystem is done. [ X ] + +**Refer to Jira!** diff --git a/Kernel/FSKit/NewFS.hxx b/Kernel/FSKit/NewFS.hxx index 25b85ee0..27ce95d5 100644 --- a/Kernel/FSKit/NewFS.hxx +++ b/Kernel/FSKit/NewFS.hxx @@ -71,7 +71,7 @@ default. #define kNewFSSeparator '\\' #define kNewFSUpDir ".." -#define kNewFSRoot "C:\\" +#define kNewFSRoot "\\" #define kNewFSLF '\r' #define kNewFSEOF (-1) diff --git a/Kernel/KernelKit/DebugOutput.hpp b/Kernel/KernelKit/DebugOutput.hpp index 10895c1a..02b73fc9 100644 --- a/Kernel/KernelKit/DebugOutput.hpp +++ b/Kernel/KernelKit/DebugOutput.hpp @@ -205,4 +205,4 @@ namespace Kernel #endif // ifdef kcout #define kcout TerminalDevice::The() -#define endl end_line() +#define endl kcout << Kernel::end_line() diff --git a/Kernel/NewKit/Json.hxx b/Kernel/NewKit/Json.hxx index 4b994606..9371bf15 100644 --- a/Kernel/NewKit/Json.hxx +++ b/Kernel/NewKit/Json.hxx @@ -16,7 +16,8 @@ #include #define cMaxJsonPath 4096 -#define cUndefinedLen 32 +#define cJSONLen 32 +#define cJSONNull "null" namespace Kernel { @@ -25,10 +26,13 @@ namespace Kernel { public: explicit JsonType() - : Kernel::JsonType(cUndefinedLen, cUndefinedLen) { - this->AsKey() += "undefined"; - this->AsValue() += "undefined"; + auto len = cJSONLen; + StringView key = StringView(len); + key += cJSONNull; + + this->AsKey() = key; + this->AsValue() = key; } explicit JsonType(SizeT lhsLen, SizeT rhsLen) @@ -40,7 +44,7 @@ namespace Kernel NEWOS_COPY_DEFAULT(JsonType); - Bool IsUndefined() { return fUndefined; } + const Bool& IsUndefined() { return fUndefined; } private: Bool fUndefined; // is this instance undefined? @@ -62,7 +66,7 @@ namespace Kernel return fValue; } - static JsonType kUndefined; + static JsonType kNull; }; /// @brief Json stream reader helper. @@ -71,7 +75,7 @@ namespace Kernel STATIC JsonType In(const Char* full_array) { if (full_array[0] != '{') - return JsonType::kUndefined; + return JsonType::kNull; SizeT len = rt_string_len(full_array); Boolean probe_value = false; diff --git a/Kernel/NewKit/Variant.hpp b/Kernel/NewKit/Variant.hpp index 27cd29cc..c118eda1 100644 --- a/Kernel/NewKit/Variant.hpp +++ b/Kernel/NewKit/Variant.hpp @@ -8,6 +8,7 @@ #include #include +#include namespace Kernel { @@ -17,8 +18,9 @@ namespace Kernel enum class VariantKind { kString, - kPointer, - kUndefined + kBlob, + kNull, + kJson, }; public: @@ -35,20 +37,28 @@ namespace Kernel : fPtr((voidPtr)stringView), fKind(VariantKind::kString) { } + + explicit Variant(JsonType* json) + : fPtr((voidPtr)json), fKind(VariantKind::kJson) + { + } + explicit Variant(nullPtr) - : fPtr(nullptr), fKind(VariantKind::kUndefined) + : fPtr(nullptr), fKind(VariantKind::kNull) { } + explicit Variant(voidPtr ptr) - : fPtr(ptr), fKind(VariantKind::kPointer) + : fPtr(ptr), fKind(VariantKind::kBlob) { } public: const Char* ToString(); + VoidPtr Leak(); private: voidPtr fPtr{nullptr}; - VariantKind fKind{VariantKind::kUndefined}; + VariantKind fKind{VariantKind::kNull}; }; } // namespace Kernel diff --git a/Kernel/Sources/FS/NewFS.cxx b/Kernel/Sources/FS/NewFS.cxx index 85926ff9..f796dd97 100644 --- a/Kernel/Sources/FS/NewFS.cxx +++ b/Kernel/Sources/FS/NewFS.cxx @@ -39,8 +39,8 @@ Kernel::SizeT drv_std_get_drv_size(); /***********************************************************************************/ /// This file implements the New File System. /// New File System implements a B-Tree based algortihm. -/// C:\\ -/// \\Path1\\ /\\ath2\\ +/// \\ +/// \\Path1\\ \\ath2\\ /// \\readme.rtf \\ListContents.pef \\readme.lnk <-- symlink. /// \\Path1\\readme.rtf /***********************************************************************************/ diff --git a/Kernel/Sources/Json.cxx b/Kernel/Sources/Json.cxx index 6ecd8e47..ffec19ce 100644 --- a/Kernel/Sources/Json.cxx +++ b/Kernel/Sources/Json.cxx @@ -9,4 +9,4 @@ using namespace Kernel; /// @brief Undefined object, is null in length. -cInitObject(Kernel::JsonType::kUndefined, Kernel::JsonType); +cInitObject(Kernel::JsonType::kNull, Kernel::JsonType); diff --git a/Kernel/Sources/Main.cxx b/Kernel/Sources/Main.cxx index 8c80d70c..c30b26e6 100644 --- a/Kernel/Sources/Main.cxx +++ b/Kernel/Sources/Main.cxx @@ -58,8 +58,8 @@ namespace Kernel::Detail constexpr auto cFolderInfo = "META-INF"; const auto cDirCount = 9; const char* cDirStr[cDirCount] = { - "C:\\Boot\\", "C:\\System\\", "C:\\Support\\", "C:\\Applications\\", - "C:\\Users\\", "C:\\Library\\", "C:\\Mount\\", "C:\\DCIM\\", "C:\\Storage\\"}; + "\\Boot\\", "\\System\\", "\\Support\\", "\\Applications\\", + "\\Users\\", "\\Library\\", "\\Mount\\", "\\DCIM\\", "\\Storage\\"}; for (Kernel::SizeT dirIndx = 0UL; dirIndx < cDirCount; ++dirIndx) { @@ -119,7 +119,7 @@ namespace Kernel::Detail } NewCatalog* catalogDisk = - this->fNewFS->GetParser()->GetCatalog("C:\\Mount\\SIM:"); + this->fNewFS->GetParser()->GetCatalog("\\Mount\\SIM:"); const Kernel::Char* cSrcName = "DISK-INF"; @@ -130,7 +130,7 @@ namespace Kernel::Detail else { catalogDisk = - (NewCatalog*)this->Leak()->CreateAlias("C:\\Mount\\SIM:"); + (NewCatalog*)this->Leak()->CreateAlias("\\Mount\\SIM:"); Kernel::StringView diskFolder(kNewFSSectorSz); diff --git a/Kernel/Sources/Variant.cxx b/Kernel/Sources/Variant.cxx index 9788f18c..7dc71df5 100644 --- a/Kernel/Sources/Variant.cxx +++ b/Kernel/Sources/Variant.cxx @@ -12,13 +12,17 @@ namespace Kernel { switch (fKind) { + case VariantKind::kJson: + return ("Class:{Json}"); case VariantKind::kString: return ("Class:{String}"); - case VariantKind::kPointer: - return ("Class:{Pointer}"); + case VariantKind::kBlob: + return ("Class:{Blob}"); default: - return ("Class:{Undefined}"); + return ("Class:{Null}"); } } + /// @brief Leak variant's instance. + VoidPtr Variant::Leak() { return fPtr; } } // namespace Kernel -- cgit v1.2.3