summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
authorAmlal <amlalelmahrouss@icloud.com>2024-12-06 15:53:20 +0100
committerAmlal <amlalelmahrouss@icloud.com>2024-12-06 15:57:01 +0100
commit46a885ad913aa24543efb154886919ad30182229 (patch)
tree3f9d6887763d8e1ea66fc89ec9aadb22f4cb9abc /dev
parent8723d3401c15cad5797697aea4735b8972aabafb (diff)
META: Friday bump.
Signed-off-by: Amlal <amlalelmahrouss@icloud.com>
Diffstat (limited to 'dev')
-rw-r--r--dev/HintKit/CompilerHint.h (renamed from dev/ZKAKit/HintKit/CompilerHint.h)6
-rw-r--r--dev/SCIKit/CompilerHint.h6
-rw-r--r--dev/ZBAKit/src/BootString.cc2
-rw-r--r--dev/ZBAKit/src/BootTextWriter.cc2
-rw-r--r--dev/ZKAKit/CompressKit/GZip.h4
-rw-r--r--dev/ZKAKit/CompressKit/RLE.h4
-rw-r--r--dev/ZKAKit/HALKit/AMD64/HalAP.cc (renamed from dev/ZKAKit/HALKit/AMD64/HalSchedulerCoreAMD64.cc)7
-rw-r--r--dev/ZKAKit/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc2
-rw-r--r--dev/ZKAKit/HALKit/ARM64/AP.h36
-rw-r--r--dev/ZKAKit/HALKit/ARM64/HalAP.cc40
-rw-r--r--dev/ZKAKit/HALKit/ARM64/HalSchedulerCore.cc34
-rw-r--r--dev/ZKAKit/HALKit/POWER/AP.h39
-rw-r--r--dev/ZKAKit/HALKit/POWER/HalAP.cc (renamed from dev/ZKAKit/HALKit/POWER/HalHart.cc)21
-rw-r--r--dev/ZKAKit/HALKit/POWER/Hart.h36
-rw-r--r--dev/ZKAKit/HALKit/RISCV/AP.h36
-rw-r--r--dev/ZKAKit/HALKit/RISCV/HalAP.cc40
-rw-r--r--dev/ZKAKit/HALKit/RISCV/Hart.h24
-rw-r--r--dev/ZKAKit/KernelKit/HardwareThreadScheduler.h20
-rw-r--r--dev/ZKAKit/KernelKit/UserProcessScheduler.h2
-rw-r--r--dev/ZKAKit/NetworkKit/LTE.h2
-rw-r--r--dev/ZKAKit/NewKit/Defines.h41
-rw-r--r--dev/ZKAKit/POSIXKit/signal.h20
-rw-r--r--dev/ZKAKit/POSIXKit/unix_layer.h (renamed from dev/ZKAKit/PosixKit/Signals.h)27
-rw-r--r--dev/ZKAKit/src/FS/HPFS.cc2
-rw-r--r--dev/ZKAKit/src/HardwareThreadScheduler.cc71
-rw-r--r--dev/ZKAKit/src/ThreadLocalStorage.cc4
-rw-r--r--dev/ZKAKit/src/UserProcessScheduler.cc9
27 files changed, 395 insertions, 142 deletions
diff --git a/dev/ZKAKit/HintKit/CompilerHint.h b/dev/HintKit/CompilerHint.h
index 00afc9fa..c3205307 100644
--- a/dev/ZKAKit/HintKit/CompilerHint.h
+++ b/dev/HintKit/CompilerHint.h
@@ -4,8 +4,8 @@
------------------------------------------- */
-#ifndef __HINTKIT_COMPILER_HINT_H__
-#define __HINTKIT_COMPILER_HINT_H__
+#ifndef HINTKIT_HINT_H
+#define HINTKIT_HINT_H
#ifdef __TK__
#pragma compiler(hint_manifest)
@@ -22,4 +22,4 @@
#define _InOut
#define _StrictInOut
-#endif // ifndef __HINTKIT_COMPILER_HINT_H__
+#endif // ifndef HINTKIT_HINT_H
diff --git a/dev/SCIKit/CompilerHint.h b/dev/SCIKit/CompilerHint.h
index 8afa1750..319e924c 100644
--- a/dev/SCIKit/CompilerHint.h
+++ b/dev/SCIKit/CompilerHint.h
@@ -4,8 +4,8 @@
------------------------------------------- */
-#ifndef __SCI_HINT_H__
-#define __SCI_HINT_H__
+#ifndef SCI_HINT_H
+#define SCI_HINT_H
#ifdef __TK__
#pragma compiler(hint_manifest)
@@ -22,4 +22,4 @@
#define _InOut
#define _StrictInOut
-#endif // ifndef __SCI_HINT_H__
+#endif // ifndef SCI_HINT_H
diff --git a/dev/ZBAKit/src/BootString.cc b/dev/ZBAKit/src/BootString.cc
index e60235f9..ce9a5898 100644
--- a/dev/ZBAKit/src/BootString.cc
+++ b/dev/ZBAKit/src/BootString.cc
@@ -2,7 +2,7 @@
Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
- File: String.cc
+ File: BootString.cc
Purpose: ZBA string library
Revision History:
diff --git a/dev/ZBAKit/src/BootTextWriter.cc b/dev/ZBAKit/src/BootTextWriter.cc
index 13ed41cc..df33f5fe 100644
--- a/dev/ZBAKit/src/BootTextWriter.cc
+++ b/dev/ZBAKit/src/BootTextWriter.cc
@@ -2,7 +2,7 @@
Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
- File: String.cc
+ File: BootTextWriter.cc
Purpose: ZBA string library
Revision History:
diff --git a/dev/ZKAKit/CompressKit/GZip.h b/dev/ZKAKit/CompressKit/GZip.h
index 834bd1af..f99742f6 100644
--- a/dev/ZKAKit/CompressKit/GZip.h
+++ b/dev/ZKAKit/CompressKit/GZip.h
@@ -11,8 +11,8 @@
namespace Kernel::GZip
{
- class IGZipObject;
- class IGZipProxy;
+ class IGZIPObject;
+ class IGZIPProxy;
} // namespace Kernel::GZip
#endif // !COMPRESSKIT_GZIP_H
diff --git a/dev/ZKAKit/CompressKit/RLE.h b/dev/ZKAKit/CompressKit/RLE.h
index 33a29e8d..95eebabd 100644
--- a/dev/ZKAKit/CompressKit/RLE.h
+++ b/dev/ZKAKit/CompressKit/RLE.h
@@ -11,8 +11,8 @@
namespace Kernel
{
- class IRleObject;
- class IRleProxy;
+ class IRLEObject;
+ class IRLEProxy;
} // namespace Kernel
#endif // !ifndef COMPRESSKIT_RLE_H
diff --git a/dev/ZKAKit/HALKit/AMD64/HalSchedulerCoreAMD64.cc b/dev/ZKAKit/HALKit/AMD64/HalAP.cc
index 4ab8671f..3405ea32 100644
--- a/dev/ZKAKit/HALKit/AMD64/HalSchedulerCoreAMD64.cc
+++ b/dev/ZKAKit/HALKit/AMD64/HalAP.cc
@@ -19,12 +19,17 @@ namespace Kernel
UserProcessScheduler::The().GetCurrentProcess().Leak().Crash();
}
+ /***********************************************************************************/
+ /// @brief Validate user stack.
+ /// @param stack_ptr the frame pointer.
+ /***********************************************************************************/
+
Bool hal_check_stack(HAL::StackFramePtr stack_ptr)
{
if (!stack_ptr)
return No;
- return Yes;
+ return stack_ptr->SP != 0 && stack_ptr->BP != 0;
}
/// @brief Wakes up thread.
diff --git a/dev/ZKAKit/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc b/dev/ZKAKit/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc
index b75f37ce..b5c35372 100644
--- a/dev/ZKAKit/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc
+++ b/dev/ZKAKit/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc
@@ -7,7 +7,7 @@
#include <ArchKit/ArchKit.h>
#include <KernelKit/UserProcessScheduler.h>
#include <NewKit/KString.h>
-#include <PosixKit/Signals.h>
+#include <POSIXKit/Signals.h>
/// @brief Handle GPF fault.
/// @param rsp
diff --git a/dev/ZKAKit/HALKit/ARM64/AP.h b/dev/ZKAKit/HALKit/ARM64/AP.h
new file mode 100644
index 00000000..ac2e7d21
--- /dev/null
+++ b/dev/ZKAKit/HALKit/ARM64/AP.h
@@ -0,0 +1,36 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024, 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 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 \ No newline at end of file
diff --git a/dev/ZKAKit/HALKit/ARM64/HalAP.cc b/dev/ZKAKit/HALKit/ARM64/HalAP.cc
new file mode 100644
index 00000000..dd4ecea4
--- /dev/null
+++ b/dev/ZKAKit/HALKit/ARM64/HalAP.cc
@@ -0,0 +1,40 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#include <HALKit/ARM64/Processor.h>
+#include <KernelKit/DebugOutput.h>
+#include <HALKit/ARM64/AP.h>
+
+using namespace Kernel;
+
+namespace Kernel::Details
+{
+ STATIC void mp_hang_fn(void)
+ {
+ while (YES)
+ ;
+ }
+} // namespace Kernel::Details
+
+/// @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::Details::mp_hang_fn));
+}
diff --git a/dev/ZKAKit/HALKit/ARM64/HalSchedulerCore.cc b/dev/ZKAKit/HALKit/ARM64/HalSchedulerCore.cc
new file mode 100644
index 00000000..a0088958
--- /dev/null
+++ b/dev/ZKAKit/HALKit/ARM64/HalSchedulerCore.cc
@@ -0,0 +1,34 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#include <HALKit/AMD64/Processor.h>
+#include <KernelKit/UserProcessScheduler.h>
+
+namespace Kernel
+{
+ /***********************************************************************************/
+ /// @brief Unimplemented function (crashes by default)
+ /// @param void
+ /***********************************************************************************/
+
+ EXTERN_C Void __zka_pure_call(void)
+ {
+ UserProcessScheduler::The().GetCurrentProcess().Leak().Crash();
+ }
+
+ /***********************************************************************************/
+ /// @brief Validate user stack.
+ /// @param stack_ptr the frame pointer.
+ /***********************************************************************************/
+
+ Bool hal_check_stack(HAL::StackFramePtr stack_ptr)
+ {
+ if (!stack_ptr)
+ return No;
+
+ return stack_ptr->SP != 0 && stack_ptr->BP != 0;
+ }
+} // namespace Kernel \ No newline at end of file
diff --git a/dev/ZKAKit/HALKit/POWER/AP.h b/dev/ZKAKit/HALKit/POWER/AP.h
new file mode 100644
index 00000000..10cf97ba
--- /dev/null
+++ b/dev/ZKAKit/HALKit/POWER/AP.h
@@ -0,0 +1,39 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
+
+ File: AP.h
+ Purpose: POWER hardware threads.
+
+ Revision History:
+
+ 14/04/24: Added file (amlel)
+
+------------------------------------------- */
+
+#pragma once
+
+#include <NewKit/Defines.h>
+
+namespace Kernel
+{
+ struct HAL_HARDWARE_THREAD;
+
+ /// @brief hardware thread indentification type.
+ typedef Kernel::Int32 hal_ap_kind;
+
+ /// @brief Hardware thread information structure.
+ 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 \ No newline at end of file
diff --git a/dev/ZKAKit/HALKit/POWER/HalHart.cc b/dev/ZKAKit/HALKit/POWER/HalAP.cc
index ed42014a..df261d94 100644
--- a/dev/ZKAKit/HALKit/POWER/HalHart.cc
+++ b/dev/ZKAKit/HALKit/POWER/HalAP.cc
@@ -6,20 +6,35 @@
#include <HALKit/POWER/Processor.h>
#include <KernelKit/DebugOutput.h>
-#include <HALKit/POWER/Hart.h>
+#include <HALKit/POWER/AP.h>
using namespace Kernel;
+namespace Kernel::Details
+{
+ STATIC void mp_hang_fn(void)
+ {
+ while (YES)
+ ;
+ }
+} // namespace Kernel::Details
+
/// @brief wakes up thread.
/// wakes up thread from hang.
void mp_wakeup_thread(HAL::StackFramePtr stack)
{
- ZKA_UNUSED(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)
{
- ZKA_UNUSED(stack);
+ if (!stack)
+ return;
+
+ hal_set_pc_to_hart(reinterpret_cast<HAL_HARDWARE_THREAD*>(stack->R15), reinterpret_cast<VoidPtr>(Kernel::Details::mp_hang_fn));
}
diff --git a/dev/ZKAKit/HALKit/POWER/Hart.h b/dev/ZKAKit/HALKit/POWER/Hart.h
deleted file mode 100644
index f3a14737..00000000
--- a/dev/ZKAKit/HALKit/POWER/Hart.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* -------------------------------------------
-
- Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
-
- File: Hart.h
- Purpose: POWER hardware threads.
-
- Revision History:
-
- 14/04/24: Added file (amlel)
-
-------------------------------------------- */
-
-#pragma once
-
-#include <NewKit/Defines.h>
-
-struct HAL_HARDWARE_THREAD;
-
-/// @brief hardware thread indentification type.
-typedef Kernel::Int32 PPCHartType;
-
-/// @brief Hardware thread information structure.
-typedef struct HAL_HARDWARE_THREAD
-{
- Kernel::UIntPtr fStartAddress;
- Kernel::UInt8 fPrivleged : 1;
- Kernel::UInt32 fPagkMMFlags;
- PPCHartType 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);
diff --git a/dev/ZKAKit/HALKit/RISCV/AP.h b/dev/ZKAKit/HALKit/RISCV/AP.h
new file mode 100644
index 00000000..ac2e7d21
--- /dev/null
+++ b/dev/ZKAKit/HALKit/RISCV/AP.h
@@ -0,0 +1,36 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024, 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 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 \ No newline at end of file
diff --git a/dev/ZKAKit/HALKit/RISCV/HalAP.cc b/dev/ZKAKit/HALKit/RISCV/HalAP.cc
new file mode 100644
index 00000000..05cd2f8a
--- /dev/null
+++ b/dev/ZKAKit/HALKit/RISCV/HalAP.cc
@@ -0,0 +1,40 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024, 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::Details
+{
+ STATIC void mp_hang_fn(void)
+ {
+ while (YES)
+ ;
+ }
+} // namespace Kernel::Details
+
+/// @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::Details::mp_hang_fn));
+}
diff --git a/dev/ZKAKit/HALKit/RISCV/Hart.h b/dev/ZKAKit/HALKit/RISCV/Hart.h
deleted file mode 100644
index 6249cf7b..00000000
--- a/dev/ZKAKit/HALKit/RISCV/Hart.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* -------------------------------------------
-
- Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
-
- File: Hart.h
- Purpose: RISC-V hardware threads.
-
- Revision History:
-
- 30/01/24: Added file (amlel)
-
-------------------------------------------- */
-
-#pragma once
-
-#include <NewKit/Defines.h>
-
-typedef Kernel::Int32 Rv64HartType;
-
-/// @brief Set PC to specific hart.
-/// @param hart the hart
-/// @param epc the pc.
-/// @return
-EXTERN_C Kernel::Void hal_set_pc_to_hart(Rv64HartType hart, Kernel::VoidPtr epc);
diff --git a/dev/ZKAKit/KernelKit/HardwareThreadScheduler.h b/dev/ZKAKit/KernelKit/HardwareThreadScheduler.h
index c020f4d4..44ea1042 100644
--- a/dev/ZKAKit/KernelKit/HardwareThreadScheduler.h
+++ b/dev/ZKAKit/KernelKit/HardwareThreadScheduler.h
@@ -14,7 +14,7 @@
/// @note Last Rev Sun 28 Jul CET 2024
/// @note Last Rev Thu, Aug 1, 2024 9:07:38 AM
-#define kMaxHartInsideSched (8U)
+#define kMaxAPInsideSched (8U)
namespace Kernel
{
@@ -25,13 +25,13 @@ namespace Kernel
enum ThreadKind
{
- kHartSystemReserved, // System reserved thread, well user can't use it
- kHartStandard, // user thread, cannot be used by Kernel
- kHartFallback, // fallback thread, cannot be used by user if not clear or
+ kAPSystemReserved, // System reserved thread, well user can't use it
+ kAPStandard, // user thread, cannot be used by Kernel
+ kAPFallback, // fallback thread, cannot be used by user if not clear or
// used by Kernel.
- kHartBoot, // The core we booted from, the mama.
- kInvalidHart,
- kHartCount,
+ kAPBoot, // The core we booted from, the mama.
+ kInvalidAP,
+ kAPCount,
};
typedef enum ThreadKind ThreadKind;
@@ -72,7 +72,7 @@ namespace Kernel
private:
HAL::StackFramePtr fStack{nullptr};
- ThreadKind fKind{ThreadKind::kHartStandard};
+ ThreadKind fKind{ThreadKind::kAPStandard};
ThreadID fID{0};
ProcessID fSourcePID{-1};
Bool fWakeup{false};
@@ -89,7 +89,7 @@ namespace Kernel
/// \brief Class to manage the thread scheduling.
///
- class HardwareThreadScheduler final : public ISchedulerObject
+ class HardwareThreadScheduler final : public ISchedulable
{
private:
friend class UserProcessHelper;
@@ -133,7 +133,7 @@ namespace Kernel
SizeT Capacity() noexcept;
private:
- Array<HardwareThread, kMaxHartInsideSched> fThreadList;
+ Array<HardwareThread, kMaxAPInsideSched> fThreadList;
ThreadID fCurrentThread{0};
};
diff --git a/dev/ZKAKit/KernelKit/UserProcessScheduler.h b/dev/ZKAKit/KernelKit/UserProcessScheduler.h
index 59e1a525..a974fa3a 100644
--- a/dev/ZKAKit/KernelKit/UserProcessScheduler.h
+++ b/dev/ZKAKit/KernelKit/UserProcessScheduler.h
@@ -273,7 +273,7 @@ namespace Kernel
/// @brief Process scheduler class.
/// The main class which you call to schedule user processes.
- class UserProcessScheduler final : public ISchedulerObject
+ class UserProcessScheduler final : public ISchedulable
{
friend class UserProcessHelper;
diff --git a/dev/ZKAKit/NetworkKit/LTE.h b/dev/ZKAKit/NetworkKit/LTE.h
index c6c01f64..7aa99ec6 100644
--- a/dev/ZKAKit/NetworkKit/LTE.h
+++ b/dev/ZKAKit/NetworkKit/LTE.h
@@ -11,6 +11,6 @@
#define _INC_NETWORK_LTE_H_
#include <NewKit/Defines.h>
-#include <NewKit/String.h>
+#include <NewKit/KString.h>
#endif // ifndef _INC_NETWORK_LTE_H_
diff --git a/dev/ZKAKit/NewKit/Defines.h b/dev/ZKAKit/NewKit/Defines.h
index 142e552e..9a11eed0 100644
--- a/dev/ZKAKit/NewKit/Defines.h
+++ b/dev/ZKAKit/NewKit/Defines.h
@@ -81,7 +81,7 @@ namespace Kernel
kEndianBig,
kEndianLittle,
kEndianMixed,
- kCount
+ kEndianCount
};
/// @brief Forward object.
@@ -106,14 +106,14 @@ namespace Kernel
/// @brief Encoding interface, used as a proxy to convert T to Char*
/// Used to cast A to B or B to A.
- class IEncoderObject
+ class ICodec
{
public:
- explicit IEncoderObject() = default;
- virtual ~IEncoderObject() = default;
+ explicit ICodec() = default;
+ virtual ~ICodec() = default;
- IEncoderObject& operator=(const IEncoderObject&) = default;
- IEncoderObject(const IEncoderObject&) = default;
+ ICodec& operator=(const ICodec&) = default;
+ ICodec(const ICodec&) = default;
public:
/// @brief Convert type to bytes.
@@ -126,6 +126,17 @@ namespace Kernel
return nullptr;
}
+ /// @brief Construct from type to class.
+ /// @tparam T the type to convert.
+ /// @param type (a1) the data.
+ /// @return a1 as Char*
+ template <typename OutputClass, typename FactoryClass>
+ OutputClass* Construct(Char* type) noexcept
+ {
+ FactoryClass class_fac;
+ return class_fac.template From<OutputClass>(type);
+ }
+
/// @brief Convert T class to Y class.
/// @tparam T the class type of type.
/// @tparam Y the result class.
@@ -134,7 +145,7 @@ namespace Kernel
template <typename T, typename Y>
Y As(T type) noexcept
{
- if (type.IsSerializable())
+ if (type.template IsSerializable())
{
return reinterpret_cast<Char*>(type);
}
@@ -145,31 +156,31 @@ namespace Kernel
/// \brief Scheduler interface, represents a scheduler object.
/// @note This is used to schedule tasks, such as threads, drivers, user threads, etc.
- class ISchedulerObject
+ class ISchedulable
{
public:
- explicit ISchedulerObject() = default;
- virtual ~ISchedulerObject() = default;
+ explicit ISchedulable() = default;
+ virtual ~ISchedulable() = default;
- ISchedulerObject& operator=(const ISchedulerObject&) = default;
- ISchedulerObject(const ISchedulerObject&) = default;
+ ISchedulable& operator=(const ISchedulable&) = default;
+ ISchedulable(const ISchedulable&) = default;
/// @brief Is this object only accepting user tasks?
virtual const Bool IsUser()
{
- return false;
+ return NO;
}
/// @brief Is this object only accepting kernel tasks?
virtual const Bool IsKernel()
{
- return false;
+ return NO;
}
/// @brief Is this object offloading to another CPU?
virtual const Bool HasMP()
{
- return false;
+ return NO;
}
};
} // namespace Kernel
diff --git a/dev/ZKAKit/POSIXKit/signal.h b/dev/ZKAKit/POSIXKit/signal.h
new file mode 100644
index 00000000..6698ff34
--- /dev/null
+++ b/dev/ZKAKit/POSIXKit/signal.h
@@ -0,0 +1,20 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#pragma once
+
+/** https://pubs.opengroup.org/onlinepubs/009695399/basedefs/signal.h.html */
+
+#include <POSIXKit/unix_layer.h>
+
+typedef Kernel::UInt32 signal_t;
+
+#define SIGKILL 0
+#define SIGPAUS 1
+#define SIGEXEC 2
+#define SIGTRAP 3
+#define SIGABRT 4
+#define SIGCONT 5 \ No newline at end of file
diff --git a/dev/ZKAKit/PosixKit/Signals.h b/dev/ZKAKit/POSIXKit/unix_layer.h
index 57a27268..c278aa19 100644
--- a/dev/ZKAKit/PosixKit/Signals.h
+++ b/dev/ZKAKit/POSIXKit/unix_layer.h
@@ -1,16 +1,11 @@
-/* -------------------------------------------
-
- Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
-
-------------------------------------------- */
-
-#pragma once
-
-#include <NewKit/Defines.h>
-
-typedef Kernel::UInt32 signal_t;
-
-#define SIGKILL 0
-#define SIGPAUS 1
-#define SIGEXEC 2
-#define SIGTRAP 3 \ No newline at end of file
+/* -------------------------------------------
+
+ Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#pragma once
+
+#include <NewKit/Defines.h>
+#include <KernelKit/UserProcessScheduler.h>
+#include <KernelKit/PEFCodeMgr.h>
diff --git a/dev/ZKAKit/src/FS/HPFS.cc b/dev/ZKAKit/src/FS/HPFS.cc
index e08ee5a7..58478dea 100644
--- a/dev/ZKAKit/src/FS/HPFS.cc
+++ b/dev/ZKAKit/src/FS/HPFS.cc
@@ -13,7 +13,7 @@
#include <KernelKit/LPC.h>
#include <NewKit/Crc32.h>
#include <NewKit/Stop.h>
-#include <NewKit/String.h>
+#include <NewKit/KString.h>
#include <NewKit/Utils.h>
#include <FirmwareKit/EPM.h>
#include <KernelKit/UserProcessScheduler.h>
diff --git a/dev/ZKAKit/src/HardwareThreadScheduler.cc b/dev/ZKAKit/src/HardwareThreadScheduler.cc
index e06942d9..036fa898 100644
--- a/dev/ZKAKit/src/HardwareThreadScheduler.cc
+++ b/dev/ZKAKit/src/HardwareThreadScheduler.cc
@@ -9,39 +9,56 @@
#include <KernelKit/HardwareThreadScheduler.h>
#include <CFKit/Property.h>
-///! BUGS: 0
-
-///! @file MP.cc
+/***********************************************************************************/
+///! @file HardwareThreadScheduler.cc
///! @brief This file handles multi processing in the Kernel.
///! @brief Multi processing is needed for multi-tasking operations.
+/***********************************************************************************/
namespace Kernel
{
- HardwareThreadScheduler kHardwareThreadScheduler;
+ /***********************************************************************************/
+ /// @note Those symbols are needed in order to switch and validate the stack.
+ /***********************************************************************************/
+
+ EXTERN Bool hal_check_stack(HAL::StackFramePtr frame_ptr);
+ EXTERN_C Bool mp_register_process(VoidPtr image, Ptr8 stack_ptr, HAL::StackFramePtr frame, ProcessID pid);
+
+ STATIC HardwareThreadScheduler kHardwareThreadScheduler;
///! A HardwareThread class takes care of it's owned hardware thread.
///! It has a stack for it's core.
+ /***********************************************************************************/
///! @brief C++ constructor.
+ /***********************************************************************************/
HardwareThread::HardwareThread() = default;
+ /***********************************************************************************/
///! @brief C++ destructor.
+ /***********************************************************************************/
HardwareThread::~HardwareThread() = default;
+ /***********************************************************************************/
//! @brief returns the id of the thread.
+ /***********************************************************************************/
const ThreadID& HardwareThread::ID() noexcept
{
return fID;
}
+ /***********************************************************************************/
//! @brief returns the kind of thread we have.
+ /***********************************************************************************/
const ThreadKind& HardwareThread::Kind() noexcept
{
return fKind;
}
+ /***********************************************************************************/
//! @brief is the thread busy?
//! @return whether the thread is busy or not.
+ /***********************************************************************************/
Bool HardwareThread::IsBusy() noexcept
{
STATIC Int64 busy_timer = 0U;
@@ -57,7 +74,9 @@ namespace Kernel
return fBusy;
}
+ /***********************************************************************************/
/// @brief Get processor stack frame.
+ /***********************************************************************************/
HAL::StackFramePtr HardwareThread::StackFrame() noexcept
{
@@ -72,10 +91,12 @@ namespace Kernel
HardwareThread::operator bool()
{
- return fStack;
+ return this->fStack && !this->fBusy;
}
+ /***********************************************************************************/
/// @brief Wakeup the processor.
+ /***********************************************************************************/
Void HardwareThread::Wake(const bool wakeup) noexcept
{
@@ -87,15 +108,12 @@ namespace Kernel
mp_wakeup_thread(fStack);
}
- /// @note Those symbols are needed in order to switch and validate the stack.
-
- EXTERN Bool hal_check_stack(HAL::StackFramePtr frame_ptr);
- EXTERN_C Bool mp_register_process(VoidPtr image, Ptr8 stack_ptr, HAL::StackFramePtr frame, ProcessID pid);
-
+ /***********************************************************************************/
/// @brief Switch to hardware thread.
/// @param stack the new hardware thread.
/// @retval true stack was changed, code is running.
/// @retval false stack is invalid, previous code is running.
+ /***********************************************************************************/
Bool HardwareThread::Switch(VoidPtr image, Ptr8 stack_ptr, HAL::StackFramePtr frame, const ProcessID& pid)
{
if (!frame ||
@@ -123,47 +141,59 @@ namespace Kernel
return ret;
}
+ /***********************************************************************************/
///! @brief Tells if processor is waked up.
+ /***********************************************************************************/
bool HardwareThread::IsWakeup() noexcept
{
return fWakeup;
}
+ /***********************************************************************************/
///! @brief Constructor and destructors.
-
///! @brief Default constructor.
+ /***********************************************************************************/
+
HardwareThreadScheduler::HardwareThreadScheduler() = default;
+ /***********************************************************************************/
///! @brief Default destructor.
+ /***********************************************************************************/
HardwareThreadScheduler::~HardwareThreadScheduler() = default;
+ /***********************************************************************************/
/// @brief Shared singleton function
+ /***********************************************************************************/
HardwareThreadScheduler& HardwareThreadScheduler::The()
{
return kHardwareThreadScheduler;
}
- /// @brief Get Stack Frame of Core
+ /***********************************************************************************/
+ /// @brief Get Stack Frame of AP.
+ /***********************************************************************************/
HAL::StackFramePtr HardwareThreadScheduler::Leak() noexcept
{
return fThreadList[fCurrentThread].fStack;
}
+ /***********************************************************************************/
/**
* Get Hardware thread at index.
* @param idx the index
* @return the reference to the hardware thread.
*/
+ /***********************************************************************************/
Ref<HardwareThread*> HardwareThreadScheduler::operator[](const SizeT& idx)
{
if (idx == 0)
{
- if (fThreadList[idx].Kind() != kHartSystemReserved)
+ if (fThreadList[idx].Kind() != kAPSystemReserved)
{
- fThreadList[idx].fKind = kHartBoot;
+ fThreadList[idx].fKind = kAPBoot;
}
}
- else if (idx >= kMaxHartInsideSched)
+ else if (idx >= kMaxAPInsideSched)
{
static HardwareThread* fakeThread = nullptr;
return {fakeThread};
@@ -172,28 +202,37 @@ namespace Kernel
return &fThreadList[idx];
}
+ /***********************************************************************************/
/**
* Check if thread pool isn't empty.
* @return
*/
+ /***********************************************************************************/
HardwareThreadScheduler::operator bool() noexcept
{
return !fThreadList.Empty();
}
+ /***********************************************************************************/
/**
* Reverse operator bool
* @return
*/
+ /***********************************************************************************/
bool HardwareThreadScheduler::operator!() noexcept
{
return fThreadList.Empty();
}
+ /***********************************************************************************/
/// @brief Returns the amount of core present.
- /// @return the number of cores.
+ /// @return the number of APs.
+ /***********************************************************************************/
SizeT HardwareThreadScheduler::Capacity() noexcept
{
+ if (fThreadList.Empty())
+ return 0UL;
+
return fThreadList.Capacity();
}
} // namespace Kernel
diff --git a/dev/ZKAKit/src/ThreadLocalStorage.cc b/dev/ZKAKit/src/ThreadLocalStorage.cc
index c6089824..5fdf56aa 100644
--- a/dev/ZKAKit/src/ThreadLocalStorage.cc
+++ b/dev/ZKAKit/src/ThreadLocalStorage.cc
@@ -32,8 +32,8 @@ Boolean tls_check_tib(THREAD_INFORMATION_BLOCK* tib_ptr)
!tib_ptr->Record)
return false;
- IEncoderObject encoder;
- const char* tib_as_bytes = encoder.AsBytes(tib_ptr);
+ ICodec encoder;
+ const Char* tib_as_bytes = encoder.AsBytes(tib_ptr);
kcout << "Checking for a valid cookie inside the TIB...\r";
diff --git a/dev/ZKAKit/src/UserProcessScheduler.cc b/dev/ZKAKit/src/UserProcessScheduler.cc
index 3c7e8879..4b24d98a 100644
--- a/dev/ZKAKit/src/UserProcessScheduler.cc
+++ b/dev/ZKAKit/src/UserProcessScheduler.cc
@@ -515,13 +515,16 @@ namespace Kernel
for (SizeT index = 0UL; index < HardwareThreadScheduler::The().Capacity(); ++index)
{
- if (HardwareThreadScheduler::The()[index].Leak()->Kind() == kInvalidHart)
+ if (!HardwareThreadScheduler::The()[index].Leak())
+ continue;
+
+ if (HardwareThreadScheduler::The()[index].Leak()->Kind() == kInvalidAP)
continue;
if (HardwareThreadScheduler::The()[index].Leak()->Kind() !=
- ThreadKind::kHartBoot &&
+ ThreadKind::kAPBoot &&
HardwareThreadScheduler::The()[index].Leak()->Kind() !=
- ThreadKind::kHartSystemReserved)
+ ThreadKind::kAPSystemReserved)
{
PID prev_pid = UserProcessHelper::TheCurrentPID();
UserProcessHelper::TheCurrentPID().Leak().Leak() = new_pid;