From 14db7b5bbf20a797d9edb07e3f7f84c9e90c2427 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 28 Aug 2025 11:56:29 +0200 Subject: feat: Implement the `Name` method for every CFObject interface. Signed-off-by: Amlal El Mahrouss --- dev/kernel/FirmwareKit/NeBoot/BootNet.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'dev') diff --git a/dev/kernel/FirmwareKit/NeBoot/BootNet.h b/dev/kernel/FirmwareKit/NeBoot/BootNet.h index ad8f07c5..0f406b57 100644 --- a/dev/kernel/FirmwareKit/NeBoot/BootNet.h +++ b/dev/kernel/FirmwareKit/NeBoot/BootNet.h @@ -20,22 +20,22 @@ struct _BOOTNET_INTERNET_HEADER; /// sent (if m_preflight = 0) /// @note Can be used to patch ROMs too (if ImpliesProgram = 1) typedef struct _BOOTNET_INTERNET_HEADER { - Kernel::Char NB1; /// magic char 1 'O' - Kernel::Char NB2; /// magic char 2 'N' - Kernel::Char NB3; /// magic char 3 'E' - Kernel::Char NB4; /// magic char 4 'T' + Kernel::Char NB1; /// magic char 1 'O' + Kernel::Char NB2; /// magic char 2 'N' + Kernel::Char NB3; /// magic char 3 'E' + Kernel::Char NB4; /// magic char 4 'T' - Kernel::UInt16 Version; + Kernel::UInt16 Version; - Kernel::Char Name[kBootNetNameLen]; /// example: Modjo + Kernel::Char Name[kBootNetNameLen]; /// example: Modjo - Kernel::Int32 Length; /// the patch length. - Kernel::Char Target[kBootNetNameLen]; /// the target file. + Kernel::Int32 Length; /// the patch length. + Kernel::Char Target[kBootNetNameLen]; /// the target file. - Kernel::Boolean ImpliesProgram : 1; /// does it imply reprogramming? + Kernel::Boolean ImpliesProgram : 1; /// does it imply reprogramming? - Kernel::Boolean Preflight : 1; /// is it a preflight packet. - Kernel::Char Data[1]; /// non preflight packet has a patch blob for a **PatchTarget** + Kernel::Boolean Preflight : 1; /// is it a preflight packet. + Kernel::Char Data[1]; /// non preflight packet has a patch blob for a **PatchTarget** } PACKED BOOTNET_INTERNET_HEADER; using BOOTNET_INTERNET_HEADER_PTR = BOOTNET_INTERNET_HEADER*; -- cgit v1.2.3 From 1df679b3bf43ca7c7730b42eee30f656045da726 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 30 Aug 2025 10:06:26 +0200 Subject: feat: acpi: `cAcpiSignatureLength` shall be UInt16 and `constexpr` Signed-off-by: Amlal El Mahrouss --- dev/kernel/src/ACPIFactoryInterface.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'dev') diff --git a/dev/kernel/src/ACPIFactoryInterface.cc b/dev/kernel/src/ACPIFactoryInterface.cc index b4ac03cc..711ea588 100644 --- a/dev/kernel/src/ACPIFactoryInterface.cc +++ b/dev/kernel/src/ACPIFactoryInterface.cc @@ -14,7 +14,7 @@ constexpr STATIC const auto kMinACPIVer = 1U; /// @brief Finds a descriptor table inside ACPI XSDT. ErrorOr ACPIFactoryInterface::Find(const Char* signature) { - if (this->fRsdp) return ErrorOr{kErrorInvalidData}; + if (this->fRsdp) return ErrorOr{-kErrorInvalidData}; if (!signature) return ErrorOr{-kErrorInvalidData}; if (*signature == 0) return ErrorOr{-kErrorInvalidData}; @@ -42,7 +42,7 @@ ErrorOr ACPIFactoryInterface::Find(const Char* signature) { (Void)(kout << "ACPI: Signature: " << xsdt->Signature << kendl); (Void)(kout << "ACPI: Address of XSDT: " << hex_number((UIntPtr) xsdt) << kendl); - const short cAcpiSignatureLength = 4; + static constexpr const UInt16 cAcpiSignatureLength = 4U; for (Size index = 0; index < this->fEntries; ++index) { SDT* sdt = reinterpret_cast(xsdt->AddressArr[index]); @@ -50,7 +50,7 @@ ErrorOr ACPIFactoryInterface::Find(const Char* signature) { (Void)(kout << "ACPI: Checksum: " << number(sdt->Checksum) << kendl); (Void)(kout << "ACPI: Revision: " << number(sdt->Revision) << kendl); - for (short signature_index = 0; signature_index < cAcpiSignatureLength; ++signature_index) { + for (UInt16 signature_index = 0; signature_index < cAcpiSignatureLength; ++signature_index) { if (sdt->Signature[signature_index] != signature[signature_index]) break; if (signature_index == (cAcpiSignatureLength - 1)) { -- cgit v1.2.3 From eeebc87d49be612183451811a043f080773c5547 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 30 Aug 2025 13:11:52 +0200 Subject: feat: BitMapMgr: move cursor to `ArchKit/ArchKit.h` to be zeroed out by HAL. Signed-off-by: Amlal El Mahrouss --- dev/kernel/ArchKit/ArchKit.h | 6 ++++-- dev/kernel/HALKit/AMD64/HalKernelMain.cc | 3 ++- dev/kernel/src/BitMapMgr.cc | 2 -- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'dev') diff --git a/dev/kernel/ArchKit/ArchKit.h b/dev/kernel/ArchKit/ArchKit.h index 37793370..8e225bf2 100644 --- a/dev/kernel/ArchKit/ArchKit.h +++ b/dev/kernel/ArchKit/ArchKit.h @@ -93,6 +93,8 @@ inline Kernel::Array kKernCall #ifdef __NE_VIRTUAL_MEMORY_SUPPORT__ -inline Kernel::VoidPtr kKernelVM = nullptr; +inline Kernel::VoidPtr kKernelVM = nullptr; -#endif // __NE_VIRTUAL_MEMORY_SUPPORT__ \ No newline at end of file +#endif // __NE_VIRTUAL_MEMORY_SUPPORT__ + +inline Kernel::SizeT kBitMapCursor = 0UL; diff --git a/dev/kernel/HALKit/AMD64/HalKernelMain.cc b/dev/kernel/HALKit/AMD64/HalKernelMain.cc index 3c6e7d36..6c2b80c7 100644 --- a/dev/kernel/HALKit/AMD64/HalKernelMain.cc +++ b/dev/kernel/HALKit/AMD64/HalKernelMain.cc @@ -41,7 +41,8 @@ EXTERN_C Int32 hal_init_platform(Kernel::HEL::BootInfoHeader* handover_hdr) { Boot::ExitBootServices(handover_hdr->f_HardwareTables.f_ImageKey, handover_hdr->f_HardwareTables.f_ImageHandle); - kKernelVM = kHandoverHeader->f_PageStart; + kBitMapCursor = 0UL; + kKernelVM = kHandoverHeader->f_PageStart; if (!kKernelVM) { MUST_PASS(kKernelVM); diff --git a/dev/kernel/src/BitMapMgr.cc b/dev/kernel/src/BitMapMgr.cc index 22737dbe..a7ca12ce 100644 --- a/dev/kernel/src/BitMapMgr.cc +++ b/dev/kernel/src/BitMapMgr.cc @@ -24,8 +24,6 @@ namespace Kernel { namespace HAL { namespace Detail { - STATIC SizeT kBitMapCursor = 0UL; - /***********************************************************************************/ /// \brief Proxy Interface to manage a bitmap allocator. /***********************************************************************************/ -- cgit v1.2.3 From d9c1f9ec143f02e66c0178557b76124b3e45a32d Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 30 Aug 2025 21:05:13 +0200 Subject: feat: debugsrv: upstream protocol implementation from NeCTI. Signed-off-by: Amlal El Mahrouss --- dev/kernel/ArchKit/ArchKit.h | 4 ++-- dev/kernel/KernelKit/DebugOutput.h | 16 ++++------------ 2 files changed, 6 insertions(+), 14 deletions(-) (limited to 'dev') diff --git a/dev/kernel/ArchKit/ArchKit.h b/dev/kernel/ArchKit/ArchKit.h index 8e225bf2..bc3447fc 100644 --- a/dev/kernel/ArchKit/ArchKit.h +++ b/dev/kernel/ArchKit/ArchKit.h @@ -93,8 +93,8 @@ inline Kernel::Array kKernCall #ifdef __NE_VIRTUAL_MEMORY_SUPPORT__ -inline Kernel::VoidPtr kKernelVM = nullptr; +inline Kernel::VoidPtr kKernelVM = nullptr; #endif // __NE_VIRTUAL_MEMORY_SUPPORT__ -inline Kernel::SizeT kBitMapCursor = 0UL; +inline Kernel::SizeT kBitMapCursor = 0UL; diff --git a/dev/kernel/KernelKit/DebugOutput.h b/dev/kernel/KernelKit/DebugOutput.h index 992d1ca7..d2839341 100644 --- a/dev/kernel/KernelKit/DebugOutput.h +++ b/dev/kernel/KernelKit/DebugOutput.h @@ -12,18 +12,6 @@ #include #include -#define kDebugPort (51820U) - -#define kDebugMag0 'K' -#define kDebugMag1 'D' -#define kDebugMag2 'B' -#define kDebugMag3 'G' - -#define kDebugSourceFile 23 -#define kDebugLine 33 -#define kDebugTeam 43 -#define kDebugEOP 49 - namespace Kernel { class TerminalDevice; class DTraceDevice; @@ -180,6 +168,10 @@ inline TerminalDevice get_console_in(Char* buf) { return self; } +inline constexpr auto kDebugPort = 51820; +inline constexpr auto kDebugMagic = "VMK1.0.0;"; +inline constexpr auto kDebugVersion = 0x0100; + inline constexpr SizeT kDebugCmdLen = 256U; typedef Char rt_debug_cmd[kDebugCmdLen]; -- cgit v1.2.3 From 11034c004ee7b232e53d69e9f1ae9000f008285f Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 31 Aug 2025 09:47:51 +0200 Subject: feat: kernel: Revamped `SignalKit` framework. DDK revamp. ci: testing improvements. Signed-off-by: Amlal El Mahrouss --- .github/workflows/kernel-ahci-dev.yml | 3 +- .github/workflows/kernel-ahci.yml | 2 +- dev/kernel/ArchKit/ArchKit.h | 2 + dev/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc | 16 ++++---- dev/kernel/HALKit/ARM64/HalCoreInterruptHandler.cc | 2 +- dev/kernel/HALKit/ARM64/HalKernelMain.cc | 4 +- dev/kernel/SignalKit/SignalGen.h | 43 ++++++++++++++++++++++ dev/kernel/SignalKit/Signals.h | 24 ------------ dev/kernel/src/UserProcessScheduler.cc | 4 +- dev/libDDK/ddk.json | 23 ------------ dev/libDDK/libDDK.json | 23 ++++++++++++ kernel_ci_x64.sh | 9 +++++ 12 files changed, 94 insertions(+), 61 deletions(-) create mode 100644 dev/kernel/SignalKit/SignalGen.h delete mode 100644 dev/kernel/SignalKit/Signals.h delete mode 100644 dev/libDDK/ddk.json create mode 100644 dev/libDDK/libDDK.json create mode 100755 kernel_ci_x64.sh (limited to 'dev') diff --git a/.github/workflows/kernel-ahci-dev.yml b/.github/workflows/kernel-ahci-dev.yml index a1a47fa3..ed6252c9 100644 --- a/.github/workflows/kernel-ahci-dev.yml +++ b/.github/workflows/kernel-ahci-dev.yml @@ -14,5 +14,4 @@ jobs: steps: - uses: actions/checkout@v4 - name: Install Packages - run: sudo apt update && sudo apt install mingw-w64 qemu-utils nasm - + run: sudo apt update && sudo apt install mingw-w64 qemu-utils nasm && ./kernel_ci_x64.sh diff --git a/.github/workflows/kernel-ahci.yml b/.github/workflows/kernel-ahci.yml index 17a68a30..17870517 100644 --- a/.github/workflows/kernel-ahci.yml +++ b/.github/workflows/kernel-ahci.yml @@ -14,5 +14,5 @@ jobs: steps: - uses: actions/checkout@v4 - name: Install Packages - run: sudo apt update && sudo apt install mingw-w64 qemu-utils nasm + run: sudo apt update && sudo apt install mingw-w64 qemu-utils nasm && ./kernel_ci_x64.sh diff --git a/dev/kernel/ArchKit/ArchKit.h b/dev/kernel/ArchKit/ArchKit.h index bc3447fc..2042bded 100644 --- a/dev/kernel/ArchKit/ArchKit.h +++ b/dev/kernel/ArchKit/ArchKit.h @@ -69,6 +69,7 @@ namespace HAL { typedef Kernel::Void (*rt_syscall_proc)(Kernel::VoidPtr); +/// @brief System Call Dispatch. struct HAL_DISPATCH_ENTRY final { Kernel::UInt64 fHash; Kernel::Bool fHooked; @@ -79,6 +80,7 @@ struct HAL_DISPATCH_ENTRY final { typedef Kernel::Void (*rt_kerncall_proc)(Kernel::SizeT, Kernel::VoidPtr, Kernel::SizeT); +/// @brief Kernel Call Dispatch. struct HAL_KERNEL_DISPATCH_ENTRY final { Kernel::UInt64 fHash; Kernel::Bool fHooked; diff --git a/dev/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc b/dev/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc index b837497e..7408639c 100644 --- a/dev/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc +++ b/dev/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc @@ -8,7 +8,7 @@ #include #include #include -#include +#include EXTERN_C Kernel::Void idt_handle_breakpoint(Kernel::UIntPtr rip); @@ -80,8 +80,9 @@ EXTERN_C void idt_handle_math(Kernel::UIntPtr rsp) { hal_idt_send_eoi(8); process.Leak().Signal.SignalArg = rsp; - process.Leak().Signal.SignalID = SIGKILL; - process.Leak().Signal.Status = process.Leak().Status; + process.Leak().Signal.SignalID = sig_generate_unique(); + ; + process.Leak().Signal.Status = process.Leak().Status; } /// @brief Handle any generic fault. @@ -95,8 +96,9 @@ EXTERN_C void idt_handle_generic(Kernel::UIntPtr rsp) { Kernel::kout << "Kernel: Generic Process Fault.\r"; process.Leak().Signal.SignalArg = rsp; - process.Leak().Signal.SignalID = SIGKILL; - process.Leak().Signal.Status = process.Leak().Status; + process.Leak().Signal.SignalID = sig_generate_unique(); + ; + process.Leak().Signal.Status = process.Leak().Status; Kernel::kout << "Kernel: SIGKILL status.\r"; } @@ -107,7 +109,7 @@ EXTERN_C Kernel::Void idt_handle_breakpoint(Kernel::UIntPtr rip) { hal_idt_send_eoi(3); process.Leak().Signal.SignalArg = rip; - process.Leak().Signal.SignalID = SIGTRAP; + process.Leak().Signal.SignalID = sig_generate_unique(); process.Leak().Signal.Status = process.Leak().Status; @@ -123,7 +125,7 @@ EXTERN_C void idt_handle_ud(Kernel::UIntPtr rsp) { hal_idt_send_eoi(6); process.Leak().Signal.SignalArg = rsp; - process.Leak().Signal.SignalID = SIGKILL; + process.Leak().Signal.SignalID = sig_generate_unique(); process.Leak().Signal.Status = process.Leak().Status; } diff --git a/dev/kernel/HALKit/ARM64/HalCoreInterruptHandler.cc b/dev/kernel/HALKit/ARM64/HalCoreInterruptHandler.cc index 0c26f4cb..dd875c63 100644 --- a/dev/kernel/HALKit/ARM64/HalCoreInterruptHandler.cc +++ b/dev/kernel/HALKit/ARM64/HalCoreInterruptHandler.cc @@ -8,7 +8,7 @@ #include #include #include -#include +#include EXTERN_C Kernel::Void int_handle_breakpoint(Kernel::UIntPtr rip); EXTERN_C BOOL mp_handle_gic_interrupt_el0(Void); diff --git a/dev/kernel/HALKit/ARM64/HalKernelMain.cc b/dev/kernel/HALKit/ARM64/HalKernelMain.cc index 20bd3d8a..d7663f4e 100644 --- a/dev/kernel/HALKit/ARM64/HalKernelMain.cc +++ b/dev/kernel/HALKit/ARM64/HalKernelMain.cc @@ -37,6 +37,8 @@ EXTERN_C void hal_init_platform(Kernel::HEL::BootInfoHeader* handover_hdr) { FB::fb_clear_video(); + kBitMapCursor = 0UL; + #ifdef __NE_ARM64_EFI__ fw_init_efi((EfiSystemTable*) handover_hdr->f_FirmwareCustomTables[1]); @@ -74,4 +76,4 @@ EXTERN_C void hal_init_platform(Kernel::HEL::BootInfoHeader* handover_hdr) { while (YES) ; } -#endif \ No newline at end of file +#endif diff --git a/dev/kernel/SignalKit/SignalGen.h b/dev/kernel/SignalKit/SignalGen.h new file mode 100644 index 00000000..e1684acb --- /dev/null +++ b/dev/kernel/SignalKit/SignalGen.h @@ -0,0 +1,43 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + +#pragma once + +#include + +#define SIGKILL 1 +#define SIGPAUS 2 +#define SIGEXEC 3 +#define SIGTRAP 4 +#define SIGABRT 5 +#define SIGCONT 6 +#define SIGSEG 7 + +#define SIGBREK 660 +#define SIGATCH 661 +#define SIGDTCH 662 + +/// @author Amlal El Mahrouss +/// @brief Signal Generation API. + +namespace Kernel { +typedef UInt32 rt_signal_kind; + +/// @brief Standard signal seed for general purpose usage. +inline static constexpr auto kBasicSignalSeed = 0x0895034f; + +/// @brief Generate signal from **Sig** +template +inline rt_signal_kind sig_generate_unique() { + static_assert(Sig > 0, "Signal is zero (invalid)"); + return Sig ^ Seed; +} + +/// @brief Validate signal from **sig** +constexpr BOOL sig_validate_unique(rt_signal_kind sig) { + return sig > 0; +} +} // namespace Kernel diff --git a/dev/kernel/SignalKit/Signals.h b/dev/kernel/SignalKit/Signals.h deleted file mode 100644 index 142ed3ab..00000000 --- a/dev/kernel/SignalKit/Signals.h +++ /dev/null @@ -1,24 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. - -------------------------------------------- */ - -#pragma once - -#include - -#define SIGKILL 0 -#define SIGPAUS 1 -#define SIGEXEC 2 -#define SIGTRAP 3 -#define SIGABRT 4 -#define SIGCONT 5 - -#define SIGBREK 666 -#define SIGATCH 661 -#define SIGDTCH 662 - -namespace Kernel { -typedef UInt32 SignalKind; -} \ No newline at end of file diff --git a/dev/kernel/src/UserProcessScheduler.cc b/dev/kernel/src/UserProcessScheduler.cc index 8a3152f0..15da4431 100644 --- a/dev/kernel/src/UserProcessScheduler.cc +++ b/dev/kernel/src/UserProcessScheduler.cc @@ -21,7 +21,7 @@ #include #include #include -#include +#include ///! BUGS: 0 @@ -593,7 +593,7 @@ Bool UserProcessHelper::CanBeScheduled(const USER_PROCESS& process) { // real time processes shouldn't wait that much. if (process.Affinity == AffinityKind::kRealTime) return Yes; - if (process.Signal.SignalID == SIGTRAP) { + if (process.Signal.SignalID == sig_generate_unique()) { return No; } diff --git a/dev/libDDK/ddk.json b/dev/libDDK/ddk.json deleted file mode 100644 index ffc05f5f..00000000 --- a/dev/libDDK/ddk.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compiler_path": "x86_64-w64-mingw32-gcc", - "compiler_std": "c++20", - "headers_path": ["../", "./"], - "sources_path": ["src/*.c", "src/*.cc", "src/*.S"], - "output_name": "ddk.sys", - "compiler_flags": [ - "-ffreestanding", - "-shared", - "-std=c17", - "-fno-rtti", - "-fno-exceptions", - "-Wl,--subsystem=17" - ], - "cpp_macros": [ - "__NEOSKRNL__", - "__DDK_AMD64__", - "__DDK__", - "kDDKVersionHighest=0x0100", - "kDDKVersionLowest=0x0100", - "kDDKVersion=0x0100" - ] -} diff --git a/dev/libDDK/libDDK.json b/dev/libDDK/libDDK.json new file mode 100644 index 00000000..113dd585 --- /dev/null +++ b/dev/libDDK/libDDK.json @@ -0,0 +1,23 @@ +{ + "compiler_path": "x86_64-w64-mingw32-gcc", + "compiler_std": "c++20", + "headers_path": ["../", "./"], + "sources_path": ["src/*.c", "src/*.cc", "src/*.S"], + "output_name": "libDDK.dll", + "compiler_flags": [ + "-ffreestanding", + "-shared", + "-std=c17", + "-fno-rtti", + "-fno-exceptions", + "-Wl,--subsystem=17" + ], + "cpp_macros": [ + "__NEOSKRNL__", + "__DDK_AMD64__", + "__DDK__", + "kDDKVersionHighest=0x0100", + "kDDKVersionLowest=0x0100", + "kDDKVersion=0x0100" + ] +} diff --git a/kernel_ci_x64.sh b/kernel_ci_x64.sh new file mode 100755 index 00000000..e052b4f2 --- /dev/null +++ b/kernel_ci_x64.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +export AHCI_SUPPORT=1 +export ATA_PIO_SUPPORT= +export ATA_DMA_SUPPORT= +export DEBUG_SUPPORT=1 + +cd dev/kernel +make -f amd64-desktop.make all -- cgit v1.2.3 From 7afa74b53110c0258c7fa9ae5aa8e7dde7534b4d Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 31 Aug 2025 16:49:59 +0200 Subject: feat! BenchKit breaking changes. why: - Made it expandable to other traits and platforms. - You can provide a `Traits` now to the `HWChrono`. Signed-off-by: Amlal El Mahrouss --- debug_ahci_arm64.sh | 16 ++++++++ dev/kernel/HALKit/AMD64/HalKernelMain.cc | 2 +- dev/misc/BenchKit/Chrono.h | 40 ------------------- dev/misc/BenchKit/Chronometer.h | 40 +++++++++++++++++++ dev/misc/BenchKit/HWChronometer.h | 66 ++++++++++++++++++++++++++++++++ dev/misc/BenchKit/X64Chrono.h | 56 --------------------------- 6 files changed, 123 insertions(+), 97 deletions(-) create mode 100755 debug_ahci_arm64.sh delete mode 100644 dev/misc/BenchKit/Chrono.h create mode 100644 dev/misc/BenchKit/Chronometer.h create mode 100644 dev/misc/BenchKit/HWChronometer.h delete mode 100644 dev/misc/BenchKit/X64Chrono.h (limited to 'dev') diff --git a/debug_ahci_arm64.sh b/debug_ahci_arm64.sh new file mode 100755 index 00000000..af20558a --- /dev/null +++ b/debug_ahci_arm64.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +export AHCI_SUPPORT=1 +export ATA_PIO_SUPPORT= +export ATA_DMA_SUPPORT= +export DEBUG_SUPPORT=1 + +cd dev/kernel +make -f arm64-desktop.make all +cd ../boot +make -f arm64-desktop.make all +make -f arm64-desktop.make disk +cd ../../ +./tools/mk_img.py ./dev/boot/src/nekernel-esp.img ./dev/boot/src/root +cd dev/boot +make -f arm64-desktop.make run-efi-arm64 diff --git a/dev/kernel/HALKit/AMD64/HalKernelMain.cc b/dev/kernel/HALKit/AMD64/HalKernelMain.cc index 6c2b80c7..f121fbb4 100644 --- a/dev/kernel/HALKit/AMD64/HalKernelMain.cc +++ b/dev/kernel/HALKit/AMD64/HalKernelMain.cc @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include diff --git a/dev/misc/BenchKit/Chrono.h b/dev/misc/BenchKit/Chrono.h deleted file mode 100644 index 3a82a94e..00000000 --- a/dev/misc/BenchKit/Chrono.h +++ /dev/null @@ -1,40 +0,0 @@ -/* ------------------------------------------- - -Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. - -------------------------------------------- */ - -#ifndef BENCHKIT_CHRONO_H -#define BENCHKIT_CHRONO_H - -#include -#include - -/// @author Amlal El Mahrouss -/// @brief BenchKit Chrono contract. - -#define BENCHKIT_INTERFACE : public ::Kernel::ChronoInterface - -namespace Kernel { -class ChronoInterface; - -/// @brief a Chronometer interface used for benchmarking. -class ChronoInterface { - public: - ChronoInterface() = default; - virtual ~ChronoInterface() = default; - - NE_COPY_DEFAULT(ChronoInterface) - - virtual Void Start() = 0; - virtual Void Stop() = 0; - virtual Void Reset() = 0; - virtual UInt64 GetElapsedTime() const = 0; -}; -} // namespace Kernel - -namespace BenchKit { -using namespace Kernel; -} - -#endif // BENCHKIT_CHRONO_H diff --git a/dev/misc/BenchKit/Chronometer.h b/dev/misc/BenchKit/Chronometer.h new file mode 100644 index 00000000..3a82a94e --- /dev/null +++ b/dev/misc/BenchKit/Chronometer.h @@ -0,0 +1,40 @@ +/* ------------------------------------------- + +Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + +#ifndef BENCHKIT_CHRONO_H +#define BENCHKIT_CHRONO_H + +#include +#include + +/// @author Amlal El Mahrouss +/// @brief BenchKit Chrono contract. + +#define BENCHKIT_INTERFACE : public ::Kernel::ChronoInterface + +namespace Kernel { +class ChronoInterface; + +/// @brief a Chronometer interface used for benchmarking. +class ChronoInterface { + public: + ChronoInterface() = default; + virtual ~ChronoInterface() = default; + + NE_COPY_DEFAULT(ChronoInterface) + + virtual Void Start() = 0; + virtual Void Stop() = 0; + virtual Void Reset() = 0; + virtual UInt64 GetElapsedTime() const = 0; +}; +} // namespace Kernel + +namespace BenchKit { +using namespace Kernel; +} + +#endif // BENCHKIT_CHRONO_H diff --git a/dev/misc/BenchKit/HWChronometer.h b/dev/misc/BenchKit/HWChronometer.h new file mode 100644 index 00000000..2b8637d8 --- /dev/null +++ b/dev/misc/BenchKit/HWChronometer.h @@ -0,0 +1,66 @@ +/* ------------------------------------------- + +Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + +#pragma once + +#include + +namespace Kernel { +struct HWChronoTraits; + +template +class HWChrono; + +/// @brief BenchKit chrono logic for x64. +struct HWChronoTraits final { + private: + STATIC UInt64 TickImpl_(void) { +#ifdef __NE_AMD64__ + UInt64 a = 0, d = 0; + + asm volatile("rdtsc" : "=a"(a), "=d"(d)); + + return (d << 32) | a; +#elif defined(__NE_ARM64__) + UInt64 result; + + asm volatile("mrs %0, cntvct_el1" : "=r"(result)); + + return result; +#else +#error !!! no backend defined !!! +#endif + } + + friend HWChrono; +}; + +/// @brief hardware chronometer implementation using a trait to extract the data. +template +class HWChrono BENCHKIT_INTERFACE { + public: + HWChrono() = default; + ~HWChrono() override = default; + + NE_COPY_DEFAULT(HWChrono) + + public: + Void Start() override { fStart = ChronoTraits::TickImpl_(); } + + Void Stop() override { fStop = ChronoTraits::TickImpl_(); } + + Void Reset() override { + fStart = 0; + fStop = 0; + } + + UInt64 GetElapsedTime() const override { return fStop - fStart; } + + private: + UInt64 fStart{}; + UInt64 fStop{}; +}; +} // namespace Kernel diff --git a/dev/misc/BenchKit/X64Chrono.h b/dev/misc/BenchKit/X64Chrono.h deleted file mode 100644 index 728e7d60..00000000 --- a/dev/misc/BenchKit/X64Chrono.h +++ /dev/null @@ -1,56 +0,0 @@ -/* ------------------------------------------- - -Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. - -------------------------------------------- */ - -#pragma once - -#include - -#if defined(__NE_AMD64__) - -namespace Kernel { -class X64Chrono; -struct X64ChronoTraits; - -/// @brief BenchKit chrono logic for x64. -struct X64ChronoTraits { - private: - STATIC UInt64 TickImpl_(void) { - UInt64 a = 0, d = 0; - - asm volatile("rdtsc" : "=a"(a), "=d"(d)); - return (d << 32) | a; - } - - friend X64Chrono; -}; - -/// @brief X86_64 hardware chrono implementation using the `rdtsc` instruction. -class X64Chrono BENCHKIT_INTERFACE { - public: - X64Chrono() = default; - ~X64Chrono() override = default; - - NE_COPY_DEFAULT(X64Chrono) - - public: - Void Start() override { fStart = X64ChronoTraits::TickImpl_(); } - - Void Stop() override { fStop = X64ChronoTraits::TickImpl_(); } - - Void Reset() override { - fStart = 0; - fStop = 0; - } - - UInt64 GetElapsedTime() const override { return fStop - fStart; } - - private: - UInt64 fStart{}; - UInt64 fStop{}; -}; -} // namespace Kernel - -#endif // defined(__NE_AMD64__) \ No newline at end of file -- cgit v1.2.3 From 257b0a377e0e0f226623e7aa807780051a9cc9e6 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 1 Sep 2025 06:12:55 +0200 Subject: feat: BenchKit: `HWChronometer` shall be `virtual`. Signed-off-by: Amlal El Mahrouss --- dev/misc/BenchKit/HWChronometer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dev') diff --git a/dev/misc/BenchKit/HWChronometer.h b/dev/misc/BenchKit/HWChronometer.h index 2b8637d8..80e1d84a 100644 --- a/dev/misc/BenchKit/HWChronometer.h +++ b/dev/misc/BenchKit/HWChronometer.h @@ -43,7 +43,7 @@ template class HWChrono BENCHKIT_INTERFACE { public: HWChrono() = default; - ~HWChrono() override = default; + virtual ~HWChrono() override = default; NE_COPY_DEFAULT(HWChrono) -- cgit v1.2.3 From 12fe96873ad4a2f1d3c7c3d9f84bc8eb367fb2f0 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 1 Sep 2025 08:43:46 +0200 Subject: feat: Signal System improvements. Signed-off-by: Amlal El Mahrouss --- dev/boot/BootKit/BitManip.h | 2 +- dev/kernel/SignalKit/SignalGen.h | 39 ++++++++++++++++++++++++--------------- dev/misc/BenchKit/HWChronometer.h | 2 +- 3 files changed, 26 insertions(+), 17 deletions(-) (limited to 'dev') diff --git a/dev/boot/BootKit/BitManip.h b/dev/boot/BootKit/BitManip.h index b1c72bfb..196953b3 100644 --- a/dev/boot/BootKit/BitManip.h +++ b/dev/boot/BootKit/BitManip.h @@ -8,7 +8,7 @@ #define __BITMANIP_H__ /// File: BitManip.h -/// Purpose: Bit manipulation helpers, based on coreboot-dev. +/// Purpose: Bit manipulation helpers, based on neboot-dev. #define bk_set_bit(X, O) X = (1 << O) | X #define bk_clear_bit(X, O) X = ~(1 << O) & X diff --git a/dev/kernel/SignalKit/SignalGen.h b/dev/kernel/SignalKit/SignalGen.h index e1684acb..ad127830 100644 --- a/dev/kernel/SignalKit/SignalGen.h +++ b/dev/kernel/SignalKit/SignalGen.h @@ -8,36 +8,45 @@ #include -#define SIGKILL 1 -#define SIGPAUS 2 -#define SIGEXEC 3 -#define SIGTRAP 4 -#define SIGABRT 5 -#define SIGCONT 6 -#define SIGSEG 7 - -#define SIGBREK 660 -#define SIGATCH 661 -#define SIGDTCH 662 +#define SIGKILL 1 /* kill */ +#define SIGPAUS 2 /* pause */ +#define SIGEXEC 3 /* execute */ +#define SIGTRAP 4 /* trap */ +#define SIGABRT 5 /* abort */ +#define SIGCONT 6 /* continue */ +#define SIGSEG 7 /* process fault */ +#define SIGBREK 8 +#define SIGATCH 9 +#define SIGDTCH 10 /// @author Amlal El Mahrouss /// @brief Signal Generation API. namespace Kernel { -typedef UInt32 rt_signal_kind; +typedef SizeT rt_signal_kind; /// @brief Standard signal seed for general purpose usage. -inline static constexpr auto kBasicSignalSeed = 0x0895034f; +inline static constexpr auto kUserSignalSeed = 0x0895034fUL; + +/// @brief Special signal seed for kernel usage. +inline static constexpr auto kKernelSignalSeed = 0x0895034f9fUL; /// @brief Generate signal from **Sig** -template +template inline rt_signal_kind sig_generate_unique() { static_assert(Sig > 0, "Signal is zero (invalid)"); return Sig ^ Seed; } +/// @brief Checks if the signal matches the seed (user_seed or kernel_seed) +template +inline BOOL sig_matches_seed(const rt_signal_kind& sig) { + static_assert(sig > 0, "Signal is zero (invalid)"); + return (sig & Seed) > 0; +} + /// @brief Validate signal from **sig** -constexpr BOOL sig_validate_unique(rt_signal_kind sig) { +inline BOOL sig_validate_unique(rt_signal_kind sig) { return sig > 0; } } // namespace Kernel diff --git a/dev/misc/BenchKit/HWChronometer.h b/dev/misc/BenchKit/HWChronometer.h index 80e1d84a..e232db7e 100644 --- a/dev/misc/BenchKit/HWChronometer.h +++ b/dev/misc/BenchKit/HWChronometer.h @@ -42,7 +42,7 @@ struct HWChronoTraits final { template class HWChrono BENCHKIT_INTERFACE { public: - HWChrono() = default; + HWChrono() = default; virtual ~HWChrono() override = default; NE_COPY_DEFAULT(HWChrono) -- cgit v1.2.3 From 0eb89d981f802f9bc91c0d3000bb93e633234744 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 1 Sep 2025 08:46:37 +0200 Subject: SignalKit: Signals shall be `user` level by default. Signed-off-by: Amlal El Mahrouss --- dev/kernel/SignalKit/SignalGen.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'dev') diff --git a/dev/kernel/SignalKit/SignalGen.h b/dev/kernel/SignalKit/SignalGen.h index ad127830..9d2c0534 100644 --- a/dev/kernel/SignalKit/SignalGen.h +++ b/dev/kernel/SignalKit/SignalGen.h @@ -32,7 +32,7 @@ inline static constexpr auto kUserSignalSeed = 0x0895034fUL; inline static constexpr auto kKernelSignalSeed = 0x0895034f9fUL; /// @brief Generate signal from **Sig** -template +template inline rt_signal_kind sig_generate_unique() { static_assert(Sig > 0, "Signal is zero (invalid)"); return Sig ^ Seed; @@ -42,7 +42,7 @@ inline rt_signal_kind sig_generate_unique() { template inline BOOL sig_matches_seed(const rt_signal_kind& sig) { static_assert(sig > 0, "Signal is zero (invalid)"); - return (sig & Seed) > 0; + return (sig & 0xFF000000) == (Seed & 0xFF000000); } /// @brief Validate signal from **sig** -- cgit v1.2.3 From 1661e5d91d8e7984f916e3ccf78311b4b8c00940 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 1 Sep 2025 08:49:46 +0200 Subject: fix: fix build on amd64. Signed-off-by: Amlal El Mahrouss --- dev/kernel/SignalKit/SignalGen.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'dev') diff --git a/dev/kernel/SignalKit/SignalGen.h b/dev/kernel/SignalKit/SignalGen.h index 9d2c0534..4be9452a 100644 --- a/dev/kernel/SignalKit/SignalGen.h +++ b/dev/kernel/SignalKit/SignalGen.h @@ -39,9 +39,8 @@ inline rt_signal_kind sig_generate_unique() { } /// @brief Checks if the signal matches the seed (user_seed or kernel_seed) -template -inline BOOL sig_matches_seed(const rt_signal_kind& sig) { - static_assert(sig > 0, "Signal is zero (invalid)"); +template +inline BOOL sig_matches_seed(rt_signal_kind sig) { return (sig & 0xFF000000) == (Seed & 0xFF000000); } -- cgit v1.2.3