diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-05-04 19:23:48 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-05-04 19:23:48 +0200 |
| commit | 770b1034a8f1bc401251ebbbeb8af82568829f09 (patch) | |
| tree | 1130dcc08167438f40189cbeff05d14125a04e09 /Private | |
| parent | fd7b08906adf40b81f3ac758ca55da501cb2283d (diff) | |
MHR-23: Improve code and add a ProcessSubsystem inside the scheduler.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private')
| -rw-r--r-- | Private/KernelKit/LoaderInterface.hpp | 2 | ||||
| -rw-r--r-- | Private/KernelKit/PEFCodeManager.hxx | 2 | ||||
| -rw-r--r-- | Private/KernelKit/ProcessScheduler.hpp | 11 | ||||
| -rw-r--r-- | Private/Source/PEFCodeManager.cxx | 19 |
4 files changed, 22 insertions, 12 deletions
diff --git a/Private/KernelKit/LoaderInterface.hpp b/Private/KernelKit/LoaderInterface.hpp index 09d0d7b5..97a12938 100644 --- a/Private/KernelKit/LoaderInterface.hpp +++ b/Private/KernelKit/LoaderInterface.hpp @@ -22,7 +22,7 @@ class LoaderInterface { NEWOS_COPY_DEFAULT(LoaderInterface); public: - virtual _Output const char* Format() = 0; + virtual _Output const char* FormatAsString() = 0; virtual _Output const char* MIME() = 0; virtual _Output const char* Path() = 0; virtual _Output ErrorOr<VoidPtr> FindStart() = 0; diff --git a/Private/KernelKit/PEFCodeManager.hxx b/Private/KernelKit/PEFCodeManager.hxx index a928e89e..2d8517cb 100644 --- a/Private/KernelKit/PEFCodeManager.hxx +++ b/Private/KernelKit/PEFCodeManager.hxx @@ -32,7 +32,7 @@ class PEFLoader : public LoaderInterface { public: const char *Path() override; - const char *Format() override; + const char *FormatAsString() override; const char *MIME() override; public: diff --git a/Private/KernelKit/ProcessScheduler.hpp b/Private/KernelKit/ProcessScheduler.hpp index 3085713f..3c080b15 100644 --- a/Private/KernelKit/ProcessScheduler.hpp +++ b/Private/KernelKit/ProcessScheduler.hpp @@ -93,7 +93,14 @@ inline bool operator>=(AffinityKind lhs, AffinityKind rhs) { // end of operator overloading. -using ProcessSubsystem = UInt32; +enum ProcessSubsystemEnum { + eProcessSubsystemLogin, + eProcessSubsystemNative, + eProcessSubsystemInvalid, + eProcessSubsystemCount, +}; + +using ProcessSubsystem = ProcessSubsystemEnum; using ProcessTime = UInt64; using PID = Int64; @@ -127,7 +134,7 @@ class ProcessHeader final { public: Char Name[kProcessLen] = {"NewOS Process"}; - ProcessSubsystem SubSystem{0}; + ProcessSubsystem SubSystem{ProcessSubsystem::eProcessSubsystemInvalid}; ProcessSelector Selector{ProcessSelector::kRingUser}; HAL::StackFramePtr StackFrame{nullptr}; AffinityKind Affinity; diff --git a/Private/Source/PEFCodeManager.cxx b/Private/Source/PEFCodeManager.cxx index cd1b301f..41a0d7f3 100644 --- a/Private/Source/PEFCodeManager.cxx +++ b/Private/Source/PEFCodeManager.cxx @@ -94,19 +94,22 @@ VoidPtr PEFLoader::FindSymbol(const char *name, Int32 kind) { PEFCommandHeader *container_header = reinterpret_cast<PEFCommandHeader *>( (UIntPtr)fCachedBlob + sizeof(PEFContainer)); + constexpr auto cMangleCharacter = '$'; + const char* cContainerKinds[] = { ".code64", ".data64", ".zero64", nullptr }; + ErrorOr<StringView> errOrSym; switch (kind) { case kPefCode: { - errOrSym = StringBuilder::Construct(".code64$"); + errOrSym = StringBuilder::Construct(cContainerKinds[0]); // code symbol. break; } case kPefData: { - errOrSym = StringBuilder::Construct(".data64$"); + errOrSym = StringBuilder::Construct(cContainerKinds[1]); // data symbol. break; } case kPefZero: { - errOrSym = StringBuilder::Construct(".zero64$"); + errOrSym = StringBuilder::Construct(cContainerKinds[2]); // block starting symbol. break; } default: @@ -115,9 +118,9 @@ VoidPtr PEFLoader::FindSymbol(const char *name, Int32 kind) { char *unconstSymbol = const_cast<char *>(name); - for (SizeT i = 0UL; i < rt_string_len(name, 0); ++i) { + for (SizeT i = 0UL; i < rt_string_len(unconstSymbol, kPefNameLen); ++i) { if (unconstSymbol[i] == ' ') { - unconstSymbol[i] = '$'; + unconstSymbol[i] = cMangleCharacter; } } @@ -170,7 +173,7 @@ bool execute_from_image(PEFLoader &exec, const Int32& procKind) noexcept { const char *PEFLoader::Path() { return fPath.Leak().CData(); } -const char *PEFLoader::Format() { +const char *PEFLoader::FormatAsString() { #ifdef __32x0__ return "32x0 PEF."; #elif defined(__64x0__) @@ -180,8 +183,8 @@ const char *PEFLoader::Format() { #elif defined(__powerpc64__) return "POWER PEF."; #else - return "Unknonwn PEF."; - #endif // __32x0__ || __64x0__ || __x86_64__ + return "Unknown PEF."; + #endif // __32x0__ || __64x0__ || __x86_64__ || __powerpc64__ } const char *PEFLoader::MIME() { return kPefApplicationMime; } |
