diff options
| author | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-04 10:59:24 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-04 10:59:24 +0100 |
| commit | e2bbec91d70847cc5a2ff67eb84ca4a3c2d03e85 (patch) | |
| tree | 1e7fec7c232b0c750157007113ce8f86d43b7e76 /Private/Source | |
| parent | aff54fd3dc6855b62c047f126c6fe20ca717ee0f (diff) | |
Kernel: Depend less on NewFS, add support for FileSystem protocol in
NewBoot.
Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Private/Source')
| -rw-r--r-- | Private/Source/HError.cxx (renamed from Private/Source/OSErr.cxx) | 2 | ||||
| -rw-r--r-- | Private/Source/KernelHeap.cxx | 12 | ||||
| -rw-r--r-- | Private/Source/NewFS-IO.cxx | 7 | ||||
| -rw-r--r-- | Private/Source/NewFS-Journal.cxx | 7 | ||||
| -rw-r--r-- | Private/Source/NewFS.cxx | 9 | ||||
| -rw-r--r-- | Private/Source/PEFSharedObjectRT.cxx | 4 | ||||
| -rw-r--r-- | Private/Source/Storage/ATA.cxx | 8 | ||||
| -rw-r--r-- | Private/Source/UserHeap.cxx | 14 |
8 files changed, 44 insertions, 19 deletions
diff --git a/Private/Source/OSErr.cxx b/Private/Source/HError.cxx index 26a9ae7e..000843df 100644 --- a/Private/Source/OSErr.cxx +++ b/Private/Source/HError.cxx @@ -7,4 +7,4 @@ * ======================================================== */ -#include <KernelKit/OSErr.hpp> +#include <KernelKit/HError.hpp> diff --git a/Private/Source/KernelHeap.cxx b/Private/Source/KernelHeap.cxx index 3c3cb9ce..72aa2d67 100644 --- a/Private/Source/KernelHeap.cxx +++ b/Private/Source/KernelHeap.cxx @@ -21,7 +21,7 @@ static Ref<PTEWrapper *> kLastWrapper; static Pmm kPmm; namespace Detail { -static voidPtr find_ptr(const SizeT &sz, const bool rw, const bool user) { +STATIC voidPtr ke_find_heap(const SizeT &sz, const bool rw, const bool user) { for (SizeT indexWrapper = 0; indexWrapper < kMaxWrappers; ++indexWrapper) { if (!kWrapperList[indexWrapper]->Present()) { kWrapperList[indexWrapper] @@ -35,21 +35,19 @@ static voidPtr find_ptr(const SizeT &sz, const bool rw, const bool user) { } } // namespace Detail -/// @brief manual allocation +/// @brief Page allocation routine. /// @param sz size of pointer /// @param rw read write (true to enable it) /// @param user is it accesible by user processes? /// @return the pointer -VoidPtr ke_new_ke_heap(const SizeT &sz, const bool rw, const bool user) { - if (kWrapperCount < sz) return nullptr; +VoidPtr ke_new_ke_heap(SizeT sz, const bool rw, const bool user) { + if (sz == 0) ++sz; - if (auto ptr = Detail::find_ptr(sz, rw, user); ptr) return ptr; + if (auto ptr = Detail::ke_find_heap(sz, rw, user); ptr) return ptr; Ref<PTEWrapper *> wrapper = kPmm.RequestPage(user, rw); if (wrapper) { - wrapper->NoExecute(true); - kLastWrapper = wrapper; kWrapperList[kWrapperCount] = wrapper; diff --git a/Private/Source/NewFS-IO.cxx b/Private/Source/NewFS-IO.cxx index 2c044def..e90ed1a4 100644 --- a/Private/Source/NewFS-IO.cxx +++ b/Private/Source/NewFS-IO.cxx @@ -7,10 +7,13 @@ * ======================================================== */ -#include <FSKit/NewFS.hxx> #include <KernelKit/DriveManager.hpp> #include <KernelKit/FileManager.hpp> -/// @brief this implements NewFS with Device Abstraction in mind. +#ifdef __USE_NEWFS__ + +/// @brief This implements NewFS with Device Abstraction in mind. /// bugs 0 + +#endif // ifdef __USE_NEWFS__ diff --git a/Private/Source/NewFS-Journal.cxx b/Private/Source/NewFS-Journal.cxx index 029e051a..72812b6e 100644 --- a/Private/Source/NewFS-Journal.cxx +++ b/Private/Source/NewFS-Journal.cxx @@ -7,9 +7,12 @@ * ======================================================== */ -#include <FSKit/NewFS.hxx> #include <KernelKit/DebugOutput.hpp> +#include <KernelKit/FileManager.hpp> +#ifdef __USE_NEWFS__ + +//! bugs: 0 //! @brief Journaling for NewFS. #define kOpCache (4) @@ -57,3 +60,5 @@ class NewFSJournalRunner final { } }; } // namespace HCore + +#endif // ifdef __USE_NEWFS__ diff --git a/Private/Source/NewFS.cxx b/Private/Source/NewFS.cxx index 114c1e6b..2cb4fae9 100644 --- a/Private/Source/NewFS.cxx +++ b/Private/Source/NewFS.cxx @@ -7,9 +7,10 @@ * ======================================================== */ -#include <FSKit/NewFS.hxx> #include <KernelKit/FileManager.hpp> +#ifdef __USE_NEWFS__ + namespace HCore { NewFilesystemManager::NewFilesystemManager() = default; @@ -40,4 +41,10 @@ NodePtr NewFilesystemManager::CreateDirectory(const char* path) { NodePtr NewFilesystemManager::CreateAlias(const char* path) { return node_cast(fImpl->CreateCatalog(path, 0, kCatalogKindAlias)); } + +const char* NewFilesystemHelper::Root() { return kFilesystemRoot; } +const char* NewFilesystemHelper::UpDir() { return kFilesystemUpDir; } +const char NewFilesystemHelper::Separator() { return kFilesystemSeparator; } } // namespace HCore + +#endif // ifdef __USE_NEWFS__ diff --git a/Private/Source/PEFSharedObjectRT.cxx b/Private/Source/PEFSharedObjectRT.cxx index 035b068f..c13314df 100644 --- a/Private/Source/PEFSharedObjectRT.cxx +++ b/Private/Source/PEFSharedObjectRT.cxx @@ -66,7 +66,7 @@ extern "C" SharedObject *__LibInit() { library->Get()->fImageEntrypointOffset = library->Load<VoidPtr>(kPefStart, string_length(kPefStart, 0), kPefCode); - kcout << "__LibInit: Task was successful... Returning library...\n"; + kcout << "__LibInit: Task was successful!\n"; return library; } @@ -94,6 +94,8 @@ extern "C" Void __LibFini(SharedObjectPtr lib, bool *successful) { lib = nullptr; + kcout << "__LibFini: Task was successful!\n"; + *successful = true; } diff --git a/Private/Source/Storage/ATA.cxx b/Private/Source/Storage/ATA.cxx index 7d8ce32f..47c05ac8 100644 --- a/Private/Source/Storage/ATA.cxx +++ b/Private/Source/Storage/ATA.cxx @@ -40,6 +40,8 @@ enum { }; const char* ata_read_28(ULong lba) { + if (!kPrdt) return nullptr; + static char buffer[512]; UIntPtr* packet = (UIntPtr*)kPrdt.Leak()->PhysicalAddress(); @@ -56,6 +58,8 @@ const char* ata_read_28(ULong lba) { #define kBufferLen 512 const char* ata_read_48(ULong lba) { + if (!kPrdt) return nullptr; + static char buffer[kBufferLen]; rt_set_memory(buffer, 0, kBufferLen); @@ -71,6 +75,8 @@ const char* ata_read_48(ULong lba) { } Int32 ata_write_48(ULong lba, const char* buffer) { + if (!kPrdt) return kATAError; + UIntPtr* packet = reinterpret_cast<UIntPtr*>(kPrdt.Leak()->PhysicalAddress()); packet[0] = k48BitWrite; @@ -83,6 +89,8 @@ Int32 ata_write_48(ULong lba, const char* buffer) { } Int32 ata_write_28(ULong lba, const char* text) { + if (!kPrdt) return kATAError; + UIntPtr* packet = (UIntPtr*)kPrdt.Leak()->PhysicalAddress(); packet[0] = k28BitWrite; diff --git a/Private/Source/UserHeap.cxx b/Private/Source/UserHeap.cxx index e22fe4f9..6a173a44 100644 --- a/Private/Source/UserHeap.cxx +++ b/Private/Source/UserHeap.cxx @@ -12,8 +12,8 @@ /// @file Heap.cxx /// @brief Heap Manager, Process heap allocator. -/// @note if you want to look at the kernel allocator, please look for KernelHeap.cxx -/// bugs: 0 +/// @note if you want to look at the kernel allocator, please look for +/// KernelHeap.cxx bugs: 0 namespace HCore { /** @@ -105,10 +105,10 @@ STATIC void ke_free_heap_internal(voidPtr virtualAddress) { /** * @brief Check for the ptr and frees it. - * + * * @param index Where to look at. * @param ptr The ptr to check. - * @return Boolean true if successful. + * @return Boolean true if successful. */ STATIC Boolean ke_check_and_free_heap(const SizeT& index, voidPtr ptr) { if (HeapManager::The()[index]) { @@ -143,8 +143,8 @@ voidPtr ke_new_heap(Int32 flags) { if (voidPtr ret = ke_find_unused_heap(flags)) return ret; // this wasn't set to true - auto ref_page = HeapManager::Leak().Leak().RequestPage( - ((flags & kPoolUser)), (flags & kPoolRw)); + auto ref_page = HeapManager::Leak().Leak().RequestPage(((flags & kPoolUser)), + (flags & kPoolRw)); if (ref_page) { ///! reserve page. @@ -153,6 +153,8 @@ voidPtr ke_new_heap(Int32 flags) { ++ref; // increment the number of addresses we have now. + ref_page->NoExecute(true); + // finally make the pool address. return ke_make_heap( reinterpret_cast<voidPtr>(ref_page.Leak()->VirtualAddress()), flags); |
