diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-04-20 10:20:22 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-04-20 10:20:22 +0200 |
| commit | 7013c094668be2204b1245496236f0cf6afa07c2 (patch) | |
| tree | 2a15832577a580e51b55b758cb792d3225870157 /Private/Source | |
| parent | e5a591054ea0992acc3cb786d3af9f358febca6d (diff) | |
MHR-5/MHR-3: Rename PowerPC to POWER, implement NewFSParser::Format
method, documenting code.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/Source')
| -rw-r--r-- | Private/Source/AppMain.cxx (renamed from Private/Source/RuntimeMain.cxx) | 6 | ||||
| -rw-r--r-- | Private/Source/FS/NewFS.cxx | 123 | ||||
| -rw-r--r-- | Private/Source/PEFCodeManager.cxx | 15 |
3 files changed, 99 insertions, 45 deletions
diff --git a/Private/Source/RuntimeMain.cxx b/Private/Source/AppMain.cxx index 5bbee3b2..ba5d822f 100644 --- a/Private/Source/RuntimeMain.cxx +++ b/Private/Source/AppMain.cxx @@ -18,15 +18,15 @@ /// @file Main microkernel entrypoint. -EXTERN_C void RuntimeMain(void) { +EXTERN_C NewOS::Void AppMain(NewOS::Void) { ///! Mounts a NewFS block. NewOS::NewFilesystemManager* newFS = new NewOS::NewFilesystemManager(); NewOS::ke_protect_ke_heap(newFS); NewOS::FilesystemManagerInterface::Mount(newFS); - + while (NewOS::ProcessScheduler::Shared().Leak().Run() > 0); ///! we're done, unmount. delete newFS; -}
\ No newline at end of file +} diff --git a/Private/Source/FS/NewFS.cxx b/Private/Source/FS/NewFS.cxx index 1d7d3621..216db7c6 100644 --- a/Private/Source/FS/NewFS.cxx +++ b/Private/Source/FS/NewFS.cxx @@ -161,7 +161,53 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive) { return false; } - return true; + Char sectorBuf[kNewFSMinimumSectorSz] = {0}; + + drive->fPacket.fPacketContent = sectorBuf; + drive->fPacket.fPacketSize = kNewFSMinimumSectorSz; + drive->fPacket.fLba = kNewFSAddressAsLba; + + drive->fInput(&drive->fPacket); + + /// disk isnt faulty and data has been fetched. + if (drive->fPacket.fPacketGood) { + NewPartitionBlock* partBlock = (NewPartitionBlock*)sectorBuf; + if (partBlock->PartitionName[0] == 0 && + rt_string_cmp(partBlock->Ident, kNewFSIdent, kNewFSIdentLen) == 0) { + /// partition is free and valid. + + rt_copy_memory((VoidPtr)kNewFSIdent, (VoidPtr)partBlock->Ident, + kNewFSIdentLen); + rt_copy_memory((VoidPtr) "New OS\0", (VoidPtr)partBlock->PartitionName, + rt_string_len("New OS\0")); + + SizeT catalogCount = 0; + SizeT sectorCount = 0; + SizeT diskSize = 0; + + partBlock->Kind = kNewFSPartitionTypeStandard; + partBlock->StartCatalog = sizeof(NewPartitionBlock) + kNewFSAddressAsLba; + partBlock->CatalogCount = catalogCount; + partBlock->SectorCount = sectorCount; + partBlock->DiskSize = diskSize; + partBlock->FreeCatalog = partBlock->StartCatalog; + + drive->fPacket.fPacketContent = sectorBuf; + drive->fPacket.fPacketSize = kNewFSMinimumSectorSz; + drive->fPacket.fLba = kNewFSAddressAsLba; + + drive->fOutput(&drive->fPacket); + + return true; + } + + kcout << "New OS: Partition already exists.\r\n"; + + /// return success as well, do not ignore that partition. + return true; + } + + return false; } /// @brief @@ -173,73 +219,80 @@ bool NewFSParser::WriteCatalog(_Input _Output NewCatalog* catalog, return false; } -/// @brief -/// @param catalogName -/// @return +/// @brief +/// @param catalogName +/// @return _Output NewCatalog* NewFSParser::FindCatalog(_Input const char* catalogName) { return nullptr; } -/// @brief -/// @param name -/// @return +/// @brief +/// @param name +/// @return _Output NewCatalog* NewFSParser::GetCatalog(_Input const char* name) { return nullptr; } -/// @brief -/// @param catalog -/// @return +/// @brief +/// @param catalog +/// @return Boolean NewFSParser::CloseCatalog(_Input _Output NewCatalog* catalog) { - return false; + return true; } -/// @brief -/// @param catalog -/// @return +/// @brief Mark catalog as removed. +/// @param catalog The catalog structure. +/// @return Boolean NewFSParser::RemoveCatalog(_Input _Output NewCatalog* catalog) { + catalog->Flags |= kNewFSFlagDeleted; + this->WriteCatalog(catalog, nullptr); + return false; } -/// @brief -/// @param catalog -/// @param dataSz -/// @return +/// ***************************************************************** /// +/// Reading,Seek,Tell are unimplemented on catalogs, refer to forks I/O instead. +/// ***************************************************************** /// + +/// @brief +/// @param catalog +/// @param dataSz +/// @return VoidPtr NewFSParser::ReadCatalog(_Input _Output NewCatalog* catalog, SizeT dataSz) { return nullptr; } -/// @brief -/// @param catalog -/// @param off -/// @return +/// @brief +/// @param catalog +/// @param off +/// @return bool NewFSParser::Seek(_Input _Output NewCatalog* catalog, SizeT off) { return false; } -/// @brief -/// @param catalog -/// @return +/// @brief +/// @param catalog +/// @return SizeT NewFSParser::Tell(_Input _Output NewCatalog* catalog) { return 0; } -/// @brief -/// @param sz -/// @return +/// @brief +/// @param sz +/// @return STATIC Lba ke_find_free_fork(SizeT sz) { return 0; } -/// @brief -/// @param sz -/// @return +/// @brief +/// @param sz +/// @return STATIC Lba ke_find_free_catalog(SizeT sz) { return 0; } -/// @brief -/// @param sz -/// @return +/// @brief +/// @param sz +/// @return STATIC Lba ke_find_free_data(SizeT sz) { return 0; } namespace NewOS::Detail { Boolean fs_init_newfs(Void) noexcept { return false; } } // namespace NewOS::Detail -#endif // ifdef __FSKIT_NEWFS__
\ No newline at end of file +#endif // ifdef __FSKIT_NEWFS__ diff --git a/Private/Source/PEFCodeManager.cxx b/Private/Source/PEFCodeManager.cxx index f8616a8c..2f60f085 100644 --- a/Private/Source/PEFCodeManager.cxx +++ b/Private/Source/PEFCodeManager.cxx @@ -17,6 +17,7 @@ namespace NewOS { namespace Detail { +/// @brief Get the PEF platform signature according to the compiled backebnd UInt32 rt_get_pef_platform(void) noexcept { #ifdef __32x0__ return kPefArch32x0; @@ -33,7 +34,7 @@ UInt32 rt_get_pef_platform(void) noexcept { } // namespace Detail /// @brief PEF loader constructor w/ blob. -/// @param blob +/// @param blob PEFLoader::PEFLoader(const VoidPtr blob) : fCachedBlob(nullptr) { fCachedBlob = blob; fBad = false; @@ -42,11 +43,11 @@ PEFLoader::PEFLoader(const VoidPtr blob) : fCachedBlob(nullptr) { } /// @brief PEF loader constructor. -/// @param path -PEFLoader::PEFLoader(const char *path) : fCachedBlob(nullptr), fBad(false) { - OwnPtr<FileStream<char>> file; +/// @param path the filesystem path. +PEFLoader::PEFLoader(const Char* path) : fCachedBlob(nullptr), fBad(false) { + OwnPtr<FileStream<Char>> file; - file.New(const_cast<Char *>(path), kRestrictRB); + file.New(const_cast<Char*>(path), kRestrictRB); if (StringBuilder::Equals(file->MIME(), this->MIME())) { fPath = StringBuilder::Construct(path).Leak(); @@ -131,7 +132,7 @@ VoidPtr PEFLoader::FindSymbol(const char *name, Int32 kind) { } /// @brief Finds the executable entrypoint. -/// @return +/// @return ErrorOr<VoidPtr> PEFLoader::FindStart() { if (auto sym = this->FindSymbol(kPefStart, kPefCode); sym) return ErrorOr<VoidPtr>(sym); @@ -140,7 +141,7 @@ ErrorOr<VoidPtr> PEFLoader::FindStart() { } /// @brief Tells if the executable is loaded or not. -/// @return +/// @return bool PEFLoader::IsLoaded() noexcept { return !fBad && fCachedBlob; } #define kPefAppnameCommandHdr "PefAppName" |
