diff options
| author | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-05 11:12:42 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-05 11:12:42 +0100 |
| commit | 81144dd05a7c01701c3bf7b04e345dccfef2bf82 (patch) | |
| tree | 163bd79816e97ca31484df86c008af3f9a803ffd /Private/Source | |
| parent | f8c9b81ff120160af60af6e9d44cba338aceb65a (diff) | |
HCR-11:
Kernel: Improvements and more.
Bootloader: Now works on real hardware (previous commit.)
Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Private/Source')
| -rw-r--r-- | Private/Source/PEFCodeManager.cxx | 2 | ||||
| -rw-r--r-- | Private/Source/ProcessManager.cxx | 8 | ||||
| -rw-r--r-- | Private/Source/SMPManager.cxx | 11 |
3 files changed, 19 insertions, 2 deletions
diff --git a/Private/Source/PEFCodeManager.cxx b/Private/Source/PEFCodeManager.cxx index efebef48..347f7f7a 100644 --- a/Private/Source/PEFCodeManager.cxx +++ b/Private/Source/PEFCodeManager.cxx @@ -43,7 +43,7 @@ PEFLoader::PEFLoader(const VoidPtr blob) : fCachedBlob(nullptr) { PEFLoader::PEFLoader(const char *path) : fCachedBlob(nullptr), fBad(false) { OwnPtr<FileStream<char>> file; - file.New(const_cast<Char *>(path)); + file.New(const_cast<Char *>(path), kRestrictRB); if (StringBuilder::Equals(file->MIME(), this->MIME())) { fPath = StringBuilder::Construct(path).Leak(); diff --git a/Private/Source/ProcessManager.cxx b/Private/Source/ProcessManager.cxx index 0c552b7f..ea9ba1f5 100644 --- a/Private/Source/ProcessManager.cxx +++ b/Private/Source/ProcessManager.cxx @@ -241,6 +241,9 @@ bool ProcessHelper::CanBeScheduled(Ref<Process> &process) { return process.Leak().PTime > static_cast<Int>(kMinMicroTime); } +/** + * @brief Scheduler spin code. + */ bool ProcessHelper::StartScheduling() { if (ProcessHelper::CanBeScheduled( ProcessManager::Shared().Leak().GetCurrent())) { @@ -256,7 +259,7 @@ bool ProcessHelper::StartScheduling() { SizeT ret = process_ref.Run(); kcout << StringBuilder::FromInt( - "ProcessHelper::StartScheduling() iterated over: % processes\r\n", ret); + "ProcessHelper::StartScheduling() Iterated over: % processes.\r\n", ret); return true; } @@ -265,6 +268,9 @@ bool ProcessHelper::Switch(HAL::StackFrame *the_stack, const PID &new_pid) { if (!the_stack || new_pid < 0) return false; for (SizeT index = 0UL; index < kMaxHarts; ++index) { + if (SMPManager::Shared().Leak()[index].Leak().Kind() == kInvalidThread) + continue; + if (SMPManager::Shared().Leak()[index].Leak().StackFrame() == the_stack) { SMPManager::Shared().Leak()[index].Leak().Busy(false); continue; diff --git a/Private/Source/SMPManager.cxx b/Private/Source/SMPManager.cxx index 87e82da1..d3c7a4c8 100644 --- a/Private/Source/SMPManager.cxx +++ b/Private/Source/SMPManager.cxx @@ -128,6 +128,17 @@ bool SMPManager::Switch(HAL::StackFrame* stack) { * @return the reference to the hardware thread. */ Ref<HardwareThread> SMPManager::operator[](const SizeT& idx) { + if (idx == 0) { + if (m_ThreadList[idx].Leak().Leak().Kind() != kSystemReserved) { + m_ThreadList[idx].Leak().Leak().m_Kind = kBoot; + } + } else if (idx >= kMaxHarts) { + HardwareThread fakeThread; + fakeThread.m_Kind = kInvalidThread; + + return {fakeThread}; + } + return m_ThreadList[idx].Leak(); } |
