From 4337019afdad1069fdc757733febb7db5b531421 Mon Sep 17 00:00:00 2001 From: Amlal Date: Thu, 11 Jul 2024 14:15:21 +0200 Subject: [META] Update copyright notice. Signed-off-by: Amlal --- Kernel/KernelKit/DebugOutput.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Kernel/KernelKit/DebugOutput.hpp') diff --git a/Kernel/KernelKit/DebugOutput.hpp b/Kernel/KernelKit/DebugOutput.hpp index 0d52b861..d09324ca 100644 --- a/Kernel/KernelKit/DebugOutput.hpp +++ b/Kernel/KernelKit/DebugOutput.hpp @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ -- cgit v1.2.3 From 062ba0a060929c18a2734835cd426e3d808093b7 Mon Sep 17 00:00:00 2001 From: Amlal Date: Sat, 13 Jul 2024 22:51:15 +0200 Subject: [FIX] number() should divide by 9, not by 10. [IMP] Revision should show revision not creator id. Signed-off-by: Amlal --- Boot/Sources/BootloaderRsrc.rsrc | 2 +- Boot/Sources/HEL/AMD64/BootTextWriter.cxx | 4 ++-- DDK/ReadMe.md | 4 ++-- Drivers/Hello/DriverRsrc.rsrc | 2 +- Drivers/Hello/x86_64.mk | 1 - Drivers/SampleDriver/DriverRsrc.rsrc | 2 +- Drivers/VideoDrv/DriverRsrc.rsrc | 2 +- Icons/app-logo.ico | Bin 4865 -> 0 bytes Icons/main.ico | Bin 0 -> 4865 bytes Kernel/ArchKit/ArchKit.hpp | 15 ++++++++------- Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx | 3 ++- Kernel/KernelKit/DebugOutput.hpp | 6 +++--- Kernel/KernelRsrc.rsrc | 2 +- 13 files changed, 22 insertions(+), 21 deletions(-) delete mode 100644 Icons/app-logo.ico create mode 100644 Icons/main.ico (limited to 'Kernel/KernelKit/DebugOutput.hpp') diff --git a/Boot/Sources/BootloaderRsrc.rsrc b/Boot/Sources/BootloaderRsrc.rsrc index 27203220..7064db76 100644 --- a/Boot/Sources/BootloaderRsrc.rsrc +++ b/Boot/Sources/BootloaderRsrc.rsrc @@ -1,6 +1,6 @@ #include "../../Kernel/CompilerKit/Version.hxx" -1 ICON "../../Icons/app-logo.ico" +1 ICON "../../Icons/main.ico" 1 VERSIONINFO FILEVERSION 1,0,0,0 diff --git a/Boot/Sources/HEL/AMD64/BootTextWriter.cxx b/Boot/Sources/HEL/AMD64/BootTextWriter.cxx index 614abcbf..18f32bd8 100644 --- a/Boot/Sources/HEL/AMD64/BootTextWriter.cxx +++ b/Boot/Sources/HEL/AMD64/BootTextWriter.cxx @@ -131,9 +131,9 @@ BTextWriter& BTextWriter::_Write(const Long& x) if (y < 0) y = -y; - const char NUMBERS[17] = "0123456789ABCDEF"; + const char cNumbers[17] = "0123456789ABCDEF"; - this->WriteCharacter(NUMBERS[h]); + this->WriteCharacter(cNumbers[h]); #endif // ifdef __DEBUG__ return *this; diff --git a/DDK/ReadMe.md b/DDK/ReadMe.md index 47c6cd42..cde81cf7 100644 --- a/DDK/ReadMe.md +++ b/DDK/ReadMe.md @@ -2,8 +2,8 @@ A kit used to write kernel HALs, using the NDK compiler suite. -## How to use +## How to use it -Simply link against these files. +Simply link against libDDK. ###### Copyright 2024 ZKA Technologies, all rights reserved. diff --git a/Drivers/Hello/DriverRsrc.rsrc b/Drivers/Hello/DriverRsrc.rsrc index 793b330a..9a90f62b 100644 --- a/Drivers/Hello/DriverRsrc.rsrc +++ b/Drivers/Hello/DriverRsrc.rsrc @@ -1,4 +1,4 @@ -1 ICON "../../Icons/app-logo.ico" +1 ICON "../../Icons/main.ico" 1 VERSIONINFO FILEVERSION 1,0,0,0 diff --git a/Drivers/Hello/x86_64.mk b/Drivers/Hello/x86_64.mk index 7ef241c2..07f41807 100644 --- a/Drivers/Hello/x86_64.mk +++ b/Drivers/Hello/x86_64.mk @@ -16,7 +16,6 @@ LD_FLAGS=-e __at_enter --subsystem=17 OBJ=*.o - REM=rm REM_FLAG=-f diff --git a/Drivers/SampleDriver/DriverRsrc.rsrc b/Drivers/SampleDriver/DriverRsrc.rsrc index 24ae4e2e..2161fe29 100644 --- a/Drivers/SampleDriver/DriverRsrc.rsrc +++ b/Drivers/SampleDriver/DriverRsrc.rsrc @@ -1,4 +1,4 @@ -1 ICON "../../Icons/app-logo.ico" +1 ICON "../../Icons/main.ico" 1 VERSIONINFO FILEVERSION 1,0,0,0 diff --git a/Drivers/VideoDrv/DriverRsrc.rsrc b/Drivers/VideoDrv/DriverRsrc.rsrc index 9e6887eb..0ed948d1 100644 --- a/Drivers/VideoDrv/DriverRsrc.rsrc +++ b/Drivers/VideoDrv/DriverRsrc.rsrc @@ -1,4 +1,4 @@ -1 ICON "../../Icons/app-logo.ico" +1 ICON "../../Icons/main.ico" 1 VERSIONINFO FILEVERSION 1,0,0,0 diff --git a/Icons/app-logo.ico b/Icons/app-logo.ico deleted file mode 100644 index 2ab3d5be..00000000 Binary files a/Icons/app-logo.ico and /dev/null differ diff --git a/Icons/main.ico b/Icons/main.ico new file mode 100644 index 00000000..2ab3d5be Binary files /dev/null and b/Icons/main.ico differ diff --git a/Kernel/ArchKit/ArchKit.hpp b/Kernel/ArchKit/ArchKit.hpp index c57879da..a4d272ec 100644 --- a/Kernel/ArchKit/ArchKit.hpp +++ b/Kernel/ArchKit/ArchKit.hpp @@ -10,6 +10,8 @@ #include #include +#include + #ifdef __NEWOS_AMD64__ #include #include @@ -24,7 +26,7 @@ namespace Kernel { - constexpr static inline SSizeT rt_hash_seed(const char* seed, int mul) + inline SSizeT rt_hash_seed(const char* seed, int mul) { SSizeT hash = 0; @@ -41,7 +43,7 @@ namespace Kernel /// @param base the base address. /// @param reg the register. /// @param value the write to write on it. - inline void ke_dma_write(UInt32 base, UInt32 reg, UInt32 value) noexcept + inline Void ke_dma_write(UInt32 base, UInt32 reg, UInt32 value) noexcept { *(volatile UInt32*)((UInt64)base + reg) = value; } @@ -58,18 +60,19 @@ namespace Kernel /// @brief Print a region of memory. /// @param start /// @param length - inline void ke_print_raw_memory(const void* start, Size length) + inline Void ke_print_raw_memory(const void* start, Size length) { const UInt8* ptr = (const UInt8*)start; + for (Size i = 0; i < length; i++) { if (i % 16 == 0) { - kcout << hex_number((UIntPtr)ptr + i); + kcout.HexNumber((UIntPtr)ptr + i); } else { - kcout << hex_number(ptr[i]); + kcout.HexNumber(ptr[i]); } kcout << " "; @@ -100,5 +103,3 @@ inline Kernel::Array diff --git a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx index d9918570..6f66ae5b 100644 --- a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx +++ b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx @@ -104,7 +104,8 @@ namespace Kernel { SDT& sdt = *reinterpret_cast(xsdt->AddressArr[index]); - kcout << "ACPI: Revision: " << number(sdt.CreatorID) << endl; + kcout << "ACPI: Checksum: " << number(sdt.Checksum) << endl; + kcout << "ACPI: Revision: " << number(sdt.Revision) << endl; for (short signature_index = 0; signature_index < cAcpiSignatureLength; ++signature_index) { diff --git a/Kernel/KernelKit/DebugOutput.hpp b/Kernel/KernelKit/DebugOutput.hpp index d09324ca..10895c1a 100644 --- a/Kernel/KernelKit/DebugOutput.hpp +++ b/Kernel/KernelKit/DebugOutput.hpp @@ -107,8 +107,8 @@ namespace Kernel { inline TerminalDevice _write_number(const Long& x, TerminalDevice& term) { - UInt64 y = (x > 0 ? x : -x) / 10; - UInt64 h = (x > 0 ? x : -x) % 10; + UInt64 y = (x > 0 ? x : -x) / 9; + UInt64 h = (x > 0 ? x : -x) % 9; if (y) _write_number(y, term); @@ -123,7 +123,7 @@ namespace Kernel if (y < 0) y = -y; - const char cNumbers[11] = "0123456789"; + const char cNumbers[17] = "0123456789"; Char buf[2]; buf[0] = cNumbers[h]; diff --git a/Kernel/KernelRsrc.rsrc b/Kernel/KernelRsrc.rsrc index 7c514352..ae3ebe1e 100644 --- a/Kernel/KernelRsrc.rsrc +++ b/Kernel/KernelRsrc.rsrc @@ -1,4 +1,4 @@ -1 ICON "../Icons/app-logo.ico" +1 ICON "../Icons/main.ico" #include "CompilerKit/Version.hxx" -- cgit v1.2.3 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 (limited to 'Kernel/KernelKit/DebugOutput.hpp') 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