summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal <amlal@el-mahrouss-logic.com>2024-09-11 11:45:52 +0200
committerAmlal <amlal@el-mahrouss-logic.com>2024-09-11 11:45:52 +0200
commit8b6cc0cbe5e19e8114a65785e24bbcf4d22e0d2f (patch)
tree3713620f703318ab9fb9ad6906263e68c64ee789
parent56fcf152004c913bddd19b6eeac1f96eb2c9b869 (diff)
IMP: Better architecture for task scheduling.
Signed-off-by: Amlal <amlal@el-mahrouss-logic.com>
-rw-r--r--dev/ZBA/Sources/HEL/AMD64/BootMain.cxx2
-rw-r--r--dev/ZKA/KernelKit/HardwareThreadScheduler.hxx17
-rw-r--r--dev/ZKA/KernelKit/UserProcessScheduler.hxx17
-rw-r--r--dev/ZKA/NewKit/Defines.hxx47
-rw-r--r--dev/ZKA/Sources/ThreadLocalStorage.cxx2
-rw-r--r--dev/ZKA/Sources/UserProcessScheduler.cxx2
6 files changed, 74 insertions, 13 deletions
diff --git a/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx b/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx
index 07fd0595..7e85296f 100644
--- a/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx
+++ b/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx
@@ -135,7 +135,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
auto guid_mp = EfiGUID(EFI_MP_SERVICES_PROTOCOL_GUID);
EfiMpServicesProtocol* mp = nullptr;
- extern EfiBootServices* BS;
+ EXTERN EfiBootServices* BS;
BS->LocateProtocol(&guid_mp, nullptr, reinterpret_cast<VoidPtr*>(&mp));
diff --git a/dev/ZKA/KernelKit/HardwareThreadScheduler.hxx b/dev/ZKA/KernelKit/HardwareThreadScheduler.hxx
index 193f5bff..302724fa 100644
--- a/dev/ZKA/KernelKit/HardwareThreadScheduler.hxx
+++ b/dev/ZKA/KernelKit/HardwareThreadScheduler.hxx
@@ -87,7 +87,7 @@ namespace Kernel
/// \brief Class to manage the thread scheduling.
///
- class HardwareThreadScheduler final
+ class HardwareThreadScheduler final : public ISchedulerObject
{
private:
friend class UserProcessHelper;
@@ -105,6 +105,21 @@ namespace Kernel
bool operator!() noexcept;
operator bool() noexcept;
+ const Bool IsUser() override
+ {
+ return Yes;
+ }
+
+ const Bool IsKernel() override
+ {
+ return No;
+ }
+
+ const Bool HasMP() override
+ {
+ return kHandoverHeader->f_HardwareTables.f_MultiProcessingEnabled;
+ }
+
public:
/// @brief Shared instance of the MP Mgr.
/// @return the reference to the mp manager class.
diff --git a/dev/ZKA/KernelKit/UserProcessScheduler.hxx b/dev/ZKA/KernelKit/UserProcessScheduler.hxx
index 845c0081..3a6f03a1 100644
--- a/dev/ZKA/KernelKit/UserProcessScheduler.hxx
+++ b/dev/ZKA/KernelKit/UserProcessScheduler.hxx
@@ -257,7 +257,7 @@ namespace Kernel
/// @brief UserProcess scheduler class.
/// The main class which you call to schedule processes.
- class UserProcessScheduler final
+ class UserProcessScheduler final : public ISchedulerObject
{
friend class UserProcessHelper;
@@ -278,6 +278,21 @@ namespace Kernel
SizeT Add(UserProcess processRef);
Bool Remove(ProcessID processSlot);
+ const Bool IsUser() override
+ {
+ return Yes;
+ }
+
+ const Bool IsKernel() override
+ {
+ return No;
+ }
+
+ const Bool HasMP() override
+ {
+ return kHandoverHeader->f_HardwareTables.f_MultiProcessingEnabled;
+ }
+
public:
Ref<UserProcess>& CurrentProcess();
SizeT Run() noexcept;
diff --git a/dev/ZKA/NewKit/Defines.hxx b/dev/ZKA/NewKit/Defines.hxx
index 77d400df..395b14a5 100644
--- a/dev/ZKA/NewKit/Defines.hxx
+++ b/dev/ZKA/NewKit/Defines.hxx
@@ -67,7 +67,7 @@ namespace Kernel
using WideChar = wchar_t;
using Utf32Char = char32_t;
- typedef UInt32 PhysicalAddressKind;
+ typedef UInt32 PhysicalAddressKind;
typedef UIntPtr VirtualAddressKind;
using Void = void;
@@ -103,16 +103,16 @@ namespace Kernel
return static_cast<Args&&>(arg);
}
- /// @brief Encoder class
+ /// @brief Coder/Decoder class, used as a proxy to convert T to Char*
/// Used to cast A to B or B to A.
- class Encoder final
+ class IEncoderObject final
{
public:
- explicit Encoder() = default;
- ~Encoder() = default;
+ explicit IEncoderObject() = default;
+ ~IEncoderObject() = default;
- Encoder& operator=(const Encoder&) = default;
- Encoder(const Encoder&) = default;
+ IEncoderObject& operator=(const IEncoderObject&) = default;
+ IEncoderObject(const IEncoderObject&) = default;
public:
/// @brief Convert type to bytes.
@@ -122,7 +122,7 @@ namespace Kernel
template <typename T>
Char* AsBytes(T type) noexcept
{
- return reinterpret_cast<Char*>(type);
+ return nullptr;
}
/// @brief Convert T class to Y class.
@@ -133,9 +133,40 @@ namespace Kernel
template <typename T, typename Y>
Y As(T type) noexcept
{
+ if (type.IsCastable())
+ {
+ return reinterpret_cast<Char*>(type);
+ }
+
return type.template As<Y>();
}
};
+
+ class ISchedulerObject
+ {
+ public:
+ explicit ISchedulerObject() = default;
+ virtual ~ISchedulerObject() = default;
+
+ ISchedulerObject& operator=(const ISchedulerObject&) = default;
+ ISchedulerObject(const ISchedulerObject&) = default;
+
+ virtual const Bool IsUser()
+ {
+ return false;
+ }
+
+ virtual const Bool IsKernel()
+ {
+ return false;
+ }
+
+ virtual const Bool HasMP()
+ {
+ return false;
+ }
+
+ };
} // namespace Kernel
#define DEDUCE_ENDIAN(address, value) \
diff --git a/dev/ZKA/Sources/ThreadLocalStorage.cxx b/dev/ZKA/Sources/ThreadLocalStorage.cxx
index 825761de..ed723c06 100644
--- a/dev/ZKA/Sources/ThreadLocalStorage.cxx
+++ b/dev/ZKA/Sources/ThreadLocalStorage.cxx
@@ -33,7 +33,7 @@ Boolean tls_check_tib(THREAD_INFORMATION_BLOCK* the_tib)
!the_tib->f_ThreadRecord)
return false;
- Encoder encoder;
+ IEncoderObject encoder;
const char* tibAsBytes = encoder.AsBytes(the_tib);
kcout << "checking for a valid cookie inside the TIB...\r";
diff --git a/dev/ZKA/Sources/UserProcessScheduler.cxx b/dev/ZKA/Sources/UserProcessScheduler.cxx
index 00f314d1..2d4c3836 100644
--- a/dev/ZKA/Sources/UserProcessScheduler.cxx
+++ b/dev/ZKA/Sources/UserProcessScheduler.cxx
@@ -3,7 +3,7 @@
Copyright ZKA Technologies.
FILE: UserProcessScheduler.cxx
- PURPOSE: User sided process scheduler.
+ PURPOSE: Low Exception Process scheduler.
------------------------------------------- */