summaryrefslogtreecommitdiffhomepage
path: root/dev/ZKAKit/KernelKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-11-05 09:34:00 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-11-05 09:34:00 +0100
commitb636137088923d092c3f0fa4221907fd43c34923 (patch)
tree2d21e43349204866d17091cfb395cd2dd1b28a90 /dev/ZKAKit/KernelKit
parent4e7ea02ed492a1fc0b167392361673244f957cce (diff)
IMP: Scheduler improvements, fixing stack issue of kernel now.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZKAKit/KernelKit')
-rw-r--r--dev/ZKAKit/KernelKit/DebugOutput.h10
-rw-r--r--dev/ZKAKit/KernelKit/DriveMgr.h6
-rw-r--r--dev/ZKAKit/KernelKit/LoaderInterface.h1
-rw-r--r--dev/ZKAKit/KernelKit/PCI/Device.h16
-rw-r--r--dev/ZKAKit/KernelKit/PEFCodeMgr.h1
-rw-r--r--dev/ZKAKit/KernelKit/UserProcessScheduler.h23
6 files changed, 31 insertions, 26 deletions
diff --git a/dev/ZKAKit/KernelKit/DebugOutput.h b/dev/ZKAKit/KernelKit/DebugOutput.h
index ec098129..dce371dd 100644
--- a/dev/ZKAKit/KernelKit/DebugOutput.h
+++ b/dev/ZKAKit/KernelKit/DebugOutput.h
@@ -109,10 +109,10 @@ namespace Kernel
if (y < 0)
y = -y;
- const Char cNumbers[11] = "0123456789";
+ const Char kNumbers[11] = "0123456789";
Char buf[2];
- buf[0] = cNumbers[h];
+ buf[0] = kNumbers[h];
buf[1] = 0;
term.operator<<(buf);
@@ -128,7 +128,7 @@ namespace Kernel
_write_number_hex(y, term);
/* fail if the hex number is not base-16 */
- if (h > 15)
+ if (h > 16)
{
_write_number_hex('?', term);
return term;
@@ -137,10 +137,10 @@ namespace Kernel
if (y < 0)
y = -y;
- const Char cNumbers[17] = "0123456789ABCDEF";
+ const Char kNumbers[17] = "0123456789ABCDEF";
Char buf[2];
- buf[0] = cNumbers[h];
+ buf[0] = kNumbers[h];
buf[1] = 0;
term.operator<<(buf);
diff --git a/dev/ZKAKit/KernelKit/DriveMgr.h b/dev/ZKAKit/KernelKit/DriveMgr.h
index 38b9624a..9407f060 100644
--- a/dev/ZKAKit/KernelKit/DriveMgr.h
+++ b/dev/ZKAKit/KernelKit/DriveMgr.h
@@ -17,9 +17,9 @@
#include <NewKit/Ref.h>
#define kMaxDriveCountPerMountpoint (4U)
-
-#define kDriveInvalidID (-1)
-#define kDriveNameLen (32)
+#define kDriveSectorSz (512U)
+#define kDriveInvalidID (-1)
+#define kDriveNameLen (32)
#define DrvSectorCnt(SIZE, SECTOR_SZ) (((SIZE) + (SECTOR_SZ)) / (SECTOR_SZ))
diff --git a/dev/ZKAKit/KernelKit/LoaderInterface.h b/dev/ZKAKit/KernelKit/LoaderInterface.h
index a8b4625c..7f759ac3 100644
--- a/dev/ZKAKit/KernelKit/LoaderInterface.h
+++ b/dev/ZKAKit/KernelKit/LoaderInterface.h
@@ -24,6 +24,7 @@ namespace Kernel
ZKA_COPY_DEFAULT(LoaderInterface);
public:
+ virtual _Output ErrorOr<VoidPtr> GetBlob() = 0;
virtual _Output const Char* AsString() = 0;
virtual _Output const Char* MIME() = 0;
virtual _Output const Char* Path() = 0;
diff --git a/dev/ZKAKit/KernelKit/PCI/Device.h b/dev/ZKAKit/KernelKit/PCI/Device.h
index a37837f1..1b51e175 100644
--- a/dev/ZKAKit/KernelKit/PCI/Device.h
+++ b/dev/ZKAKit/KernelKit/PCI/Device.h
@@ -53,14 +53,14 @@ namespace Kernel::PCI
}
public:
- UShort DeviceId();
- UShort VendorId();
- UShort InterfaceId();
- UChar Class();
- UChar Subclass();
- UChar ProgIf();
- UChar HeaderType();
- UInt32 Bar(UInt32 bar_in);
+ UShort DeviceId();
+ UShort VendorId();
+ UShort InterfaceId();
+ UChar Class();
+ UChar Subclass();
+ UChar ProgIf();
+ UChar HeaderType();
+ UIntPtr Bar(UInt32 bar_in);
public:
void EnableMmio(UInt32 bar_in);
diff --git a/dev/ZKAKit/KernelKit/PEFCodeMgr.h b/dev/ZKAKit/KernelKit/PEFCodeMgr.h
index 6887f521..89b4ea40 100644
--- a/dev/ZKAKit/KernelKit/PEFCodeMgr.h
+++ b/dev/ZKAKit/KernelKit/PEFCodeMgr.h
@@ -41,6 +41,7 @@ namespace Kernel
public:
ErrorOr<VoidPtr> FindStart() override;
VoidPtr FindSymbol(const Char* name, Int32 kind) override;
+ ErrorOr<VoidPtr> GetBlob() override;
public:
bool IsLoaded() noexcept;
diff --git a/dev/ZKAKit/KernelKit/UserProcessScheduler.h b/dev/ZKAKit/KernelKit/UserProcessScheduler.h
index 9880b565..4f9b04e8 100644
--- a/dev/ZKAKit/KernelKit/UserProcessScheduler.h
+++ b/dev/ZKAKit/KernelKit/UserProcessScheduler.h
@@ -39,16 +39,18 @@ namespace Kernel
typedef Int64 ProcessID;
//! @brief Local Process name length.
- inline constexpr SizeT kProcessLen = 4096U;
+ inline constexpr SizeT kProcessNameLen = 4096U;
//! @brief Local Process status enum.
enum class ProcessStatusKind : Int32
{
+ kInvalid,
kStarting,
kRunning,
kKilled,
kFrozen,
- kDead
+ kDead,
+ kCount,
};
//! @brief Affinity is the amount of nano-seconds this process is going
@@ -134,17 +136,18 @@ namespace Kernel
~UserProcess();
public:
- ZKA_COPY_DEFAULT(UserProcess)
+ ZKA_COPY_DEFAULT(UserProcess);
public:
- Char Name[kProcessLen] = {"Application Process (Unnamed)"};
+ Char Name[kProcessNameLen] = {"Application Process (Unnamed)"};
ProcessSubsystem SubSystem{ProcessSubsystem::kProcessSubsystemInvalid};
User* Owner{nullptr};
HAL::StackFramePtr StackFrame{nullptr};
AffinityKind Affinity{AffinityKind::kStandard};
ProcessStatusKind Status{ProcessStatusKind::kDead};
UInt8* StackReserve{nullptr};
- ImagePtr Image{nullptr};
+ ImagePtr Code{nullptr};
+ ImagePtr ExecImg{nullptr};
SizeT StackSize{kSchedMaxStackSz};
IPEFDLLObject* PefDLLDelegate{nullptr};
SizeT MemoryCursor{0};
@@ -264,7 +267,7 @@ namespace Kernel
UserProcessTeam& CurrentTeam();
public:
- SizeT Add(UserProcess process);
+ ProcessID Add(UserProcess* process);
const Bool Remove(ProcessID process_id);
const Bool IsUser() override;
@@ -289,10 +292,10 @@ namespace Kernel
class UserProcessHelper final
{
public:
- STATIC bool Switch(VoidPtr image_ptr, UInt8* stack_ptr, HAL::StackFramePtr frame_ptr, const PID& new_pid);
- STATIC bool CanBeScheduled(const UserProcess& process);
- STATIC PID& TheCurrentPID();
- STATIC SizeT StartScheduling();
+ STATIC Bool Switch(VoidPtr image_ptr, UInt8* stack_ptr, HAL::StackFramePtr frame_ptr, const PID& new_pid);
+ STATIC Bool CanBeScheduled(const UserProcess& process);
+ STATIC ErrorOr<PID> TheCurrentPID();
+ STATIC SizeT StartScheduling();
};
const UInt32& sched_get_exit_code(void) noexcept;