summaryrefslogtreecommitdiffhomepage
path: root/Kernel/HALKit
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-07-31 00:13:51 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-07-31 00:13:51 +0200
commit3bfb95803ba25a04ddb57ebbc0f25e4dec29d7e0 (patch)
tree94fc17899142c1631797b9b6257b04359282741b /Kernel/HALKit
parent659435af7da4ffb15a309063c892b518707fa9d0 (diff)
[IMP] Can now pass arguments to kernel via handover, new version 0x0113.
[IMP] Timeout functions for heap allocation. [IMP] new mp_ and sched_ category of functions. Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Kernel/HALKit')
-rw-r--r--Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx13
-rw-r--r--Kernel/HALKit/AMD64/HalHart.cxx4
-rw-r--r--Kernel/HALKit/AMD64/HalKernelMain.cxx56
-rw-r--r--Kernel/HALKit/ARM64/HalHart.cxx4
-rw-r--r--Kernel/HALKit/ARM64/HalKernelMain.cxx2
-rw-r--r--Kernel/HALKit/POWER/HalHart.cxx4
6 files changed, 43 insertions, 40 deletions
diff --git a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx
index 0557afac..2f82da6b 100644
--- a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx
+++ b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx
@@ -120,9 +120,6 @@ namespace Kernel::HAL
STATIC MadtType* kApicInfoBlock = nullptr;
- EXTERN_C SizeT kApicMadtAddressesCount = 0UL;
- EXTERN_C SizeT cBspDone = 0UL;
-
enum
{
cAPICEOI = 0xb0,
@@ -225,15 +222,7 @@ namespace Kernel::HAL
if (kApicMadt != nullptr)
{
- UInt8 bsp_id, bsp_done = No;
-
- UInt32 num_cores = 4;
- UInt32* local_apic_ptr = nullptr;
- UInt32* local_apic_ids[255] = {0};
-
- MadtType* type = (MadtType*)kApicMadt;
-
- local_apic_ptr = (UInt32*)type->Address;
+ kApicInfoBlock = (MadtType*)kApicMadt;
}
else
{
diff --git a/Kernel/HALKit/AMD64/HalHart.cxx b/Kernel/HALKit/AMD64/HalHart.cxx
index adbf148c..93e1056d 100644
--- a/Kernel/HALKit/AMD64/HalHart.cxx
+++ b/Kernel/HALKit/AMD64/HalHart.cxx
@@ -12,7 +12,7 @@ namespace Kernel
{
/// @brief wakes up thread.
/// wakes up thread from hang.
- void rt_wakeup_thread(HAL::StackFrame* stack)
+ void mp_wakeup_thread(HAL::StackFrame* stack)
{
HAL::rt_cli();
@@ -23,7 +23,7 @@ namespace Kernel
/// @brief makes the thread sleep on a loop.
/// hooks and hangs thread to prevent code from executing.
- void rt_hang_thread(HAL::StackFrame* stack)
+ void mp_hang_thread(HAL::StackFrame* stack)
{
while (true)
{
diff --git a/Kernel/HALKit/AMD64/HalKernelMain.cxx b/Kernel/HALKit/AMD64/HalKernelMain.cxx
index 4a6fa302..d21d2f9c 100644
--- a/Kernel/HALKit/AMD64/HalKernelMain.cxx
+++ b/Kernel/HALKit/AMD64/HalKernelMain.cxx
@@ -24,8 +24,6 @@
X; \
Kernel::ke_stop(RUNTIME_CHECK_BOOTSTRAP);
-
-
Kernel::Property cKernelVersion;
Kernel::Property cAutoFormatDisk;
@@ -34,19 +32,19 @@ EXTERN_C void KeMain();
EXTERN_C Kernel::VoidPtr kInterruptVectorTable[];
-struct PACKED HeapAllocInfo final
+struct PACKED HEAP_ALLOC_INFO final
{
Kernel::VoidPtr fThe;
Kernel::Size fTheSz;
};
-struct PACKED ProcessBlockInfo final
+struct PACKED PROCESS_BLOCK_INFO final
{
ThreadInformationBlock* fTIB;
ThreadInformationBlock* fPIB;
};
-struct PACKED ProcessExitInfo final
+struct PACKED PROCESS_EXIT_INFO final
{
STATIC constexpr auto cReasonLen = 512;
@@ -146,7 +144,7 @@ EXTERN_C void hal_init_platform(
kSyscalls[cNewInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void {
// get HAC struct.
- HeapAllocInfo* rdxInf = reinterpret_cast<HeapAllocInfo*>(rdx);
+ HEAP_ALLOC_INFO* rdxInf = reinterpret_cast<HEAP_ALLOC_INFO*>(rdx);
if (!rdxInf)
return;
@@ -157,7 +155,7 @@ EXTERN_C void hal_init_platform(
kSyscalls[cDeleteInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void {
// get HAC struct.
- HeapAllocInfo* rdxInf = reinterpret_cast<HeapAllocInfo*>(rdx);
+ HEAP_ALLOC_INFO* rdxInf = reinterpret_cast<HEAP_ALLOC_INFO*>(rdx);
if (!rdxInf)
return;
@@ -167,7 +165,7 @@ EXTERN_C void hal_init_platform(
};
kSyscalls[cTlsInstallInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void {
- ProcessBlockInfo* rdxPb = reinterpret_cast<ProcessBlockInfo*>(rdx);
+ PROCESS_BLOCK_INFO* rdxPb = reinterpret_cast<PROCESS_BLOCK_INFO*>(rdx);
if (!rdxPb)
return;
@@ -177,7 +175,7 @@ EXTERN_C void hal_init_platform(
};
kSyscalls[cExitInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void {
- ProcessExitInfo* rdxEi = reinterpret_cast<ProcessExitInfo*>(rdx);
+ PROCESS_EXIT_INFO* rdxEi = reinterpret_cast<PROCESS_EXIT_INFO*>(rdx);
if (!rdxEi)
return;
@@ -187,22 +185,22 @@ EXTERN_C void hal_init_platform(
};
kSyscalls[cLastExitInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void {
- ProcessExitInfo* rdxEi = reinterpret_cast<ProcessExitInfo*>(rdx);
+ PROCESS_EXIT_INFO* rdxEi = reinterpret_cast<PROCESS_EXIT_INFO*>(rdx);
if (!rdxEi)
return;
- rdxEi->fCode = Kernel::rt_get_exit_code();
+ rdxEi->fCode = Kernel::sched_get_exit_code();
};
kSyscalls[cRebootInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void {
- Kernel::ACPIFactoryInterface acpi(kHandoverHeader->f_HardwareTables.f_VendorPtr);
- acpi.Reboot();
+ Kernel::PowerFactoryInterface pow(kHandoverHeader->f_HardwareTables.f_VendorPtr);
+ pow.Reboot();
};
kSyscalls[cShutdownInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void {
- Kernel::ACPIFactoryInterface acpi(kHandoverHeader->f_HardwareTables.f_VendorPtr);
- acpi.Shutdown();
+ Kernel::PowerFactoryInterface pow(kHandoverHeader->f_HardwareTables.f_VendorPtr);
+ pow.Shutdown();
};
kSyscalls[cSerialAlertInterrupt].Leak().Leak()->fHooked = true;
@@ -220,16 +218,32 @@ EXTERN_C void hal_init_platform(
Kernel::StringView strVer(cMaxPropLen);
strVer += "\\Properties\\KernelVersion";
- cKernelVersion.GetKey() = strVer;
- cKernelVersion.GetValue() = __MAHROUSS__;
+ cKernelVersion.GetKey() = strVer;
+ cKernelVersion.GetValue() = __MAHROUSS_VER__;
- Kernel::StringView strAutoMount(cMaxPropLen);
+ Kernel::StringView strAutoMount(cMaxPropLen);
strAutoMount += "\\Properties\\AutoMountFS?";
- cAutoFormatDisk.GetKey() = strAutoMount;
- cAutoFormatDisk.GetValue() = Yes;
+ cAutoFormatDisk.GetKey() = strAutoMount;
+
+
+ for (size_t i = 0; i < cMaxCmdLine; i++)
+ {
+ if (Kernel::rt_string_cmp(kHandoverHeader->f_CommandLine[i], "/AutoFormat", Kernel::rt_string_len("/AutoFormat")) == 0)
+ {
+ cAutoFormatDisk.GetValue() = Yes;
+ break;
+ }
+ }
- Kernel::HAL::hal_system_get_cores(kHandoverHeader->f_HardwareTables.f_VendorPtr);
+ for (size_t i = 0; i < cMaxCmdLine; i++)
+ {
+ if (Kernel::rt_string_cmp(kHandoverHeader->f_CommandLine[i], "/SMP", Kernel::rt_string_len("/SMP")) == 0)
+ {
+ Kernel::HAL::hal_system_get_cores(kHandoverHeader->f_HardwareTables.f_VendorPtr);
+ break;
+ }
+ }
mInitKernel(KeMain());
}
diff --git a/Kernel/HALKit/ARM64/HalHart.cxx b/Kernel/HALKit/ARM64/HalHart.cxx
index d7a34505..2ed87b91 100644
--- a/Kernel/HALKit/ARM64/HalHart.cxx
+++ b/Kernel/HALKit/ARM64/HalHart.cxx
@@ -12,14 +12,14 @@ namespace Kernel
{
/// @brief wakes up thread.
/// wakes up thread from hang.
- void rt_wakeup_thread(HAL::StackFrame* stack)
+ void mp_wakeup_thread(HAL::StackFrame* stack)
{
rt_do_context_switch(stack);
}
/// @brief makes the thread sleep on a loop.
/// hooks and hangs thread to prevent code from executing.
- void rt_hang_thread(HAL::StackFrame* stack)
+ void mp_hang_thread(HAL::StackFrame* stack)
{
while (true)
{
diff --git a/Kernel/HALKit/ARM64/HalKernelMain.cxx b/Kernel/HALKit/ARM64/HalKernelMain.cxx
index a5285f0f..0d6a8ca5 100644
--- a/Kernel/HALKit/ARM64/HalKernelMain.cxx
+++ b/Kernel/HALKit/ARM64/HalKernelMain.cxx
@@ -150,7 +150,7 @@ EXTERN_C void hal_init_platform(
if (!rdxEi)
return;
- rdxEi->fCode = Kernel::rt_get_exit_code();
+ rdxEi->fCode = Kernel::sched_get_exit_code();
};
kSyscalls[cRebootInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void {
diff --git a/Kernel/HALKit/POWER/HalHart.cxx b/Kernel/HALKit/POWER/HalHart.cxx
index 5ff12218..a49aeb3a 100644
--- a/Kernel/HALKit/POWER/HalHart.cxx
+++ b/Kernel/HALKit/POWER/HalHart.cxx
@@ -12,14 +12,14 @@ using namespace Kernel;
/// @brief wakes up thread.
/// wakes up thread from hang.
-void rt_wakeup_thread(HAL::StackFramePtr stack)
+void mp_wakeup_thread(HAL::StackFramePtr stack)
{
NEWOS_UNUSED(stack);
}
/// @brief makes thread sleep.
/// hooks and hangs thread to prevent code from executing.
-void rt_hang_thread(HAL::StackFramePtr stack)
+void mp_hang_thread(HAL::StackFramePtr stack)
{
NEWOS_UNUSED(stack);
}