diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-03-23 19:13:48 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-03-23 19:15:17 +0100 |
| commit | a13e1c0911c0627184bc38f18c7fdda64447b3ad (patch) | |
| tree | 073a62c09bf216e85a3f310376640fa1805147f9 /dev/kernel/HALKit/RISCV | |
| parent | 149fa096eb306d03686b3b67e813cf1a78e08cd0 (diff) | |
meta(kernel): Reworked repository's filesystem structure.
Removing useless parts of the project too.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/kernel/HALKit/RISCV')
| -rw-r--r-- | dev/kernel/HALKit/RISCV/.keep | 0 | ||||
| -rw-r--r-- | dev/kernel/HALKit/RISCV/AP.h | 35 | ||||
| -rw-r--r-- | dev/kernel/HALKit/RISCV/APM/.gitkeep | 0 | ||||
| -rw-r--r-- | dev/kernel/HALKit/RISCV/HalAP.cc | 40 | ||||
| -rw-r--r-- | dev/kernel/HALKit/RISCV/ReadMe.md | 4 | ||||
| -rw-r--r-- | dev/kernel/HALKit/RISCV/Storage/.gitkeep | 0 |
6 files changed, 79 insertions, 0 deletions
diff --git a/dev/kernel/HALKit/RISCV/.keep b/dev/kernel/HALKit/RISCV/.keep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/dev/kernel/HALKit/RISCV/.keep diff --git a/dev/kernel/HALKit/RISCV/AP.h b/dev/kernel/HALKit/RISCV/AP.h new file mode 100644 index 00000000..c198a404 --- /dev/null +++ b/dev/kernel/HALKit/RISCV/AP.h @@ -0,0 +1,35 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved. + + File: AP.h + Purpose: RISC-V hardware threads. + + Revision History: + + 30/01/24: Added file (amlel) + +------------------------------------------- */ + +#pragma once + +#include <NewKit/Defines.h> + +namespace NeOS +{ + typedef Int64 hal_ap_kind; + + typedef struct HAL_HARDWARE_THREAD + { + NeOS::UIntPtr fStartAddress; + NeOS::UInt8 fPrivleged : 1; + NeOS::UInt32 fPageMemoryFlags; + hal_ap_kind fIdentNumber; + } HAL_HARDWARE_THREAD; + + /// @brief Set PC to specific hart. + /// @param hart the hart + /// @param epc the pc. + /// @return + EXTERN_C NeOS::Void hal_set_pc_to_hart(HAL_HARDWARE_THREAD* hart, NeOS::VoidPtr epc); +} // namespace NeOS diff --git a/dev/kernel/HALKit/RISCV/APM/.gitkeep b/dev/kernel/HALKit/RISCV/APM/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/dev/kernel/HALKit/RISCV/APM/.gitkeep diff --git a/dev/kernel/HALKit/RISCV/HalAP.cc b/dev/kernel/HALKit/RISCV/HalAP.cc new file mode 100644 index 00000000..788acf0f --- /dev/null +++ b/dev/kernel/HALKit/RISCV/HalAP.cc @@ -0,0 +1,40 @@ +/* -------------------------------------------
+
+ Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#include <HALKit/RISCV/Processor.h>
+#include <KernelKit/DebugOutput.h>
+#include <HALKit/RISCV/AP.h>
+
+using namespace NeOS;
+
+namespace NeOS::Detail
+{
+ STATIC void mp_hang_fn(void)
+ {
+ while (YES)
+ ;
+ }
+} // namespace NeOS::Detail
+
+/// @brief wakes up thread.
+/// wakes up thread from hang.
+void mp_wakeup_thread(HAL::StackFramePtr stack)
+{
+ if (!stack)
+ return;
+
+ hal_set_pc_to_hart(reinterpret_cast<HAL_HARDWARE_THREAD*>(stack->R15), reinterpret_cast<VoidPtr>(stack->BP));
+}
+
+/// @brief makes thread sleep.
+/// hooks and hangs thread to prevent code from executing.
+void mp_hang_thread(HAL::StackFramePtr stack)
+{
+ if (!stack)
+ return;
+
+ hal_set_pc_to_hart(reinterpret_cast<HAL_HARDWARE_THREAD*>(stack->R15), reinterpret_cast<VoidPtr>(NeOS::Detail::mp_hang_fn));
+}
diff --git a/dev/kernel/HALKit/RISCV/ReadMe.md b/dev/kernel/HALKit/RISCV/ReadMe.md new file mode 100644 index 00000000..b099aa31 --- /dev/null +++ b/dev/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 diff --git a/dev/kernel/HALKit/RISCV/Storage/.gitkeep b/dev/kernel/HALKit/RISCV/Storage/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/dev/kernel/HALKit/RISCV/Storage/.gitkeep |
