diff options
| author | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-05 15:21:26 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-05 15:21:47 +0100 |
| commit | b3666c011a512d7758a8c095872241e8f3964850 (patch) | |
| tree | fedd546a3179a9ee5cd2c498cf905559eb417b9a | |
| parent | 81144dd05a7c01701c3bf7b04e345dccfef2bf82 (diff) | |
HCR-11: See below;
Bootloader:
- Fix BFileReader on UEFI.
Kernel:
- Improve The scheduler and SMP manager.
Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
| -rw-r--r-- | Private/HALKit/AMD64/HalProcessPrimitives.cxx | 6 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalSMPCoreManager.asm | 5 | ||||
| -rw-r--r-- | Private/KernelKit/ProcessManager.hpp | 8 | ||||
| -rw-r--r-- | Private/NewBoot/BootKit/BootKit.hxx | 2 | ||||
| -rw-r--r-- | Private/NewBoot/Source/FileReader.cxx | 23 | ||||
| -rw-r--r-- | Private/Source/ProcessManager.cxx | 7 |
6 files changed, 22 insertions, 29 deletions
diff --git a/Private/HALKit/AMD64/HalProcessPrimitives.cxx b/Private/HALKit/AMD64/HalProcessPrimitives.cxx index 86f77e35..36cd26db 100644 --- a/Private/HALKit/AMD64/HalProcessPrimitives.cxx +++ b/Private/HALKit/AMD64/HalProcessPrimitives.cxx @@ -14,10 +14,6 @@ using namespace HCore; Void Process::AssignStart(UIntPtr &imageStart) noexcept { if (imageStart == 0) this->Crash(); -#ifdef __x86_64__ this->StackFrame->Rbp = imageStart; -#elif defined(__powerpc) - // link return register towards the __start symbol. - this->StackFrame->R3 = imageStart; -#endif + this->StackFrame->Rsp = this->StackFrame->Rbp; } diff --git a/Private/HALKit/AMD64/HalSMPCoreManager.asm b/Private/HALKit/AMD64/HalSMPCoreManager.asm index 9741d092..08f34517 100644 --- a/Private/HALKit/AMD64/HalSMPCoreManager.asm +++ b/Private/HALKit/AMD64/HalSMPCoreManager.asm @@ -15,7 +15,7 @@ section .text rt_do_context_switch: mov rcx, r15 - + mov [r15+0], rax mov [r15+8], rbx mov [r15+16], rcx @@ -32,4 +32,7 @@ rt_do_context_switch: mov [r15+104], r13 mov [r15+112], r14 mov [r15+120], r15 + + ;; Set APIC address of current core. + ret diff --git a/Private/KernelKit/ProcessManager.hpp b/Private/KernelKit/ProcessManager.hpp index 8c536a3b..52c3e7b3 100644 --- a/Private/KernelKit/ProcessManager.hpp +++ b/Private/KernelKit/ProcessManager.hpp @@ -114,10 +114,10 @@ class Process final { void AssignStart(UIntPtr &imageStart) noexcept; public: - Char Name[kProcessLen] = {"HCore Process"}; - ProcessSubsystem SubSystem; - ProcessSelector Selector; - HAL::StackFrame *StackFrame{nullptr}; + Char Name[kProcessLen] = {"CoreProcess"}; + ProcessSubsystem SubSystem{0}; + ProcessSelector Selector{ProcessSelector::kRingUser}; + HAL::StackFramePtr StackFrame{nullptr}; AffinityKind Affinity; ProcessStatus Status; diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx index 9a34f568..c768ca9c 100644 --- a/Private/NewBoot/BootKit/BootKit.hxx +++ b/Private/NewBoot/BootKit/BootKit.hxx @@ -93,6 +93,8 @@ class BFileReader final { UInt32 mSizeFile{0}; }; +#define kMaxReadSize (320) + /***********************************************************************************/ /// Include other APIs. /***********************************************************************************/ diff --git a/Private/NewBoot/Source/FileReader.cxx b/Private/NewBoot/Source/FileReader.cxx index a18c5093..8ee59237 100644 --- a/Private/NewBoot/Source/FileReader.cxx +++ b/Private/NewBoot/Source/FileReader.cxx @@ -110,21 +110,6 @@ Void BFileReader::ReadAll(EfiHandlePtr ImageHandle) { /// File FAT info. - UInt32 szInfo = sizeof(EfiFileInfo); - EfiFileInfo* info = nullptr; - - BS->AllocatePool(EfiLoaderData, szInfo, (void**)&info); - - guidEfp = EfiGUID(EFI_FILE_INFO_GUID); - - if (kernelFile->GetInfo(kernelFile, &guidEfp, &szInfo, info) != kEfiOk) { - mWriter.WriteString(L"HCoreLdr: Fetch-Protocol: No-Such-Path: ") - .WriteString(mPath) - .WriteString(L"\r\n"); - this->mErrorCode = kNotSupported; - return; - } - /// Allocate Handover page. VoidPtr blob = (VoidPtr)kHandoverStartKernel; @@ -134,12 +119,16 @@ Void BFileReader::ReadAll(EfiHandlePtr ImageHandle) { EFI::RaiseHardError(L"HCoreLdr_PageError", L"Allocation error."); } - mSizeFile = info->FileSize; + mSizeFile = KIB(kMaxReadSize); mFile = kernelFile; mErrorCode = kOperationOkay; mBlob = blob; - this->File()->Read(this->File(), &mSizeFile, this->Blob()); + mWriter.WriteString(L"HCoreLdr: ReadAll: FETCH: ") + .WriteString(mPath) + .WriteString(L"\r\n"); + + mFile->Read(mFile, &mSizeFile, mBlob); mWriter.WriteString(L"HCoreLdr: ReadAll: OK: ") .WriteString(mPath) diff --git a/Private/Source/ProcessManager.cxx b/Private/Source/ProcessManager.cxx index ea9ba1f5..af3fa351 100644 --- a/Private/Source/ProcessManager.cxx +++ b/Private/Source/ProcessManager.cxx @@ -133,8 +133,9 @@ void Process::Exit(Int32 exit_code) { if (this->Ring != (Int32)ProcessSelector::kRingDriver && this->Ring != (Int32)ProcessSelector::kRingKernel) { - ke_free_heap(this->Pool); + if (this->Pool) ke_free_heap(this->Pool); + this->Pool = nullptr; this->PoolCursor = nullptr; this->FreeMemory = kPoolMaxSz; @@ -143,9 +144,11 @@ void Process::Exit(Int32 exit_code) { //! Delete image if not done already. if (this->Image) ke_delete_ke_heap(this->Image); - if (this->StackFrame) ke_delete_ke_heap((VoidPtr)this->StackFrame); + this->Image = nullptr; + this->StackFrame = nullptr; + ProcessManager::Shared().Leak().Remove(this->ProcessId); } |
