From ce84bea215424ff36a2c18cab67835edfa8f71b5 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 27 May 2024 13:50:07 +0200 Subject: MHR-23: :boom: Change ::Shared() to ::The(). Signed-off-by: Amlal El Mahrouss --- Kernel/KernelKit/DebugOutput.hpp | 18 +++++++++--------- Kernel/KernelKit/ProcessScheduler.hpp | 2 +- Kernel/KernelKit/SMPManager.hpp | 2 +- Kernel/KernelKit/ThreadLocalStorage.inl | 8 ++++---- 4 files changed, 15 insertions(+), 15 deletions(-) (limited to 'Kernel/KernelKit') diff --git a/Kernel/KernelKit/DebugOutput.hpp b/Kernel/KernelKit/DebugOutput.hpp index 594ca701..3acee338 100644 --- a/Kernel/KernelKit/DebugOutput.hpp +++ b/Kernel/KernelKit/DebugOutput.hpp @@ -73,26 +73,26 @@ namespace NewOS NEWOS_COPY_DEFAULT(TerminalDevice); - static TerminalDevice& Shared() noexcept; + static TerminalDevice& The() noexcept; }; inline TerminalDevice& end_line() { - TerminalDevice& selfTerm = TerminalDevice::Shared(); + TerminalDevice& selfTerm = TerminalDevice::The(); selfTerm << "\r"; return selfTerm; } inline TerminalDevice& carriage_return() { - TerminalDevice& selfTerm = TerminalDevice::Shared(); + TerminalDevice& selfTerm = TerminalDevice::The(); selfTerm << "\r"; return selfTerm; } inline TerminalDevice& tabulate() { - TerminalDevice& selfTerm = TerminalDevice::Shared(); + TerminalDevice& selfTerm = TerminalDevice::The(); selfTerm << "\t"; return selfTerm; } @@ -100,7 +100,7 @@ namespace NewOS /// @brief emulate a terminal bell, like the VT100 does. inline TerminalDevice& bell() { - TerminalDevice& selfTerm = TerminalDevice::Shared(); + TerminalDevice& selfTerm = TerminalDevice::The(); selfTerm << "\a"; return selfTerm; } @@ -166,7 +166,7 @@ namespace NewOS inline TerminalDevice& hex_number(const Long& x) { - TerminalDevice& selfTerm = TerminalDevice::Shared(); + TerminalDevice& selfTerm = TerminalDevice::The(); selfTerm << "0x"; Detail::_write_number_hex(x, selfTerm); @@ -176,7 +176,7 @@ namespace NewOS inline TerminalDevice& number(const Long& x) { - TerminalDevice& selfTerm = TerminalDevice::Shared(); + TerminalDevice& selfTerm = TerminalDevice::The(); Detail::_write_number(x, selfTerm); @@ -185,7 +185,7 @@ namespace NewOS inline TerminalDevice& get_console_in(Char* buf) { - TerminalDevice& selfTerm = TerminalDevice::Shared(); + TerminalDevice& selfTerm = TerminalDevice::The(); selfTerm >> buf; return selfTerm; } @@ -204,5 +204,5 @@ namespace NewOS #undef kcout #endif // ifdef kcout -#define kcout TerminalDevice::Shared() +#define kcout TerminalDevice::The() #define endl end_line() diff --git a/Kernel/KernelKit/ProcessScheduler.hpp b/Kernel/KernelKit/ProcessScheduler.hpp index 8670691f..9adaac0d 100644 --- a/Kernel/KernelKit/ProcessScheduler.hpp +++ b/Kernel/KernelKit/ProcessScheduler.hpp @@ -270,7 +270,7 @@ namespace NewOS SizeT Run() noexcept; public: - static Ref Shared(); + static Ref The(); private: ProcessTeam mTeam; diff --git a/Kernel/KernelKit/SMPManager.hpp b/Kernel/KernelKit/SMPManager.hpp index 12260a33..eb8c908a 100644 --- a/Kernel/KernelKit/SMPManager.hpp +++ b/Kernel/KernelKit/SMPManager.hpp @@ -105,7 +105,7 @@ namespace NewOS public: /// @brief Shared instance of the SMP Manager. /// @return the reference to the smp manager. - static Ref Shared(); + static Ref The(); public: /// @brief Returns the amount of threads present in the system. diff --git a/Kernel/KernelKit/ThreadLocalStorage.inl b/Kernel/KernelKit/ThreadLocalStorage.inl index 6407900f..e2137ed6 100644 --- a/Kernel/KernelKit/ThreadLocalStorage.inl +++ b/Kernel/KernelKit/ThreadLocalStorage.inl @@ -15,9 +15,9 @@ inline T* tls_new_ptr(void) { using namespace NewOS; - MUST_PASS(ProcessScheduler::Shared().Leak().GetCurrent()); + MUST_PASS(ProcessScheduler::The().Leak().GetCurrent()); - auto ref_process = ProcessScheduler::Shared().Leak().GetCurrent(); + auto ref_process = ProcessScheduler::The().Leak().GetCurrent(); T* pointer = (T*)ref_process.Leak().New(sizeof(T)); return pointer; @@ -32,9 +32,9 @@ inline bool tls_delete_ptr(T* ptr) using namespace NewOS; - MUST_PASS(ProcessScheduler::Shared().Leak().GetCurrent()); + MUST_PASS(ProcessScheduler::The().Leak().GetCurrent()); - auto ref_process = ProcessScheduler::Shared().Leak().GetCurrent(); + auto ref_process = ProcessScheduler::The().Leak().GetCurrent(); return ref_process.Leak().Delete(ptr, sizeof(T)); } -- cgit v1.2.3 From 9db58da40cfcb6643412bfae25aefc0cd1077f9d Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 27 May 2024 20:45:46 +0200 Subject: MHR-23: Improve project structure, make it better. Signed-off-by: Amlal El Mahrouss --- .vscode/c_cpp_properties.json | 12 +- DriverKit/KernelCall.c | 25 +++ DriverKit/KernelDev.c | 37 ++++ DriverKit/KernelDev.h | 33 +++ DriverKit/KernelDispatchCall.S | 21 ++ DriverKit/KernelPrint.c | 33 +++ DriverKit/KernelPrint.h | 18 ++ DriverKit/KernelStd.h | 22 ++ DriverKit/KernelStdCxx.cc | 24 +++ DriverKit/KernelString.c | 34 +++ DriverKit/KernelString.h | 16 ++ DriverKit/ReadMe.txt | 4 + Drivers/.gitkeep | 0 Drivers/Bonjour/Bonjour.c | 20 ++ Drivers/Bonjour/DriverRsrc.rsrc | 25 +++ Drivers/Bonjour/x86_64.mk | 51 +++++ Drivers/DynamicLoader/DriverRsrc.rsrc | 25 +++ Drivers/DynamicLoader/DynamicLoader.c | 26 +++ Drivers/DynamicLoader/x86_64.mk | 51 +++++ Drivers/SampleDriver/DriverRsrc.rsrc | 25 +++ Drivers/SampleDriver/SampleDriver.c | 26 +++ Drivers/SampleDriver/x86_64.mk | 51 +++++ Kernel/DriverKit/KernelCall.c | 25 --- Kernel/DriverKit/KernelDev.c | 37 ---- Kernel/DriverKit/KernelDev.h | 33 --- Kernel/DriverKit/KernelDispatchCall.S | 21 -- Kernel/DriverKit/KernelPrint.c | 33 --- Kernel/DriverKit/KernelPrint.h | 18 -- Kernel/DriverKit/KernelStd.h | 22 -- Kernel/DriverKit/KernelStdCxx.cc | 24 --- Kernel/DriverKit/KernelString.c | 34 --- Kernel/DriverKit/KernelString.h | 16 -- Kernel/Drivers/.gitkeep | 0 Kernel/Drivers/Bonjour/Bonjour.c | 20 -- Kernel/Drivers/Bonjour/DriverRsrc.rsrc | 25 --- Kernel/Drivers/Bonjour/x86_64.mk | 52 ----- Kernel/Drivers/MahroussUpdate/DriverRsrc.rsrc | 25 --- Kernel/Drivers/MahroussUpdate/MahroussUpdate.cc | 24 --- Kernel/Drivers/MahroussUpdate/MahroussUpdate.hxx | 37 ---- Kernel/Drivers/MahroussUpdate/x86_64.mk | 53 ----- Kernel/Drivers/SampleDriver/DriverRsrc.rsrc | 25 --- Kernel/Drivers/SampleDriver/SampleDriver.c | 25 --- Kernel/Drivers/SampleDriver/x86_64.mk | 52 ----- Kernel/KernelKit/DeviceManager.hpp | 4 +- Kernel/KernelKit/DriveManager.hxx | 6 +- Kernel/KernelKit/Framebuffer.hpp | 1 + Kernel/KernelKit/XCOFF.hxx | 24 ++- Kernel/KernelRsrc.rsrc | 6 +- SDK/Dist/.gitkeep | 0 SDK/Libraries/.gitkeep | 0 SDK/Libraries/CoreCxxRuntime/.gitkeep | 0 SDK/Libraries/CoreCxxRuntime/Private.xml | 3 + .../CoreCxxRuntime/Sources/New+Delete.cxx | 33 +++ SDK/Libraries/CorePEFRuntime/.gitkeep | 0 SDK/Libraries/CorePEFRuntime/Private.xml | 3 + SDK/Libraries/CorePEFRuntime/Sources/PEFStart.c | 23 ++ SDK/Libraries/CoreSystem/.gitkeep | 0 SDK/Libraries/CoreSystem/AMD64/CoreAssembly.s | 28 +++ SDK/Libraries/CoreSystem/ARM64/.gitkeep | 0 SDK/Libraries/CoreSystem/Headers/Alert.h | 25 +++ SDK/Libraries/CoreSystem/Headers/Defines.h | 235 +++++++++++++++++++++ SDK/Libraries/CoreSystem/Headers/File.h | 52 +++++ SDK/Libraries/CoreSystem/Headers/Heap.h | 39 ++++ SDK/Libraries/CoreSystem/Headers/Hint.h | 20 ++ SDK/Libraries/CoreSystem/Headers/Intl.h | 29 +++ SDK/Libraries/CoreSystem/Headers/Math.h | 27 +++ SDK/Libraries/CoreSystem/Headers/Rsrc.h | 12 ++ SDK/Libraries/CoreSystem/Headers/Thread.h | 47 +++++ SDK/Libraries/CoreSystem/Headers/Transport.h | 48 +++++ SDK/Libraries/CoreSystem/POWER/CoreAssembly.s | 23 ++ SDK/Libraries/CoreSystem/Private.xml | 4 + SDK/Libraries/CoreSystem/RISCV/.gitkeep | 0 SDK/Libraries/CoreSystem/ReadMe.md | 13 ++ SDK/Libraries/CoreSystem/Sources/App.c | 31 +++ SDK/Libraries/CoreSystem/Sources/CRTStartup.c | 12 ++ SDK/Libraries/CoreSystem/Sources/File.c | 58 +++++ SDK/Libraries/CoreSystem/Sources/Heap.c | 54 +++++ SDK/Libraries/CoreSystem/Sources/Math.c | 14 ++ SDK/Libraries/CoreSystem/Sources/Thread.c | 9 + SDK/Libraries/CoreSystem/amd64.mk | 22 ++ SDK/Libraries/CoreSystem/compile_flags.txt | 4 + SDK/Library/.gitkeep | 0 SDK/Library/CoreCxxRuntime/.gitkeep | 0 SDK/Library/CoreCxxRuntime/Private.xml | 3 - SDK/Library/CoreCxxRuntime/Sources/New+Delete.cxx | 33 --- SDK/Library/CorePEFRuntime/.gitkeep | 0 SDK/Library/CorePEFRuntime/Private.xml | 3 - SDK/Library/CorePEFRuntime/Sources/PEFStart.c | 23 -- SDK/Library/CoreSystem/.gitkeep | 0 SDK/Library/CoreSystem/AMD64/CoreAssembly.s | 28 --- SDK/Library/CoreSystem/ARM64/.gitkeep | 0 SDK/Library/CoreSystem/Headers/Alert.h | 25 --- SDK/Library/CoreSystem/Headers/Defines.h | 235 --------------------- SDK/Library/CoreSystem/Headers/File.h | 52 ----- SDK/Library/CoreSystem/Headers/Heap.h | 39 ---- SDK/Library/CoreSystem/Headers/Hint.h | 20 -- SDK/Library/CoreSystem/Headers/Intl.h | 29 --- SDK/Library/CoreSystem/Headers/Math.h | 27 --- SDK/Library/CoreSystem/Headers/Rsrc.h | 12 -- SDK/Library/CoreSystem/Headers/Thread.h | 47 ----- SDK/Library/CoreSystem/Headers/Transport.h | 48 ----- SDK/Library/CoreSystem/POWER/CoreAssembly.s | 23 -- SDK/Library/CoreSystem/Private.xml | 4 - SDK/Library/CoreSystem/RISCV/.gitkeep | 0 SDK/Library/CoreSystem/ReadMe.md | 13 -- SDK/Library/CoreSystem/Sources/App.c | 31 --- SDK/Library/CoreSystem/Sources/CRTStartup.c | 12 -- SDK/Library/CoreSystem/Sources/File.c | 58 ----- SDK/Library/CoreSystem/Sources/Heap.c | 54 ----- SDK/Library/CoreSystem/Sources/Math.c | 14 -- SDK/Library/CoreSystem/Sources/Thread.c | 9 - SDK/Library/CoreSystem/amd64.mk | 22 -- SDK/Library/CoreSystem/compile_flags.txt | 4 - SDK/Tools/.gitkeep | 0 114 files changed, 1470 insertions(+), 1487 deletions(-) create mode 100644 DriverKit/KernelCall.c create mode 100644 DriverKit/KernelDev.c create mode 100644 DriverKit/KernelDev.h create mode 100644 DriverKit/KernelDispatchCall.S create mode 100644 DriverKit/KernelPrint.c create mode 100644 DriverKit/KernelPrint.h create mode 100644 DriverKit/KernelStd.h create mode 100644 DriverKit/KernelStdCxx.cc create mode 100644 DriverKit/KernelString.c create mode 100644 DriverKit/KernelString.h create mode 100644 DriverKit/ReadMe.txt create mode 100644 Drivers/.gitkeep create mode 100644 Drivers/Bonjour/Bonjour.c create mode 100644 Drivers/Bonjour/DriverRsrc.rsrc create mode 100644 Drivers/Bonjour/x86_64.mk create mode 100644 Drivers/DynamicLoader/DriverRsrc.rsrc create mode 100644 Drivers/DynamicLoader/DynamicLoader.c create mode 100644 Drivers/DynamicLoader/x86_64.mk create mode 100644 Drivers/SampleDriver/DriverRsrc.rsrc create mode 100644 Drivers/SampleDriver/SampleDriver.c create mode 100644 Drivers/SampleDriver/x86_64.mk delete mode 100644 Kernel/DriverKit/KernelCall.c delete mode 100644 Kernel/DriverKit/KernelDev.c delete mode 100644 Kernel/DriverKit/KernelDev.h delete mode 100644 Kernel/DriverKit/KernelDispatchCall.S delete mode 100644 Kernel/DriverKit/KernelPrint.c delete mode 100644 Kernel/DriverKit/KernelPrint.h delete mode 100644 Kernel/DriverKit/KernelStd.h delete mode 100644 Kernel/DriverKit/KernelStdCxx.cc delete mode 100644 Kernel/DriverKit/KernelString.c delete mode 100644 Kernel/DriverKit/KernelString.h delete mode 100644 Kernel/Drivers/.gitkeep delete mode 100644 Kernel/Drivers/Bonjour/Bonjour.c delete mode 100644 Kernel/Drivers/Bonjour/DriverRsrc.rsrc delete mode 100644 Kernel/Drivers/Bonjour/x86_64.mk delete mode 100644 Kernel/Drivers/MahroussUpdate/DriverRsrc.rsrc delete mode 100644 Kernel/Drivers/MahroussUpdate/MahroussUpdate.cc delete mode 100644 Kernel/Drivers/MahroussUpdate/MahroussUpdate.hxx delete mode 100644 Kernel/Drivers/MahroussUpdate/x86_64.mk delete mode 100644 Kernel/Drivers/SampleDriver/DriverRsrc.rsrc delete mode 100644 Kernel/Drivers/SampleDriver/SampleDriver.c delete mode 100644 Kernel/Drivers/SampleDriver/x86_64.mk create mode 100644 SDK/Dist/.gitkeep create mode 100644 SDK/Libraries/.gitkeep create mode 100644 SDK/Libraries/CoreCxxRuntime/.gitkeep create mode 100644 SDK/Libraries/CoreCxxRuntime/Private.xml create mode 100644 SDK/Libraries/CoreCxxRuntime/Sources/New+Delete.cxx create mode 100644 SDK/Libraries/CorePEFRuntime/.gitkeep create mode 100644 SDK/Libraries/CorePEFRuntime/Private.xml create mode 100644 SDK/Libraries/CorePEFRuntime/Sources/PEFStart.c create mode 100644 SDK/Libraries/CoreSystem/.gitkeep create mode 100644 SDK/Libraries/CoreSystem/AMD64/CoreAssembly.s create mode 100644 SDK/Libraries/CoreSystem/ARM64/.gitkeep create mode 100644 SDK/Libraries/CoreSystem/Headers/Alert.h create mode 100644 SDK/Libraries/CoreSystem/Headers/Defines.h create mode 100644 SDK/Libraries/CoreSystem/Headers/File.h create mode 100644 SDK/Libraries/CoreSystem/Headers/Heap.h create mode 100644 SDK/Libraries/CoreSystem/Headers/Hint.h create mode 100644 SDK/Libraries/CoreSystem/Headers/Intl.h create mode 100644 SDK/Libraries/CoreSystem/Headers/Math.h create mode 100644 SDK/Libraries/CoreSystem/Headers/Rsrc.h create mode 100644 SDK/Libraries/CoreSystem/Headers/Thread.h create mode 100644 SDK/Libraries/CoreSystem/Headers/Transport.h create mode 100644 SDK/Libraries/CoreSystem/POWER/CoreAssembly.s create mode 100644 SDK/Libraries/CoreSystem/Private.xml create mode 100644 SDK/Libraries/CoreSystem/RISCV/.gitkeep create mode 100644 SDK/Libraries/CoreSystem/ReadMe.md create mode 100644 SDK/Libraries/CoreSystem/Sources/App.c create mode 100644 SDK/Libraries/CoreSystem/Sources/CRTStartup.c create mode 100644 SDK/Libraries/CoreSystem/Sources/File.c create mode 100644 SDK/Libraries/CoreSystem/Sources/Heap.c create mode 100644 SDK/Libraries/CoreSystem/Sources/Math.c create mode 100644 SDK/Libraries/CoreSystem/Sources/Thread.c create mode 100644 SDK/Libraries/CoreSystem/amd64.mk create mode 100644 SDK/Libraries/CoreSystem/compile_flags.txt delete mode 100644 SDK/Library/.gitkeep delete mode 100644 SDK/Library/CoreCxxRuntime/.gitkeep delete mode 100644 SDK/Library/CoreCxxRuntime/Private.xml delete mode 100644 SDK/Library/CoreCxxRuntime/Sources/New+Delete.cxx delete mode 100644 SDK/Library/CorePEFRuntime/.gitkeep delete mode 100644 SDK/Library/CorePEFRuntime/Private.xml delete mode 100644 SDK/Library/CorePEFRuntime/Sources/PEFStart.c delete mode 100644 SDK/Library/CoreSystem/.gitkeep delete mode 100644 SDK/Library/CoreSystem/AMD64/CoreAssembly.s delete mode 100644 SDK/Library/CoreSystem/ARM64/.gitkeep delete mode 100644 SDK/Library/CoreSystem/Headers/Alert.h delete mode 100644 SDK/Library/CoreSystem/Headers/Defines.h delete mode 100644 SDK/Library/CoreSystem/Headers/File.h delete mode 100644 SDK/Library/CoreSystem/Headers/Heap.h delete mode 100644 SDK/Library/CoreSystem/Headers/Hint.h delete mode 100644 SDK/Library/CoreSystem/Headers/Intl.h delete mode 100644 SDK/Library/CoreSystem/Headers/Math.h delete mode 100644 SDK/Library/CoreSystem/Headers/Rsrc.h delete mode 100644 SDK/Library/CoreSystem/Headers/Thread.h delete mode 100644 SDK/Library/CoreSystem/Headers/Transport.h delete mode 100644 SDK/Library/CoreSystem/POWER/CoreAssembly.s delete mode 100644 SDK/Library/CoreSystem/Private.xml delete mode 100644 SDK/Library/CoreSystem/RISCV/.gitkeep delete mode 100644 SDK/Library/CoreSystem/ReadMe.md delete mode 100644 SDK/Library/CoreSystem/Sources/App.c delete mode 100644 SDK/Library/CoreSystem/Sources/CRTStartup.c delete mode 100644 SDK/Library/CoreSystem/Sources/File.c delete mode 100644 SDK/Library/CoreSystem/Sources/Heap.c delete mode 100644 SDK/Library/CoreSystem/Sources/Math.c delete mode 100644 SDK/Library/CoreSystem/Sources/Thread.c delete mode 100644 SDK/Library/CoreSystem/amd64.mk delete mode 100644 SDK/Library/CoreSystem/compile_flags.txt delete mode 100644 SDK/Tools/.gitkeep (limited to 'Kernel/KernelKit') diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index cda7d4a1..d9d86a41 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -4,9 +4,11 @@ "name": "MicroKernel (Macintosh)", "includePath": [ "${workspaceFolder}/Kernel/**", + "${workspaceFolder}/Drivers/**", "${workspaceFolder}/Boot/**", - "${workspaceFolder}/SDK/Library/CoreSystem/**", - "${workspaceFolder}/SDK/Library/**" + "${workspaceFolder}/**", + "${workspaceFolder}/SDK/Libraries/CoreSystem/**", + "${workspaceFolder}/SDK/Libraries/**" ], "defines": [ "__MAHROUSS__", @@ -36,10 +38,12 @@ { "name": "MicroKernel (Windows)", "includePath": [ + "${workspaceFolder}/Drivers/**", "${workspaceFolder}/Kernel/**", "${workspaceFolder}/Boot/**", - "${workspaceFolder}/SDK/Library/CoreSystem/**", - "${workspaceFolder}/SDK/Library/**" + "${workspaceFolder}/**", + "${workspaceFolder}/SDK/Libraries/CoreSystem/**", + "${workspaceFolder}/SDK/Libraries/**" ], "defines": [ "__MAHROUSS__", diff --git a/DriverKit/KernelCall.c b/DriverKit/KernelCall.c new file mode 100644 index 00000000..d61f8439 --- /dev/null +++ b/DriverKit/KernelCall.c @@ -0,0 +1,25 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + + Purpose: Kernel Definitions. + +------------------------------------------- */ + +#include +#include + +DK_EXTERN __attribute__((naked)) void __kernelDispatchCall(int32_t cnt, ...); + +DK_EXTERN void* kernelCall(const char* kernelRpcName, int32_t cnt, ...) +{ + if (!kernelRpcName || cnt == 0) + return NIL; + + va_list arg; + va_start(arg, cnt); + + __kernelDispatchCall(cnt, arg); + + va_end(arg); +} diff --git a/DriverKit/KernelDev.c b/DriverKit/KernelDev.c new file mode 100644 index 00000000..704f17da --- /dev/null +++ b/DriverKit/KernelDev.c @@ -0,0 +1,37 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + + Purpose: Kernel Text I/O. + +------------------------------------------- */ + +#include + +/// @brief Open a new binary device from path. +DK_EXTERN kernelDeviceRef kernelOpenBinaryDevice(const char* devicePath) +{ + if (!devicePath) + return NIL; + + return kernelCall("OpenBinaryDevice", 1, devicePath); +} + +/// @brief Open a new character device from path. +DK_EXTERN kernelDeviceRef kernelOpenCharDevice(const char* devicePath) +{ + if (!devicePath) + return NIL; + + return kernelCall("OpenCharDevice", 1, devicePath); +} + +/// @brief Close any device. +/// @param device valid device. +DK_EXTERN void kernelCloseDevice(kernelDeviceRef device) +{ + if (!device) + return; + + kernelCall("CloseDevice", 1, device); +} diff --git a/DriverKit/KernelDev.h b/DriverKit/KernelDev.h new file mode 100644 index 00000000..c3435e8d --- /dev/null +++ b/DriverKit/KernelDev.h @@ -0,0 +1,33 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + + Purpose: Kernel Devices. + +------------------------------------------- */ + +#pragma once + +#include + +struct _kernelDevice; + +/// @brief Kernel Device driver. +typedef struct _kernelDevice +{ + char name[255]; // the device name. Could be /./DEVICE_NAME/ + int32_t (*read)(); // read from device. + int32_t (*write)(); // write to device. + struct _kernelDevice* (*open)(const char* path); // open device. + void (*close)(struct _kernelDevice* dev); // close device. +} kernelDevice, *kernelDeviceRef; + +/// @brief Open a new binary device from path. +DK_EXTERN kernelDeviceRef kernelOpenBinaryDevice(const char* devicePath); + +/// @brief Open a new character device from path. +DK_EXTERN kernelDeviceRef kernelOpenCharDevice(const char* devicePath); + +/// @brief Close any device. +/// @param device valid device. +DK_EXTERN void kernelCloseDevice(kernelDeviceRef device); diff --git a/DriverKit/KernelDispatchCall.S b/DriverKit/KernelDispatchCall.S new file mode 100644 index 00000000..64b6663e --- /dev/null +++ b/DriverKit/KernelDispatchCall.S @@ -0,0 +1,21 @@ +.globl __kernelDispatchCall + +.section .text + +/* Really simple function, takes our va-list, + and brings it to the trap handler in the kernel. */ + +#ifdef __x86_64__ + +__kernelDispatchCall: + int $0x33 + ret + +#elif defined(__powerpc64__) + +__kernelDispatchCall: + /* There is no specific interrupt request id for a system call in POWER. */ + sc + blr + +#endif diff --git a/DriverKit/KernelPrint.c b/DriverKit/KernelPrint.c new file mode 100644 index 00000000..533bf34a --- /dev/null +++ b/DriverKit/KernelPrint.c @@ -0,0 +1,33 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + + Purpose: Kernel Text I/O. + +------------------------------------------- */ + +#include + +DK_EXTERN void kernelPrintChar(const char ch) +{ + kernelCall("WriteCharacter", 1, ch); +} + +/// @brief print string to UART. +/// @param message UART to transmit. +DK_EXTERN void kernelPrintStr(const char* message) +{ + if (!message) + return; + if (*message == 0) + return; + + size_t index = 0; + size_t len = kernelStringLength(message); + + while (index < len) + { + kernelPrintChar(message[index]); + ++index; + } +} diff --git a/DriverKit/KernelPrint.h b/DriverKit/KernelPrint.h new file mode 100644 index 00000000..7bf0dda9 --- /dev/null +++ b/DriverKit/KernelPrint.h @@ -0,0 +1,18 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + + Purpose: Kernel Text I/O. + +------------------------------------------- */ + +#pragma once + +#include + +/// @brief print character into UART. +DK_EXTERN void kernelPrintChar(const char ch); + +/// @brief print string to UART. +/// @param message UART to transmit. +DK_EXTERN void kernelPrintStr(const char* message); diff --git a/DriverKit/KernelStd.h b/DriverKit/KernelStd.h new file mode 100644 index 00000000..b0dba70e --- /dev/null +++ b/DriverKit/KernelStd.h @@ -0,0 +1,22 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + + Purpose: Kernel Definitions. + +------------------------------------------- */ + +#pragma once + +#if defined(__cplusplus) +#define DK_EXTERN extern "C" +#define NIL nullptr +#else +#define DK_EXTERN extern +#define NIL NULL +#endif // defined(__cplusplus) + +#include +#include + +DK_EXTERN void* kernelCall(const char* kernelRpcName, int32_t cnt, ...); diff --git a/DriverKit/KernelStdCxx.cc b/DriverKit/KernelStdCxx.cc new file mode 100644 index 00000000..633437dc --- /dev/null +++ b/DriverKit/KernelStdCxx.cc @@ -0,0 +1,24 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + + Purpose: Driver C++ Definitions. + +------------------------------------------- */ + +#include + +void* operator new(size_t sz) { + if (!sz) ++sz; + + auto ptr = kernelCall("NewKernelHeap", 1, sz); + kernelCall("ProtectKernelHeap", 1, ptr); + + return ptr; +} + +void operator delete(void* ptr) noexcept { + if (!ptr) return; + + kernelCall("DeleteKernelHeap", 1,ptr); +} diff --git a/DriverKit/KernelString.c b/DriverKit/KernelString.c new file mode 100644 index 00000000..6f28f4d8 --- /dev/null +++ b/DriverKit/KernelString.c @@ -0,0 +1,34 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + + Purpose: Kernel Strings. + +------------------------------------------- */ + +#include + +DK_EXTERN size_t kernelStringLength(const char* str) +{ + size_t index = 0; + + while (str[index] != 0) + { + ++index; + } + + return index; +} + +DK_EXTERN int kernelStringCopy(char* dst, const char* src, size_t len) +{ + size_t index = 0; + + while (index != len) + { + dst[index] = src[index]; + ++index; + } + + return index; +} diff --git a/DriverKit/KernelString.h b/DriverKit/KernelString.h new file mode 100644 index 00000000..db063a1b --- /dev/null +++ b/DriverKit/KernelString.h @@ -0,0 +1,16 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + + Purpose: Kernel Strings. + +------------------------------------------- */ + +#pragma once + +#include + +/// @brief DriverKit equivalent of POSIX's string.h. + +DK_EXTERN size_t kernelStringLength(const char* str); +DK_EXTERN int kernelStringCopy(char* dst, const char* src, size_t len); diff --git a/DriverKit/ReadMe.txt b/DriverKit/ReadMe.txt new file mode 100644 index 00000000..e33c88ec --- /dev/null +++ b/DriverKit/ReadMe.txt @@ -0,0 +1,4 @@ +== The Driver Kit == + +-> A kit used to write user level drivers. +-> Use MPCC to compile the code, it can work on a patched GNU compiler. diff --git a/Drivers/.gitkeep b/Drivers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Drivers/Bonjour/Bonjour.c b/Drivers/Bonjour/Bonjour.c new file mode 100644 index 00000000..52187ac1 --- /dev/null +++ b/Drivers/Bonjour/Bonjour.c @@ -0,0 +1,20 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include +#include + +int __ImageStart(void) +{ + kernelPrintStr("Bonjour: Starting up zeroconf...\r"); + return 0; +} + +int __ImageEnd(void) +{ + kernelPrintStr("Bonjour: Shutting down zeroconf...\r"); + return 0; +} diff --git a/Drivers/Bonjour/DriverRsrc.rsrc b/Drivers/Bonjour/DriverRsrc.rsrc new file mode 100644 index 00000000..494e85ee --- /dev/null +++ b/Drivers/Bonjour/DriverRsrc.rsrc @@ -0,0 +1,25 @@ +1 ICON "../../Root/Boot/Icons/bonjour-logo.ico" + +1 VERSIONINFO +FILEVERSION 1,0,0,0 +PRODUCTVERSION 1,0,0,0 +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904E4" + BEGIN + VALUE "CompanyName", "SoftwareLabs" + VALUE "FileDescription", "New OS Bonjour driver." + VALUE "FileVersion", "1.00" + VALUE "InternalName", "Bonjour." + VALUE "LegalCopyright", "Copyright SoftwareLabs, all rights reserved." + VALUE "OriginalFilename", "Bonjour.exe" + VALUE "ProductName", "Bonjour." + VALUE "ProductVersion", "1.00" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 1252 + END +END diff --git a/Drivers/Bonjour/x86_64.mk b/Drivers/Bonjour/x86_64.mk new file mode 100644 index 00000000..afbc70ad --- /dev/null +++ b/Drivers/Bonjour/x86_64.mk @@ -0,0 +1,51 @@ +################################################## +# (C) SoftwareLabs, all rights reserved. +# This is the sample driver makefile. +################################################## + +CC_GNU=x86_64-w64-mingw32-gcc +LD_GNU=x86_64-w64-mingw32-ld + +WINDRES=x86_64-w64-mingw32-windres + +ADD_FILE=touch +COPY=cp +HTTP_GET=wget + +LD_FLAGS=-e __ImageStart --subsystem=17 + +OBJ=*.o + + +REM=rm +REM_FLAG=-f + +FLAG_ASM=-f win64 +FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mgeneral-regs-only -mno-red-zone -D__KERNEL__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -std=c17 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./ + +.PHONY: invalid-recipe +invalid-recipe: + @echo "invalid-recipe: Use make all instead." + +.PHONY: all +all: compile-amd64 + $(LD_GNU) $(OBJ) $(LD_FLAGS) -o Bonjour.exe + +ifneq ($(DEBUG_SUPPORT), ) +DEBUG = -D__DEBUG__ +endif + +.PHONY: compile-amd64 +compile-amd64: + $(WINDRES) DriverRsrc.rsrc -O coff -o DriverRsrc.o + $(CC_GNU) $(FLAG_GNU) $(DEBUG) $(wildcard *.c) $(wildcard ../../DriverKit/*.c) $(wildcard ../../DriverKit/*.S) + +.PHONY: clean +clean: + $(REM) $(REM_FLAG) $(OBJ) Bonjour.exe + +.PHONY: help +help: + @echo "=== HELP ===" + @echo "clean: Clean driver." + @echo "compile-amd64: Build driver." diff --git a/Drivers/DynamicLoader/DriverRsrc.rsrc b/Drivers/DynamicLoader/DriverRsrc.rsrc new file mode 100644 index 00000000..3a3b8774 --- /dev/null +++ b/Drivers/DynamicLoader/DriverRsrc.rsrc @@ -0,0 +1,25 @@ +1 ICON "../../Root/Boot/Icons/driver-logo.ico" + +1 VERSIONINFO +FILEVERSION 1,0,0,0 +PRODUCTVERSION 1,0,0,0 +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904E4" + BEGIN + VALUE "CompanyName", "SoftwareLabs" + VALUE "FileDescription", "New OS driver." + VALUE "FileVersion", "1.00" + VALUE "InternalName", "SampleDriver" + VALUE "LegalCopyright", "Copyright SoftwareLabs, all rights reserved." + VALUE "OriginalFilename", "SampleDriver.exe" + VALUE "ProductName", "SampleDriver" + VALUE "ProductVersion", "1.00" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 1252 + END +END diff --git a/Drivers/DynamicLoader/DynamicLoader.c b/Drivers/DynamicLoader/DynamicLoader.c new file mode 100644 index 00000000..16ffc06e --- /dev/null +++ b/Drivers/DynamicLoader/DynamicLoader.c @@ -0,0 +1,26 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include +#include + +int __ImageStart(void) +{ + kernelPrintStr("DynamicLoader: Starting up...\r"); + return 0; +} + +int __ImageEnd(void) +{ + kernelPrintStr("DynamicLoader: Shutting down...\r"); + return 0; +} + +///! @brief Use this to check your stack, if using MinGW/MSVC. +void ___chkstk_ms(void) +{ + (void)0; +} diff --git a/Drivers/DynamicLoader/x86_64.mk b/Drivers/DynamicLoader/x86_64.mk new file mode 100644 index 00000000..1d46948b --- /dev/null +++ b/Drivers/DynamicLoader/x86_64.mk @@ -0,0 +1,51 @@ +################################################## +# (C) SoftwareLabs, all rights reserved. +# This is the sample driver makefile. +################################################## + +CC_GNU=x86_64-w64-mingw32-gcc +LD_GNU=x86_64-w64-mingw32-ld + +WINDRES=x86_64-w64-mingw32-windres + +ADD_FILE=touch +COPY=cp +HTTP_GET=wget + +LD_FLAGS=-e __ImageStart --subsystem=17 + +OBJ=*.o + + +REM=rm +REM_FLAG=-f + +FLAG_ASM=-f win64 +FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mgeneral-regs-only -mno-red-zone -D__KERNEL__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -std=c17 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./ + +.PHONY: invalid-recipe +invalid-recipe: + @echo "invalid-recipe: Use make all instead." + +.PHONY: all +all: compile-amd64 + $(LD_GNU) $(OBJ) $(LD_FLAGS) -o SampleDriver.exe + +ifneq ($(DEBUG_SUPPORT), ) +DEBUG = -D__DEBUG__ +endif + +.PHONY: compile-amd64 +compile-amd64: + $(WINDRES) DriverRsrc.rsrc -O coff -o DriverRsrc.o + $(CC_GNU) $(FLAG_GNU) $(DEBUG) $(wildcard *.c) $(wildcard ../../DriverKit/*.c) $(wildcard ../../DriverKit/*.S) + +.PHONY: clean +clean: + $(REM) $(REM_FLAG) $(OBJ) SampleDriver.exe + +.PHONY: help +help: + @echo "=== HELP ===" + @echo "clean: Clean driver." + @echo "compile-amd64: Build driver." diff --git a/Drivers/SampleDriver/DriverRsrc.rsrc b/Drivers/SampleDriver/DriverRsrc.rsrc new file mode 100644 index 00000000..3a3b8774 --- /dev/null +++ b/Drivers/SampleDriver/DriverRsrc.rsrc @@ -0,0 +1,25 @@ +1 ICON "../../Root/Boot/Icons/driver-logo.ico" + +1 VERSIONINFO +FILEVERSION 1,0,0,0 +PRODUCTVERSION 1,0,0,0 +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904E4" + BEGIN + VALUE "CompanyName", "SoftwareLabs" + VALUE "FileDescription", "New OS driver." + VALUE "FileVersion", "1.00" + VALUE "InternalName", "SampleDriver" + VALUE "LegalCopyright", "Copyright SoftwareLabs, all rights reserved." + VALUE "OriginalFilename", "SampleDriver.exe" + VALUE "ProductName", "SampleDriver" + VALUE "ProductVersion", "1.00" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 1252 + END +END diff --git a/Drivers/SampleDriver/SampleDriver.c b/Drivers/SampleDriver/SampleDriver.c new file mode 100644 index 00000000..4085bf4f --- /dev/null +++ b/Drivers/SampleDriver/SampleDriver.c @@ -0,0 +1,26 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include +#include + +int __ImageStart(void) +{ + kernelPrintStr("SampleDriver: Starting up...\r"); + return 0; +} + +int __ImageEnd(void) +{ + kernelPrintStr("SampleDriver: Shutting down...\r"); + return 0; +} + +///! @brief Use this to check your stack, if using MinGW/MSVC. +void ___chkstk_ms(void) +{ + (void)0; +} diff --git a/Drivers/SampleDriver/x86_64.mk b/Drivers/SampleDriver/x86_64.mk new file mode 100644 index 00000000..1d46948b --- /dev/null +++ b/Drivers/SampleDriver/x86_64.mk @@ -0,0 +1,51 @@ +################################################## +# (C) SoftwareLabs, all rights reserved. +# This is the sample driver makefile. +################################################## + +CC_GNU=x86_64-w64-mingw32-gcc +LD_GNU=x86_64-w64-mingw32-ld + +WINDRES=x86_64-w64-mingw32-windres + +ADD_FILE=touch +COPY=cp +HTTP_GET=wget + +LD_FLAGS=-e __ImageStart --subsystem=17 + +OBJ=*.o + + +REM=rm +REM_FLAG=-f + +FLAG_ASM=-f win64 +FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mgeneral-regs-only -mno-red-zone -D__KERNEL__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -std=c17 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./ + +.PHONY: invalid-recipe +invalid-recipe: + @echo "invalid-recipe: Use make all instead." + +.PHONY: all +all: compile-amd64 + $(LD_GNU) $(OBJ) $(LD_FLAGS) -o SampleDriver.exe + +ifneq ($(DEBUG_SUPPORT), ) +DEBUG = -D__DEBUG__ +endif + +.PHONY: compile-amd64 +compile-amd64: + $(WINDRES) DriverRsrc.rsrc -O coff -o DriverRsrc.o + $(CC_GNU) $(FLAG_GNU) $(DEBUG) $(wildcard *.c) $(wildcard ../../DriverKit/*.c) $(wildcard ../../DriverKit/*.S) + +.PHONY: clean +clean: + $(REM) $(REM_FLAG) $(OBJ) SampleDriver.exe + +.PHONY: help +help: + @echo "=== HELP ===" + @echo "clean: Clean driver." + @echo "compile-amd64: Build driver." diff --git a/Kernel/DriverKit/KernelCall.c b/Kernel/DriverKit/KernelCall.c deleted file mode 100644 index d61f8439..00000000 --- a/Kernel/DriverKit/KernelCall.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - - Purpose: Kernel Definitions. - -------------------------------------------- */ - -#include -#include - -DK_EXTERN __attribute__((naked)) void __kernelDispatchCall(int32_t cnt, ...); - -DK_EXTERN void* kernelCall(const char* kernelRpcName, int32_t cnt, ...) -{ - if (!kernelRpcName || cnt == 0) - return NIL; - - va_list arg; - va_start(arg, cnt); - - __kernelDispatchCall(cnt, arg); - - va_end(arg); -} diff --git a/Kernel/DriverKit/KernelDev.c b/Kernel/DriverKit/KernelDev.c deleted file mode 100644 index 704f17da..00000000 --- a/Kernel/DriverKit/KernelDev.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - - Purpose: Kernel Text I/O. - -------------------------------------------- */ - -#include - -/// @brief Open a new binary device from path. -DK_EXTERN kernelDeviceRef kernelOpenBinaryDevice(const char* devicePath) -{ - if (!devicePath) - return NIL; - - return kernelCall("OpenBinaryDevice", 1, devicePath); -} - -/// @brief Open a new character device from path. -DK_EXTERN kernelDeviceRef kernelOpenCharDevice(const char* devicePath) -{ - if (!devicePath) - return NIL; - - return kernelCall("OpenCharDevice", 1, devicePath); -} - -/// @brief Close any device. -/// @param device valid device. -DK_EXTERN void kernelCloseDevice(kernelDeviceRef device) -{ - if (!device) - return; - - kernelCall("CloseDevice", 1, device); -} diff --git a/Kernel/DriverKit/KernelDev.h b/Kernel/DriverKit/KernelDev.h deleted file mode 100644 index c3435e8d..00000000 --- a/Kernel/DriverKit/KernelDev.h +++ /dev/null @@ -1,33 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - - Purpose: Kernel Devices. - -------------------------------------------- */ - -#pragma once - -#include - -struct _kernelDevice; - -/// @brief Kernel Device driver. -typedef struct _kernelDevice -{ - char name[255]; // the device name. Could be /./DEVICE_NAME/ - int32_t (*read)(); // read from device. - int32_t (*write)(); // write to device. - struct _kernelDevice* (*open)(const char* path); // open device. - void (*close)(struct _kernelDevice* dev); // close device. -} kernelDevice, *kernelDeviceRef; - -/// @brief Open a new binary device from path. -DK_EXTERN kernelDeviceRef kernelOpenBinaryDevice(const char* devicePath); - -/// @brief Open a new character device from path. -DK_EXTERN kernelDeviceRef kernelOpenCharDevice(const char* devicePath); - -/// @brief Close any device. -/// @param device valid device. -DK_EXTERN void kernelCloseDevice(kernelDeviceRef device); diff --git a/Kernel/DriverKit/KernelDispatchCall.S b/Kernel/DriverKit/KernelDispatchCall.S deleted file mode 100644 index 64b6663e..00000000 --- a/Kernel/DriverKit/KernelDispatchCall.S +++ /dev/null @@ -1,21 +0,0 @@ -.globl __kernelDispatchCall - -.section .text - -/* Really simple function, takes our va-list, - and brings it to the trap handler in the kernel. */ - -#ifdef __x86_64__ - -__kernelDispatchCall: - int $0x33 - ret - -#elif defined(__powerpc64__) - -__kernelDispatchCall: - /* There is no specific interrupt request id for a system call in POWER. */ - sc - blr - -#endif diff --git a/Kernel/DriverKit/KernelPrint.c b/Kernel/DriverKit/KernelPrint.c deleted file mode 100644 index 533bf34a..00000000 --- a/Kernel/DriverKit/KernelPrint.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - - Purpose: Kernel Text I/O. - -------------------------------------------- */ - -#include - -DK_EXTERN void kernelPrintChar(const char ch) -{ - kernelCall("WriteCharacter", 1, ch); -} - -/// @brief print string to UART. -/// @param message UART to transmit. -DK_EXTERN void kernelPrintStr(const char* message) -{ - if (!message) - return; - if (*message == 0) - return; - - size_t index = 0; - size_t len = kernelStringLength(message); - - while (index < len) - { - kernelPrintChar(message[index]); - ++index; - } -} diff --git a/Kernel/DriverKit/KernelPrint.h b/Kernel/DriverKit/KernelPrint.h deleted file mode 100644 index 7bf0dda9..00000000 --- a/Kernel/DriverKit/KernelPrint.h +++ /dev/null @@ -1,18 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - - Purpose: Kernel Text I/O. - -------------------------------------------- */ - -#pragma once - -#include - -/// @brief print character into UART. -DK_EXTERN void kernelPrintChar(const char ch); - -/// @brief print string to UART. -/// @param message UART to transmit. -DK_EXTERN void kernelPrintStr(const char* message); diff --git a/Kernel/DriverKit/KernelStd.h b/Kernel/DriverKit/KernelStd.h deleted file mode 100644 index b0dba70e..00000000 --- a/Kernel/DriverKit/KernelStd.h +++ /dev/null @@ -1,22 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - - Purpose: Kernel Definitions. - -------------------------------------------- */ - -#pragma once - -#if defined(__cplusplus) -#define DK_EXTERN extern "C" -#define NIL nullptr -#else -#define DK_EXTERN extern -#define NIL NULL -#endif // defined(__cplusplus) - -#include -#include - -DK_EXTERN void* kernelCall(const char* kernelRpcName, int32_t cnt, ...); diff --git a/Kernel/DriverKit/KernelStdCxx.cc b/Kernel/DriverKit/KernelStdCxx.cc deleted file mode 100644 index 99bcc579..00000000 --- a/Kernel/DriverKit/KernelStdCxx.cc +++ /dev/null @@ -1,24 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - - Purpose: Driver C++ Definitions. - -------------------------------------------- */ - -#include - -void* operator new(size_t sz) { - if (!sz) ++sz; - - auto ptr = kernelCall("NewKernelHeap", 1, sz); - kernelCall("KernelHeapProtect", 1, ptr); - - return ptr; -} - -void operator delete(void* ptr) noexcept { - if (!ptr) return; - - kernelCall("DeleteKernelHeap", 1,ptr); -} diff --git a/Kernel/DriverKit/KernelString.c b/Kernel/DriverKit/KernelString.c deleted file mode 100644 index 6f28f4d8..00000000 --- a/Kernel/DriverKit/KernelString.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - - Purpose: Kernel Strings. - -------------------------------------------- */ - -#include - -DK_EXTERN size_t kernelStringLength(const char* str) -{ - size_t index = 0; - - while (str[index] != 0) - { - ++index; - } - - return index; -} - -DK_EXTERN int kernelStringCopy(char* dst, const char* src, size_t len) -{ - size_t index = 0; - - while (index != len) - { - dst[index] = src[index]; - ++index; - } - - return index; -} diff --git a/Kernel/DriverKit/KernelString.h b/Kernel/DriverKit/KernelString.h deleted file mode 100644 index db063a1b..00000000 --- a/Kernel/DriverKit/KernelString.h +++ /dev/null @@ -1,16 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - - Purpose: Kernel Strings. - -------------------------------------------- */ - -#pragma once - -#include - -/// @brief DriverKit equivalent of POSIX's string.h. - -DK_EXTERN size_t kernelStringLength(const char* str); -DK_EXTERN int kernelStringCopy(char* dst, const char* src, size_t len); diff --git a/Kernel/Drivers/.gitkeep b/Kernel/Drivers/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Kernel/Drivers/Bonjour/Bonjour.c b/Kernel/Drivers/Bonjour/Bonjour.c deleted file mode 100644 index 52187ac1..00000000 --- a/Kernel/Drivers/Bonjour/Bonjour.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#include -#include - -int __ImageStart(void) -{ - kernelPrintStr("Bonjour: Starting up zeroconf...\r"); - return 0; -} - -int __ImageEnd(void) -{ - kernelPrintStr("Bonjour: Shutting down zeroconf...\r"); - return 0; -} diff --git a/Kernel/Drivers/Bonjour/DriverRsrc.rsrc b/Kernel/Drivers/Bonjour/DriverRsrc.rsrc deleted file mode 100644 index 494e85ee..00000000 --- a/Kernel/Drivers/Bonjour/DriverRsrc.rsrc +++ /dev/null @@ -1,25 +0,0 @@ -1 ICON "../../Root/Boot/Icons/bonjour-logo.ico" - -1 VERSIONINFO -FILEVERSION 1,0,0,0 -PRODUCTVERSION 1,0,0,0 -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "080904E4" - BEGIN - VALUE "CompanyName", "SoftwareLabs" - VALUE "FileDescription", "New OS Bonjour driver." - VALUE "FileVersion", "1.00" - VALUE "InternalName", "Bonjour." - VALUE "LegalCopyright", "Copyright SoftwareLabs, all rights reserved." - VALUE "OriginalFilename", "Bonjour.exe" - VALUE "ProductName", "Bonjour." - VALUE "ProductVersion", "1.00" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x809, 1252 - END -END diff --git a/Kernel/Drivers/Bonjour/x86_64.mk b/Kernel/Drivers/Bonjour/x86_64.mk deleted file mode 100644 index b2493edf..00000000 --- a/Kernel/Drivers/Bonjour/x86_64.mk +++ /dev/null @@ -1,52 +0,0 @@ -################################################## -# (C) SoftwareLabs, all rights reserved. -# This is the sample driver makefile. -################################################## - -CC_GNU=x86_64-w64-mingw32-gcc -LD_GNU=x86_64-w64-mingw32-ld - -WINDRES=x86_64-w64-mingw32-windres - -ADD_FILE=touch -COPY=cp -HTTP_GET=wget - -LD_FLAGS=-e __ImageStart --subsystem=17 - -OBJ=*.o - - -REM=rm -REM_FLAG=-f - -FLAG_ASM=-f win64 -FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mgeneral-regs-only -mno-red-zone -D__KERNEL__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -std=c17 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./ - -.PHONY: invalid-recipe -invalid-recipe: - @echo "invalid-recipe: Use make all instead." - -.PHONY: all -all: compile-amd64 - $(LD_GNU) $(OBJ) $(LD_FLAGS) -o Bonjour.exe - cp Bonjour.exe ../../Root/Boot/Bonjour.exe - -ifneq ($(DEBUG_SUPPORT), ) -DEBUG = -D__DEBUG__ -endif - -.PHONY: compile-amd64 -compile-amd64: - $(WINDRES) DriverRsrc.rsrc -O coff -o DriverRsrc.o - $(CC_GNU) $(FLAG_GNU) $(DEBUG) $(wildcard *.c) $(wildcard ../../DriverKit/*.c) $(wildcard ../../DriverKit/*.S) - -.PHONY: clean -clean: - $(REM) $(REM_FLAG) $(OBJ) Bonjour.exe - -.PHONY: help -help: - @echo "=== HELP ===" - @echo "clean: Clean driver." - @echo "compile-amd64: Build driver." diff --git a/Kernel/Drivers/MahroussUpdate/DriverRsrc.rsrc b/Kernel/Drivers/MahroussUpdate/DriverRsrc.rsrc deleted file mode 100644 index 88261a47..00000000 --- a/Kernel/Drivers/MahroussUpdate/DriverRsrc.rsrc +++ /dev/null @@ -1,25 +0,0 @@ -1 ICON "../../Root/Boot/Icons/update-logo.ico" - -1 VERSIONINFO -FILEVERSION 1,0,0,0 -PRODUCTVERSION 1,0,0,0 -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "080904E4" - BEGIN - VALUE "CompanyName", "SoftwareLabs" - VALUE "FileDescription", "New OS Mahrouss Update driver." - VALUE "FileVersion", "1.00" - VALUE "InternalName", "Mahrouss Update." - VALUE "LegalCopyright", "Copyright SoftwareLabs, all rights reserved." - VALUE "OriginalFilename", "MahroussUpdate.exe" - VALUE "ProductName", "MahroussUpdate." - VALUE "ProductVersion", "1.00" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x809, 1252 - END -END diff --git a/Kernel/Drivers/MahroussUpdate/MahroussUpdate.cc b/Kernel/Drivers/MahroussUpdate/MahroussUpdate.cc deleted file mode 100644 index eb8d03c7..00000000 --- a/Kernel/Drivers/MahroussUpdate/MahroussUpdate.cc +++ /dev/null @@ -1,24 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#include -#include - -#include - -DK_EXTERN int __ImageStart(void) { - kernelPrintStr("Mahrouss Update: Looking for updates...\r"); - UpdateRequest req("mup://release-mahrouss.logic/newos/"); - - return 0; -} - -DK_EXTERN int __ImageEnd(void) { - return 0; -} - -///! @brief Use this to check your stack, if using MinGW/MSVC. -DK_EXTERN void ___chkstk_ms(void) {} diff --git a/Kernel/Drivers/MahroussUpdate/MahroussUpdate.hxx b/Kernel/Drivers/MahroussUpdate/MahroussUpdate.hxx deleted file mode 100644 index dbcaed43..00000000 --- a/Kernel/Drivers/MahroussUpdate/MahroussUpdate.hxx +++ /dev/null @@ -1,37 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#pragma once - -#include - -#include "DriverKit/KernelPrint.h" - -/// @file Software update job driver. - -class UpdateRequest; -class UpdateRequestObserver; - -class UpdateRequest -{ -public: - explicit UpdateRequest(const char* patchUrl = "mup://invalid-url-scheme/") - { - kernelStringCopy(this->fPatchUrl, patchUrl, kernelStringLength(patchUrl)); - - kernelPrintStr("Mahrouss Update, Looking at: "); - kernelPrintStr(patchUrl); - kernelPrintChar('\r'); - kernelPrintChar('\n'); - } - - ~UpdateRequest() - { - } - -private: - char fPatchUrl[4096] = {0}; -}; diff --git a/Kernel/Drivers/MahroussUpdate/x86_64.mk b/Kernel/Drivers/MahroussUpdate/x86_64.mk deleted file mode 100644 index 13b30d59..00000000 --- a/Kernel/Drivers/MahroussUpdate/x86_64.mk +++ /dev/null @@ -1,53 +0,0 @@ -################################################## -# (C) SoftwareLabs, all rights reserved. -# This is the sample driver makefile. -################################################## - -CC_GNU=x86_64-w64-mingw32-gcc -LD_GNU=x86_64-w64-mingw32-ld - -WINDRES=x86_64-w64-mingw32-windres - -ADD_FILE=touch -COPY=cp -HTTP_GET=wget - -LD_FLAGS=-e __ImageStart --subsystem=17 - -OBJ=*.o - - -REM=rm -REM_FLAG=-f - -FLAG_ASM=-f win64 -FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mgeneral-regs-only -mno-red-zone -D__KERNEL__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./ - -.PHONY: invalid-recipe -invalid-recipe: - @echo "invalid-recipe: Use make all instead." - -.PHONY: all -all: compile-amd64 - $(LD_GNU) $(OBJ) $(LD_FLAGS) -o MahroussUpdate.exe - cp MahroussUpdate.exe ../../Root/Boot/MahroussUpdate.exe - -ifneq ($(DEBUG_SUPPORT), ) -DEBUG = -D__DEBUG__ -endif - -.PHONY: compile-amd64 -compile-amd64: - $(WINDRES) DriverRsrc.rsrc -O coff -o DriverRsrc.o - $(CC_GNU) $(FLAG_GNU) -std=c17 $(DEBUG) $(wildcard *.c) $(wildcard ../../DriverKit/*.c) $(wildcard ../../DriverKit/*.S) - $(CC_GNU) $(FLAG_GNU) -std=c++17 -fno-rtti -fno-exceptions $(DEBUG) $(wildcard *.cc) $(wildcard ../../DriverKit/*.cc) - -.PHONY: clean -clean: - $(REM) $(REM_FLAG) $(OBJ) MahroussUpdate.exe - -.PHONY: help -help: - @echo "=== HELP ===" - @echo "clean: Clean driver." - @echo "compile-amd64: Build driver." diff --git a/Kernel/Drivers/SampleDriver/DriverRsrc.rsrc b/Kernel/Drivers/SampleDriver/DriverRsrc.rsrc deleted file mode 100644 index 3a3b8774..00000000 --- a/Kernel/Drivers/SampleDriver/DriverRsrc.rsrc +++ /dev/null @@ -1,25 +0,0 @@ -1 ICON "../../Root/Boot/Icons/driver-logo.ico" - -1 VERSIONINFO -FILEVERSION 1,0,0,0 -PRODUCTVERSION 1,0,0,0 -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "080904E4" - BEGIN - VALUE "CompanyName", "SoftwareLabs" - VALUE "FileDescription", "New OS driver." - VALUE "FileVersion", "1.00" - VALUE "InternalName", "SampleDriver" - VALUE "LegalCopyright", "Copyright SoftwareLabs, all rights reserved." - VALUE "OriginalFilename", "SampleDriver.exe" - VALUE "ProductName", "SampleDriver" - VALUE "ProductVersion", "1.00" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x809, 1252 - END -END diff --git a/Kernel/Drivers/SampleDriver/SampleDriver.c b/Kernel/Drivers/SampleDriver/SampleDriver.c deleted file mode 100644 index b92b1ef8..00000000 --- a/Kernel/Drivers/SampleDriver/SampleDriver.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#include -#include - -int __ImageStart(void) -{ - kernelPrintStr("SampleDriver: Starting up...\r"); - return 0; -} - -int __ImageEnd(void) -{ - kernelPrintStr("SampleDriver: Shutting down...\r"); - return 0; -} - -///! @brief Use this to check your stack, if using MinGW/MSVC. -void ___chkstk_ms(void) -{ -} diff --git a/Kernel/Drivers/SampleDriver/x86_64.mk b/Kernel/Drivers/SampleDriver/x86_64.mk deleted file mode 100644 index 5bdf0331..00000000 --- a/Kernel/Drivers/SampleDriver/x86_64.mk +++ /dev/null @@ -1,52 +0,0 @@ -################################################## -# (C) SoftwareLabs, all rights reserved. -# This is the sample driver makefile. -################################################## - -CC_GNU=x86_64-w64-mingw32-gcc -LD_GNU=x86_64-w64-mingw32-ld - -WINDRES=x86_64-w64-mingw32-windres - -ADD_FILE=touch -COPY=cp -HTTP_GET=wget - -LD_FLAGS=-e __ImageStart --subsystem=17 - -OBJ=*.o - - -REM=rm -REM_FLAG=-f - -FLAG_ASM=-f win64 -FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mgeneral-regs-only -mno-red-zone -D__KERNEL__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -std=c17 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./ - -.PHONY: invalid-recipe -invalid-recipe: - @echo "invalid-recipe: Use make all instead." - -.PHONY: all -all: compile-amd64 - $(LD_GNU) $(OBJ) $(LD_FLAGS) -o SampleDriver.exe - cp SampleDriver.exe ../../Root/Boot/SampleDriver.exe - -ifneq ($(DEBUG_SUPPORT), ) -DEBUG = -D__DEBUG__ -endif - -.PHONY: compile-amd64 -compile-amd64: - $(WINDRES) DriverRsrc.rsrc -O coff -o DriverRsrc.o - $(CC_GNU) $(FLAG_GNU) $(DEBUG) $(wildcard *.c) $(wildcard ../../DriverKit/*.c) $(wildcard ../../DriverKit/*.S) - -.PHONY: clean -clean: - $(REM) $(REM_FLAG) $(OBJ) SampleDriver.exe - -.PHONY: help -help: - @echo "=== HELP ===" - @echo "clean: Clean driver." - @echo "compile-amd64: Build driver." diff --git a/Kernel/KernelKit/DeviceManager.hpp b/Kernel/KernelKit/DeviceManager.hpp index 6e2a803f..dc53fed5 100644 --- a/Kernel/KernelKit/DeviceManager.hpp +++ b/Kernel/KernelKit/DeviceManager.hpp @@ -21,8 +21,6 @@ #include #include -#define kDriveManagerCount 4U - // Last Rev // Wed, Apr 3, 2024 9:09:41 AM @@ -70,7 +68,7 @@ namespace NewOS } bool operator!() { - return !fOut && !fIn; + return !fOut || !fIn; } private: diff --git a/Kernel/KernelKit/DriveManager.hxx b/Kernel/KernelKit/DriveManager.hxx index 7978221a..019812a3 100644 --- a/Kernel/KernelKit/DriveManager.hxx +++ b/Kernel/KernelKit/DriveManager.hxx @@ -14,8 +14,10 @@ #include #include -#define kDriveInvalidID -1 -#define kDriveNameLen 32 +#define kDriveManagerCount (4U) + +#define kDriveInvalidID (-1) +#define kDriveNameLen (32) namespace NewOS { diff --git a/Kernel/KernelKit/Framebuffer.hpp b/Kernel/KernelKit/Framebuffer.hpp index fd4eff04..1f189e77 100644 --- a/Kernel/KernelKit/Framebuffer.hpp +++ b/Kernel/KernelKit/Framebuffer.hpp @@ -39,6 +39,7 @@ namespace NewOS : fFrameBufferAddr(addr) { } + ~Framebuffer() { } diff --git a/Kernel/KernelKit/XCOFF.hxx b/Kernel/KernelKit/XCOFF.hxx index f2e49c4c..55e37bfd 100644 --- a/Kernel/KernelKit/XCOFF.hxx +++ b/Kernel/KernelKit/XCOFF.hxx @@ -16,12 +16,15 @@ #include -#define kXCOFF64Magic (0x01F7) +#define cXCOFF64Magic (0x01F7) -#define kXCOFFRelFlg (0x0001) -#define kXCOFFExecutable (0x0002) -#define kXCOFFLnno (0x0004) -#define kXCOFFLSyms (0x0008) +#define cXCOFFRelFlg (0x0001) +#define cXCOFFExecutable (0x0002) +#define cXCOFFLnno (0x0004) +#define cXCOFFLSyms (0x0008) + +struct XCoffFileHeader; +struct XCoffForkHeader; /// @brief XCoff file header, meant for POWER apps. typedef struct XCoffFileHeader @@ -33,6 +36,15 @@ typedef struct XCoffFileHeader NewOS::UIntPtr fSymPtr; NewOS::UInt32 fNumSyms; NewOS::UInt16 fOptHdr; // ?: Number of bytes in optional header -} XCoffFileHeader; +} XCoffFileHeader32, XCoffFileHeader64; + +#define cForkNameLen (255) + +/// @brief This the executable manifest fork. +typedef struct XCoffForkHeader { + NewOS::Char fPropertiesXMLFork[cForkNameLen]; + NewOS::Char fDynamicLoaderFork[cForkNameLen]; + NewOS::Char fCodeSignFork[cForkNameLen]; +} XCoffForkHeader; #endif // ifndef __XCOFF__ diff --git a/Kernel/KernelRsrc.rsrc b/Kernel/KernelRsrc.rsrc index 6689d10c..91699b63 100644 --- a/Kernel/KernelRsrc.rsrc +++ b/Kernel/KernelRsrc.rsrc @@ -11,12 +11,12 @@ BEGIN BLOCK "080904E4" BEGIN VALUE "CompanyName", "SoftwareLabs" - VALUE "FileDescription", "New OS multiplatform kernel." + VALUE "FileDescription", "NuX/OS kernel." VALUE "FileVersion", KERNEL_VERSION - VALUE "InternalName", "NewKernel" + VALUE "InternalName", "NeXUS" VALUE "LegalCopyright", "SoftwareLabs" VALUE "OriginalFilename", "NewOSKrnl.exe" - VALUE "ProductName", "NewKernel" + VALUE "ProductName", "NewOSKrnl" VALUE "ProductVersion", KERNEL_VERSION END END diff --git a/SDK/Dist/.gitkeep b/SDK/Dist/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/SDK/Libraries/.gitkeep b/SDK/Libraries/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/SDK/Libraries/CoreCxxRuntime/.gitkeep b/SDK/Libraries/CoreCxxRuntime/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/SDK/Libraries/CoreCxxRuntime/Private.xml b/SDK/Libraries/CoreCxxRuntime/Private.xml new file mode 100644 index 00000000..7ee426c0 --- /dev/null +++ b/SDK/Libraries/CoreCxxRuntime/Private.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/SDK/Libraries/CoreCxxRuntime/Sources/New+Delete.cxx b/SDK/Libraries/CoreCxxRuntime/Sources/New+Delete.cxx new file mode 100644 index 00000000..cc59586f --- /dev/null +++ b/SDK/Libraries/CoreCxxRuntime/Sources/New+Delete.cxx @@ -0,0 +1,33 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include + +typedef SizeType size_t; + +void* operator new[](size_t sz) +{ + if (sz == 0) + ++sz; + + return RtHeapAllocate(sz, kStandardAllocation); +} + +void* operator new(size_t sz) +{ + if (sz == 0) + ++sz; + + return RtHeapAllocate(sz, kArrayAllocation); +} + +void operator delete[](void* ptr) +{ + if (ptr == nullptr) + return; + + RtHeapFree(ptr); +} \ No newline at end of file diff --git a/SDK/Libraries/CorePEFRuntime/.gitkeep b/SDK/Libraries/CorePEFRuntime/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/SDK/Libraries/CorePEFRuntime/Private.xml b/SDK/Libraries/CorePEFRuntime/Private.xml new file mode 100644 index 00000000..7ee426c0 --- /dev/null +++ b/SDK/Libraries/CorePEFRuntime/Private.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/SDK/Libraries/CorePEFRuntime/Sources/PEFStart.c b/SDK/Libraries/CorePEFRuntime/Sources/PEFStart.c new file mode 100644 index 00000000..e9a45f09 --- /dev/null +++ b/SDK/Libraries/CorePEFRuntime/Sources/PEFStart.c @@ -0,0 +1,23 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include + +/// @brief Application entrypoint. +/// @param void +/// @return void +CS_EXTERN_C VoidType AppMain(VoidType); + +/// @brief Process entrypoint. +/// @param void +/// @return void +CS_EXTERN_C VoidType __ImageStart(VoidType) +{ + kSharedApplication = RtGetAppPointer(); + CS_MUST_PASS(kSharedApplication); + + AppMain(); +} diff --git a/SDK/Libraries/CoreSystem/.gitkeep b/SDK/Libraries/CoreSystem/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/SDK/Libraries/CoreSystem/AMD64/CoreAssembly.s b/SDK/Libraries/CoreSystem/AMD64/CoreAssembly.s new file mode 100644 index 00000000..5d1484cf --- /dev/null +++ b/SDK/Libraries/CoreSystem/AMD64/CoreAssembly.s @@ -0,0 +1,28 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + + Purpose: AMD64 low level I/O + +------------------------------------------- */ + +.text + +.globl RtGetAppPointer +.globl RtAssertTriggerInterrupt + +/* @brief Application getter */ +/* @throws: ApptError: appartement error. */ +RtGetAppPointer: + mov $0x10, %rcx /* sysGetProcessObject */ + int $0x32 + + /* rax gets saved and returned. */ + ret + +RtAssertTriggerInterrupt: + mov $0x11, %rcx /* sysTerminateCurrentProcess */ + int $0x32 + + ret + diff --git a/SDK/Libraries/CoreSystem/ARM64/.gitkeep b/SDK/Libraries/CoreSystem/ARM64/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/SDK/Libraries/CoreSystem/Headers/Alert.h b/SDK/Libraries/CoreSystem/Headers/Alert.h new file mode 100644 index 00000000..7decd4ca --- /dev/null +++ b/SDK/Libraries/CoreSystem/Headers/Alert.h @@ -0,0 +1,25 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +/************************************************************* + * + * File: Alert.h + * Purpose: New OS alert dialog. + * Date: 3/26/24 + * + * Copyright SoftwareLabs, all rights reserved. + * + *************************************************************/ + +#pragma once + +#include + +/// @brief Shows an alert box, as provided by the OS. +/// @param fmt The alert formating. +/// @param +/// @return +CS_EXTERN_C VoidType UiAlert(const CharacterTypeUTF8* fmt, ...); diff --git a/SDK/Libraries/CoreSystem/Headers/Defines.h b/SDK/Libraries/CoreSystem/Headers/Defines.h new file mode 100644 index 00000000..a7e46234 --- /dev/null +++ b/SDK/Libraries/CoreSystem/Headers/Defines.h @@ -0,0 +1,235 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#pragma once + +#ifdef CS_MUST_PASS +#undef CS_MUST_PASS +#endif + +#ifdef _DEBUG +#define CS_MUST_PASS(e) \ + { \ + if (!e) \ + { \ + UiAlert("Assertion failed.\nExpression :%s\nFile: %s\nLine: %i", #e, __FILE__, __LINE__) RtAssertTriggerInterrupt() \ + } \ + } +#else +#define CS_MUST_PASS(e) CS_UNREFERENCED_PARAMETER(e) +#endif + +#ifdef __cplusplus + +#define CS_EXTERN_C extern "C" + +#else + +#define CS_EXTERN_C extern + +#endif + +struct ApplicationInterface; +struct GUID; + +CS_EXTERN_C void RtAssertTriggerInterrupt(void); + +#define CS_STDCALL __attribute__((stdcall)) +#define CS_CDECL __attribute__((cdecl)) +#define CS_MSCALL __attribute__((ms_abi)) + +#define PACKED __attribute__((packed)) + +#define CS_PASCAL CS_STDCALL + +#include + +typedef __UINT8_TYPE__ ByteType; +typedef __UINT16_TYPE__ WordType; +typedef __UINT32_TYPE__ DWordType; +typedef __UINT64_TYPE__ QWordType; +typedef __SIZE_TYPE__ SizeType; + +typedef char CharacterTypeUTF8; +typedef CharacterTypeUTF8* PtrCharacterType; + +typedef void* PtrVoidType; +typedef void VoidType; + +#ifdef __SINGLE_PRECISION__ +typedef float FloatType; +typedef float PositionType; +#else +typedef double FloatType; +typedef double PositionType; +#endif + +typedef __UINTPTR_TYPE__ UIntPtrType; +typedef __INTPTR_TYPE__ IntPtrType; +typedef __UINT64_TYPE__ UInt64Type; +typedef __INT64_TYPE__ Int64Type; +typedef __UINT32_TYPE__ UInt32Type; +typedef __INT32_TYPE__ Int32Type; + +typedef CharacterTypeUTF8 BooleanType; + +#define Yes 1 +#define No 0 + +#define CS_PTR * + +#define CS_UNREFERENCED_PARAMETER(e) ((VoidType)(e)) + +#ifdef __x86_64__ + +#define CS_FAR __far +#define CS_NEAR __near + +#define _M_AMD64 2 +#else + +#define CS_FAR +#define CS_NEAR + +#endif + +#ifdef __aarch64__ +#define _M_AARCH64 3 +#endif + +#ifdef __powerpc64__ +#define _M_PPC64 4 +#endif + +#ifdef __64x0__ +#define _M_64000 5 +#endif + +#ifdef __riscv__ +#define _M_RISCV 6 +#endif + +#define CS_STATIC static +#define CS_INLINE inline +#define CS_CONST const + +#ifdef __cplusplus +#define CS_CONSTEXPR constexpr +#else +#define CS_CONSTEXPR +#endif // __cplusplus + +enum RtProcessCall +{ + kCallAllocPtr = 1, + kCallFreePtr, + kCallSizePtr, + kCallCheckPtr, + kCallAllocStack, + /// @brief Open a specific handle + /// (can be used as sel to call methods related to it.) + kCallOpenFile, + kCallCloseFile, + kCallOpenDir, + kCallCloseDir, + kCallOpenDevice, + kCallCloseDevice, + kCallCreateWindow, + kCallCloseWindow, + kCallCreateMenu, + kCallCloseMenu, + kCallRandomNumberGenerator, + kCallGetArgsCount, + kCallGetArgsPtr, + kCallFileExists, + kCallDirectoryExists, + kCallSymlinkExists, + kCallDeviceExists, + kCallDriveExists, + /// @brief Number of process calls. + kCallsCount, +}; + +/** + * @brief GUID type, something you can also find in CFKit. + * @author Amlal El Mahrouss + */ +typedef struct GUID +{ + DWordType Data1; + WordType Data2; + WordType Data3; + ByteType Data4[8]; +} GUIDType, *PtrGUIDType; + +/// \brief Application Interface. +/// \author Amlal El Mahrouss +typedef struct ApplicationInterface +{ + VoidType (*Release)(struct ApplicationInterface* Self, DWordType ExitCode); + IntPtrType (*Invoke)(struct ApplicationInterface* Self, DWordType Sel, ...); + VoidType (*Query)(struct ApplicationInterface* Self, PtrVoidType* Dst, SizeType SzDst, struct GUID* GuidOf); +} ApplicationInterface, *ApplicationInterfaceRef; + +#ifdef __cplusplus + +#define CS_COPY_DELETE(KLASS) \ + KLASS& operator=(const KLASS&) = delete; \ + KLASS(const KLASS&) = delete; + +#define CS_COPY_DEFAULT(KLASS) \ + KLASS& operator=(const KLASS&) = default; \ + KLASS(const KLASS&) = default; + +#define CS_MOVE_DELETE(KLASS) \ + KLASS& operator=(KLASS&&) = delete; \ + KLASS(KLASS&&) = delete; + +#define CS_MOVE_DEFAULT(KLASS) \ + KLASS& operator=(KLASS&&) = default; \ + KLASS(KLASS&&) = default; + +#define app_cast reinterpret_cast + +template +using StrType = CharacterTypeUTF8[N]; + +#else + +#define app_cast (ApplicationInterfaceRef) + +#endif // ifdef C++ + +/// @brief Get app singleton. +/// @param +/// @return +CS_EXTERN_C ApplicationInterfaceRef RtGetAppPointer(VoidType); + +/// @brief Get argument count +/// @param +/// @return +CS_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType); + +/// @brief Get argument pointer. +/// @param +/// @return +CS_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType); + +CS_EXTERN_C ApplicationInterfaceRef kSharedApplication; + +typedef CharacterTypeUTF8 StrType255[255]; + +#define True 1 +#define False 0 +#define Bool BooleanType + +#define NullPtr ((PtrVoidType)0) + +#ifndef kInvalidRef +#define kInvalidRef 0 +#endif + +#include diff --git a/SDK/Libraries/CoreSystem/Headers/File.h b/SDK/Libraries/CoreSystem/Headers/File.h new file mode 100644 index 00000000..0013b074 --- /dev/null +++ b/SDK/Libraries/CoreSystem/Headers/File.h @@ -0,0 +1,52 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#pragma once + +#include + +#define kMaxForkNameLength (256U) /* long fork names. */ + +struct _Fork; + +/// @brief Filesystem wrapper. + +typedef QWordType FSRef; + +/// @brief Opens a new file. +/// @param path where to find it. +/// @param rest the restrict (rw, rwe, r+, w+, r, w) +/// @return FSRef the file. +CS_EXTERN_C FSRef CSOpenFile(const CharacterTypeUTF8* path, const CharacterTypeUTF8* r); + +/// @brief Closes the file and flushes it to the said file. +/// @param refCS the filesystem reference. +/// @return +CS_EXTERN_C VoidType CSCloseFile(FSRef refCS); + +/// @brief A fork information header. +typedef struct _Fork +{ + Int32Type forkFlags; + Int32Type forkKind; + CharacterTypeUTF8 forkName[kMaxForkNameLength]; + SizeType forkSize; + CharacterTypeUTF8 forkData[]; +} ForkType, ForkTypePtr; + +typedef ForkType* FSForkRef; + +/// @brief Gets the fork inside a file. +/// @param refCS the filesystem ref +/// @param forkName the fork's name +/// @return the fork data. +CS_EXTERN_C FSForkRef CSGetFork(FSRef refCS, const CharacterTypeUTF8* forkName); + +/// @brief Check if the filesystem path is valid. +/// @return if not return false, or true. +CS_EXTERN_C BooleanType CSIsValidPath(const CharacterTypeUTF8* path); + +/// END OF FILE diff --git a/SDK/Libraries/CoreSystem/Headers/Heap.h b/SDK/Libraries/CoreSystem/Headers/Heap.h new file mode 100644 index 00000000..b2ad6e74 --- /dev/null +++ b/SDK/Libraries/CoreSystem/Headers/Heap.h @@ -0,0 +1,39 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#pragma once + +#include + +#define cAllocationKindCount (2U) + +enum CsAllocationKind +{ + kStandardAllocation = 0xC, + kArrayAllocation = 0xD, +}; + +/// @brief Allocates a new pointer from process pool. +/// @param sz the size +/// @param flags the allocation flags. +/// @return +CS_EXTERN_C PtrVoidType CSAllocateHeap(QWordType sz, + DWordType flags); + +/// @brief Check if the pointer exists. +/// @param ptr the pointer to free. +/// @return +CS_EXTERN_C BooleanType CSIsHeapValid(PtrVoidType ptr); + +/// @brief Gets the size of the process' pointer. +/// @param ptr the pointer to free. +/// @return +CS_EXTERN_C QWordType CSGetHeapSize(PtrVoidType ptr); + +/// @brief Frees the process pointer. +/// @param ptr the pointer to free. +/// @return +CS_EXTERN_C VoidType CSFreeHeap(PtrVoidType ptr); diff --git a/SDK/Libraries/CoreSystem/Headers/Hint.h b/SDK/Libraries/CoreSystem/Headers/Hint.h new file mode 100644 index 00000000..ee14711d --- /dev/null +++ b/SDK/Libraries/CoreSystem/Headers/Hint.h @@ -0,0 +1,20 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#pragma once + +#pragma compiler(hint_manifest) + +#define _Input +#define _Output + +#define _Optional + +#define _StrictCheckInput +#define _StrictCheckOutput + +#define _InOut +#define _StrictInOut diff --git a/SDK/Libraries/CoreSystem/Headers/Intl.h b/SDK/Libraries/CoreSystem/Headers/Intl.h new file mode 100644 index 00000000..b868adca --- /dev/null +++ b/SDK/Libraries/CoreSystem/Headers/Intl.h @@ -0,0 +1,29 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#pragma once + +/// @brief Intlization primitives. + +#include + +typedef UInt64Type IntlRef; + +/// @brief Get app locale. +/// @param name locale name. +/// @return +IntlRef IntlGetLocale(const char* name); + +/// @brief Set app locale. +/// @param intl the locale +/// @return +BooleanType IntlSetLocale(const IntlRef intl); + +/// @brief locale helpers. + +/// @brief translate a string from a locale. +const CharacterTypeUTF8* Intl(const CharacterTypeUTF8* input, + const IntlRef locale); diff --git a/SDK/Libraries/CoreSystem/Headers/Math.h b/SDK/Libraries/CoreSystem/Headers/Math.h new file mode 100644 index 00000000..0a13e86f --- /dev/null +++ b/SDK/Libraries/CoreSystem/Headers/Math.h @@ -0,0 +1,27 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#pragma once + +#include + +/////////////////////////////////////////////////////////////////////// +/// Random functions /// +/////////////////////////////////////////////////////////////////////// + +/// @brief Number generator helper. +/// @return Random generated number. +CS_EXTERN_C SizeType MathRand(VoidType); + +/////////////////////////////////////////////////////////////////////// +/// Mathematical functions /// +/////////////////////////////////////////////////////////////////////// + +CS_EXTERN_C FloatType Sqrt(FloatType number); + +CS_EXTERN_C FloatType Cosine(FloatType number); +CS_EXTERN_C FloatType Sine(FloatType number); +CS_EXTERN_C FloatType Tangent(FloatType number); \ No newline at end of file diff --git a/SDK/Libraries/CoreSystem/Headers/Rsrc.h b/SDK/Libraries/CoreSystem/Headers/Rsrc.h new file mode 100644 index 00000000..7fe52910 --- /dev/null +++ b/SDK/Libraries/CoreSystem/Headers/Rsrc.h @@ -0,0 +1,12 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#pragma once + +#include + +/// @file Rsrc.h +/// @brief RXML forks. \ No newline at end of file diff --git a/SDK/Libraries/CoreSystem/Headers/Thread.h b/SDK/Libraries/CoreSystem/Headers/Thread.h new file mode 100644 index 00000000..15b40df3 --- /dev/null +++ b/SDK/Libraries/CoreSystem/Headers/Thread.h @@ -0,0 +1,47 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +// +// Created by Amlal on 3/18/24 +// + +#ifndef __THREAD__ +#define __THREAD__ + +#include + +#define kThreadErrorExit (-33) + +/// @brief Thread reference. +typedef QWordType ThreadRef; + +/// @brief Main application thread. +CS_EXTERN_C ThreadRef kMainThread; + +typedef VoidType (*ThreadEntrypointKind)(VoidType); + +/// @brief Creates a new thread, and runs the code. +/// @param threadName the thread's name. +/// @param threadStart where to start. +/// @return +CS_EXTERN_C ThreadRef CSThreadCreate(const CharacterTypeUTF8* threadName, ThreadEntrypointKind threadStart); + +/// @brief Dispoes the thread, and exits with code kThreadErrorExit +/// @param ref the thread reference. +/// @return nothing. +CS_EXTERN_C VoidType CSThreadRelease(ThreadRef ref); + +/// @brief Waits for the thread to complete. +/// @param ref the thread reference. +/// @return nothing. +CS_EXTERN_C VoidType CSThreadJoin(ThreadRef ref); + +/// @brief Yields the current thread. +/// @param ref the thead reference. +/// @return +CS_EXTERN_C VoidType CSThreadYield(ThreadRef ref); + +#endif // __THREAD__ diff --git a/SDK/Libraries/CoreSystem/Headers/Transport.h b/SDK/Libraries/CoreSystem/Headers/Transport.h new file mode 100644 index 00000000..3f6db3f1 --- /dev/null +++ b/SDK/Libraries/CoreSystem/Headers/Transport.h @@ -0,0 +1,48 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +// +// Created by Amlal on 5/12/24 +// + +#ifndef __TRANSPORT__ +#define __TRANSPORT__ + +/// @file: Transport.h +/// @brief Open Transport Layer, an alternative to berkeley sockets. + +#include + +typedef QWordType TrStreamType; + +/// @brief Opens a new socket +/// @param afType address family +/// @param sockType type of socket +/// @param sockProto socket protocol. +/// @return The STREAMS socket. +/// @note return is const. +CS_EXTERN_C CS_CONST TrStreamType CSOpenSocket(UInt32Type afType, UInt32Type sockType, UInt32Type sockProto); + +/// @brief Close a STREAMS socket. +/// @param streams The streams socket. +/// @return +CS_EXTERN_C VoidType CSCloseSocket(CS_CONST TrStreamType streams); + +/// @brief Get OpenTransport version. +/// @param void +/// @return +CS_EXTERN_C CS_CONST Int32Type CSGetVersion(VoidType); + +enum +{ + TrSocketProtoTCP, /// TCP socket + TrSocketProtoUDP, /// UDP socket + TrSocketProtoUN, /// IPC socket + TrSocketProtoRaw, /// Raw socket + TrSocketProtoCount, +}; + +#endif // __TRANSPORT__ \ No newline at end of file diff --git a/SDK/Libraries/CoreSystem/POWER/CoreAssembly.s b/SDK/Libraries/CoreSystem/POWER/CoreAssembly.s new file mode 100644 index 00000000..e7919f23 --- /dev/null +++ b/SDK/Libraries/CoreSystem/POWER/CoreAssembly.s @@ -0,0 +1,23 @@ +; /* ------------------------------------------- +; +; Copyright SoftwareLabs +; +; Purpose: POWER low level I/O +; +; ------------------------------------------- */ + +/* @brief Application getter */ +/* @throws: ApptError: appartement error. */ +export .code64 RtGetAppPointer: + mflr r3 + stw 0x10, 0(r3) /* sysGetProcessObject */ + sc + + blr + +export .code64 RtAssertTriggerInterrupt: + mflr r3 + stw 0x11, 0(r3) /* sysTerminateCurrentProcess */ + sc + + blr diff --git a/SDK/Libraries/CoreSystem/Private.xml b/SDK/Libraries/CoreSystem/Private.xml new file mode 100644 index 00000000..4be6c388 --- /dev/null +++ b/SDK/Libraries/CoreSystem/Private.xml @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/SDK/Libraries/CoreSystem/RISCV/.gitkeep b/SDK/Libraries/CoreSystem/RISCV/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/SDK/Libraries/CoreSystem/ReadMe.md b/SDK/Libraries/CoreSystem/ReadMe.md new file mode 100644 index 00000000..ae5df339 --- /dev/null +++ b/SDK/Libraries/CoreSystem/ReadMe.md @@ -0,0 +1,13 @@ +# CoreSystem +## Core System framework. + +Currently contains: + +- Heap API. +- File API. +- Data API. +- Threading API. + +Needs to have: +- Device API +- Drive API. \ No newline at end of file diff --git a/SDK/Libraries/CoreSystem/Sources/App.c b/SDK/Libraries/CoreSystem/Sources/App.c new file mode 100644 index 00000000..42ea19c6 --- /dev/null +++ b/SDK/Libraries/CoreSystem/Sources/App.c @@ -0,0 +1,31 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include + +/// @brief Main Application object, retrieved from the RtGetAppPointer symbol. +ApplicationInterfaceRef kSharedApplication = NullPtr; + +/// @brief Gets the app arguments count. +/// @param void no arguments. +/// @return The number of arguments given to the application. +CS_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType) +{ + CS_MUST_PASS(kSharedApplication); + + return kSharedApplication->Invoke(kSharedApplication, kCallGetArgsCount); +} + +/// @brief Gets the app arguments pointer. +/// @param void no arguments. +/// @return +CS_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType) +{ + CS_MUST_PASS(kSharedApplication); + + return (CharacterTypeUTF8**)kSharedApplication->Invoke(kSharedApplication, + kCallGetArgsPtr); +} diff --git a/SDK/Libraries/CoreSystem/Sources/CRTStartup.c b/SDK/Libraries/CoreSystem/Sources/CRTStartup.c new file mode 100644 index 00000000..1cfad65d --- /dev/null +++ b/SDK/Libraries/CoreSystem/Sources/CRTStartup.c @@ -0,0 +1,12 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include + +VoidType __DllMainCRTStartup(VoidType) +{ + kSharedApplication = RtGetAppPointer(); +} \ No newline at end of file diff --git a/SDK/Libraries/CoreSystem/Sources/File.c b/SDK/Libraries/CoreSystem/Sources/File.c new file mode 100644 index 00000000..7547e7f2 --- /dev/null +++ b/SDK/Libraries/CoreSystem/Sources/File.c @@ -0,0 +1,58 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include +#include + +enum FileOp +{ + kFlushFile, + kReadFork, + kWriteFork, + kOpenFork, + kCloseFork, +}; + +/// @brief Opens a new file. +/// @param path where to find it. +/// @param rest the restrict (rw, rwe, r+, w+, r, w) +/// @return FSRef the file. +CS_EXTERN_C FSRef CSOpenFile(const CharacterTypeUTF8* path, + const CharacterTypeUTF8* rest) +{ + CS_MUST_PASS(kSharedApplication); + CS_MUST_PASS(path && CSIsValidPath(path) == Yes); + CS_MUST_PASS(rest); + + return kSharedApplication->Invoke(kSharedApplication, kCallOpenFile, path, + rest); +} + +/// @brief Closes the file and flushes it to the said file. +/// @param refCS the filesystem reference. +/// @return +CS_EXTERN_C VoidType CSCloseFile(FSRef refCS) +{ + CS_MUST_PASS(kSharedApplication); + + kSharedApplication->Invoke(kSharedApplication, refCS, kFlushFile); + kSharedApplication->Invoke(kSharedApplication, kCallCloseFile, refCS); +} + +/// @brief Check if filesystem path is valid. +/// @param path +/// @return +CS_EXTERN_C BooleanType CSIsValidPath(const CharacterTypeUTF8* path) +{ + CS_MUST_PASS(kSharedApplication); + CS_MUST_PASS(path); + + return kSharedApplication->Invoke(kSharedApplication, kCallFileExists, path) || + kSharedApplication->Invoke(kSharedApplication, kCallDirectoryExists, path) || + kSharedApplication->Invoke(kSharedApplication, kCallSymlinkExists, path) || + kSharedApplication->Invoke(kSharedApplication, kCallDriveExists, path) || + kSharedApplication->Invoke(kSharedApplication, kCallDeviceExists, path); +} \ No newline at end of file diff --git a/SDK/Libraries/CoreSystem/Sources/Heap.c b/SDK/Libraries/CoreSystem/Sources/Heap.c new file mode 100644 index 00000000..e7a77ba5 --- /dev/null +++ b/SDK/Libraries/CoreSystem/Sources/Heap.c @@ -0,0 +1,54 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include +#include + +/// @brief Allocate from the user's heap. +/// @param sz size of object. +/// @param flags flags. +/// @return +CS_EXTERN_C PtrVoidType CSAllocateHeap(QWordType sz, DWordType flags) +{ + CS_MUST_PASS(kSharedApplication); + CS_MUST_PASS(sz); + CS_MUST_PASS(flags); + + return (PtrVoidType)kSharedApplication->Invoke(kSharedApplication, + kCallAllocPtr, sz, flags); +} + +/// @brief Free pointer from the user's heap. +/// @param ptr the pointer to free. +CS_EXTERN_C VoidType CSFreeHeap(PtrVoidType ptr) +{ + CS_MUST_PASS(kSharedApplication); + CS_MUST_PASS(ptr); + + CS_UNREFERENCED_PARAMETER( + kSharedApplication->Invoke(kSharedApplication, kCallFreePtr, ptr)); +} + +/// @brief Get pointer size. +/// @param ptr the pointer to find. +/// @return the size. +CS_EXTERN_C QWordType CSGetHeapSize(PtrVoidType ptr) +{ + CS_MUST_PASS(kSharedApplication); + + CS_MUST_PASS(ptr); + return kSharedApplication->Invoke(kSharedApplication, kCallSizePtr, ptr); +} + +/// @brief Check if the pointer exists. +/// @param ptr the pointer to check. +/// @return if it exists +CS_EXTERN_C BooleanType CSIsHeapValid(PtrVoidType ptr) +{ + CS_MUST_PASS(kSharedApplication); + CS_MUST_PASS(ptr); + return kSharedApplication->Invoke(kSharedApplication, kCallCheckPtr, ptr); +} diff --git a/SDK/Libraries/CoreSystem/Sources/Math.c b/SDK/Libraries/CoreSystem/Sources/Math.c new file mode 100644 index 00000000..19df42f3 --- /dev/null +++ b/SDK/Libraries/CoreSystem/Sources/Math.c @@ -0,0 +1,14 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include + +/// @brief Number generator helper. +/// @return Random generated number. +CS_EXTERN_C SizeType MathRand(VoidType) +{ + return kSharedApplication->Invoke(kSharedApplication, kCallRandomNumberGenerator); +} \ No newline at end of file diff --git a/SDK/Libraries/CoreSystem/Sources/Thread.c b/SDK/Libraries/CoreSystem/Sources/Thread.c new file mode 100644 index 00000000..7d00bf9e --- /dev/null +++ b/SDK/Libraries/CoreSystem/Sources/Thread.c @@ -0,0 +1,9 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#include + +ThreadRef kMainThread = 0; diff --git a/SDK/Libraries/CoreSystem/amd64.mk b/SDK/Libraries/CoreSystem/amd64.mk new file mode 100644 index 00000000..e64de90f --- /dev/null +++ b/SDK/Libraries/CoreSystem/amd64.mk @@ -0,0 +1,22 @@ +################################################## +# (C) SoftwareLabs, all rights reserved. +# This is the CoreSystem Makefile. +################################################## + +CC=x86_64-w64-mingw32-gcc +AR=x86_64-w64-mingw32-ar +CCINC=-I./ +CCFLAGS=-D__SINGLE_PRECISION__ -nostdlib -std=c17 -ffreestanding -Xlinker --subsystem=17 -e __DllMainCRTStartup -shared +OUTPUT=CoreSystem.lib + +.PHONY: all +all: build-core-amd64 + @echo "[CoreSystem.lib] Build done." + +.PHONY: build-core-amd64 +build-core-amd64: + $(CC) $(CCINC) $(CCFLAGS) $(wildcard Sources/*.c) $(wildcard AMD64/*.s) -o $(OUTPUT) + +.PHONY: clean +clean: + rm -f $(wildcard *.lib) diff --git a/SDK/Libraries/CoreSystem/compile_flags.txt b/SDK/Libraries/CoreSystem/compile_flags.txt new file mode 100644 index 00000000..749a500e --- /dev/null +++ b/SDK/Libraries/CoreSystem/compile_flags.txt @@ -0,0 +1,4 @@ +-I./ +-I../ +-I../../../Kernel +-std=c17 diff --git a/SDK/Library/.gitkeep b/SDK/Library/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/SDK/Library/CoreCxxRuntime/.gitkeep b/SDK/Library/CoreCxxRuntime/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/SDK/Library/CoreCxxRuntime/Private.xml b/SDK/Library/CoreCxxRuntime/Private.xml deleted file mode 100644 index 7ee426c0..00000000 --- a/SDK/Library/CoreCxxRuntime/Private.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/SDK/Library/CoreCxxRuntime/Sources/New+Delete.cxx b/SDK/Library/CoreCxxRuntime/Sources/New+Delete.cxx deleted file mode 100644 index cc59586f..00000000 --- a/SDK/Library/CoreCxxRuntime/Sources/New+Delete.cxx +++ /dev/null @@ -1,33 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#include - -typedef SizeType size_t; - -void* operator new[](size_t sz) -{ - if (sz == 0) - ++sz; - - return RtHeapAllocate(sz, kStandardAllocation); -} - -void* operator new(size_t sz) -{ - if (sz == 0) - ++sz; - - return RtHeapAllocate(sz, kArrayAllocation); -} - -void operator delete[](void* ptr) -{ - if (ptr == nullptr) - return; - - RtHeapFree(ptr); -} \ No newline at end of file diff --git a/SDK/Library/CorePEFRuntime/.gitkeep b/SDK/Library/CorePEFRuntime/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/SDK/Library/CorePEFRuntime/Private.xml b/SDK/Library/CorePEFRuntime/Private.xml deleted file mode 100644 index 7ee426c0..00000000 --- a/SDK/Library/CorePEFRuntime/Private.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/SDK/Library/CorePEFRuntime/Sources/PEFStart.c b/SDK/Library/CorePEFRuntime/Sources/PEFStart.c deleted file mode 100644 index e9a45f09..00000000 --- a/SDK/Library/CorePEFRuntime/Sources/PEFStart.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#include - -/// @brief Application entrypoint. -/// @param void -/// @return void -CS_EXTERN_C VoidType AppMain(VoidType); - -/// @brief Process entrypoint. -/// @param void -/// @return void -CS_EXTERN_C VoidType __ImageStart(VoidType) -{ - kSharedApplication = RtGetAppPointer(); - CS_MUST_PASS(kSharedApplication); - - AppMain(); -} diff --git a/SDK/Library/CoreSystem/.gitkeep b/SDK/Library/CoreSystem/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/SDK/Library/CoreSystem/AMD64/CoreAssembly.s b/SDK/Library/CoreSystem/AMD64/CoreAssembly.s deleted file mode 100644 index 5d1484cf..00000000 --- a/SDK/Library/CoreSystem/AMD64/CoreAssembly.s +++ /dev/null @@ -1,28 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - - Purpose: AMD64 low level I/O - -------------------------------------------- */ - -.text - -.globl RtGetAppPointer -.globl RtAssertTriggerInterrupt - -/* @brief Application getter */ -/* @throws: ApptError: appartement error. */ -RtGetAppPointer: - mov $0x10, %rcx /* sysGetProcessObject */ - int $0x32 - - /* rax gets saved and returned. */ - ret - -RtAssertTriggerInterrupt: - mov $0x11, %rcx /* sysTerminateCurrentProcess */ - int $0x32 - - ret - diff --git a/SDK/Library/CoreSystem/ARM64/.gitkeep b/SDK/Library/CoreSystem/ARM64/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/SDK/Library/CoreSystem/Headers/Alert.h b/SDK/Library/CoreSystem/Headers/Alert.h deleted file mode 100644 index 7decd4ca..00000000 --- a/SDK/Library/CoreSystem/Headers/Alert.h +++ /dev/null @@ -1,25 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -/************************************************************* - * - * File: Alert.h - * Purpose: New OS alert dialog. - * Date: 3/26/24 - * - * Copyright SoftwareLabs, all rights reserved. - * - *************************************************************/ - -#pragma once - -#include - -/// @brief Shows an alert box, as provided by the OS. -/// @param fmt The alert formating. -/// @param -/// @return -CS_EXTERN_C VoidType UiAlert(const CharacterTypeUTF8* fmt, ...); diff --git a/SDK/Library/CoreSystem/Headers/Defines.h b/SDK/Library/CoreSystem/Headers/Defines.h deleted file mode 100644 index a7e46234..00000000 --- a/SDK/Library/CoreSystem/Headers/Defines.h +++ /dev/null @@ -1,235 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#pragma once - -#ifdef CS_MUST_PASS -#undef CS_MUST_PASS -#endif - -#ifdef _DEBUG -#define CS_MUST_PASS(e) \ - { \ - if (!e) \ - { \ - UiAlert("Assertion failed.\nExpression :%s\nFile: %s\nLine: %i", #e, __FILE__, __LINE__) RtAssertTriggerInterrupt() \ - } \ - } -#else -#define CS_MUST_PASS(e) CS_UNREFERENCED_PARAMETER(e) -#endif - -#ifdef __cplusplus - -#define CS_EXTERN_C extern "C" - -#else - -#define CS_EXTERN_C extern - -#endif - -struct ApplicationInterface; -struct GUID; - -CS_EXTERN_C void RtAssertTriggerInterrupt(void); - -#define CS_STDCALL __attribute__((stdcall)) -#define CS_CDECL __attribute__((cdecl)) -#define CS_MSCALL __attribute__((ms_abi)) - -#define PACKED __attribute__((packed)) - -#define CS_PASCAL CS_STDCALL - -#include - -typedef __UINT8_TYPE__ ByteType; -typedef __UINT16_TYPE__ WordType; -typedef __UINT32_TYPE__ DWordType; -typedef __UINT64_TYPE__ QWordType; -typedef __SIZE_TYPE__ SizeType; - -typedef char CharacterTypeUTF8; -typedef CharacterTypeUTF8* PtrCharacterType; - -typedef void* PtrVoidType; -typedef void VoidType; - -#ifdef __SINGLE_PRECISION__ -typedef float FloatType; -typedef float PositionType; -#else -typedef double FloatType; -typedef double PositionType; -#endif - -typedef __UINTPTR_TYPE__ UIntPtrType; -typedef __INTPTR_TYPE__ IntPtrType; -typedef __UINT64_TYPE__ UInt64Type; -typedef __INT64_TYPE__ Int64Type; -typedef __UINT32_TYPE__ UInt32Type; -typedef __INT32_TYPE__ Int32Type; - -typedef CharacterTypeUTF8 BooleanType; - -#define Yes 1 -#define No 0 - -#define CS_PTR * - -#define CS_UNREFERENCED_PARAMETER(e) ((VoidType)(e)) - -#ifdef __x86_64__ - -#define CS_FAR __far -#define CS_NEAR __near - -#define _M_AMD64 2 -#else - -#define CS_FAR -#define CS_NEAR - -#endif - -#ifdef __aarch64__ -#define _M_AARCH64 3 -#endif - -#ifdef __powerpc64__ -#define _M_PPC64 4 -#endif - -#ifdef __64x0__ -#define _M_64000 5 -#endif - -#ifdef __riscv__ -#define _M_RISCV 6 -#endif - -#define CS_STATIC static -#define CS_INLINE inline -#define CS_CONST const - -#ifdef __cplusplus -#define CS_CONSTEXPR constexpr -#else -#define CS_CONSTEXPR -#endif // __cplusplus - -enum RtProcessCall -{ - kCallAllocPtr = 1, - kCallFreePtr, - kCallSizePtr, - kCallCheckPtr, - kCallAllocStack, - /// @brief Open a specific handle - /// (can be used as sel to call methods related to it.) - kCallOpenFile, - kCallCloseFile, - kCallOpenDir, - kCallCloseDir, - kCallOpenDevice, - kCallCloseDevice, - kCallCreateWindow, - kCallCloseWindow, - kCallCreateMenu, - kCallCloseMenu, - kCallRandomNumberGenerator, - kCallGetArgsCount, - kCallGetArgsPtr, - kCallFileExists, - kCallDirectoryExists, - kCallSymlinkExists, - kCallDeviceExists, - kCallDriveExists, - /// @brief Number of process calls. - kCallsCount, -}; - -/** - * @brief GUID type, something you can also find in CFKit. - * @author Amlal El Mahrouss - */ -typedef struct GUID -{ - DWordType Data1; - WordType Data2; - WordType Data3; - ByteType Data4[8]; -} GUIDType, *PtrGUIDType; - -/// \brief Application Interface. -/// \author Amlal El Mahrouss -typedef struct ApplicationInterface -{ - VoidType (*Release)(struct ApplicationInterface* Self, DWordType ExitCode); - IntPtrType (*Invoke)(struct ApplicationInterface* Self, DWordType Sel, ...); - VoidType (*Query)(struct ApplicationInterface* Self, PtrVoidType* Dst, SizeType SzDst, struct GUID* GuidOf); -} ApplicationInterface, *ApplicationInterfaceRef; - -#ifdef __cplusplus - -#define CS_COPY_DELETE(KLASS) \ - KLASS& operator=(const KLASS&) = delete; \ - KLASS(const KLASS&) = delete; - -#define CS_COPY_DEFAULT(KLASS) \ - KLASS& operator=(const KLASS&) = default; \ - KLASS(const KLASS&) = default; - -#define CS_MOVE_DELETE(KLASS) \ - KLASS& operator=(KLASS&&) = delete; \ - KLASS(KLASS&&) = delete; - -#define CS_MOVE_DEFAULT(KLASS) \ - KLASS& operator=(KLASS&&) = default; \ - KLASS(KLASS&&) = default; - -#define app_cast reinterpret_cast - -template -using StrType = CharacterTypeUTF8[N]; - -#else - -#define app_cast (ApplicationInterfaceRef) - -#endif // ifdef C++ - -/// @brief Get app singleton. -/// @param -/// @return -CS_EXTERN_C ApplicationInterfaceRef RtGetAppPointer(VoidType); - -/// @brief Get argument count -/// @param -/// @return -CS_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType); - -/// @brief Get argument pointer. -/// @param -/// @return -CS_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType); - -CS_EXTERN_C ApplicationInterfaceRef kSharedApplication; - -typedef CharacterTypeUTF8 StrType255[255]; - -#define True 1 -#define False 0 -#define Bool BooleanType - -#define NullPtr ((PtrVoidType)0) - -#ifndef kInvalidRef -#define kInvalidRef 0 -#endif - -#include diff --git a/SDK/Library/CoreSystem/Headers/File.h b/SDK/Library/CoreSystem/Headers/File.h deleted file mode 100644 index 594b4edb..00000000 --- a/SDK/Library/CoreSystem/Headers/File.h +++ /dev/null @@ -1,52 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#pragma once - -#include - -struct _Fork; - -/// @brief Filesystem wrapper. - -typedef QWordType FSRef; - -/// @brief Opens a new file. -/// @param path where to find it. -/// @param rest the restrict (rw, rwe, r+, w+, r, w) -/// @return FSRef the file. -CS_EXTERN_C FSRef CSOpenFile(const CharacterTypeUTF8* path, const CharacterTypeUTF8* r); - -/// @brief Closes the file and flushes it to the said file. -/// @param refCS the filesystem reference. -/// @return -CS_EXTERN_C VoidType CSCloseFile(FSRef refCS); - -#define kMaxForkNameLength (256U) /* long fork names. */ - -/// @brief A fork information header. -typedef struct _Fork -{ - Int32Type forkFlags; - Int32Type forkKind; - CharacterTypeUTF8 forkName[kMaxForkNameLength]; - SizeType forkSize; - CharacterTypeUTF8 forkData[]; -} ForkType, ForkTypePtr; - -typedef ForkType* FSForkRef; - -/// @brief Gets the fork inside a file. -/// @param refCS the filesystem ref -/// @param forkName the fork's name -/// @return the fork data. -CS_EXTERN_C FSForkRef CSGetFork(FSRef refCS, const CharacterTypeUTF8* forkName); - -/// @brief Check if the filesystem path is valid. -/// @return if not return false, or true. -CS_EXTERN_C BooleanType CSIsValidPath(const CharacterTypeUTF8* path); - -/// END OF FILE diff --git a/SDK/Library/CoreSystem/Headers/Heap.h b/SDK/Library/CoreSystem/Headers/Heap.h deleted file mode 100644 index b2ad6e74..00000000 --- a/SDK/Library/CoreSystem/Headers/Heap.h +++ /dev/null @@ -1,39 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#pragma once - -#include - -#define cAllocationKindCount (2U) - -enum CsAllocationKind -{ - kStandardAllocation = 0xC, - kArrayAllocation = 0xD, -}; - -/// @brief Allocates a new pointer from process pool. -/// @param sz the size -/// @param flags the allocation flags. -/// @return -CS_EXTERN_C PtrVoidType CSAllocateHeap(QWordType sz, - DWordType flags); - -/// @brief Check if the pointer exists. -/// @param ptr the pointer to free. -/// @return -CS_EXTERN_C BooleanType CSIsHeapValid(PtrVoidType ptr); - -/// @brief Gets the size of the process' pointer. -/// @param ptr the pointer to free. -/// @return -CS_EXTERN_C QWordType CSGetHeapSize(PtrVoidType ptr); - -/// @brief Frees the process pointer. -/// @param ptr the pointer to free. -/// @return -CS_EXTERN_C VoidType CSFreeHeap(PtrVoidType ptr); diff --git a/SDK/Library/CoreSystem/Headers/Hint.h b/SDK/Library/CoreSystem/Headers/Hint.h deleted file mode 100644 index ee14711d..00000000 --- a/SDK/Library/CoreSystem/Headers/Hint.h +++ /dev/null @@ -1,20 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#pragma once - -#pragma compiler(hint_manifest) - -#define _Input -#define _Output - -#define _Optional - -#define _StrictCheckInput -#define _StrictCheckOutput - -#define _InOut -#define _StrictInOut diff --git a/SDK/Library/CoreSystem/Headers/Intl.h b/SDK/Library/CoreSystem/Headers/Intl.h deleted file mode 100644 index b868adca..00000000 --- a/SDK/Library/CoreSystem/Headers/Intl.h +++ /dev/null @@ -1,29 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#pragma once - -/// @brief Intlization primitives. - -#include - -typedef UInt64Type IntlRef; - -/// @brief Get app locale. -/// @param name locale name. -/// @return -IntlRef IntlGetLocale(const char* name); - -/// @brief Set app locale. -/// @param intl the locale -/// @return -BooleanType IntlSetLocale(const IntlRef intl); - -/// @brief locale helpers. - -/// @brief translate a string from a locale. -const CharacterTypeUTF8* Intl(const CharacterTypeUTF8* input, - const IntlRef locale); diff --git a/SDK/Library/CoreSystem/Headers/Math.h b/SDK/Library/CoreSystem/Headers/Math.h deleted file mode 100644 index 0a13e86f..00000000 --- a/SDK/Library/CoreSystem/Headers/Math.h +++ /dev/null @@ -1,27 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#pragma once - -#include - -/////////////////////////////////////////////////////////////////////// -/// Random functions /// -/////////////////////////////////////////////////////////////////////// - -/// @brief Number generator helper. -/// @return Random generated number. -CS_EXTERN_C SizeType MathRand(VoidType); - -/////////////////////////////////////////////////////////////////////// -/// Mathematical functions /// -/////////////////////////////////////////////////////////////////////// - -CS_EXTERN_C FloatType Sqrt(FloatType number); - -CS_EXTERN_C FloatType Cosine(FloatType number); -CS_EXTERN_C FloatType Sine(FloatType number); -CS_EXTERN_C FloatType Tangent(FloatType number); \ No newline at end of file diff --git a/SDK/Library/CoreSystem/Headers/Rsrc.h b/SDK/Library/CoreSystem/Headers/Rsrc.h deleted file mode 100644 index 7fe52910..00000000 --- a/SDK/Library/CoreSystem/Headers/Rsrc.h +++ /dev/null @@ -1,12 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#pragma once - -#include - -/// @file Rsrc.h -/// @brief RXML forks. \ No newline at end of file diff --git a/SDK/Library/CoreSystem/Headers/Thread.h b/SDK/Library/CoreSystem/Headers/Thread.h deleted file mode 100644 index 15b40df3..00000000 --- a/SDK/Library/CoreSystem/Headers/Thread.h +++ /dev/null @@ -1,47 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -// -// Created by Amlal on 3/18/24 -// - -#ifndef __THREAD__ -#define __THREAD__ - -#include - -#define kThreadErrorExit (-33) - -/// @brief Thread reference. -typedef QWordType ThreadRef; - -/// @brief Main application thread. -CS_EXTERN_C ThreadRef kMainThread; - -typedef VoidType (*ThreadEntrypointKind)(VoidType); - -/// @brief Creates a new thread, and runs the code. -/// @param threadName the thread's name. -/// @param threadStart where to start. -/// @return -CS_EXTERN_C ThreadRef CSThreadCreate(const CharacterTypeUTF8* threadName, ThreadEntrypointKind threadStart); - -/// @brief Dispoes the thread, and exits with code kThreadErrorExit -/// @param ref the thread reference. -/// @return nothing. -CS_EXTERN_C VoidType CSThreadRelease(ThreadRef ref); - -/// @brief Waits for the thread to complete. -/// @param ref the thread reference. -/// @return nothing. -CS_EXTERN_C VoidType CSThreadJoin(ThreadRef ref); - -/// @brief Yields the current thread. -/// @param ref the thead reference. -/// @return -CS_EXTERN_C VoidType CSThreadYield(ThreadRef ref); - -#endif // __THREAD__ diff --git a/SDK/Library/CoreSystem/Headers/Transport.h b/SDK/Library/CoreSystem/Headers/Transport.h deleted file mode 100644 index 3f6db3f1..00000000 --- a/SDK/Library/CoreSystem/Headers/Transport.h +++ /dev/null @@ -1,48 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -// -// Created by Amlal on 5/12/24 -// - -#ifndef __TRANSPORT__ -#define __TRANSPORT__ - -/// @file: Transport.h -/// @brief Open Transport Layer, an alternative to berkeley sockets. - -#include - -typedef QWordType TrStreamType; - -/// @brief Opens a new socket -/// @param afType address family -/// @param sockType type of socket -/// @param sockProto socket protocol. -/// @return The STREAMS socket. -/// @note return is const. -CS_EXTERN_C CS_CONST TrStreamType CSOpenSocket(UInt32Type afType, UInt32Type sockType, UInt32Type sockProto); - -/// @brief Close a STREAMS socket. -/// @param streams The streams socket. -/// @return -CS_EXTERN_C VoidType CSCloseSocket(CS_CONST TrStreamType streams); - -/// @brief Get OpenTransport version. -/// @param void -/// @return -CS_EXTERN_C CS_CONST Int32Type CSGetVersion(VoidType); - -enum -{ - TrSocketProtoTCP, /// TCP socket - TrSocketProtoUDP, /// UDP socket - TrSocketProtoUN, /// IPC socket - TrSocketProtoRaw, /// Raw socket - TrSocketProtoCount, -}; - -#endif // __TRANSPORT__ \ No newline at end of file diff --git a/SDK/Library/CoreSystem/POWER/CoreAssembly.s b/SDK/Library/CoreSystem/POWER/CoreAssembly.s deleted file mode 100644 index e7919f23..00000000 --- a/SDK/Library/CoreSystem/POWER/CoreAssembly.s +++ /dev/null @@ -1,23 +0,0 @@ -; /* ------------------------------------------- -; -; Copyright SoftwareLabs -; -; Purpose: POWER low level I/O -; -; ------------------------------------------- */ - -/* @brief Application getter */ -/* @throws: ApptError: appartement error. */ -export .code64 RtGetAppPointer: - mflr r3 - stw 0x10, 0(r3) /* sysGetProcessObject */ - sc - - blr - -export .code64 RtAssertTriggerInterrupt: - mflr r3 - stw 0x11, 0(r3) /* sysTerminateCurrentProcess */ - sc - - blr diff --git a/SDK/Library/CoreSystem/Private.xml b/SDK/Library/CoreSystem/Private.xml deleted file mode 100644 index 4be6c388..00000000 --- a/SDK/Library/CoreSystem/Private.xml +++ /dev/null @@ -1,4 +0,0 @@ - - \ No newline at end of file diff --git a/SDK/Library/CoreSystem/RISCV/.gitkeep b/SDK/Library/CoreSystem/RISCV/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/SDK/Library/CoreSystem/ReadMe.md b/SDK/Library/CoreSystem/ReadMe.md deleted file mode 100644 index ae5df339..00000000 --- a/SDK/Library/CoreSystem/ReadMe.md +++ /dev/null @@ -1,13 +0,0 @@ -# CoreSystem -## Core System framework. - -Currently contains: - -- Heap API. -- File API. -- Data API. -- Threading API. - -Needs to have: -- Device API -- Drive API. \ No newline at end of file diff --git a/SDK/Library/CoreSystem/Sources/App.c b/SDK/Library/CoreSystem/Sources/App.c deleted file mode 100644 index 42ea19c6..00000000 --- a/SDK/Library/CoreSystem/Sources/App.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#include - -/// @brief Main Application object, retrieved from the RtGetAppPointer symbol. -ApplicationInterfaceRef kSharedApplication = NullPtr; - -/// @brief Gets the app arguments count. -/// @param void no arguments. -/// @return The number of arguments given to the application. -CS_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType) -{ - CS_MUST_PASS(kSharedApplication); - - return kSharedApplication->Invoke(kSharedApplication, kCallGetArgsCount); -} - -/// @brief Gets the app arguments pointer. -/// @param void no arguments. -/// @return -CS_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType) -{ - CS_MUST_PASS(kSharedApplication); - - return (CharacterTypeUTF8**)kSharedApplication->Invoke(kSharedApplication, - kCallGetArgsPtr); -} diff --git a/SDK/Library/CoreSystem/Sources/CRTStartup.c b/SDK/Library/CoreSystem/Sources/CRTStartup.c deleted file mode 100644 index 1cfad65d..00000000 --- a/SDK/Library/CoreSystem/Sources/CRTStartup.c +++ /dev/null @@ -1,12 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#include - -VoidType __DllMainCRTStartup(VoidType) -{ - kSharedApplication = RtGetAppPointer(); -} \ No newline at end of file diff --git a/SDK/Library/CoreSystem/Sources/File.c b/SDK/Library/CoreSystem/Sources/File.c deleted file mode 100644 index 7547e7f2..00000000 --- a/SDK/Library/CoreSystem/Sources/File.c +++ /dev/null @@ -1,58 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#include -#include - -enum FileOp -{ - kFlushFile, - kReadFork, - kWriteFork, - kOpenFork, - kCloseFork, -}; - -/// @brief Opens a new file. -/// @param path where to find it. -/// @param rest the restrict (rw, rwe, r+, w+, r, w) -/// @return FSRef the file. -CS_EXTERN_C FSRef CSOpenFile(const CharacterTypeUTF8* path, - const CharacterTypeUTF8* rest) -{ - CS_MUST_PASS(kSharedApplication); - CS_MUST_PASS(path && CSIsValidPath(path) == Yes); - CS_MUST_PASS(rest); - - return kSharedApplication->Invoke(kSharedApplication, kCallOpenFile, path, - rest); -} - -/// @brief Closes the file and flushes it to the said file. -/// @param refCS the filesystem reference. -/// @return -CS_EXTERN_C VoidType CSCloseFile(FSRef refCS) -{ - CS_MUST_PASS(kSharedApplication); - - kSharedApplication->Invoke(kSharedApplication, refCS, kFlushFile); - kSharedApplication->Invoke(kSharedApplication, kCallCloseFile, refCS); -} - -/// @brief Check if filesystem path is valid. -/// @param path -/// @return -CS_EXTERN_C BooleanType CSIsValidPath(const CharacterTypeUTF8* path) -{ - CS_MUST_PASS(kSharedApplication); - CS_MUST_PASS(path); - - return kSharedApplication->Invoke(kSharedApplication, kCallFileExists, path) || - kSharedApplication->Invoke(kSharedApplication, kCallDirectoryExists, path) || - kSharedApplication->Invoke(kSharedApplication, kCallSymlinkExists, path) || - kSharedApplication->Invoke(kSharedApplication, kCallDriveExists, path) || - kSharedApplication->Invoke(kSharedApplication, kCallDeviceExists, path); -} \ No newline at end of file diff --git a/SDK/Library/CoreSystem/Sources/Heap.c b/SDK/Library/CoreSystem/Sources/Heap.c deleted file mode 100644 index e7a77ba5..00000000 --- a/SDK/Library/CoreSystem/Sources/Heap.c +++ /dev/null @@ -1,54 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#include -#include - -/// @brief Allocate from the user's heap. -/// @param sz size of object. -/// @param flags flags. -/// @return -CS_EXTERN_C PtrVoidType CSAllocateHeap(QWordType sz, DWordType flags) -{ - CS_MUST_PASS(kSharedApplication); - CS_MUST_PASS(sz); - CS_MUST_PASS(flags); - - return (PtrVoidType)kSharedApplication->Invoke(kSharedApplication, - kCallAllocPtr, sz, flags); -} - -/// @brief Free pointer from the user's heap. -/// @param ptr the pointer to free. -CS_EXTERN_C VoidType CSFreeHeap(PtrVoidType ptr) -{ - CS_MUST_PASS(kSharedApplication); - CS_MUST_PASS(ptr); - - CS_UNREFERENCED_PARAMETER( - kSharedApplication->Invoke(kSharedApplication, kCallFreePtr, ptr)); -} - -/// @brief Get pointer size. -/// @param ptr the pointer to find. -/// @return the size. -CS_EXTERN_C QWordType CSGetHeapSize(PtrVoidType ptr) -{ - CS_MUST_PASS(kSharedApplication); - - CS_MUST_PASS(ptr); - return kSharedApplication->Invoke(kSharedApplication, kCallSizePtr, ptr); -} - -/// @brief Check if the pointer exists. -/// @param ptr the pointer to check. -/// @return if it exists -CS_EXTERN_C BooleanType CSIsHeapValid(PtrVoidType ptr) -{ - CS_MUST_PASS(kSharedApplication); - CS_MUST_PASS(ptr); - return kSharedApplication->Invoke(kSharedApplication, kCallCheckPtr, ptr); -} diff --git a/SDK/Library/CoreSystem/Sources/Math.c b/SDK/Library/CoreSystem/Sources/Math.c deleted file mode 100644 index 19df42f3..00000000 --- a/SDK/Library/CoreSystem/Sources/Math.c +++ /dev/null @@ -1,14 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#include - -/// @brief Number generator helper. -/// @return Random generated number. -CS_EXTERN_C SizeType MathRand(VoidType) -{ - return kSharedApplication->Invoke(kSharedApplication, kCallRandomNumberGenerator); -} \ No newline at end of file diff --git a/SDK/Library/CoreSystem/Sources/Thread.c b/SDK/Library/CoreSystem/Sources/Thread.c deleted file mode 100644 index 7d00bf9e..00000000 --- a/SDK/Library/CoreSystem/Sources/Thread.c +++ /dev/null @@ -1,9 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#include - -ThreadRef kMainThread = 0; diff --git a/SDK/Library/CoreSystem/amd64.mk b/SDK/Library/CoreSystem/amd64.mk deleted file mode 100644 index e64de90f..00000000 --- a/SDK/Library/CoreSystem/amd64.mk +++ /dev/null @@ -1,22 +0,0 @@ -################################################## -# (C) SoftwareLabs, all rights reserved. -# This is the CoreSystem Makefile. -################################################## - -CC=x86_64-w64-mingw32-gcc -AR=x86_64-w64-mingw32-ar -CCINC=-I./ -CCFLAGS=-D__SINGLE_PRECISION__ -nostdlib -std=c17 -ffreestanding -Xlinker --subsystem=17 -e __DllMainCRTStartup -shared -OUTPUT=CoreSystem.lib - -.PHONY: all -all: build-core-amd64 - @echo "[CoreSystem.lib] Build done." - -.PHONY: build-core-amd64 -build-core-amd64: - $(CC) $(CCINC) $(CCFLAGS) $(wildcard Sources/*.c) $(wildcard AMD64/*.s) -o $(OUTPUT) - -.PHONY: clean -clean: - rm -f $(wildcard *.lib) diff --git a/SDK/Library/CoreSystem/compile_flags.txt b/SDK/Library/CoreSystem/compile_flags.txt deleted file mode 100644 index 749a500e..00000000 --- a/SDK/Library/CoreSystem/compile_flags.txt +++ /dev/null @@ -1,4 +0,0 @@ --I./ --I../ --I../../../Kernel --std=c17 diff --git a/SDK/Tools/.gitkeep b/SDK/Tools/.gitkeep deleted file mode 100644 index e69de29b..00000000 -- cgit v1.2.3 From fc0d38259fd6670966b916b1f28a11f3cb2a4c45 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 1 Jun 2024 09:29:31 +0200 Subject: MHR-23: SMP: Add hal_send_start_ipi and hal_send_end_ipi, as well as DMA utilities. Signed-off-by: Amlal El Mahrouss --- Boot/makefile | 2 +- Drv/DynamicLoader/DynamicLoader.c | 6 +- Kernel/ArchKit/ArchKit.hpp | 41 +++ Kernel/Builtins/ACPI/ACPI.hxx | 23 +- Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx | 29 +- .../HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp | 2 +- .../HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp | 67 ++++- Kernel/HALKit/AMD64/HalKernelMain.cxx | 2 +- Kernel/HALKit/AMD64/HalSMPCore.cxx | 2 +- Kernel/HALKit/AMD64/Processor.hpp | 65 +++++ Kernel/KernelKit/KernelHeap.hpp | 5 + Kernel/KernelKit/ProcessScheduler.hpp | 303 --------------------- Kernel/KernelKit/ProcessScheduler.hxx | 303 +++++++++++++++++++++ Kernel/KernelKit/ThreadLocalStorage.inl | 2 +- Kernel/Sources/AppMain.cxx | 26 +- Kernel/Sources/CodeManager.cxx | 2 +- Kernel/Sources/KernelHeap.cxx | 27 +- Kernel/Sources/PEFCodeManager.cxx | 2 +- Kernel/Sources/PEFSharedObjectRT.cxx | 2 +- Kernel/Sources/ProcessScheduler.cxx | 6 +- Kernel/Sources/ProcessTeam.cxx | 2 +- Kernel/Sources/SMPManager.cxx | 6 +- Kernel/Sources/Semaphore.cxx | 2 +- Kernel/Sources/ThreadLocalStorage.cxx | 2 +- Kernel/Sources/UserHeap.cxx | 2 +- Kernel/makefile | 2 +- 26 files changed, 579 insertions(+), 354 deletions(-) delete mode 100644 Kernel/KernelKit/ProcessScheduler.hpp create mode 100644 Kernel/KernelKit/ProcessScheduler.hxx (limited to 'Kernel/KernelKit') diff --git a/Boot/makefile b/Boot/makefile index 6c38208d..5b1ab16b 100644 --- a/Boot/makefile +++ b/Boot/makefile @@ -26,7 +26,7 @@ BIOS=OVMF.fd IMG=epm.img IMG_2=epm-slave.img -EMU_FLAGS=-net none -smp 4,sockets=1,cores=4,threads=1 -m 4G -M q35 \ +EMU_FLAGS=-net none -smp 2 -m 4G -M q35 \ -bios $(BIOS) -device piix3-ide,id=ide \ -drive id=disk,file=$(IMG),format=raw,if=none \ -device ide-hd,drive=disk,bus=ide.0 -drive \ diff --git a/Drv/DynamicLoader/DynamicLoader.c b/Drv/DynamicLoader/DynamicLoader.c index 45083a5c..f7eb9458 100644 --- a/Drv/DynamicLoader/DynamicLoader.c +++ b/Drv/DynamicLoader/DynamicLoader.c @@ -7,19 +7,23 @@ #include #include +/// @brief Start function +/// @return status code int __ImageStart(void) { kernelPrintStr("SDLD: Starting up...\r"); return 0; } +/// @brief End function. +/// @return status code int __ImageEnd(void) { kernelPrintStr("SDLD: Shutting down...\r"); return 0; } -///! @brief Use this to check your stack, if using MinGW/MSVC. +///! @brief Check if stack has enough space. void ___chkstk_ms(void) { (void)0; diff --git a/Kernel/ArchKit/ArchKit.hpp b/Kernel/ArchKit/ArchKit.hpp index 83770272..fa899984 100644 --- a/Kernel/ArchKit/ArchKit.hpp +++ b/Kernel/ArchKit/ArchKit.hpp @@ -34,6 +34,47 @@ namespace NewOS return hash; } + + /// @brief write to mapped memory register + /// @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 + { + *(volatile UInt32*)((UInt64)base + reg) = value; + } + + /// @brief read from mapped memory register. + /// @param base base address + /// @param reg the register. + /// @return the value inside the register. + inline UInt32 ke_dma_read(UInt32 base, UInt32 reg) noexcept + { + return *(volatile UInt32*)((UInt64)base + reg); + } + + /// @brief Print a region of memory. + /// @param start + /// @param 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); + } + else + { + kcout << hex_number(ptr[i]); + } + + kcout << " "; + } + + kcout << "\r"; + } } // namespace NewOS #define kKernelMaxSystemCalls (256) diff --git a/Kernel/Builtins/ACPI/ACPI.hxx b/Kernel/Builtins/ACPI/ACPI.hxx index 13ea6ecc..d9bfeaca 100644 --- a/Kernel/Builtins/ACPI/ACPI.hxx +++ b/Kernel/Builtins/ACPI/ACPI.hxx @@ -15,7 +15,7 @@ namespace NewOS { - class SDT + class PACKED SDT { public: Char Signature[4]; @@ -29,7 +29,7 @@ namespace NewOS UInt32 CreatorRevision; }; - class RSDP : public SDT + class PACKED RSDP : public SDT { public: UInt32 RsdtAddress; @@ -38,7 +38,7 @@ namespace NewOS UInt8 Reserved0[3]; }; - class ConfigHeader + class PACKED ConfigHeader { public: UInt64 BaseAddress; @@ -59,7 +59,7 @@ namespace NewOS Invalid = 0xFF, }; - class Address + class PACKED Address { public: AddressSpace AddressSpaceId; @@ -68,6 +68,21 @@ namespace NewOS UInt8 Reserved; UIntPtr Address; }; + + class PACKED RSDT + { + public: + Char Signature[4]; + UInt32 Length; + UInt8 Revision; + Char Checksum; + Char OemId[6]; + Char OemTableId[8]; + UInt32 OemRev; + UInt32 CreatorID; + UInt32 CreatorRevision; + UInt64 AddressArr[]; + }; } // namespace NewOS #endif // !__ACPI__ diff --git a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx index ff5372f4..f92554f8 100644 --- a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx +++ b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx @@ -7,6 +7,8 @@ #include #include #include +#include +#include namespace NewOS { @@ -73,28 +75,37 @@ namespace NewOS return ErrorOr{-4}; } - SDT* xsdt = (SDT*)(rsdPtr->XsdtAddress >> (rsdPtr->XsdtAddress & 0xFFF)); + /// FIXME + RSDT* xsdt = (RSDT*)rsdPtr->XsdtAddress; - SizeT num = -(xsdt->Length - sizeof(SDT)) / 8; + if (NewOS::HAL::ke_map_address((PDE*)hal_read_cr3(), rsdPtr->XsdtAddress, (UIntPtr)xsdt, NewOS::HAL::eFlagsRw)) + return ErrorOr{-5}; + + Int64 num = (xsdt->Length - sizeof(SDT)) / sizeof(UInt64); + + if (num < 1) + { + return ErrorOr{-6}; + } this->fEntries = num; - kcout << "ACPI: Number of entries: " << number(num) << endl; + kcout << "ACPI: Number of entries: " << number(this->fEntries) << endl; kcout << "ACPI: Address of XSDT: " << hex_number((UIntPtr)xsdt) << endl; - constexpr short ACPI_SIGNATURE_LENGTH = 4; + const short cAcpiSignatureLength = 4; for (Size index = 0; index < this->fEntries; ++index) { - SDT& sdt = xsdt[index]; + SDT* sdt = (SDT*)(xsdt->AddressArr[index]); - for (short signature_index = 0; signature_index < ACPI_SIGNATURE_LENGTH; ++signature_index) + for (short signature_index = 0; signature_index < cAcpiSignatureLength; ++signature_index) { - if (sdt.Signature[signature_index] != signature[signature_index]) + if (sdt->Signature[signature_index] != signature[signature_index]) break; - if (signature_index == 4) - return ErrorOr(reinterpret_cast(&sdt)); + if (signature_index == (cAcpiSignatureLength - 1)) + return ErrorOr(reinterpret_cast(sdt)); } } diff --git a/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp b/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp index 0ac7a50e..d06dc6a6 100644 --- a/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp +++ b/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp @@ -5,7 +5,7 @@ ------------------------------------------- */ #include -#include +#include #include /// @brief Handle GPF fault. diff --git a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp index abd19586..287b1882 100644 --- a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp +++ b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp @@ -7,6 +7,12 @@ #include #include #include +#include + +#define kAPIC_ICR_Low 0x300 +#define kAPIC_ICR_High 0x310 +#define kAPIC_SIPI_Vector 0x00500 +#define kAPIC_EIPI_Vector 0x00400 /////////////////////////////////////////////////////////////////////////////////////// @@ -62,7 +68,7 @@ namespace NewOS::HAL struct MadtProcessorLocalApic final { Char AcpiProcessorId; - Char Reserved; + Char ApicId; UInt32 Flags; }; @@ -102,15 +108,66 @@ namespace NewOS::HAL /////////////////////////////////////////////////////////////////////////////////////// - void hal_system_get_cores(voidPtr rsdPtr) + /// @brief Send start IPI for CPU. + /// @param apicId + /// @param vector + /// @param targetAddress + /// @return + Void hal_send_start_ipi(UInt32 apicId, UInt8 vector, UInt32 targetAddress) + { + NewOS::ke_dma_write(targetAddress, kAPIC_ICR_High, apicId << 24); + NewOS::ke_dma_write(targetAddress, kAPIC_ICR_Low, kAPIC_SIPI_Vector | vector); + } + + /// @brief Send end IPI for CPU. + /// @param apicId + /// @param vector + /// @param targetAddress + /// @return + Void hal_send_end_ipi(UInt32 apicId, UInt8 vector, UInt32 targetAddress) + { + NewOS::ke_dma_write(targetAddress, kAPIC_ICR_High, apicId << 24); + NewOS::ke_dma_write(targetAddress, kAPIC_ICR_Low, kAPIC_EIPI_Vector | vector); + } + + Void hal_system_get_cores(voidPtr rsdPtr) { auto acpi = ACPIFactoryInterface(rsdPtr); kApicMadt = acpi.Find(kApicSignature).Leak().Leak(); - if (kApicMadt) + if (kApicMadt != nullptr) { - kcout << "New OS: APIC is present...\r"; - kApicInfoBlock = (MadtType*)kApicMadt; + auto madt = (SDT*)kApicMadt; + + const UInt8* madt_end = (const UInt8*)madt + madt->Length; + const UInt8* entry_ptr = (const UInt8*)(madt + 1); + + while (entry_ptr < madt_end) + { + const MadtType::MadtAddress* entry_header = (const MadtType::MadtAddress*)entry_ptr; + + switch (entry_header->Flags) + { + case 0: { + const MadtProcessorLocalApic* local_apic = (const MadtProcessorLocalApic*)entry_ptr; + if (local_apic->Flags & 1) + { + // Processor is enabled + kcout << "Processor ID: %d, APIC ID: %d\n" + << number(local_apic->AcpiProcessorId) << number(local_apic->ApicId); + } + break; + } + default: + break; + } + + entry_ptr += entry_header->RecordLen; + } + + while (true) + { + } } else { diff --git a/Kernel/HALKit/AMD64/HalKernelMain.cxx b/Kernel/HALKit/AMD64/HalKernelMain.cxx index 07656060..3136bf76 100644 --- a/Kernel/HALKit/AMD64/HalKernelMain.cxx +++ b/Kernel/HALKit/AMD64/HalKernelMain.cxx @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include diff --git a/Kernel/HALKit/AMD64/HalSMPCore.cxx b/Kernel/HALKit/AMD64/HalSMPCore.cxx index 90703e13..7aa13068 100644 --- a/Kernel/HALKit/AMD64/HalSMPCore.cxx +++ b/Kernel/HALKit/AMD64/HalSMPCore.cxx @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include +#include using namespace NewOS; Void ProcessHeader::SetEntrypoint(UIntPtr& imageStart) noexcept diff --git a/Kernel/HALKit/AMD64/Processor.hpp b/Kernel/HALKit/AMD64/Processor.hpp index 235e425d..608a502f 100644 --- a/Kernel/HALKit/AMD64/Processor.hpp +++ b/Kernel/HALKit/AMD64/Processor.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #ifdef kCPUBackendName #undef kCPUBackendName @@ -53,6 +54,68 @@ namespace NewOS namespace NewOS::HAL { + + enum + { + eFlagsUser, + eFlagsRw, + eFlagsExecDisable + }; + + /// @brief Map address to PDE. + /// @param pde a valid page directory. + /// @param phys_addr a valid phyiscal address. + /// @param virt_addr a valid virtual address. + /// @param flags the flags to put on the page. + inline Int32 ke_map_address(PDE* pde, UIntPtr phys_addr, UIntPtr virt_addr, UInt32 flags) + { + UInt16 pml4_index = (virt_addr >> 39) & 0x1FF; + + if (!pde->Pte[pml4_index].Present) + { + pde->Pte[pml4_index].Present = true; + kcout << "PM: It is present now.\r"; + } + else + { + kcout << "PM: It is already present.\r"; + kcout << "Address? " << hex_number(pde->Pte[pml4_index].PhysicalAddress) << endl; + kcout << "User? " << (pde->Pte[pml4_index].User ? "yes" : "no") << "\r"; + kcout << "RW? " << (pde->Pte[pml4_index].Rw ? "yes" : "no") << "\r"; + + return 1; + } + + pde->Pte[pml4_index].PhysicalAddress = phys_addr; + pde->Pte[pml4_index].Rw = flags & eFlagsRw; + pde->Pte[pml4_index].User = flags & eFlagsUser; + pde->Pte[pml4_index].ExecDisable = flags & eFlagsExecDisable; + + return 0; + } + + /// @brief Map address to PDE. + /// @param pde + /// @param phys_addr + /// @param virt_addr + /// @param flags + inline void ke_unmap_address(PDE* pde, UIntPtr phys_addr, UIntPtr virt_addr, UInt32 flags) + { + UInt16 pml4_index = (virt_addr >> 39) & 0x1FF; + UInt16 pdpt_index = (virt_addr >> 30) & 0x1FF; + UInt16 pd_index = (virt_addr >> 21) & 0x1FF; + UInt16 pt_index = (virt_addr >> 12) & 0x1FF; + + if (pde->Pte[pml4_index].Present) + { + pde->Pte[pml4_index].Present = false; + pde->Pte[pml4_index].PhysicalAddress = 0; + pde->Pte[pml4_index].Rw = 0; + pde->Pte[pml4_index].User = 0; + pde->Pte[pml4_index].ExecDisable = 0; + } + } + EXTERN_C UChar In8(UInt16 port); EXTERN_C UShort In16(UInt16 port); EXTERN_C UInt In32(UInt16 port); @@ -162,6 +225,8 @@ namespace NewOS::HAL }; Void hal_system_get_cores(VoidPtr rsdPtr); + Void hal_send_start_ipi(UInt32 apicId, UInt8 vector, UInt32 targetAddress); + Void hal_send_end_ipi(UInt32 apicId, UInt8 vector, UInt32 targetAddress); /// @brief Processor specific structures. namespace Detail diff --git a/Kernel/KernelKit/KernelHeap.hpp b/Kernel/KernelKit/KernelHeap.hpp index c7b898ed..e2ab19b5 100644 --- a/Kernel/KernelKit/KernelHeap.hpp +++ b/Kernel/KernelKit/KernelHeap.hpp @@ -36,4 +36,9 @@ namespace NewOS /// @param heapPtr HIB pointer. /// @return if it valid: point has crc now., otherwise fail. Boolean ke_protect_ke_heap(VoidPtr heapPtr); + + /// @brief Makes a kernel heap page. + /// @param heapPtr + /// @return + Int32 ke_make_ke_page(VoidPtr heapPtr); } // namespace NewOS diff --git a/Kernel/KernelKit/ProcessScheduler.hpp b/Kernel/KernelKit/ProcessScheduler.hpp deleted file mode 100644 index 9adaac0d..00000000 --- a/Kernel/KernelKit/ProcessScheduler.hpp +++ /dev/null @@ -1,303 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#ifndef __PROCESS_SCHEDULER__ -#define __PROCESS_SCHEDULER__ - -#include -#include -#include -#include -#include -#include - -#define kSchedMinMicroTime AffinityKind::kHartStandard -#define kSchedInvalidPID (-1) - -#define kSchedProcessLimitPerTeam (100U) - -//////////////////////////////////////////////////// - -// LAST REV: Mon Feb 12 13:52:01 CET 2024 - -//////////////////////////////////////////////////// - -namespace NewOS -{ - class ProcessHeader; - class ProcessTeam; - class ProcessScheduler; - - //! @brief Process identifier. - typedef Int64 ProcessID; - - //! @brief Process name length. - inline constexpr SizeT kProcessLen = 256U; - - //! @brief Forward declaration. - class ProcessHeader; - class ProcessScheduler; - class ProcessHelper; - - //! @brief Process status enum. - enum class ProcessStatus : Int32 - { - kStarting, - kRunning, - kKilled, - kFrozen, - kDead - }; - - //! @brief Affinity is the amount of nano-seconds this process is going - //! to run. - enum class AffinityKind : Int32 - { - kInvalid = 300, - kVeryHigh = 250, - kHigh = 200, - kHartStandard = 150, - kLowUsage = 100, - kVeryLowUsage = 50, - }; - - // operator overloading. - - inline bool operator<(AffinityKind lhs, AffinityKind rhs) - { - Int32 lhs_int = static_cast(lhs); - Int32 rhs_int = static_cast(rhs); - - return lhs_int < rhs_int; - } - - inline bool operator>(AffinityKind lhs, AffinityKind rhs) - { - Int32 lhs_int = static_cast(lhs); - Int32 rhs_int = static_cast(rhs); - - return lhs_int > rhs_int; - } - - inline bool operator<=(AffinityKind lhs, AffinityKind rhs) - { - Int32 lhs_int = static_cast(lhs); - Int32 rhs_int = static_cast(rhs); - - return lhs_int <= rhs_int; - } - - inline bool operator>=(AffinityKind lhs, AffinityKind rhs) - { - Int32 lhs_int = static_cast(lhs); - Int32 rhs_int = static_cast(rhs); - - return lhs_int >= rhs_int; - } - - // end of operator overloading. - - enum ProcessSubsystemEnum - { - eProcessSubsystemLogin, - eProcessSubsystemNative, - eProcessSubsystemInvalid, - eProcessSubsystemCount, - }; - - using ProcessSubsystem = ProcessSubsystemEnum; - using ProcessTime = UInt64; - using PID = Int64; - - // for permission manager, tells where we run the code. - enum class ProcessSelector : Int - { - kRingUser, /* user ring (or ring 3 in x86) */ - kRingDriver, /* ring 2 in x86, hypervisor privileges in other archs */ - kRingKernel, /* machine privileges */ - }; - - // Helper types. - using ImagePtr = VoidPtr; - using HeapPtr = VoidPtr; - - // @name ProcessHeader - // @brief Process Header (PH) - // Holds information about the running process. - // Thread execution is being abstracted away. - class ProcessHeader final - { - public: - explicit ProcessHeader(VoidPtr startImage = nullptr) - : Image(startImage) - { - MUST_PASS(startImage); - } - - ~ProcessHeader() = default; - - NEWOS_COPY_DEFAULT(ProcessHeader) - - public: - void SetEntrypoint(UIntPtr& imageStart) noexcept; - - public: - Char Name[kProcessLen] = {"NewOS Process"}; - ProcessSubsystem SubSystem{ProcessSubsystem::eProcessSubsystemInvalid}; - ProcessSelector Selector{ProcessSelector::kRingUser}; - HAL::StackFramePtr StackFrame{nullptr}; - AffinityKind Affinity; - ProcessStatus Status; - - // Memory, images. - HeapPtr HeapCursor{nullptr}; - ImagePtr Image{nullptr}; - HeapPtr HeapPtr{nullptr}; - - // memory usage - SizeT UsedMemory{0}; - SizeT FreeMemory{0}; - - enum - { - kAppKind = 3, - kLibKind = 3, - kDriverKind = 0, - kKindCount, - }; - - enum - { - kRingUserKind = 3, - kRingDriverKind = 0, - }; - - ProcessTime PTime; - PID ProcessId{kSchedInvalidPID}; - Int32 Ring{kRingDriverKind}; - Int32 Kind{kAppKind}; - - public: - //! @brief boolean operator, check status. - operator bool() - { - return Status != ProcessStatus::kDead; - } - - //! @brief Crash the app, exits with code ~0. - void Crash(); - - //! @brief Exits app. - void Exit(Int32 exitCode = 0); - - //! @brief TLS Allocate - VoidPtr New(const SizeT& sz); - - //! @brief TLS Free. - Boolean Delete(VoidPtr ptr, const SizeT& sz); - - //! @brief Wakes up threads. - void Wake(const bool wakeup = false); - - // ProcessHeader getters. - public: - //! @brief ProcessHeader name getter, example: "C RunTime" - const Char* GetName(); - - const ProcessSelector& GetSelector(); - const ProcessStatus& GetStatus(); - const AffinityKind& GetAffinity(); - - private: - friend ProcessScheduler; - friend ProcessHelper; - }; - - /// \brief Processs Team (contains multiple processes inside it.) - /// Equivalent to a process batch - class ProcessTeam final - { - public: - explicit ProcessTeam() = default; - ~ProcessTeam() = default; - - NEWOS_COPY_DEFAULT(ProcessTeam); - - MutableArray>& AsArray(); - Ref& AsRef(); - - public: - MutableArray> mProcessList; - Ref mCurrentProcess; - }; - - using ProcessHeaderRef = ProcessHeader*; - - /// @brief ProcessHeader manager class. - /// The main class which you call to schedule an app. - class ProcessScheduler final - { - private: - explicit ProcessScheduler() = default; - - public: - ~ProcessScheduler() = default; - - NEWOS_COPY_DEFAULT(ProcessScheduler) - - operator bool() - { - return mTeam.AsArray().Count() > 0; - } - - bool operator!() - { - return mTeam.AsArray().Count() == 0; - } - - public: - ProcessTeam& CurrentTeam(); - - public: - SizeT Add(Ref& headerRef); - bool Remove(SizeT headerIndex); - - public: - Ref& GetCurrent(); - SizeT Run() noexcept; - - public: - static Ref The(); - - private: - ProcessTeam mTeam; - }; - - /* - * Just a helper class, which contains some utilities for the scheduler. - */ - - class ProcessHelper final - { - public: - static bool Switch(HAL::StackFrame* newStack, const PID& newPid); - static bool CanBeScheduled(Ref& process); - static PID& GetCurrentPID(); - static bool StartScheduling(); - }; - - const Int32& rt_get_exit_code() noexcept; -} // namespace NewOS - -#include - -//////////////////////////////////////////////////// - -// END - -//////////////////////////////////////////////////// - -#endif /* ifndef __PROCESS_SCHEDULER__ */ diff --git a/Kernel/KernelKit/ProcessScheduler.hxx b/Kernel/KernelKit/ProcessScheduler.hxx new file mode 100644 index 00000000..33c9f313 --- /dev/null +++ b/Kernel/KernelKit/ProcessScheduler.hxx @@ -0,0 +1,303 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#ifndef __PROCESS_SCHEDULER__ +#define __PROCESS_SCHEDULER__ + +#include +#include +#include +#include +#include +#include + +#define kSchedMinMicroTime AffinityKind::kHartStandard +#define kSchedInvalidPID (-1) + +#define kSchedProcessLimitPerTeam (100U) + +//////////////////////////////////////////////////// + +// LAST REV: Mon Feb 12 13:52:01 CET 2024 + +//////////////////////////////////////////////////// + +namespace NewOS +{ + class ProcessHeader; + class ProcessTeam; + class ProcessScheduler; + + //! @brief Process identifier. + typedef Int64 ProcessID; + + //! @brief Process name length. + inline constexpr SizeT kProcessLen = 256U; + + //! @brief Forward declaration. + class ProcessHeader; + class ProcessScheduler; + class ProcessHelper; + + //! @brief Process status enum. + enum class ProcessStatus : Int32 + { + kStarting, + kRunning, + kKilled, + kFrozen, + kDead + }; + + //! @brief Affinity is the amount of nano-seconds this process is going + //! to run. + enum class AffinityKind : Int32 + { + kInvalid = 300, + kVeryHigh = 250, + kHigh = 200, + kHartStandard = 150, + kLowUsage = 100, + kVeryLowUsage = 50, + }; + + // operator overloading. + + inline bool operator<(AffinityKind lhs, AffinityKind rhs) + { + Int32 lhs_int = static_cast(lhs); + Int32 rhs_int = static_cast(rhs); + + return lhs_int < rhs_int; + } + + inline bool operator>(AffinityKind lhs, AffinityKind rhs) + { + Int32 lhs_int = static_cast(lhs); + Int32 rhs_int = static_cast(rhs); + + return lhs_int > rhs_int; + } + + inline bool operator<=(AffinityKind lhs, AffinityKind rhs) + { + Int32 lhs_int = static_cast(lhs); + Int32 rhs_int = static_cast(rhs); + + return lhs_int <= rhs_int; + } + + inline bool operator>=(AffinityKind lhs, AffinityKind rhs) + { + Int32 lhs_int = static_cast(lhs); + Int32 rhs_int = static_cast(rhs); + + return lhs_int >= rhs_int; + } + + // end of operator overloading. + + enum ProcessSubsystemEnum + { + eProcessSubsystemLogin, + eProcessSubsystemNative, + eProcessSubsystemInvalid, + eProcessSubsystemCount, + }; + + using ProcessSubsystem = ProcessSubsystemEnum; + using ProcessTime = UInt64; + using PID = Int64; + + // for permission manager, tells where we run the code. + enum class ProcessSelector : Int + { + kRingUser, /* user ring (or ring 3 in x86) */ + kRingDriver, /* ring 2 in x86, hypervisor privileges in other archs */ + kRingKernel, /* machine privileges */ + }; + + // Helper types. + using ImagePtr = VoidPtr; + using HeapPtr = VoidPtr; + + // @name ProcessHeader + // @brief Process Header (PH) + // Holds information about the running process. + // Thread execution is being abstracted away. + class ProcessHeader final + { + public: + explicit ProcessHeader(VoidPtr startImage = nullptr) + : Image(startImage) + { + MUST_PASS(startImage); + } + + ~ProcessHeader() = default; + + NEWOS_COPY_DEFAULT(ProcessHeader) + + public: + void SetEntrypoint(UIntPtr& imageStart) noexcept; + + public: + Char Name[kProcessLen] = {"NewOS Process"}; + ProcessSubsystem SubSystem{ProcessSubsystem::eProcessSubsystemInvalid}; + ProcessSelector Selector{ProcessSelector::kRingUser}; + HAL::StackFramePtr StackFrame{nullptr}; + AffinityKind Affinity; + ProcessStatus Status; + + // Memory, images. + HeapPtr HeapCursor{nullptr}; + ImagePtr Image{nullptr}; + HeapPtr HeapPtr{nullptr}; + + // memory usage + SizeT UsedMemory{0}; + SizeT FreeMemory{0}; + + enum + { + kAppKind = 1, + kShLibKind = 2, + kDriverKind = 3, + kKindCount, + }; + + enum + { + kRingUserKind = 3, + kRingDriverKind = 0, + }; + + ProcessTime PTime; + PID ProcessId{kSchedInvalidPID}; + Int32 Ring{kRingDriverKind}; + Int32 Kind{kAppKind}; + + public: + //! @brief boolean operator, check status. + operator bool() + { + return Status != ProcessStatus::kDead; + } + + //! @brief Crash the app, exits with code ~0. + void Crash(); + + //! @brief Exits app. + void Exit(Int32 exitCode = 0); + + //! @brief TLS Allocate + VoidPtr New(const SizeT& sz); + + //! @brief TLS Free. + Boolean Delete(VoidPtr ptr, const SizeT& sz); + + //! @brief Wakes up threads. + void Wake(const bool wakeup = false); + + // ProcessHeader getters. + public: + //! @brief ProcessHeader name getter, example: "C RunTime" + const Char* GetName(); + + const ProcessSelector& GetSelector(); + const ProcessStatus& GetStatus(); + const AffinityKind& GetAffinity(); + + private: + friend ProcessScheduler; + friend ProcessHelper; + }; + + /// \brief Processs Team (contains multiple processes inside it.) + /// Equivalent to a process batch + class ProcessTeam final + { + public: + explicit ProcessTeam() = default; + ~ProcessTeam() = default; + + NEWOS_COPY_DEFAULT(ProcessTeam); + + MutableArray>& AsArray(); + Ref& AsRef(); + + public: + MutableArray> mProcessList; + Ref mCurrentProcess; + }; + + using ProcessHeaderRef = ProcessHeader*; + + /// @brief ProcessHeader manager class. + /// The main class which you call to schedule an app. + class ProcessScheduler final + { + private: + explicit ProcessScheduler() = default; + + public: + ~ProcessScheduler() = default; + + NEWOS_COPY_DEFAULT(ProcessScheduler) + + operator bool() + { + return mTeam.AsArray().Count() > 0; + } + + bool operator!() + { + return mTeam.AsArray().Count() == 0; + } + + public: + ProcessTeam& CurrentTeam(); + + public: + SizeT Add(Ref& headerRef); + bool Remove(SizeT headerIndex); + + public: + Ref& GetCurrent(); + SizeT Run() noexcept; + + public: + static Ref The(); + + private: + ProcessTeam mTeam; + }; + + /* + * Just a helper class, which contains some utilities for the scheduler. + */ + + class ProcessHelper final + { + public: + static bool Switch(HAL::StackFrame* newStack, const PID& newPid); + static bool CanBeScheduled(Ref& process); + static PID& GetCurrentPID(); + static bool StartScheduling(); + }; + + const Int32& rt_get_exit_code() noexcept; +} // namespace NewOS + +#include + +//////////////////////////////////////////////////// + +// END + +//////////////////////////////////////////////////// + +#endif /* ifndef __PROCESS_SCHEDULER__ */ diff --git a/Kernel/KernelKit/ThreadLocalStorage.inl b/Kernel/KernelKit/ThreadLocalStorage.inl index e2137ed6..a8269a14 100644 --- a/Kernel/KernelKit/ThreadLocalStorage.inl +++ b/Kernel/KernelKit/ThreadLocalStorage.inl @@ -7,7 +7,7 @@ //! @brief Allocates a pointer from the process's tls. #ifndef __PROCESS_MANAGER__ -#include +#include #endif template diff --git a/Kernel/Sources/AppMain.cxx b/Kernel/Sources/AppMain.cxx index 692d4376..62795893 100644 --- a/Kernel/Sources/AppMain.cxx +++ b/Kernel/Sources/AppMain.cxx @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -182,31 +182,31 @@ namespace NewOS::Detail /// @brief System loader entrypoint. /// @param void no parameters. /// @return void no return value. - STATIC NewOS::Void AppSystemLoader(NewOS::Void) + STATIC NewOS::Void AppSystem(NewOS::Void) { - NewOS::PEFLoader coreGraphicsShLib("/System/WindowServer"); + NewOS::PEFLoader wndServer("/System/WindowServer"); - if (!coreGraphicsShLib.IsLoaded()) + if (!wndServer.IsLoaded()) { NewOS::ke_stop(RUNTIME_CHECK_FAILED); } - NewOS::Utils::execute_from_image(coreGraphicsShLib, - NewOS::ProcessHeader::kLibKind); + NewOS::Utils::execute_from_image(wndServer, + NewOS::ProcessHeader::kAppKind); - NewOS::PEFLoader logonService("/System/Login"); + NewOS::PEFLoader launchServer("/System/Launcher"); - if (!logonService.IsLoaded()) + if (!launchServer.IsLoaded()) { NewOS::ke_stop(RUNTIME_CHECK_FAILED); } - NewOS::Utils::execute_from_image(logonService, + NewOS::Utils::execute_from_image(launchServer, NewOS::ProcessHeader::kAppKind); - NewOS::kcout << "SystemLoader: Exiting process, we're done initializing stuff..."; + NewOS::kcout << "System: done, sleeping..."; - NewOS::ProcessScheduler::The().Leak().GetCurrent().Leak().Exit(0); + while (true) {} } } // namespace NewOS::Detail @@ -218,8 +218,8 @@ EXTERN_C NewOS::Void AppMain(NewOS::Void) /// Now run kernel loop, until no process are running. NewOS::Detail::FilesystemWizard wizard; // automatic. - auto cLoaderName = "SystemLoader"; - NewOS::execute_from_image(NewOS::Detail::AppSystemLoader, cLoaderName); + auto cLoaderName = "System"; + NewOS::execute_from_image(NewOS::Detail::AppSystem, cLoaderName); while (NewOS::ProcessScheduler::The().Leak().Run() > 0) {} } diff --git a/Kernel/Sources/CodeManager.cxx b/Kernel/Sources/CodeManager.cxx index 7483b32f..10de3512 100644 --- a/Kernel/Sources/CodeManager.cxx +++ b/Kernel/Sources/CodeManager.cxx @@ -6,7 +6,7 @@ #include #include -#include +#include namespace NewOS { diff --git a/Kernel/Sources/KernelHeap.cxx b/Kernel/Sources/KernelHeap.cxx index a8ca467e..93f0c164 100644 --- a/Kernel/Sources/KernelHeap.cxx +++ b/Kernel/Sources/KernelHeap.cxx @@ -38,7 +38,10 @@ namespace NewOS SizeT fTargetPtrSize; /// @brief 64-bit target pointer. UIntPtr fTargetPtr; - UInt8 fPadding[kKernelHeapHeaderPaddingSz]; + /// @brief Is this a page pointer? + Boolean fPagePtr; + /// @brief Padding bytes for header. + UInt8 fPadding[kKernelHeapHeaderPaddingSz]; }; typedef HeapInformationBlock* HeapInformationBlockPtr; @@ -64,6 +67,7 @@ namespace NewOS heapInfo->fMagic = kKernelHeapMagic; heapInfo->fCRC32 = 0; // dont fill it for now. heapInfo->fTargetPtr = wrapper.VirtualAddress(); + heapInfo->fPagePtr = 0; ++kHeapCount; @@ -71,6 +75,27 @@ namespace NewOS sizeof(Detail::HeapInformationBlock)); } + /// @brief Makes a page heap. + /// @param heapPtr + /// @return + Int32 ke_make_ke_page(VoidPtr heapPtr) + { + if (kHeapCount < 1) + return -kErrorInternal; + if (((IntPtr)heapPtr - sizeof(Detail::HeapInformationBlock)) <= 0) + return -kErrorInternal; + if (((IntPtr)heapPtr - kBadPtr) < 0) + return -kErrorInternal; + + Detail::HeapInformationBlockPtr virtualAddress = + reinterpret_cast( + (UIntPtr)heapPtr - sizeof(Detail::HeapInformationBlock)); + + virtualAddress->fPagePtr = 1; + + return 0; + } + /// @brief Declare pointer as free. /// @param heapPtr the pointer. /// @return diff --git a/Kernel/Sources/PEFCodeManager.cxx b/Kernel/Sources/PEFCodeManager.cxx index c0997dff..a84730e9 100644 --- a/Kernel/Sources/PEFCodeManager.cxx +++ b/Kernel/Sources/PEFCodeManager.cxx @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Kernel/Sources/PEFSharedObjectRT.cxx b/Kernel/Sources/PEFSharedObjectRT.cxx index 33df8857..3ddef245 100644 --- a/Kernel/Sources/PEFSharedObjectRT.cxx +++ b/Kernel/Sources/PEFSharedObjectRT.cxx @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include diff --git a/Kernel/Sources/ProcessScheduler.cxx b/Kernel/Sources/ProcessScheduler.cxx index 32e1fbde..bf088cc6 100644 --- a/Kernel/Sources/ProcessScheduler.cxx +++ b/Kernel/Sources/ProcessScheduler.cxx @@ -9,7 +9,7 @@ /// @brief MicroKernel process scheduler. /***********************************************************************************/ -#include +#include #include #include #include @@ -206,7 +206,7 @@ namespace NewOS if (!process.Leak().Image) { - if (process.Leak().Kind != ProcessHeader::kLibKind) + if (process.Leak().Kind != ProcessHeader::kShLibKind) { return -kErrorNoEntrypoint; } @@ -223,7 +223,7 @@ namespace NewOS /// Create heap according to type of process. if (process.Leak().Kind == ProcessHeader::kAppKind) process.Leak().HeapPtr = rt_new_heap(kUserHeapUser | kUserHeapRw); - else if (process.Leak().Kind == ProcessHeader::kLibKind) + else if (process.Leak().Kind == ProcessHeader::kShLibKind) process.Leak().HeapPtr = rt_new_heap(kUserHeapUser | kUserHeapRw | kUserHeapShared); else process.Leak().HeapPtr = rt_new_heap(kUserHeapDriver | kUserHeapRw); diff --git a/Kernel/Sources/ProcessTeam.cxx b/Kernel/Sources/ProcessTeam.cxx index 7e311399..068e0dbb 100644 --- a/Kernel/Sources/ProcessTeam.cxx +++ b/Kernel/Sources/ProcessTeam.cxx @@ -9,7 +9,7 @@ /// @brief Process teams implementation. /***********************************************************************************/ -#include +#include namespace NewOS { diff --git a/Kernel/Sources/SMPManager.cxx b/Kernel/Sources/SMPManager.cxx index b2f239e3..29e0fa26 100644 --- a/Kernel/Sources/SMPManager.cxx +++ b/Kernel/Sources/SMPManager.cxx @@ -5,7 +5,7 @@ ------------------------------------------- */ #include -#include +#include #include ///! BUGS: 0 @@ -95,7 +95,6 @@ namespace NewOS { /// Keep the arguments, switch the base pointer, stack pointer /// fs and gs registers. - fStack->Rbp = stack->Rbp; fStack->Rsp = stack->Rsp; fStack->Fs = stack->Fs; @@ -103,6 +102,7 @@ namespace NewOS } rt_do_context_switch(fStack); + return true; } @@ -172,6 +172,8 @@ namespace NewOS rt_copy_memory(stack, fThreadList[idx].Leak().Leak().fStack, sizeof(HAL::StackFrame)); + fThreadList[idx].Leak().Leak().Switch(fThreadList[idx].Leak().Leak().fStack); + fThreadList[idx].Leak().Leak().fPID = ProcessHelper::GetCurrentPID(); fThreadList[idx].Leak().Leak().Busy(false); diff --git a/Kernel/Sources/Semaphore.cxx b/Kernel/Sources/Semaphore.cxx index 7bd1d513..e2e135d0 100644 --- a/Kernel/Sources/Semaphore.cxx +++ b/Kernel/Sources/Semaphore.cxx @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include +#include #include #include diff --git a/Kernel/Sources/ThreadLocalStorage.cxx b/Kernel/Sources/ThreadLocalStorage.cxx index 2d7e61eb..00305006 100644 --- a/Kernel/Sources/ThreadLocalStorage.cxx +++ b/Kernel/Sources/ThreadLocalStorage.cxx @@ -7,7 +7,7 @@ * ======================================================== */ -#include +#include #include ///! BUGS: 0 diff --git a/Kernel/Sources/UserHeap.cxx b/Kernel/Sources/UserHeap.cxx index da5d7b5a..64b75641 100644 --- a/Kernel/Sources/UserHeap.cxx +++ b/Kernel/Sources/UserHeap.cxx @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include +#include #include #include diff --git a/Kernel/makefile b/Kernel/makefile index b7749100..14bd1cae 100644 --- a/Kernel/makefile +++ b/Kernel/makefile @@ -69,7 +69,7 @@ link-amd64-epm: .PHONY: all all: newos-amd64-epm link-amd64-epm - @echo "NewKernel => OK." + @echo "NewOSKrnl => OK." .PHONY: help help: -- cgit v1.2.3 From 39415bb759f7eb67fb393385c28c3d2e5d7f6857 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 2 Jun 2024 09:25:18 +0200 Subject: MHR-23: Porting to ARM64 now. Signed-off-by: Amlal El Mahrouss --- Boot/BootKit/BootKit.hxx | 4 +- Boot/ReadMe.md | 2 +- Boot/Sources/BootloaderRsrc.rsrc | 6 +- Boot/Sources/HEL/AMD64/BootATA.cxx | 2 +- Boot/Sources/HEL/AMD64/BootFileReader.cxx | 8 +- Boot/Sources/HEL/AMD64/BootMain.cxx | 4 +- Boot/Sources/HEL/POWER/CoreBootStartup.S | 2 +- Boot/Sources/HEL/RISCV/BootRISCV.S | 4 +- Boot/Sources/Root/SplashScreen.fmt | 4 +- Boot/makefile | 6 +- Drv/DynamicLoader/DriverRsrc.rsrc | 25 ----- Drv/DynamicLoader/DynamicLoader.c | 30 ------ Drv/DynamicLoader/x86_64.mk | 51 ---------- Kernel/Docs/SPECIFICATION.md | 2 +- Kernel/Docs/TODO-LIST.md | 2 +- .../HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp | 18 ++-- .../HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp | 3 +- Kernel/HALKit/AMD64/Storage/AHCI.cxx | 2 +- Kernel/KernelKit/DriveManager.hxx | 2 +- Kernel/KernelRsrc.rsrc | 2 +- Kernel/Linker/16x0.json | 2 +- Kernel/Linker/32x0.json | 2 +- Kernel/Linker/64x0.json | 2 +- Kernel/NetworkKit/NetworkDevice.inl | 4 +- Kernel/Sources/CxxAbi.cxx | 2 +- Kernel/Sources/FS/NewFS.cxx | 53 +++++----- Kernel/Sources/IndexableProperty.cxx | 2 +- Kernel/Sources/KernelCheck.cxx | 4 +- Kernel/Sources/PEFSharedObject.cxx | 106 ++++++++++++++++++++ Kernel/Sources/PEFSharedObjectRT.cxx | 107 --------------------- Kernel/Sources/ThreadLocalStorage.cxx | 6 +- Kernel/makefile | 2 +- 32 files changed, 184 insertions(+), 287 deletions(-) delete mode 100644 Drv/DynamicLoader/DriverRsrc.rsrc delete mode 100644 Drv/DynamicLoader/DynamicLoader.c delete mode 100644 Drv/DynamicLoader/x86_64.mk create mode 100644 Kernel/Sources/PEFSharedObject.cxx delete mode 100644 Kernel/Sources/PEFSharedObjectRT.cxx (limited to 'Kernel/KernelKit') diff --git a/Boot/BootKit/BootKit.hxx b/Boot/BootKit/BootKit.hxx index 77badc23..311d6c7f 100644 --- a/Boot/BootKit/BootKit.hxx +++ b/Boot/BootKit/BootKit.hxx @@ -284,7 +284,7 @@ private: EFI::ThrowError(L"Developer-Error", L"This is caused by the developer of the bootloader."); } - writer.Write((catalogKind->Kind == kNewFSCatalogKindFile) ? L"New Boot: Write-File: " : L"New Boot: Write-Directory: ").Write(blob->fFileName).Write(L"\r"); + writer.Write((catalogKind->Kind == kNewFSCatalogKindFile) ? L"newosldr: Write-File: " : L"newosldr: Write-Directory: ").Write(blob->fFileName).Write(L"\r"); memcpy(catalogKind->Name, blob->fFileName, strlen(blob->fFileName)); @@ -360,7 +360,7 @@ inline Boolean BDiskFormatFactory::Format(const char* partName, fDiskDev.Write(buf, sectorSz); BTextWriter writer; - writer.Write(L"New Boot: Write-Partition: OK.\r"); + writer.Write(L"newosldr: Write-Partition: OK.\r"); return true; } diff --git a/Boot/ReadMe.md b/Boot/ReadMe.md index d5f2b89e..ce5b30cd 100644 --- a/Boot/ReadMe.md +++ b/Boot/ReadMe.md @@ -1,4 +1,4 @@ -# NewBoot +# newosldr You need: diff --git a/Boot/Sources/BootloaderRsrc.rsrc b/Boot/Sources/BootloaderRsrc.rsrc index 0282192b..857e08e4 100644 --- a/Boot/Sources/BootloaderRsrc.rsrc +++ b/Boot/Sources/BootloaderRsrc.rsrc @@ -13,10 +13,10 @@ BEGIN VALUE "CompanyName", "SoftwareLabs" VALUE "FileDescription", "New OS multi-platform bootloader." VALUE "FileVersion", BOOTLOADER_VERSION - VALUE "InternalName", "NewBoot" + VALUE "InternalName", "newosldr" VALUE "LegalCopyright", "Copyright SoftwareLabs, all rights reserved." - VALUE "OriginalFilename", "NewOSLdr.exe" - VALUE "ProductName", "NewBoot" + VALUE "OriginalFilename", "newosldr.exe" + VALUE "ProductName", "newosldr" VALUE "ProductVersion", BOOTLOADER_VERSION END END diff --git a/Boot/Sources/HEL/AMD64/BootATA.cxx b/Boot/Sources/HEL/AMD64/BootATA.cxx index c82cb2ea..d2753110 100644 --- a/Boot/Sources/HEL/AMD64/BootATA.cxx +++ b/Boot/Sources/HEL/AMD64/BootATA.cxx @@ -81,7 +81,7 @@ ATAInit_Retry: if (statRdy & ATA_SR_ERR) { writer.Write( - L"New Boot: ATA: Select error, not an IDE based hard-drive.\r"); + L"newosldr: ATA: Select error, not an IDE based hard-drive.\r"); return false; } diff --git a/Boot/Sources/HEL/AMD64/BootFileReader.cxx b/Boot/Sources/HEL/AMD64/BootFileReader.cxx index 7ec6b7ab..e6e70509 100644 --- a/Boot/Sources/HEL/AMD64/BootFileReader.cxx +++ b/Boot/Sources/HEL/AMD64/BootFileReader.cxx @@ -57,13 +57,13 @@ BFileReader::BFileReader(const CharacterTypeUTF16* path, if (BS->HandleProtocol(ImageHandle, &guidImg, (void**)&img) != kEfiOk) { - mWriter.Write(L"New Boot: Fetch-Protocol: No-Such-Protocol").Write(L"\r"); + mWriter.Write(L"newosldr: Fetch-Protocol: No-Such-Protocol").Write(L"\r"); this->mErrorCode = kNotSupported; } if (BS->HandleProtocol(img->DeviceHandle, &guidEfp, (void**)&efp) != kEfiOk) { - mWriter.Write(L"New Boot: Fetch-Protocol: No-Such-Protocol").Write(L"\r"); + mWriter.Write(L"newosldr: Fetch-Protocol: No-Such-Protocol").Write(L"\r"); this->mErrorCode = kNotSupported; return; } @@ -72,7 +72,7 @@ BFileReader::BFileReader(const CharacterTypeUTF16* path, if (efp->OpenVolume(efp, &rootFs) != kEfiOk) { - mWriter.Write(L"New Boot: Fetch-Protocol: No-Such-Volume").Write(L"\r"); + mWriter.Write(L"newosldr: Fetch-Protocol: No-Such-Volume").Write(L"\r"); this->mErrorCode = kNotSupported; return; } @@ -82,7 +82,7 @@ BFileReader::BFileReader(const CharacterTypeUTF16* path, if (rootFs->Open(rootFs, &kernelFile, mPath, kEFIFileRead, kEFIReadOnly) != kEfiOk) { - mWriter.Write(L"New Boot: Fetch-Protocol: No-Such-Path: ") + mWriter.Write(L"newosldr: Fetch-Protocol: No-Such-Path: ") .Write(mPath) .Write(L"\r"); this->mErrorCode = kNotSupported; diff --git a/Boot/Sources/HEL/AMD64/BootMain.cxx b/Boot/Sources/HEL/AMD64/BootMain.cxx index 7609c1af..cb8bccba 100644 --- a/Boot/Sources/HEL/AMD64/BootMain.cxx +++ b/Boot/Sources/HEL/AMD64/BootMain.cxx @@ -68,7 +68,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, /// Splash screen stuff - writer.Write(L"SoftwareLabs (R) New Boot: ") + writer.Write(L"SoftwareLabs (R) newosldr: ") .Write(BVersionString::The()); writer.Write(L"\rNew Boot: Firmware Vendor: ") @@ -99,7 +99,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, vendorTable[4] == 'P' && vendorTable[5] == 'T' && vendorTable[6] == 'R' && vendorTable[7] == ' ') { - writer.Write(L"New Boot: Found ACPI RSD PTR!\r"); + writer.Write(L"newosldr: Found ACPI RSD PTR!\r"); handoverHdrPtr->f_HardwareTables.f_RsdPtr = (VoidPtr)vendorTable; break; diff --git a/Boot/Sources/HEL/POWER/CoreBootStartup.S b/Boot/Sources/HEL/POWER/CoreBootStartup.S index f8ff99d7..ed39c3b5 100644 --- a/Boot/Sources/HEL/POWER/CoreBootStartup.S +++ b/Boot/Sources/HEL/POWER/CoreBootStartup.S @@ -13,7 +13,7 @@ boot_hdr_mag: .ascii "CB" boot_hdr_name: // it has to match ten bytes. - .asciz "NewBoot\0\0\0" + .asciz "newosldr\0\0" boot_hdr_ver: .word 0x104 boot_hdr_proc: diff --git a/Boot/Sources/HEL/RISCV/BootRISCV.S b/Boot/Sources/HEL/RISCV/BootRISCV.S index 7a7e7db0..b682d597 100644 --- a/Boot/Sources/HEL/RISCV/BootRISCV.S +++ b/Boot/Sources/HEL/RISCV/BootRISCV.S @@ -13,10 +13,10 @@ k_hdr_mag: .ascii "LX" k_hdr_name: // it has to match ten bytes. - .asciz "New OS\0\0\0\0" + .asciz "newosldr\0\0" k_hdr_ver: .word 0x104 k_hdr_proc: - .long __bootloader_start + .long bootloader_start /* end */ \ No newline at end of file diff --git a/Boot/Sources/Root/SplashScreen.fmt b/Boot/Sources/Root/SplashScreen.fmt index 863d7b62..42005568 100644 --- a/Boot/Sources/Root/SplashScreen.fmt +++ b/Boot/Sources/Root/SplashScreen.fmt @@ -1,7 +1,7 @@ ================================================================== Welcome to NeWS. Brought to you by: Amlal EL Mahrouss. -* NewBoot, NewKernel: Amlal EL Mahrouss. -This copy can boot directly to NewKernel (Unified System). +* newosldr, newoskrnl: Amlal EL Mahrouss. +This copy can boot directly to newoskrnl (Unified System). Copyright SoftwareLabs, all rights reserved. ================================================================== diff --git a/Boot/makefile b/Boot/makefile index 5b1ab16b..e979c309 100644 --- a/Boot/makefile +++ b/Boot/makefile @@ -50,8 +50,8 @@ FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mno-red-zone -D__KERNEL__ -D__NEWBOOT__ -DEFI_FUNCTION_WRAPPER -I./ -I../Kernel -I./ -c -nostdlib -fno-rtti -fno-exceptions \ -std=c++20 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./ -BOOT_LOADER=NewOSLdr.exe -KERNEL=NewOSKrnl.exe +BOOT_LOADER=newosldr.exe +KERNEL=newoskrnl.exe .PHONY: invalid-recipe invalid-recipe: @@ -92,7 +92,7 @@ download-edk: $(HTTP_GET) https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd -O OVMF.fd BINS=*.bin -EXECUTABLES=NewOSLdr.exe NewOSKrnl.exe OVMF.fd +EXECUTABLES=newosldr.exe newoskrnl.exe OVMF.fd TARGETS=$(REM_FLAG) $(OBJ) $(BIN) $(IMG) $(IMG_2) $(EXECUTABLES) diff --git a/Drv/DynamicLoader/DriverRsrc.rsrc b/Drv/DynamicLoader/DriverRsrc.rsrc deleted file mode 100644 index 565895b0..00000000 --- a/Drv/DynamicLoader/DriverRsrc.rsrc +++ /dev/null @@ -1,25 +0,0 @@ -1 ICON "../../Kernel/Root/Boot/Icons/driver-logo.ico" - -1 VERSIONINFO -FILEVERSION 1,0,0,0 -PRODUCTVERSION 1,0,0,0 -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "080904E4" - BEGIN - VALUE "CompanyName", "SoftwareLabs" - VALUE "FileDescription", "SoftwareLabs Dynamic Loader Driver." - VALUE "FileVersion", "1.00" - VALUE "InternalName", "DynamicLoader" - VALUE "LegalCopyright", "Copyright SoftwareLabs, all rights reserved." - VALUE "OriginalFilename", "DynamicLoader.exe" - VALUE "ProductName", "SDLD" - VALUE "ProductVersion", "1.00" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x809, 1252 - END -END diff --git a/Drv/DynamicLoader/DynamicLoader.c b/Drv/DynamicLoader/DynamicLoader.c deleted file mode 100644 index f7eb9458..00000000 --- a/Drv/DynamicLoader/DynamicLoader.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ------------------------------------------- - - Copyright SoftwareLabs - -------------------------------------------- */ - -#include -#include - -/// @brief Start function -/// @return status code -int __ImageStart(void) -{ - kernelPrintStr("SDLD: Starting up...\r"); - return 0; -} - -/// @brief End function. -/// @return status code -int __ImageEnd(void) -{ - kernelPrintStr("SDLD: Shutting down...\r"); - return 0; -} - -///! @brief Check if stack has enough space. -void ___chkstk_ms(void) -{ - (void)0; -} diff --git a/Drv/DynamicLoader/x86_64.mk b/Drv/DynamicLoader/x86_64.mk deleted file mode 100644 index 54ee54f0..00000000 --- a/Drv/DynamicLoader/x86_64.mk +++ /dev/null @@ -1,51 +0,0 @@ -################################################## -# (C) SoftwareLabs, all rights reserved. -# This is the sample driver makefile. -################################################## - -CC_GNU=x86_64-w64-mingw32-gcc -LD_GNU=x86_64-w64-mingw32-ld - -WINDRES=x86_64-w64-mingw32-windres - -ADD_FILE=touch -COPY=cp -HTTP_GET=wget - -LD_FLAGS=-e __ImageStart --subsystem=17 - -OBJ=*.o - - -REM=rm -REM_FLAG=-f - -FLAG_ASM=-f win64 -FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mgeneral-regs-only -mno-red-zone -D__KERNEL__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -std=c17 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./ - -.PHONY: invalid-recipe -invalid-recipe: - @echo "invalid-recipe: Use make all instead." - -.PHONY: all -all: compile-amd64 - $(LD_GNU) $(OBJ) $(LD_FLAGS) -o SampleDriver.exe - -ifneq ($(DEBUG_SUPPORT), ) -DEBUG = -D__DEBUG__ -endif - -.PHONY: compile-amd64 -compile-amd64: - $(WINDRES) DriverRsrc.rsrc -O coff -o DriverRsrc.o - $(CC_GNU) $(FLAG_GNU) $(DEBUG) $(wildcard *.c) $(wildcard ../../DDK/*.c) $(wildcard ../../DDK/*.S) - -.PHONY: clean -clean: - $(REM) $(REM_FLAG) $(OBJ) SampleDriver.exe - -.PHONY: help -help: - @echo "=== HELP ===" - @echo "clean: Clean driver." - @echo "compile-amd64: Build driver." diff --git a/Kernel/Docs/SPECIFICATION.md b/Kernel/Docs/SPECIFICATION.md index e218947e..6f9ac3d3 100644 --- a/Kernel/Docs/SPECIFICATION.md +++ b/Kernel/Docs/SPECIFICATION.md @@ -51,7 +51,7 @@ =================================== -# 4: The NewBoot +# 4: The newosldr =================================== diff --git a/Kernel/Docs/TODO-LIST.md b/Kernel/Docs/TODO-LIST.md index b7780b9f..ed7b1cf9 100644 --- a/Kernel/Docs/TODO-LIST.md +++ b/Kernel/Docs/TODO-LIST.md @@ -18,6 +18,6 @@ Status: -NewBoot: Need to boot from EPM partition. +newosldr: Need to boot from EPM partition.
NewKernel: New Filesystem in progress. diff --git a/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp b/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp index d06dc6a6..6d831d3b 100644 --- a/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp +++ b/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp @@ -14,11 +14,11 @@ EXTERN_C void idt_handle_gpf(NewOS::UIntPtr rsp) { MUST_PASS(NewOS::ProcessScheduler::The().Leak().GetCurrent()); - NewOS::kcout << "New OS: Stack Pointer: " + NewOS::kcout << "newoskrnl: Stack Pointer: " << NewOS::StringBuilder::FromInt("rsp{%}", rsp); NewOS::kcout - << "New OS: General Protection Fault, caused by " + << "newoskrnl: General Protection Fault, caused by " << NewOS::ProcessScheduler::The().Leak().GetCurrent().Leak().GetName(); NewOS::ProcessScheduler::The().Leak().GetCurrent().Leak().Crash(); @@ -31,14 +31,14 @@ EXTERN_C void idt_handle_scheduler(NewOS::UIntPtr rsp) NewOS::kcout << NewOS::StringBuilder::FromInt("rsp{%}", rsp); NewOS::kcout - << "New OS: Will be scheduled back later " + << "newoskrnl: Will be scheduled back later " << NewOS::ProcessScheduler::The().Leak().GetCurrent().Leak().GetName() << NewOS::end_line(); /// schedule another process. if (!NewOS::ProcessHelper::StartScheduling()) { - NewOS::kcout << "New OS: Continue schedule this process...\r"; + NewOS::kcout << "newoskrnl: Continue schedule this process...\r"; } } @@ -50,7 +50,7 @@ EXTERN_C void idt_handle_pf(NewOS::UIntPtr rsp) NewOS::kcout << NewOS::StringBuilder::FromInt("rsp{%}", rsp); NewOS::kcout - << "New OS: Segmentation Fault, caused by " + << "newoskrnl: Segmentation Fault, caused by " << NewOS::ProcessScheduler::The().Leak().GetCurrent().Leak().GetName(); NewOS::ProcessScheduler::The().Leak().GetCurrent().Leak().Crash(); @@ -64,7 +64,7 @@ EXTERN_C void idt_handle_math(NewOS::UIntPtr rsp) NewOS::kcout << NewOS::StringBuilder::FromInt("rsp{%}", rsp); NewOS::kcout - << "New OS: Math error, caused by " + << "newoskrnl: Math error, caused by " << NewOS::ProcessScheduler::The().Leak().GetCurrent().Leak().GetName(); NewOS::ProcessScheduler::The().Leak().GetCurrent().Leak().Crash(); @@ -78,7 +78,7 @@ EXTERN_C void idt_handle_generic(NewOS::UIntPtr rsp) NewOS::kcout << NewOS::StringBuilder::FromInt("sp{%}", rsp); NewOS::kcout - << "New OS: Execution error, caused by " + << "newoskrnl: Execution error, caused by " << NewOS::ProcessScheduler::The().Leak().GetCurrent().Leak().GetName(); NewOS::ProcessScheduler::The().Leak().GetCurrent().Leak().Crash(); @@ -90,11 +90,11 @@ EXTERN_C void idt_handle_ud(NewOS::UIntPtr rsp) { MUST_PASS(NewOS::ProcessScheduler::The().Leak().GetCurrent()); - NewOS::kcout << "New OS: Stack Pointer: " + NewOS::kcout << "newoskrnl: Stack Pointer: " << NewOS::StringBuilder::FromInt("rsp{%}", rsp); NewOS::kcout - << "New OS: Invalid interrupt, caused by " + << "newoskrnl: Invalid interrupt, caused by " << NewOS::ProcessScheduler::The().Leak().GetCurrent().Leak().GetName(); NewOS::ProcessScheduler::The().Leak().GetCurrent().Leak().Crash(); diff --git a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp index 5ab40532..a184efc2 100644 --- a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp +++ b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp @@ -146,12 +146,13 @@ namespace NewOS::HAL if (madt->MadtRecords[i].Flags == 0x01) // if local apic. { // then register as a core for scheduler. + kcout << "newoskrnl: register core as scheduler thread.\r"; } } } else { - kcout << "New OS: APIC is not present! it is a vital component.\r"; + kcout << "newoskrnl: APIC is not present! it is a vital component.\r"; ke_stop(RUNTIME_CHECK_FAILED); } } diff --git a/Kernel/HALKit/AMD64/Storage/AHCI.cxx b/Kernel/HALKit/AMD64/Storage/AHCI.cxx index 93cef10c..a8045617 100644 --- a/Kernel/HALKit/AMD64/Storage/AHCI.cxx +++ b/Kernel/HALKit/AMD64/Storage/AHCI.cxx @@ -43,7 +43,7 @@ NewOS::Boolean drv_std_init(NewOS::UInt16& PortsImplemented) iterator[devIndex].Leak().EnableMmio(); /// enable the memory i/o for this ahci device. kAhciDevice = iterator[devIndex].Leak(); /// and then leak the reference. - kcout << "New Kernel: [PCI] Found AHCI controller.\r"; + kcout << "newoskrnl: [PCI] Found AHCI controller.\r"; return true; } diff --git a/Kernel/KernelKit/DriveManager.hxx b/Kernel/KernelKit/DriveManager.hxx index 019812a3..01058d00 100644 --- a/Kernel/KernelKit/DriveManager.hxx +++ b/Kernel/KernelKit/DriveManager.hxx @@ -113,7 +113,7 @@ namespace NewOS return &mD; default: { DbgLastError() = kErrorNoSuchDisk; - kcout << "New OS: No such disk.\n"; + kcout << "newoskrnl: No such disk.\n"; break; } diff --git a/Kernel/KernelRsrc.rsrc b/Kernel/KernelRsrc.rsrc index 91699b63..56c94a06 100644 --- a/Kernel/KernelRsrc.rsrc +++ b/Kernel/KernelRsrc.rsrc @@ -15,7 +15,7 @@ BEGIN VALUE "FileVersion", KERNEL_VERSION VALUE "InternalName", "NeXUS" VALUE "LegalCopyright", "SoftwareLabs" - VALUE "OriginalFilename", "NewOSKrnl.exe" + VALUE "OriginalFilename", "newoskrnl.exe" VALUE "ProductName", "NewOSKrnl" VALUE "ProductVersion", KERNEL_VERSION END diff --git a/Kernel/Linker/16x0.json b/Kernel/Linker/16x0.json index 40cee7c9..77235537 100644 --- a/Kernel/Linker/16x0.json +++ b/Kernel/Linker/16x0.json @@ -1,6 +1,6 @@ { "executable_type": "kernel", - "output_name": "NewOSKrnl.exe", + "output_name": "newoskrnl.exe", "start_proc": "__ImageStart", "format": "PEF" } diff --git a/Kernel/Linker/32x0.json b/Kernel/Linker/32x0.json index 40cee7c9..77235537 100644 --- a/Kernel/Linker/32x0.json +++ b/Kernel/Linker/32x0.json @@ -1,6 +1,6 @@ { "executable_type": "kernel", - "output_name": "NewOSKrnl.exe", + "output_name": "newoskrnl.exe", "start_proc": "__ImageStart", "format": "PEF" } diff --git a/Kernel/Linker/64x0.json b/Kernel/Linker/64x0.json index 40cee7c9..77235537 100644 --- a/Kernel/Linker/64x0.json +++ b/Kernel/Linker/64x0.json @@ -1,6 +1,6 @@ { "executable_type": "kernel", - "output_name": "NewOSKrnl.exe", + "output_name": "newoskrnl.exe", "start_proc": "__ImageStart", "format": "PEF" } diff --git a/Kernel/NetworkKit/NetworkDevice.inl b/Kernel/NetworkKit/NetworkDevice.inl index 614ccadf..750520ff 100644 --- a/Kernel/NetworkKit/NetworkDevice.inl +++ b/Kernel/NetworkKit/NetworkDevice.inl @@ -15,7 +15,7 @@ namespace NewOS void (*on_cleanup)(void)) : DeviceInterface(out, in), fCleanup(on_cleanup) { - kcout << "New OS: NetworkDevice initialized.\r"; + kcout << "newoskrnl: NetworkDevice initialized.\r"; MUST_PASS(out && in && on_cleanup); } @@ -24,7 +24,7 @@ namespace NewOS { MUST_PASS(fCleanup); - kcout << "New OS: NetworkDevice cleanup.\r"; + kcout << "newoskrnl: NetworkDevice cleanup.\r"; if (fCleanup) fCleanup(); } diff --git a/Kernel/Sources/CxxAbi.cxx b/Kernel/Sources/CxxAbi.cxx index 9aea8db7..0b01928a 100644 --- a/Kernel/Sources/CxxAbi.cxx +++ b/Kernel/Sources/CxxAbi.cxx @@ -14,7 +14,7 @@ uarch_t __atexit_func_count; extern "C" void __cxa_pure_virtual() { - NewOS::kcout << "New OS: C++ placeholder method.\n"; + NewOS::kcout << "newoskrnl: C++ placeholder method.\n"; } extern "C" void ___chkstk_ms() diff --git a/Kernel/Sources/FS/NewFS.cxx b/Kernel/Sources/FS/NewFS.cxx index 6f19c8ed..5e07fef8 100644 --- a/Kernel/Sources/FS/NewFS.cxx +++ b/Kernel/Sources/FS/NewFS.cxx @@ -73,11 +73,11 @@ _Output NewFork* NewFSParser::CreateFork(_Input NewCatalog* catalog, drv->fInput(&drv->fPacket); - kcout << "New OS: Next-Fork: " << hex_number(curFork.NextSibling) << endl; + kcout << "newoskrnl: Next-Fork: " << hex_number(curFork.NextSibling) << endl; if (curFork.Flags == kNewFSFlagCreated) { - kcout << "New OS: Fork already exists.\r"; + kcout << "newoskrnl: Fork already exists.\r"; /// sanity check. if (StringBuilder::Equals(curFork.ForkName, theFork.ForkName) && @@ -126,10 +126,10 @@ _Output NewFork* NewFSParser::CreateFork(_Input NewCatalog* catalog, drv->fOutput(&drv->fPacket); /// log what we have now. - kcout << "New OS: Wrote fork data at: " << hex_number(theFork.DataOffset) + kcout << "newoskrnl: Wrote fork data at: " << hex_number(theFork.DataOffset) << endl; - kcout << "New OS: Wrote fork at: " << hex_number(lba) << endl; + kcout << "newoskrnl: Wrote fork at: " << hex_number(lba) << endl; return &theFork; } @@ -372,9 +372,9 @@ _Output NewCatalog* NewFSParser::CreateCatalog(_Input const char* name, drive->fOutput(&drive->fPacket); - kcout << "New OS: Create new catalog, status: " + kcout << "newoskrnl: Create new catalog, status: " << hex_number(catalogChild->Flags) << endl; - kcout << "New OS: Create new catalog, status: " << catalogChild->Name + kcout << "newoskrnl: Create new catalog, status: " << catalogChild->Name << endl; drive->fPacket.fPacketContent = sectorBufPartBlock; @@ -449,7 +449,7 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive) partBlock->Version = kNewFSVersionInteger; - const auto cUntitledHD = "New OS HD\0"; + const auto cUntitledHD = "newoskrnl HD\0"; rt_copy_memory((VoidPtr)kNewFSIdent, (VoidPtr)partBlock->Ident, kNewFSIdentLen); @@ -475,14 +475,14 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive) drive->fOutput(&drive->fPacket); - kcout << "Drive-Kind: " << drive->fDriveKind() << endl; + kcout << "newoskrnl: drive kind: " << drive->fDriveKind() << endl; - kcout << "Partition-Name: " << partBlock->PartitionName << endl; - kcout << "Start-Catalog: " << hex_number(partBlock->StartCatalog) << endl; - kcout << "Catalog-Count: " << hex_number(partBlock->CatalogCount) << endl; - kcout << "Free-Catalog: " << hex_number(partBlock->FreeCatalog) << endl; - kcout << "Free-Sectors: " << hex_number(partBlock->FreeSectors) << endl; - kcout << "Sector-Size: " << hex_number(partBlock->SectorSize) << endl; + kcout << "newoskrnl: partition name: " << partBlock->PartitionName << endl; + kcout << "newoskrnl: start: " << hex_number(partBlock->StartCatalog) << endl; + kcout << "newoskrnl: number of catalogs: " << hex_number(partBlock->CatalogCount) << endl; + kcout << "newoskrnl: free catalog: " << hex_number(partBlock->FreeCatalog) << endl; + kcout << "newoskrnl: free sectors: " << hex_number(partBlock->FreeSectors) << endl; + kcout << "newoskrnl: sector size: " << hex_number(partBlock->SectorSize) << endl; /// write the root catalog. this->CreateCatalog(kNewFSRoot, 0, kNewFSCatalogKindDir); @@ -490,7 +490,7 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive) return true; } - kcout << "New OS: PartitionBlock already exists.\r"; + kcout << "newoskrnl: PartitionBlock already exists.\r"; /// return success as well, do not ignore that partition. return true; @@ -531,14 +531,14 @@ bool NewFSParser::WriteCatalog(_Input _Output NewCatalog* catalog, voidPtr data, drive->fInput(&drive->fPacket); - kcout << "Fork-Name: " << forkData->ForkName << endl; + kcout << "newoskrnl: forkName: " << forkData->ForkName << endl; /// sanity check the fork. if (forkData->DataOffset <= kNewFSCatalogStartAddress) { DbgLastError() = kErrorDiskIsCorrupted; - kcout << "New OS: Invalid fork offset.\r"; + kcout << "newoskrnl: Invalid fork offset.\r"; delete forkData; return false; @@ -552,7 +552,8 @@ bool NewFSParser::WriteCatalog(_Input _Output NewCatalog* catalog, voidPtr data, drive->fPacket.fPacketContent = data; drive->fPacket.fPacketSize = sizeOfData; drive->fPacket.fLba = forkData->DataOffset; - kcout << "Fork-Offset: " << hex_number(forkData->DataOffset) << endl; + + kcout << "newoskrnl: data offset: " << hex_number(forkData->DataOffset) << endl; drive->fOutput(&drive->fPacket); @@ -563,10 +564,12 @@ bool NewFSParser::WriteCatalog(_Input _Output NewCatalog* catalog, voidPtr data, catalog == nullptr) { delete catalog; + drive->fPacket.fPacketContent = data; drive->fPacket.fPacketSize = sizeOfData; drive->fPacket.fLba = forkData->DataOffset; - kcout << "Fork-Offset: " << hex_number(forkData->DataOffset) << endl; + + kcout << "newoskrnl: data offset: " << hex_number(forkData->DataOffset) << endl; drive->fOutput(&drive->fPacket); @@ -670,7 +673,7 @@ _NewFSSearchThroughCatalogList: NewCatalog* catalogPtr = new NewCatalog(); rt_copy_memory(catalog, catalogPtr, sizeof(NewCatalog)); - kcout << "New OS: Found catalog at: " << hex_number(startCatalogList) << endl; + kcout << "newoskrnl: found catalog at: " << hex_number(startCatalogList) << endl; outLba = startCatalogList; delete[] sectorBuf; @@ -809,8 +812,8 @@ VoidPtr NewFSParser::ReadCatalog(_Input _Output NewCatalog* catalog, Lba dataForkLba = catalog->DataFork; Size dataForkSize = catalog->DataForkSize; - kcout << "Found-Catalog: " << catalog->Name - << ", Data-Fork: " << hex_number(dataForkLba) << endl; + kcout << "newoskrnl: catalog " << catalog->Name + << ", fork: " << hex_number(dataForkLba) << endl; Char* sectorBuf = new Char[sizeof(NewFork)]; auto drive = sMountpointInterface.GetAddressOf(this->fDriveIndex); @@ -830,7 +833,7 @@ VoidPtr NewFSParser::ReadCatalog(_Input _Output NewCatalog* catalog, forkData = (NewFork*)sectorBuf; - kcout << "Fork-Name: " << forkData->ForkName << endl; + kcout << "newoskrnl: name: " << forkData->ForkName << endl; if (forkData->DataOffset <= kNewFSCatalogStartAddress) { @@ -930,11 +933,11 @@ namespace NewOS::Detail if (!StringBuilder::Equals(partBlock->Ident, kNewFSIdent)) { - kcout << "New OS: New FS Partition is corrupt.\r"; + kcout << "newoskrnl: New FS Partition is corrupt.\r"; return false; } - kcout << "New OS: Read partition: " << partBlock->PartitionName << ", with success!\r"; + kcout << "newoskrnl: Read partition: " << partBlock->PartitionName << ", with success!\r"; return true; } diff --git a/Kernel/Sources/IndexableProperty.cxx b/Kernel/Sources/IndexableProperty.cxx index 16694f52..6c773b9a 100644 --- a/Kernel/Sources/IndexableProperty.cxx +++ b/Kernel/Sources/IndexableProperty.cxx @@ -50,7 +50,7 @@ namespace NewOS indexer.AddFlag(kIndexerClaimed); rt_copy_memory((VoidPtr)indexer.LeakProperty().Path, (VoidPtr)filename, filenameLen); - kcout << "New OS: FSKit: index new file: " << filename << endl; + kcout << "newoskrnl: FSKit: index new file: " << filename << endl; } } } // namespace Indexer diff --git a/Kernel/Sources/KernelCheck.cxx b/Kernel/Sources/KernelCheck.cxx index b59417d4..6b355011 100644 --- a/Kernel/Sources/KernelCheck.cxx +++ b/Kernel/Sources/KernelCheck.cxx @@ -98,8 +98,8 @@ namespace NewOS if (!expr) { #ifdef __DEBUG__ - kcout << "New Kernel: File: " << file << "\r"; - kcout << "New Kernel: Line: " << line << "\r"; + kcout << "newoskrnl: File: " << file << "\r"; + kcout << "newoskrnl: Line: " << line << "\r"; #endif // __DEBUG__ diff --git a/Kernel/Sources/PEFSharedObject.cxx b/Kernel/Sources/PEFSharedObject.cxx new file mode 100644 index 00000000..06825a3c --- /dev/null +++ b/Kernel/Sources/PEFSharedObject.cxx @@ -0,0 +1,106 @@ +/* + * ======================================================== + * + * NewOS + * Copyright SoftwareLabs, all rights reserved. + * + * ======================================================== + */ + +#include +#include +#include +#include +#include +#include + +/* ------------------------------------------- + + Revision History: + + 01/02/24: Rework shared library ABI, except a rt_library_init and + rt_library_free (amlel) 15/02/24: Breaking changes, changed the name of the + routines. (amlel) + + ------------------------------------------- */ + +using namespace NewOS; + +/***********************************************************************************/ +/// @file SharedObjectRT.cxx +/// @brief Shared Object runtime. +/***********************************************************************************/ + +/***********************************************************************************/ +/* @brief Library runtime initializer. */ +/***********************************************************************************/ + +EXTERN_C SharedObjectPtr rt_library_init(void) +{ + SharedObjectPtr library = tls_new_class(); + + if (!library) + { + ProcessScheduler::The().Leak().GetCurrent().Leak().Crash(); + + return nullptr; + } + + library->Mount(tls_new_class()); + + if (!library->Get()) + { + ProcessScheduler::The().Leak().GetCurrent().Leak().Crash(); + + return nullptr; + } + + library->Get()->fImageObject = + ProcessScheduler::The().Leak().GetCurrent().Leak().Image; + + if (!library->Get()->fImageObject) + { + ProcessScheduler::The().Leak().GetCurrent().Leak().Crash(); + + return nullptr; + } + + library->Get()->fImageEntrypointOffset = + library->Load(kPefStart, rt_string_len(kPefStart, 0), kPefCode); + + return library; +} + +/***********************************************************************************/ +/* @brief Ends the library. */ +/* @note Please check if the lib got freed! */ +/* @param SharedObjectPtr the library to free. */ +/***********************************************************************************/ + +EXTERN_C Void rt_library_free(SharedObjectPtr lib, bool* successful) +{ + MUST_PASS(successful); + + // sanity check (will also trigger a bug check if this fails) + if (lib == nullptr) + { + *successful = false; + ProcessScheduler::The().Leak().GetCurrent().Leak().Crash(); + } + + delete lib->Get(); + delete lib; + + lib = nullptr; + + *successful = true; +} + +/***********************************************************************************/ + +/// @brief Unimplemented function (crashes by default) +/// @param +EXTERN_C void __mh_purecall(void) +{ + kcout << "newoskrnl: unimplemented symbol!\r"; +} diff --git a/Kernel/Sources/PEFSharedObjectRT.cxx b/Kernel/Sources/PEFSharedObjectRT.cxx deleted file mode 100644 index 3ddef245..00000000 --- a/Kernel/Sources/PEFSharedObjectRT.cxx +++ /dev/null @@ -1,107 +0,0 @@ -/* - * ======================================================== - * - * NewOS - * Copyright SoftwareLabs, all rights reserved. - * - * ======================================================== - */ - -#include -#include -#include -#include -#include -#include - -/* ------------------------------------------- - - Revision History: - - 01/02/24: Rework shared library ABI, except a rt_library_init and - rt_library_free (amlel) 15/02/24: Breaking changes, changed the name of the - routines. (amlel) - - ------------------------------------------- */ - -using namespace NewOS; - -/***********************************************************************************/ -/// @file SharedObjectRT.cxx -/// @brief Shared Object runtime. -/***********************************************************************************/ - -/***********************************************************************************/ -/* @brief Library runtime initializer. */ -/***********************************************************************************/ - -EXTERN_C SharedObjectPtr rt_library_init(void) -{ - SharedObjectPtr library = tls_new_class(); - - if (!library) - { - ProcessScheduler::The().Leak().GetCurrent().Leak().Crash(); - - return nullptr; - } - - library->Mount(tls_new_class()); - - if (!library->Get()) - { - ProcessScheduler::The().Leak().GetCurrent().Leak().Crash(); - - return nullptr; - } - - library->Get()->fImageObject = - ProcessScheduler::The().Leak().GetCurrent().Leak().Image; - - if (!library->Get()->fImageObject) - { - ProcessScheduler::The().Leak().GetCurrent().Leak().Crash(); - - return nullptr; - } - - library->Get()->fImageEntrypointOffset = - library->Load(kPefStart, rt_string_len(kPefStart, 0), kPefCode); - - return library; -} - -/***********************************************************************************/ -/* @brief Ends the library. */ -/* @note Please check if the lib got freed! */ -/* @param SharedObjectPtr the library to free. */ -/***********************************************************************************/ - -EXTERN_C Void rt_library_free(SharedObjectPtr lib, bool* successful) -{ - MUST_PASS(successful); - - // sanity check (will also trigger a bug check if this fails) - if (lib == nullptr) - { - *successful = false; - ProcessScheduler::The().Leak().GetCurrent().Leak().Crash(); - } - - delete lib->Get(); - delete lib; - - lib = nullptr; - - *successful = true; -} - -/***********************************************************************************/ - -/// @brief Unimplemented function (crashes by default) -/// @param -EXTERN_C void __mh_purecall(void) -{ - ProcessScheduler::The().Leak().GetCurrent().Leak().Crash(); - return; -} diff --git a/Kernel/Sources/ThreadLocalStorage.cxx b/Kernel/Sources/ThreadLocalStorage.cxx index 00305006..f72bab67 100644 --- a/Kernel/Sources/ThreadLocalStorage.cxx +++ b/Kernel/Sources/ThreadLocalStorage.cxx @@ -33,7 +33,7 @@ Boolean tls_check_tib(ThreadInformationBlock* tib) Encoder encoder; const char* tibAsBytes = encoder.AsBytes(tib); - kcout << "New OS: Checking for a valid cookie...\r"; + kcout << "newoskrnl: Checking for a valid cookie...\r"; return tibAsBytes[0] == kCookieMag0 && tibAsBytes[1] == kCookieMag1 && tibAsBytes[2] == kCookieMag2; @@ -50,9 +50,9 @@ EXTERN_C Void tls_check_syscall_impl(NewOS::HAL::StackFramePtr stackPtr) noexcep if (!tls_check_tib(tib)) { - kcout << "New OS: Verification failed, Crashing...\r"; + kcout << "newoskrnl: Verification failed, Crashing...\r"; ProcessScheduler::The().Leak().GetCurrent().Leak().Crash(); } - kcout << "New OS: Verification succeeded! Keeping on...\r"; + kcout << "newoskrnl: Verification succeeded! Keeping on...\r"; } diff --git a/Kernel/makefile b/Kernel/makefile index 14bd1cae..c550956a 100644 --- a/Kernel/makefile +++ b/Kernel/makefile @@ -37,7 +37,7 @@ LDFLAGS = -e __ImageStart --subsystem=17 LDOBJ = Objects/*.obj # This file is the kernel, responsible of task management and memory. -KERNEL = NewOSKrnl.exe +KERNEL = newoskrnl.exe .PHONY: error error: -- cgit v1.2.3 From 2cecacfe4f0cbbd8869cbd2c93a2f943aabd44ad Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 3 Jun 2024 00:14:06 +0200 Subject: MHR-23: remove FIXME. Signed-off-by: Amlal El Mahrouss --- Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx | 1 - Kernel/KernelKit/ProcessScheduler.hxx | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'Kernel/KernelKit') diff --git a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx index 7bdec117..14241f60 100644 --- a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx +++ b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx @@ -73,7 +73,6 @@ namespace NewOS if (rsdPtr->Revision <= 1) return ErrorOr{-1}; - /// FIXME RSDT* xsdt = (RSDT*)(rsdPtr->RsdtAddress); Int64 num = (xsdt->Length - sizeof(SDT)) / sizeof(UInt32); diff --git a/Kernel/KernelKit/ProcessScheduler.hxx b/Kernel/KernelKit/ProcessScheduler.hxx index 33c9f313..bd8cb628 100644 --- a/Kernel/KernelKit/ProcessScheduler.hxx +++ b/Kernel/KernelKit/ProcessScheduler.hxx @@ -14,7 +14,7 @@ #include #include -#define kSchedMinMicroTime AffinityKind::kHartStandard +#define kSchedMinMicroTime (AffinityKind::kHartStandard) #define kSchedInvalidPID (-1) #define kSchedProcessLimitPerTeam (100U) -- cgit v1.2.3 From 9994b8f3f88131f41be1061fb0947177e66dc7b0 Mon Sep 17 00:00:00 2001 From: Amlal EL Mahrouss Date: Wed, 5 Jun 2024 08:28:39 +0200 Subject: MHR-23: Add EPM PDF, add docs in KernelCall.c and fix log in NewFS.cxx Signed-off-by: Amlal EL Mahrouss --- DDK/KernelCall.c | 5 +++++ Kernel/Docs/Explicit Partition Map.pdf | Bin 0 -> 12326 bytes Kernel/KernelKit/PEF.hpp | 2 +- Kernel/Sources/FS/NewFS.cxx | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 Kernel/Docs/Explicit Partition Map.pdf (limited to 'Kernel/KernelKit') diff --git a/DDK/KernelCall.c b/DDK/KernelCall.c index 17e0b5d5..26a0b83b 100644 --- a/DDK/KernelCall.c +++ b/DDK/KernelCall.c @@ -11,6 +11,11 @@ DK_EXTERN __attribute__((naked)) void __kernelDispatchCall(int32_t cnt, ...); +/// @brief Execute a function on the kernel. +/// @param kernelRpcName the name of the function. +/// @param cnt number of arguments. +/// @param +/// @return DK_EXTERN void* kernelCall(const char* kernelRpcName, int32_t cnt, ...) { if (!kernelRpcName || cnt == 0) diff --git a/Kernel/Docs/Explicit Partition Map.pdf b/Kernel/Docs/Explicit Partition Map.pdf new file mode 100644 index 00000000..1e2f5318 Binary files /dev/null and b/Kernel/Docs/Explicit Partition Map.pdf differ diff --git a/Kernel/KernelKit/PEF.hpp b/Kernel/KernelKit/PEF.hpp index 1874aa4e..98a413aa 100644 --- a/Kernel/KernelKit/PEF.hpp +++ b/Kernel/KernelKit/PEF.hpp @@ -44,7 +44,7 @@ namespace NewOS { kPefSubArchAMD, kPefSubArchIntel, - kPefSubArchARM, + kPefSubArchGeneric, kPefSubArchIBM, }; diff --git a/Kernel/Sources/FS/NewFS.cxx b/Kernel/Sources/FS/NewFS.cxx index 5e07fef8..a60fc228 100644 --- a/Kernel/Sources/FS/NewFS.cxx +++ b/Kernel/Sources/FS/NewFS.cxx @@ -46,7 +46,7 @@ _Output NewFork* NewFSParser::CreateFork(_Input NewCatalog* catalog, Lba lba = (theFork.Kind == kNewFSDataForkKind) ? catalog->DataFork : catalog->ResourceFork; - kcout << "Fork Lba: " << hex_number(lba) << endl; + kcout << "newoskrnl: fork lba: " << hex_number(lba) << endl; if (lba <= kNewFSCatalogStartAddress) return nullptr; -- cgit v1.2.3