summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/HALKit/RISCV
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-05-02 19:38:46 +0200
committerGitHub <noreply@github.com>2025-05-02 19:38:46 +0200
commit997be16e5ac9a68d54882ab69529815860d62955 (patch)
tree19d6129c2d776bb1edc5d4a7325e39ca176c3403 /dev/kernel/HALKit/RISCV
parent618104e74c195d7508a18450524f8ed7f9af8cc6 (diff)
parentb3b4b1ebdcd6adeac914869017c86d892b7a8ced (diff)
Merge pull request #28 from nekernel-org/dev
0.0.2
Diffstat (limited to 'dev/kernel/HALKit/RISCV')
-rw-r--r--dev/kernel/HALKit/RISCV/AP.h46
-rw-r--r--dev/kernel/HALKit/RISCV/HalAP.cc40
-rw-r--r--dev/kernel/HALKit/RISCV/HalApplicationProcessor.cc39
3 files changed, 62 insertions, 63 deletions
diff --git a/dev/kernel/HALKit/RISCV/AP.h b/dev/kernel/HALKit/RISCV/AP.h
index 0a8546e9..0e94fd97 100644
--- a/dev/kernel/HALKit/RISCV/AP.h
+++ b/dev/kernel/HALKit/RISCV/AP.h
@@ -1,13 +1,13 @@
/* -------------------------------------------
- Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
+ Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
- File: AP.h
- Purpose: RISC-V hardware threads.
+ File: AP.h
+ Purpose: RISC-V hardware threads.
- Revision History:
+ Revision History:
- 30/01/24: Added file (amlel)
+ 30/01/24: Added file (amlel)
------------------------------------------- */
@@ -15,21 +15,21 @@
#include <NewKit/Defines.h>
-namespace Kernel
-{
- typedef Int64 hal_ap_kind;
-
- typedef struct HAL_HARDWARE_THREAD
- {
- Kernel::UIntPtr fStartAddress;
- Kernel::UInt8 fPrivleged : 1;
- Kernel::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 Kernel::Void hal_set_pc_to_hart(HAL_HARDWARE_THREAD* hart, Kernel::VoidPtr epc);
-} // namespace Kernel
+namespace Kernel {
+typedef Int64 hal_ap_kind;
+
+typedef struct HAL_HARDWARE_THREAD {
+ Kernel::UIntPtr fStartAddress;
+ Kernel::UIntPtr fStackPtr;
+ Kernel::UIntPtr fFramePtr;
+ Kernel::UInt8 fPrivileged : 1;
+ Kernel::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 Kernel::Void hal_set_pc_to_hart(HAL_HARDWARE_THREAD* hart, Kernel::VoidPtr epc);
+} // namespace Kernel
diff --git a/dev/kernel/HALKit/RISCV/HalAP.cc b/dev/kernel/HALKit/RISCV/HalAP.cc
deleted file mode 100644
index 72a3cf13..00000000
--- a/dev/kernel/HALKit/RISCV/HalAP.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-/* -------------------------------------------
-
- 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 Kernel;
-
-namespace Kernel::Detail
-{
- STATIC void mp_hang_fn(void)
- {
- while (YES)
- ;
- }
-} // namespace Kernel::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>(Kernel::Detail::mp_hang_fn));
-}
diff --git a/dev/kernel/HALKit/RISCV/HalApplicationProcessor.cc b/dev/kernel/HALKit/RISCV/HalApplicationProcessor.cc
new file mode 100644
index 00000000..548167a4
--- /dev/null
+++ b/dev/kernel/HALKit/RISCV/HalApplicationProcessor.cc
@@ -0,0 +1,39 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#include <HALKit/RISCV/AP.h>
+#include <HALKit/RISCV/Processor.h>
+#include <KernelKit/DebugOutput.h>
+
+using namespace Kernel;
+
+namespace Kernel {
+namespace Detail {
+ STATIC void mp_hang_fn(void) {
+ while (YES);
+ }
+
+} // namespace 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>(Kernel::Detail::mp_hang_fn));
+}
+
+} // namespace Kernel