summaryrefslogtreecommitdiffhomepage
path: root/Kernel/HALKit
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/HALKit')
-rw-r--r--Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx37
-rw-r--r--Kernel/HALKit/AMD64/HalInterruptAPI.asm10
-rw-r--r--Kernel/HALKit/AMD64/HalKernelMain.cxx2
-rw-r--r--Kernel/HALKit/AMD64/HalRoutines.s1
-rw-r--r--Kernel/HALKit/AMD64/HalUtils.asm32
5 files changed, 29 insertions, 53 deletions
diff --git a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx
index 48d737fe..0557afac 100644
--- a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx
+++ b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx
@@ -67,13 +67,13 @@ namespace Kernel::HAL
/// @brief Multiple APIC Descriptor Table.
struct MadtType final : public SDT
{
+ UInt32 Address;
+ UInt32 Flags; // 1 = Dual Legacy PICs installed
+
struct MadtAddress final
{
Char RecordType;
Char RecordLen; // record length
-
- UInt32 Address;
- UInt32 Flags; // 1 = Dual Legacy PICs installed
} MadtRecords[];
};
@@ -120,13 +120,8 @@ namespace Kernel::HAL
STATIC MadtType* kApicInfoBlock = nullptr;
- STATIC struct
- {
- UIntPtr fAddress{0};
- UInt32 fKind{0};
- } kApicMadtAddresses[255] = {};
-
- STATIC SizeT kApicMadtAddressesCount = 0UL;
+ EXTERN_C SizeT kApicMadtAddressesCount = 0UL;
+ EXTERN_C SizeT cBspDone = 0UL;
enum
{
@@ -170,9 +165,12 @@ namespace Kernel::HAL
}
/// @internal
- EXTERN_C Void hal_apic_acknowledge(Void)
+ EXTERN_C Void hal_ap_startup(Void)
{
- kcout << "newoskrnl: acknowledge APIC.\r";
+ while (Yes)
+ {
+
+ }
}
/// @internal
@@ -216,6 +214,8 @@ namespace Kernel::HAL
return (eax & 0xfffff000) | ((UIntPtr)(edx & 0x0f) << 32);
}
+ EXTERN_C Void hal_ap_trampoline(Void);
+
/// @brief Fetch and enable cores inside main CPU.
/// @param rsdPtr RSD PTR structure.
Void hal_system_get_cores(voidPtr rsdPtr)
@@ -225,16 +225,15 @@ namespace Kernel::HAL
if (kApicMadt != nullptr)
{
- MadtType* madt = reinterpret_cast<MadtType*>(kApicMadt);
-
- cpu_set_apic_base(cpu_get_apic_base());
+ UInt8 bsp_id, bsp_done = No;
- // set SVR register to bit 8 to start recieve interrupts.
+ UInt32 num_cores = 4;
+ UInt32* local_apic_ptr = nullptr;
+ UInt32* local_apic_ids[255] = {0};
- auto flagsSet = Kernel::ke_dma_read(cAPICAddress, 0xF0); // SVR register.
- flagsSet |= 0x100;
+ MadtType* type = (MadtType*)kApicMadt;
- Kernel::ke_dma_write(cAPICAddress, 0xF0, flagsSet | 0x100);
+ local_apic_ptr = (UInt32*)type->Address;
}
else
{
diff --git a/Kernel/HALKit/AMD64/HalInterruptAPI.asm b/Kernel/HALKit/AMD64/HalInterruptAPI.asm
index c09d5a06..b7cddea8 100644
--- a/Kernel/HALKit/AMD64/HalInterruptAPI.asm
+++ b/Kernel/HALKit/AMD64/HalInterruptAPI.asm
@@ -119,16 +119,8 @@ IntExp 30
IntNormal 31
-[extern hal_apic_acknowledge]
-
-__NEW_INT_34:
- push rax
- call hal_apic_acknowledge
- pop rax
-
- iretq
-
IntNormal 32
+IntNormal 34
IntNormal 33
IntNormal 35
diff --git a/Kernel/HALKit/AMD64/HalKernelMain.cxx b/Kernel/HALKit/AMD64/HalKernelMain.cxx
index a4067c84..4a6fa302 100644
--- a/Kernel/HALKit/AMD64/HalKernelMain.cxx
+++ b/Kernel/HALKit/AMD64/HalKernelMain.cxx
@@ -216,7 +216,7 @@ EXTERN_C void hal_init_platform(
kSyscalls[cRebootInterrupt].Leak().Leak()->fHooked = true;
kSyscalls[cLPCSanitizeMsg].Leak().Leak()->fHooked = true;
- // newoskrnl version 1.00
+ // newoskrnl version 1.00.
Kernel::StringView strVer(cMaxPropLen);
strVer += "\\Properties\\KernelVersion";
diff --git a/Kernel/HALKit/AMD64/HalRoutines.s b/Kernel/HALKit/AMD64/HalRoutines.s
index e4944111..321ad3d3 100644
--- a/Kernel/HALKit/AMD64/HalRoutines.s
+++ b/Kernel/HALKit/AMD64/HalRoutines.s
@@ -2,6 +2,7 @@
.globl hal_load_gdt
.globl rt_wait_400ns
.globl rt_get_current_context
+.globl hal_ap_trampoline
.section .text
rt_wait_400ns:
diff --git a/Kernel/HALKit/AMD64/HalUtils.asm b/Kernel/HALKit/AMD64/HalUtils.asm
index 6681a692..86d9983e 100644
--- a/Kernel/HALKit/AMD64/HalUtils.asm
+++ b/Kernel/HALKit/AMD64/HalUtils.asm
@@ -23,27 +23,11 @@ rt_install_tib:
;; //////////////////////////////////////////////////// ;;
-[global rt_jump_user_mode]
-
-;; @used rcx, address to jump on.
-;; @note adjusted for long mode.
-rt_jump_user_mode:
- cmp rcx, 0
- je rt_jump_user_mode_failed
-
- mov ax, (6 * 8) | 3 ; user data segment with RPL 3
- mov ds, ax
- mov es, ax
- mov fs, ax
- mov gs, ax ; SS is handled by iret
-
- mov rax, rsp
- push (6 * 8) | 3
- push rax
- pushf
- push (5 * 8) | 3 ; user code segment with RPL 3
- push rcx
- iretq
- ;; we just failed to validate the rcx, fallback and return to previous pc.
-rt_jump_user_mode_failed:
- ret \ No newline at end of file
+[extern cBspDone]
+[extern kApicMadtAddressesCount]
+[extern hal_ap_startup]
+[global hal_ap_trampoline]
+
+hal_ap_trampoline:
+hal_ap_trampoline_1:
+ jmp hal_ap_startup