diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-21 03:45:08 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-21 03:45:08 +0200 |
| commit | c85a99c2afdd4c9dfa9d8f0f212e4625b6adade7 (patch) | |
| tree | 3bb631cf7c49b74fbf6d02104059e0540f26ba4b /dev | |
| parent | bec0e457ad346783be7f84be71bb0eddc881847c (diff) | |
feat(kernel): source code improvements.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/boot/modules/SysChk/SysChk.cc | 1 | ||||
| -rw-r--r-- | dev/boot/src/BootTextWriter.cc | 16 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/HalAPStartup.s | 12 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc | 67 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/HalApplicationProcessorGNU.s | 8 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/HalApplicationProcessorStartup.asm | 75 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/Paging.h | 4 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/Processor.h | 8 | ||||
| -rwxr-xr-x | dev/kernel/HALKit/AMD64/make_ap_blob.sh | 3 | ||||
| -rw-r--r-- | dev/kernel/HALKit/ARM64/HalApplicationProcessor.cc | 97 | ||||
| -rw-r--r-- | dev/kernel/HALKit/ARM64/HalCommonAPI.s (renamed from dev/kernel/HALKit/ARM64/HalFlushTLB.S) | 0 | ||||
| -rw-r--r-- | dev/kernel/HALKit/ARM64/HalInterruptAPI.s | 3 | ||||
| -rw-r--r-- | dev/kernel/HALKit/ARM64/HalTimerARM64.cc | 1 | ||||
| -rw-r--r-- | dev/kernel/HALKit/ARM64/Paging.h | 4 | ||||
| -rw-r--r-- | dev/kernel/HALKit/ARM64/Processor.h | 28 | ||||
| -rw-r--r-- | dev/kernel/KernelKit/KernelTaskScheduler.h | 5 |
16 files changed, 139 insertions, 193 deletions
diff --git a/dev/boot/modules/SysChk/SysChk.cc b/dev/boot/modules/SysChk/SysChk.cc index 4f71ee31..1601148e 100644 --- a/dev/boot/modules/SysChk/SysChk.cc +++ b/dev/boot/modules/SysChk/SysChk.cc @@ -34,6 +34,7 @@ EXTERN_C Int32 SysChkModuleMain(Kernel::HEL::BootInfoHeader* handover) { #elif defined(__AHCI__) Boot::BDiskFormatFactory<BootDeviceSATA> partition_factory; #endif + if (partition_factory.IsPartitionValid()) return kEfiOk; return partition_factory.Format(kMachineModel); diff --git a/dev/boot/src/BootTextWriter.cc b/dev/boot/src/BootTextWriter.cc index 5e826c6d..6ffb7de6 100644 --- a/dev/boot/src/BootTextWriter.cc +++ b/dev/boot/src/BootTextWriter.cc @@ -24,6 +24,8 @@ @brief puts wrapper over EFI ConOut. */ Boot::BootTextWriter& Boot::BootTextWriter::Write(const CharacterTypeUTF16* str) { + NE_UNUSED(str); + #ifdef __DEBUG__ if (!str || *str == 0) return *this; @@ -50,6 +52,8 @@ Boot::BootTextWriter& Boot::BootTextWriter::Write(const CharacterTypeUTF16* str) /// @brief UTF-8 equivalent of Write (UTF-16). /// @param str the input string. Boot::BootTextWriter& Boot::BootTextWriter::Write(const Char* str) { + NE_UNUSED(str); + #ifdef __DEBUG__ if (!str || *str == 0) return *this; @@ -74,6 +78,8 @@ Boot::BootTextWriter& Boot::BootTextWriter::Write(const Char* str) { } Boot::BootTextWriter& Boot::BootTextWriter::Write(const UChar* str) { + NE_UNUSED(str); + #ifdef __DEBUG__ if (!str || *str == 0) return *this; @@ -101,6 +107,8 @@ Boot::BootTextWriter& Boot::BootTextWriter::Write(const UChar* str) { @brief putc wrapper over EFI ConOut. */ Boot::BootTextWriter& Boot::BootTextWriter::WriteCharacter(CharacterTypeUTF16 c) { + NE_UNUSED(c); + #ifdef __DEBUG__ EfiCharType str[2]; @@ -113,6 +121,8 @@ Boot::BootTextWriter& Boot::BootTextWriter::WriteCharacter(CharacterTypeUTF16 c) } Boot::BootTextWriter& Boot::BootTextWriter::Write(const UInt64& x) { + NE_UNUSED(x); + #ifdef __DEBUG__ this->_Write(x); this->Write("h"); @@ -122,6 +132,8 @@ Boot::BootTextWriter& Boot::BootTextWriter::Write(const UInt64& x) { } Boot::BootTextWriter& Boot::BootTextWriter::_Write(const UInt64& x) { + NE_UNUSED(x); + #ifdef __DEBUG__ UInt64 y = (x > 0 ? x : -x) / 16; UInt64 h = (x > 0 ? x : -x) % 16; @@ -136,9 +148,9 @@ Boot::BootTextWriter& Boot::BootTextWriter::_Write(const UInt64& x) { if (y == ~0UL) y = -y; - const char cNumbers[] = "0123456789ABCDEF"; + const char kNumberList[] = "0123456789ABCDEF"; - this->WriteCharacter(cNumbers[h]); + this->WriteCharacter(kNumberList[h]); #endif // ifdef __DEBUG__ return *this; diff --git a/dev/kernel/HALKit/AMD64/HalAPStartup.s b/dev/kernel/HALKit/AMD64/HalAPStartup.s new file mode 100644 index 00000000..ec17bf7b --- /dev/null +++ b/dev/kernel/HALKit/AMD64/HalAPStartup.s @@ -0,0 +1,12 @@ +.data + +.global hal_ap_blob_start +.global hal_ap_blob_length + +hal_ap_blob_start: + cli + hlt + jmp hal_ap_blob_start + +hal_ap_blob_length: + .long 4 diff --git a/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc b/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc index 46ad8fd6..e4ad1024 100644 --- a/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc +++ b/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc @@ -4,21 +4,8 @@ ------------------------------------------- */ -#include <ArchKit/ArchKit.h> -#include <HALKit/AMD64/Processor.h> -#include <KernelKit/BinaryMutex.h> -#include <KernelKit/HardwareThreadScheduler.h> -#include <KernelKit/ProcessScheduler.h> -#include <KernelKit/Timer.h> -#include <NewKit/KernelPanic.h> -#include <modules/ACPI/ACPIFactoryInterface.h> -#include <modules/CoreGfx/TextGfx.h> -#include "NewKit/Defines.h" - #define APIC_MAG "APIC" -#define AP_BLOB_SIZE 126 - #define APIC_ICR_LOW 0x300 #define APIC_ICR_HIGH 0x310 #define APIC_SIPI_VEC 0x00500 @@ -35,6 +22,16 @@ #define APIC_BASE_MSR_BSP 0x100 #define APIC_BASE_MSR_ENABLE 0x800 +#include <ArchKit/ArchKit.h> +#include <HALKit/AMD64/Processor.h> +#include <KernelKit/BinaryMutex.h> +#include <KernelKit/HardwareThreadScheduler.h> +#include <KernelKit/ProcessScheduler.h> +#include <KernelKit/Timer.h> +#include <NewKit/KernelPanic.h> +#include <modules/ACPI/ACPIFactoryInterface.h> +#include <modules/CoreGfx/TextGfx.h> + /// @note: _hal_switch_context is internal /////////////////////////////////////////////////////////////////////////////////////// @@ -44,8 +41,6 @@ /////////////////////////////////////////////////////////////////////////////////////// namespace Kernel::HAL { -EXTERN_C Void sched_jump_to_task(HAL::StackFramePtr stack_frame); - struct HAL_APIC_MADT; struct HAL_HARDWARE_THREAD; @@ -54,6 +49,8 @@ struct HAL_HARDWARE_THREAD final { ProcessID mThreadID{0}; }; +EXTERN_C Void sched_jump_to_task(HAL::StackFramePtr stack_frame); + STATIC HAL_APIC_MADT* kMADTBlock = nullptr; STATIC Bool kSMPAware = false; STATIC Int64 kSMPCount = 0; @@ -64,6 +61,8 @@ STATIC Int32 kSMPInterrupt = 0; STATIC UInt64 kAPICLocales[kMaxAPInsideSched] = {0}; STATIC VoidPtr kRawMADT = nullptr; +STATIC HAL_HARDWARE_THREAD kHWThread[kSchedProcessLimitPerTeam] = {{}}; + /// @brief Multiple APIC Descriptor Table. struct HAL_APIC_MADT final SDT_OBJECT { UInt32 Address; // Madt address @@ -97,7 +96,10 @@ Void hal_send_ipi_msg(UInt32 target, UInt32 apic_id, UInt8 vector) { } } -STATIC HAL_HARDWARE_THREAD kHWThread[kSchedProcessLimitPerTeam] = {{}}; +/***********************************************************************************/ +/// @brief Get current stack frame for a thread. +/// @param thrdid The thread ID. +/***********************************************************************************/ EXTERN_C HAL::StackFramePtr mp_get_current_context(Int64 thrdid) { const auto process_index = thrdid % kSchedProcessLimitPerTeam; @@ -105,16 +107,28 @@ EXTERN_C HAL::StackFramePtr mp_get_current_context(Int64 thrdid) { return kHWThread[process_index].mFramePtr; } +/***********************************************************************************/ +/// @brief Register current stack frame for a thread. +/// @param stack_frame The current stack frame. +/// @param thrdid The thread ID. +/***********************************************************************************/ + EXTERN_C BOOL mp_register_process(HAL::StackFramePtr stack_frame, ProcessID thrdid) { if (thrdid > kSMPCount) return NO; - if (mp_is_smp()) { - kHWThread[thrdid].mFramePtr = stack_frame; - kHWThread[thrdid].mThreadID = thrdid; + if (!mp_is_smp()) { + if (stack_frame) { + kHWThread[thrdid].mFramePtr = stack_frame; + kHWThread[thrdid].mThreadID = thrdid; + HardwareThreadScheduler::The()[thrdid].Leak()->Busy(NO); - HardwareThreadScheduler::The()[thrdid].Leak()->Busy(NO); + sched_jump_to_task(stack_frame); - sched_jump_to_task(stack_frame); + return YES; + } + } else { + kHWThread[thrdid].mFramePtr = stack_frame; + kHWThread[thrdid].mThreadID = thrdid; return YES; } @@ -131,19 +145,10 @@ Bool mp_is_smp(Void) noexcept { } /***********************************************************************************/ -/// @brief Assembly symbol to bootstrap AP. -/***********************************************************************************/ -EXTERN_C Char* hal_ap_blob_start; - -/***********************************************************************************/ -/// @brief Assembly symbol to bootstrap AP. -/***********************************************************************************/ -EXTERN_C Char* hal_ap_blob_end; - -/***********************************************************************************/ /// @brief Fetch and enable SMP scheduler. /// @param vendor_ptr SMP containing structure. /***********************************************************************************/ + Void mp_init_cores(VoidPtr vendor_ptr) noexcept { if (!vendor_ptr) return; diff --git a/dev/kernel/HALKit/AMD64/HalApplicationProcessorGNU.s b/dev/kernel/HALKit/AMD64/HalApplicationProcessorGNU.s deleted file mode 100644 index a8ad3b76..00000000 --- a/dev/kernel/HALKit/AMD64/HalApplicationProcessorGNU.s +++ /dev/null @@ -1,8 +0,0 @@ -.data - -.global hal_ap_blob_start /* Export the start symbol */ -.global hal_ap_blob_end /* Export the end symbol */ - -hal_ap_blob_start: - .incbin "HALKit/AMD64/HalApplicationProcessorStartup.bin" -hal_ap_blob_end: diff --git a/dev/kernel/HALKit/AMD64/HalApplicationProcessorStartup.asm b/dev/kernel/HALKit/AMD64/HalApplicationProcessorStartup.asm deleted file mode 100644 index 2adc8fed..00000000 --- a/dev/kernel/HALKit/AMD64/HalApplicationProcessorStartup.asm +++ /dev/null @@ -1,75 +0,0 @@ -;; /* -;; * ======================================================== -;; * -;; * NeKernel -;; * Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. -;; * -;; * 25/03/25: FIX: Fix warning regarding resb being used inside a non-bss area (using no-op instead). -;; * -;; * ======================================================== -;; */ - -[bits 16] -[org 0x7c00] - -hal_ap_start: - mov ax, 0x0 - mov ss, ax - mov esp, 0x7000 - - cli - mov eax, cr0 - or eax, 1 - mov cr0, eax - jmp .hal_ap_start_flush -.hal_ap_start_flush: - mov ax, 0x10 - mov ds, ax - mov es, ax - mov fs, ax - mov gs, ax - mov ss, ax - - mov eax, cr4 - or eax, 1 << 5 - mov cr4, eax - - mov eax, cr3 - mov cr3, eax - - mov ecx, 0xC0000080 - rdmsr - or eax, 1 - wrmsr - - mov eax, cr0 - or eax, (1 << 31) - mov cr0, eax - - jmp 0x08:hal_ap_64bit_entry -hal_ap_end: - -hal_ap_length: - dq hal_ap_end - hal_ap_start - -[bits 64] - -hal_ap_64bit_entry: - mov ax, 0x23 - mov ds, ax - mov es, ax - mov fs, ax - mov gs, ax - mov ss, ax - - mov rsp, rbx - - push 0x33 - lea rax, [hal_ap_64bit_entry_loop] - push rax - o64 pushf - - o64 iret - -hal_ap_64bit_entry_loop: - jmp $ diff --git a/dev/kernel/HALKit/AMD64/Paging.h b/dev/kernel/HALKit/AMD64/Paging.h index 061bae45..b73b8604 100644 --- a/dev/kernel/HALKit/AMD64/Paging.h +++ b/dev/kernel/HALKit/AMD64/Paging.h @@ -6,6 +6,8 @@ #pragma once +#ifdef __NE_AMD64__ + /** --------------------------------------------------- * THIS FILE CONTAINS CODE FOR X86_64 PAGING. @@ -85,3 +87,5 @@ struct PDE { ATTRIBUTE(aligned(kib_cast(4))) PTE fPTE[512]; }; } // namespace Kernel + +#endif // __NE_AMD64__
\ No newline at end of file diff --git a/dev/kernel/HALKit/AMD64/Processor.h b/dev/kernel/HALKit/AMD64/Processor.h index 8fb69c0c..c574f8d5 100644 --- a/dev/kernel/HALKit/AMD64/Processor.h +++ b/dev/kernel/HALKit/AMD64/Processor.h @@ -13,6 +13,8 @@ #pragma once +#ifdef __NE_AMD64__ + #include <FirmwareKit/Handover.h> #include <HALKit/AMD64/Paging.h> #include <NewKit/Array.h> @@ -73,7 +75,7 @@ enum { kMMFlagsNX = 1 << 4, kMMFlagsPCD = 1 << 5, kMMFlagsPwt = 1 << 6, - kMMFlagsCount = 4, + kMMFlagsCount = 6, }; struct PACKED Register64 final { @@ -283,4 +285,6 @@ EXTERN_C ATTRIBUTE(naked) Kernel::Void hal_load_gdt(Kernel::HAL::Register64 ptr) inline Kernel::VoidPtr kKernelBitMpStart = nullptr; inline Kernel::UIntPtr kKernelBitMpSize = 0UL; -inline Kernel::VoidPtr kKernelCR3 = nullptr;
\ No newline at end of file +inline Kernel::VoidPtr kKernelCR3 = nullptr; + +#endif // __NE_AMD64__ */
\ No newline at end of file diff --git a/dev/kernel/HALKit/AMD64/make_ap_blob.sh b/dev/kernel/HALKit/AMD64/make_ap_blob.sh deleted file mode 100755 index 3f079187..00000000 --- a/dev/kernel/HALKit/AMD64/make_ap_blob.sh +++ /dev/null @@ -1,3 +0,0 @@ -# !/bin/sh - -nasm -f bin HalApplicationProcessorStartup.asm -o HalApplicationProcessorStartup.bin
\ No newline at end of file diff --git a/dev/kernel/HALKit/ARM64/HalApplicationProcessor.cc b/dev/kernel/HALKit/ARM64/HalApplicationProcessor.cc index d37a3e54..5be41e4e 100644 --- a/dev/kernel/HALKit/ARM64/HalApplicationProcessor.cc +++ b/dev/kernel/HALKit/ARM64/HalApplicationProcessor.cc @@ -4,6 +4,23 @@ ------------------------------------------- */
+#define GICD_BASE 0x08000000
+#define GICC_BASE 0x08010000
+
+#define GICD_CTLR 0x000
+#define GICD_ISENABLER 0x100
+#define GICD_ICENABLER 0x180
+#define GICD_ISPENDR 0x200
+#define GICD_ICPENDR 0x280
+#define GICD_IPRIORITYR 0x400
+#define GICD_ITARGETSR 0x800
+#define GICD_ICFGR 0xC00
+
+#define GICC_CTLR 0x000
+#define GICC_PMR 0x004
+#define GICC_IAR 0x00C
+#define GICC_EOIR 0x010
+
#include <HALKit/ARM64/ApplicationProcessor.h>
#include <HALKit/ARM64/Processor.h>
#include <KernelKit/DebugOutput.h>
@@ -11,28 +28,11 @@ #include <KernelKit/ProcessScheduler.h>
#include <KernelKit/Timer.h>
-#define GICD_BASE 0x08000000 // Distributor base address
-#define GICC_BASE 0x08010000 // CPU interface base address
-
-#define GICD_CTLR 0x000 // Distributor Control Register
-#define GICD_ISENABLER 0x100 // Interrupt Set-Enable Registers
-#define GICD_ICENABLER 0x180 // Interrupt Clear-Enable Registers
-#define GICD_ISPENDR 0x200 // Interrupt Set-Pending Registers
-#define GICD_ICPENDR 0x280 // Interrupt Clear-Pending Registers
-#define GICD_IPRIORITYR 0x400 // Interrupt Priority Registers
-#define GICD_ITARGETSR 0x800 // Interrupt Processor Targets Registers
-#define GICD_ICFGR 0xC00 // Interrupt Configuration Registers
-
-#define GICC_CTLR 0x000 // CPU Interface Control Register
-#define GICC_PMR 0x004 // Interrupt Priority Mask Register
-#define GICC_IAR 0x00C // Interrupt Acknowledge Register
-#define GICC_EOIR 0x010 // End of Interrupt Register
-
// ================================================================= //
namespace Kernel {
struct HAL_HARDWARE_THREAD final {
- HAL::StackFramePtr mFrame;
+ HAL::StackFramePtr mFramePtr;
ProcessID mThreadID{0};
};
@@ -41,49 +41,37 @@ STATIC HAL_HARDWARE_THREAD kHWThread[kMaxAPInsideSched] = {{nullptr}}; namespace Detail {
STATIC BOOL kGICEnabled = NO;
- STATIC void mp_hang_fn(void) {
- while (YES)
- ;
-
- dbg_break_point();
- }
-
- Void mp_setup_gic_el0(Void) {
- // enable distributor.
+ /***********************************************************************************/
+ /// @brief Enables the GIC with EL0 configuration.
+ /// @internal
+ /***********************************************************************************/
+ STATIC Void mp_setup_gic_el0(Void) {
ke_dma_write<UInt32>(GICD_BASE, GICD_CTLR, YES);
UInt32 gicc_ctlr = ke_dma_read<UInt32>(GICC_BASE, GICC_CTLR);
- const auto kEnableSignalInt = YES;
+ const UInt8 kEnableSignalInt = 0x1;
- gicc_ctlr |= kEnableSignalInt; // Enable signaling of interrupts
- gicc_ctlr |= (kEnableSignalInt << 1); // Allow Group 1 interrupts in EL0
+ gicc_ctlr |= kEnableSignalInt;
+ gicc_ctlr |= (kEnableSignalInt << 0x1);
ke_dma_write<UInt32>(GICC_BASE, GICC_CTLR, gicc_ctlr);
- // Set priority mask (accept all priorities)
ke_dma_write<UInt32>(GICC_BASE, GICC_PMR, 0xFF);
UInt32 icfgr = ke_dma_read<UInt32>(GICD_BASE, GICD_ICFGR + (0x20 / 0x10) * 4);
- icfgr |= (0x2 << ((32 % 16) * 2)); // Edge-triggered
- ke_dma_write<UInt32>(GICD_BASE, GICD_ICFGR + (0x20 / 0x10) * 4, icfgr);
+ icfgr |= (0x2 << ((32 % 16) * 2));
- // Target interrupt 32 to CPU 1
+ ke_dma_write<UInt32>(GICD_BASE, GICD_ICFGR + (0x20 / 0x10) * 4, icfgr);
ke_dma_write<UInt32>(GICD_BASE, GICD_ITARGETSR + (0x20 / 0x04) * 4, 0x2 << ((32 % 4) * 8));
-
- // Set interrupt 32 priority to lowest (0xFF)
ke_dma_write<UInt32>(GICD_BASE, GICD_IPRIORITYR + (0x20 / 0x04) * 4, 0xFF << ((32 % 4) * 8));
-
- // Enable interrupt 32 for AP.
ke_dma_write<UInt32>(GICD_BASE, GICD_ISENABLER + 4, 0x01);
}
- BOOL mp_handle_gic_interrupt_el0(Void) {
- // Read the interrupt ID
+ EXTERN_C BOOL mp_handle_gic_interrupt_el0(Void) {
UInt32 interrupt_id = ke_dma_read<UInt32>(GICC_BASE, GICC_IAR);
- // Check if it's a valid interrupt (not spurious)
if ((interrupt_id & 0x3FF) < 1020) {
auto interrupt = interrupt_id & 0x3FF;
@@ -106,15 +94,25 @@ namespace Detail { return YES;
}
- // spurious interrupt
return NO;
}
} // namespace Detail
+/***********************************************************************************/
+/// @brief Get current stack frame for a thread.
+/// @param thrdid The thread ID.
+/***********************************************************************************/
+
EXTERN_C HAL::StackFramePtr mp_get_current_context(ProcessID thrdid) {
- return kHWThread[thrdid].mFrame;
+ return kHWThread[thrdid].mFramePtr;
}
+/***********************************************************************************/
+/// @brief Register current stack frame for a thread.
+/// @param stack_frame The current stack frame.
+/// @param thrdid The thread ID.
+/***********************************************************************************/
+
EXTERN_C Bool mp_register_process(HAL::StackFramePtr stack_frame, ProcessID thrdid) {
MUST_PASS(Detail::kGICEnabled);
@@ -123,25 +121,20 @@ EXTERN_C Bool mp_register_process(HAL::StackFramePtr stack_frame, ProcessID thrd const auto process_index = thrdid;
- kHWThread[process_index].mFrame = stack_frame;
+ kHWThread[process_index].mFramePtr = stack_frame;
kHWThread[process_index].mThreadID = thrdid;
- STATIC HardwareTimer timer{rtl_milliseconds(1000)};
- timer.Wait();
-
- HardwareThreadScheduler::The()[thrdid].Leak()->Busy(NO);
-
return YES;
}
-/// @internal
+/***********************************************************************************/
/// @brief Initialize the Global Interrupt Controller.
+/// @internal
+/***********************************************************************************/
Void mp_init_cores(Void) noexcept {
if (!Detail::kGICEnabled) {
Detail::kGICEnabled = YES;
Detail::mp_setup_gic_el0();
}
-
- return Detail::kGICEnabled;
}
} // namespace Kernel
\ No newline at end of file diff --git a/dev/kernel/HALKit/ARM64/HalFlushTLB.S b/dev/kernel/HALKit/ARM64/HalCommonAPI.s index e76b6e3f..e76b6e3f 100644 --- a/dev/kernel/HALKit/ARM64/HalFlushTLB.S +++ b/dev/kernel/HALKit/ARM64/HalCommonAPI.s diff --git a/dev/kernel/HALKit/ARM64/HalInterruptAPI.s b/dev/kernel/HALKit/ARM64/HalInterruptAPI.s new file mode 100644 index 00000000..cafebb7d --- /dev/null +++ b/dev/kernel/HALKit/ARM64/HalInterruptAPI.s @@ -0,0 +1,3 @@ +/* (c) 2024-2025 Amlal El Mahrouss */ + +.text diff --git a/dev/kernel/HALKit/ARM64/HalTimerARM64.cc b/dev/kernel/HALKit/ARM64/HalTimerARM64.cc index 32f64aec..2a595f11 100644 --- a/dev/kernel/HALKit/ARM64/HalTimerARM64.cc +++ b/dev/kernel/HALKit/ARM64/HalTimerARM64.cc @@ -12,3 +12,4 @@ ------------------------------------------- */ #include <ArchKit/ArchKit.h> +#include <KernelKit/Timer.h>
\ No newline at end of file diff --git a/dev/kernel/HALKit/ARM64/Paging.h b/dev/kernel/HALKit/ARM64/Paging.h index 2eb02bc1..88eedcd8 100644 --- a/dev/kernel/HALKit/ARM64/Paging.h +++ b/dev/kernel/HALKit/ARM64/Paging.h @@ -12,6 +12,8 @@ ------------------------------------------------------- */ +#ifdef __NE_ARM64__ + #include <NewKit/Defines.h> #ifndef kPageMax @@ -101,3 +103,5 @@ typedef HAL::PDE_4KB PDE; } // namespace Kernel EXTERN_C void hal_flush_tlb(); + +#endif // __NE_ARM64__
\ No newline at end of file diff --git a/dev/kernel/HALKit/ARM64/Processor.h b/dev/kernel/HALKit/ARM64/Processor.h index 9f16d8f5..f52b854f 100644 --- a/dev/kernel/HALKit/ARM64/Processor.h +++ b/dev/kernel/HALKit/ARM64/Processor.h @@ -6,12 +6,14 @@ #pragma once +#ifdef __NE_ARM64__ + #include <FirmwareKit/Handover.h> #include <NewKit/Array.h> #include <NewKit/Defines.h> #include <NewKit/Utils.h> -#define kCPUBackendName "ARMv8" +#define kCPUBackendName "aarch64" namespace Kernel::HAL { struct PACKED Register64 final { @@ -21,11 +23,11 @@ struct PACKED Register64 final { /// @brief Memory Manager mapping flags. enum { - kMMFlagsPresent = 1 << 0, - kMMFlagsWr = 1 << 1, - kMMFlagsUser = 1 << 2, - kMMFlagsNX = 1 << 3, - kMMFlagsPCD = 1 << 4, + kMMFlagsInvalid = 1 << 0, + kMMFlagsPresent = 1 << 1, + kMMFlagsWr = 1 << 2, + kMMFlagsUser = 1 << 3, + kMMFlagsNX = 1 << 4, kMMFlagsCount = 4, }; @@ -62,16 +64,6 @@ inline Void rt_halt() noexcept { } } -template <typename DataKind> -inline void hal_dma_write(UIntPtr address, DataKind value) { - *reinterpret_cast<volatile DataKind*>(address) = value; -} - -template <typename DataKind> -inline DataKind hal_dma_read(UIntPtr address) { - return *reinterpret_cast<volatile DataKind*>(address); -} - inline Void hal_wfi(Void) { asm volatile("wfi"); } @@ -80,6 +72,8 @@ inline Void hal_wfi(Void) { inline Kernel::VoidPtr kKernelBitMpStart = nullptr; inline Kernel::UIntPtr kKernelBitMpSize = 0UL; -inline Kernel::VoidPtr kKernelPhysicalStart = nullptr; +inline Kernel::VoidPtr kKernelPDE = nullptr; #include <HALKit/ARM64/Paging.h> + +#endif // __NE_ARM64__
\ No newline at end of file diff --git a/dev/kernel/KernelKit/KernelTaskScheduler.h b/dev/kernel/KernelKit/KernelTaskScheduler.h index 942cd8b4..f4ff4125 100644 --- a/dev/kernel/KernelKit/KernelTaskScheduler.h +++ b/dev/kernel/KernelKit/KernelTaskScheduler.h @@ -15,9 +15,8 @@ #include <KernelKit/LockDelegate.h> namespace Kernel { -struct KERNEL_TASK; - -struct KERNEL_TASK final { +class KERNEL_TASK final { +public: Char Name[kSchedNameLen] = {"KERNEL_TASK"}; ProcessSubsystem SubSystem{ProcessSubsystem::kProcessSubsystemDriver}; HAL::StackFramePtr StackFrame{nullptr}; |
