summaryrefslogtreecommitdiffhomepage
path: root/Kernel/HALKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-05-09 19:23:04 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-05-09 19:23:04 +0200
commit915c14eb3b717bbd168d069e296a4246c6aef117 (patch)
treeb01b1e9a522b66bc070fb0e5b34efc70f172cc92 /Kernel/HALKit
parentaf8a516fc22865abd80d6e26f1541fa3d6bebfdc (diff)
MHR-23: Starting to implement SMP for AMD64.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Kernel/HALKit')
-rw-r--r--Kernel/HALKit/64x0/ReadMe.md4
-rw-r--r--Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx11
-rw-r--r--Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp33
-rw-r--r--Kernel/HALKit/AMD64/HalHardwareMP.cpp4
-rw-r--r--Kernel/HALKit/AMD64/HalInterruptAPI.asm20
-rw-r--r--Kernel/HALKit/AMD64/ReadMe.md4
-rw-r--r--Kernel/HALKit/ARM64/ReadMe.md4
-rw-r--r--Kernel/HALKit/POWER/ReadMe.md4
-rw-r--r--Kernel/HALKit/RISCV/ReadMe.md4
9 files changed, 57 insertions, 31 deletions
diff --git a/Kernel/HALKit/64x0/ReadMe.md b/Kernel/HALKit/64x0/ReadMe.md
new file mode 100644
index 00000000..6744f602
--- /dev/null
+++ b/Kernel/HALKit/64x0/ReadMe.md
@@ -0,0 +1,4 @@
+64x0 Hardware Abstraction Layer
+
+- Supported CPU: SoftwareLabs 64x0
+- Supported Firmware: CoreBoot \ No newline at end of file
diff --git a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx
index 3609165f..f4c9226e 100644
--- a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx
+++ b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx
@@ -75,7 +75,7 @@ namespace NewOS
SDT* xsdt = (SDT*)(rsdPtr->XsdtAddress >> (rsdPtr->XsdtAddress & 0xFFF));
- SizeT num = xsdt->Length + sizeof(SDT) / 8;
+ SizeT num = (xsdt->Length + sizeof(SDT)) / 8;
this->fEntries = num;
@@ -83,10 +83,11 @@ namespace NewOS
kcout << "ACPI: Address of XSDT: " << hex_number((UIntPtr)xsdt) << endl;
constexpr short ACPI_SIGNATURE_LENGTH = 4;
+ SizeT offsetToAdd = 0UL;
for (Size index = 0; index < num; ++index)
{
- SDT* sdt = (SDT*)*((UInt64*)(UInt64)xsdt + sizeof(SDT) + (index * 8));
+ SDT* sdt = &(xsdt[index]) + offsetToAdd;
for (int signature_index = 0; signature_index < 4; signature_index++)
{
@@ -94,11 +95,13 @@ namespace NewOS
break;
if (signature_index == 3)
- return ErrorOr<voidPtr>(reinterpret_cast<voidPtr>((SDT*)sdt));
+ return ErrorOr<voidPtr>(reinterpret_cast<voidPtr>(sdt));
}
+
+ offsetToAdd = sdt->Length;
}
- return ErrorOr<voidPtr>{-1};
+ return ErrorOr<voidPtr>{nullptr};
}
/***
diff --git a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
index 2129d790..ec6d47da 100644
--- a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
+++ b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
@@ -23,12 +23,12 @@ namespace NewOS::HAL
constexpr Int32 kThreadBoot = 4;
/*
- *
- * this is used to store info about the current running thread
- * we use this struct to determine if we can use it, or mark it as used or on
- * sleep.
- *
- */
+ *
+ * this is used to store info about the current running thread
+ * we use this struct to determine if we can use it, or mark it as used or on
+ * sleep.
+ *
+ */
struct ProcessorInfoAMD64 final
{
@@ -51,12 +51,12 @@ namespace NewOS::HAL
{
struct MadtAddress final
{
+ UInt32 fAddress;
UInt32 fFlags; // 1 = Dual Legacy PICs installed
- UInt32 fPhysicalAddress;
Char fType;
Char fRecLen; // record length
- } Madt[];
+ } fMadt[];
};
struct MadtProcessorLocalApic final
@@ -104,20 +104,23 @@ namespace NewOS::HAL
void hal_system_get_cores(voidPtr rsdPtr)
{
- kcout << "New OS: Constructing ACPIFactoryInterface...\r";
-
auto acpi = ACPIFactoryInterface(rsdPtr);
kApicMadt = acpi.Find(kApicSignature).Leak().Leak();
if (kApicMadt)
{
- kcout << "New OS: Successfuly fetched the MADT!\r";
+ kcout << "New OS: Successfuly fetched the cores!\r";
kApicInfoBlock = (MadtType*)kApicMadt;
+
+ kcout << "New OS: Revision: ";
+ kcout.HexNumber(kApicInfoBlock->Revision).EndLine();
+
+ ke_stop(RUNTIME_CHECK_BOOTSTRAP);
}
- else
- {
- MUST_PASS(false);
- }
+ else
+ {
+ ke_stop(RUNTIME_CHECK_BOOTSTRAP);
+ }
}
} // namespace NewOS::HAL
diff --git a/Kernel/HALKit/AMD64/HalHardwareMP.cpp b/Kernel/HALKit/AMD64/HalHardwareMP.cpp
index 2ebf45fd..83e99ef8 100644
--- a/Kernel/HALKit/AMD64/HalHardwareMP.cpp
+++ b/Kernel/HALKit/AMD64/HalHardwareMP.cpp
@@ -16,7 +16,7 @@ namespace NewOS
{
HAL::rt_cli();
- stack->Rcx = 0;
+
HAL::rt_sti();
}
@@ -27,7 +27,7 @@ namespace NewOS
{
HAL::rt_cli();
- stack->Rcx = 1;
+
HAL::rt_sti();
}
diff --git a/Kernel/HALKit/AMD64/HalInterruptAPI.asm b/Kernel/HALKit/AMD64/HalInterruptAPI.asm
index e4063388..875a1abc 100644
--- a/Kernel/HALKit/AMD64/HalInterruptAPI.asm
+++ b/Kernel/HALKit/AMD64/HalInterruptAPI.asm
@@ -14,16 +14,16 @@
%define kInterruptId 0x21
%macro IntExp 1
-global __HCR_INT_%1
-__HCR_INT_%1:
+global __NEW_INT_%1
+__NEW_INT_%1:
cld
iretq
%endmacro
%macro IntNormal 1
-global __HCR_INT_%1
-__HCR_INT_%1:
+global __NEW_INT_%1
+__NEW_INT_%1:
cld
iretq
@@ -54,7 +54,7 @@ IntNormal 4
IntNormal 5
;; Invalid opcode interrupt
-__HCR_INT_6:
+__NEW_INT_6:
cli
push rax
@@ -75,7 +75,7 @@ IntExp 11
IntExp 12
-__HCR_INT_13:
+__NEW_INT_13:
cli
push rax
@@ -88,7 +88,7 @@ __HCR_INT_13:
sti
iretq
-__HCR_INT_14:
+__NEW_INT_14:
cli
push rax
@@ -135,7 +135,7 @@ IntNormal 41
IntNormal 42
IntNormal 43
-__HCR_INT_44:
+__NEW_INT_44:
cli
;; TODO: CoreEvents dispatch routine.
@@ -153,7 +153,7 @@ IntNormal 47
IntNormal 48
IntNormal 49
-__HCR_INT_50:
+__NEW_INT_50:
cli
;; todo handle system calls.
@@ -217,6 +217,6 @@ section .data
kInterruptVectorTable:
%assign i 0
%rep 256
- dq __HCR_INT_%+i
+ dq __NEW_INT_%+i
%assign i i+1
%endrep
diff --git a/Kernel/HALKit/AMD64/ReadMe.md b/Kernel/HALKit/AMD64/ReadMe.md
new file mode 100644
index 00000000..0be48c77
--- /dev/null
+++ b/Kernel/HALKit/AMD64/ReadMe.md
@@ -0,0 +1,4 @@
+AMD64 Hardware Abstraction Layer
+
+- Supported CPU: AMD64 CPU
+- Supported Firmware: EDK 2 \ No newline at end of file
diff --git a/Kernel/HALKit/ARM64/ReadMe.md b/Kernel/HALKit/ARM64/ReadMe.md
new file mode 100644
index 00000000..89679e18
--- /dev/null
+++ b/Kernel/HALKit/ARM64/ReadMe.md
@@ -0,0 +1,4 @@
+ARM64 Hardware Abstraction Layer
+
+- Supported CPU: Qualcomm CPU
+- Supported Firmware: EDK 2 \ No newline at end of file
diff --git a/Kernel/HALKit/POWER/ReadMe.md b/Kernel/HALKit/POWER/ReadMe.md
new file mode 100644
index 00000000..a9751581
--- /dev/null
+++ b/Kernel/HALKit/POWER/ReadMe.md
@@ -0,0 +1,4 @@
+POWER Hardware Abstraction Layer
+
+- Supported CPU: POWER
+- Supported Firmware: CoreBoot \ No newline at end of file
diff --git a/Kernel/HALKit/RISCV/ReadMe.md b/Kernel/HALKit/RISCV/ReadMe.md
new file mode 100644
index 00000000..b099aa31
--- /dev/null
+++ b/Kernel/HALKit/RISCV/ReadMe.md
@@ -0,0 +1,4 @@
+RISCV64 Hardware Abstraction Layer
+
+- Supported CPU: RISCV64
+- Supported Firmware: CoreBoot \ No newline at end of file