diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-08-24 08:51:21 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-08-24 08:54:22 +0200 |
| commit | 4185fcc698e237225902646736c6b23f6b5e54be (patch) | |
| tree | 7b0fc0bb58cb20c61e676b13e3e0f7fd52c73a56 /dev/ZKA/Sources | |
| parent | b31d81cd939ed3e8bb5fade029b32876e71ed54c (diff) | |
[IMP+REFACTORS] See below.
+ Add SysChk driver instead of BootScr.
+ Working on AHCI driver, did progress on detection, need to find out
why the signature are set to zero.
+ Refactor PE loader structures.
Add BecomeBusMaster call when probing AHCI disk.
+ Alongside some other modifications.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZKA/Sources')
| -rw-r--r-- | dev/ZKA/Sources/DLLMain.cxx | 189 | ||||
| -rw-r--r-- | dev/ZKA/Sources/DriveManager.cxx | 2 | ||||
| -rw-r--r-- | dev/ZKA/Sources/FS/NewFS.cxx | 4 |
3 files changed, 193 insertions, 2 deletions
diff --git a/dev/ZKA/Sources/DLLMain.cxx b/dev/ZKA/Sources/DLLMain.cxx new file mode 100644 index 00000000..edfc804f --- /dev/null +++ b/dev/ZKA/Sources/DLLMain.cxx @@ -0,0 +1,189 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + + File: Main.cxx + Purpose: Main entrypoint of kernel. + +------------------------------------------- */ + +#include <ArchKit/ArchKit.hxx> +#include <CompilerKit/Detail.hxx> +#include <FirmwareKit/Handover.hxx> +#include <KernelKit/FileManager.hxx> +#include <KernelKit/Framebuffer.hxx> +#include <KernelKit/Heap.hxx> +#include <KernelKit/PEF.hxx> +#include <KernelKit/PEFCodeManager.hxx> +#include <KernelKit/ProcessScheduler.hxx> +#include <KernelKit/ProcessHeap.hxx> +#include <NewKit/Json.hxx> +#include <NewKit/KernelCheck.hxx> +#include <NewKit/String.hxx> +#include <NewKit/Utils.hxx> +#include <KernelKit/CodeManager.hxx> +#include <CFKit/Property.hxx> + +EXTERN Kernel::Property cKernelVersion; + +namespace Kernel::Detail +{ + /// @brief Filesystem auto formatter, additional checks are also done by the class. + class FilesystemInstaller final + { + Kernel::NewFilesystemManager* fNewFS{nullptr}; + + public: + /// @brief wizard constructor. + explicit FilesystemInstaller() + { + if (Kernel::FilesystemManagerInterface::GetMounted()) + { + // Partition is mounted, cool! + Kernel::kcout + << "newoskrnl: No need to create for a new NewFS (EPM) partition here...\r"; + + fNewFS = reinterpret_cast<Kernel::NewFilesystemManager*>(Kernel::FilesystemManagerInterface::GetMounted()); + } + else + { + // Mounts a NewFS from main drive. + fNewFS = new Kernel::NewFilesystemManager(); + + Kernel::FilesystemManagerInterface::Mount(fNewFS); + } + + if (fNewFS->GetParser()) + { + constexpr auto cFolderInfo = "META-INF"; + const auto cDirCount = 7; + const char* cDirStr[cDirCount] = { + "\\Boot\\", "\\System\\", "\\Support\\", "\\Applications\\", + "\\Users\\", "\\Library\\", "\\Mount\\"}; + + for (Kernel::SizeT dirIndx = 0UL; dirIndx < cDirCount; ++dirIndx) + { + auto catalogDir = fNewFS->GetParser()->GetCatalog(cDirStr[dirIndx]); + + if (catalogDir) + { + Kernel::kcout << "newoskrnl: already exists.\r"; + + delete catalogDir; + continue; + } + + catalogDir = fNewFS->GetParser()->CreateCatalog(cDirStr[dirIndx], 0, + kNewFSCatalogKindDir); + + NFS_FORK_STRUCT theFork{0}; + + const Kernel::Char* cSrcName = cFolderInfo; + + Kernel::rt_copy_memory((Kernel::VoidPtr)(cSrcName), theFork.ForkName, + Kernel::rt_string_len(cSrcName)); + + Kernel::rt_copy_memory((Kernel::VoidPtr)(catalogDir->Name), + theFork.CatalogName, + Kernel::rt_string_len(catalogDir->Name)); + + delete catalogDir; + + theFork.DataSize = kNewFSForkSize; + theFork.ResourceId = 0; + theFork.ResourceKind = Kernel::kNewFSRsrcForkKind; + theFork.Kind = Kernel::kNewFSDataForkKind; + + Kernel::StringView metadataFolder(kNewFSSectorSz); + + metadataFolder += + "<!properties/>\r<p>Kind: folder</p>\r<p>Created by: system</p>\r<p>Edited by: " + "system</p>\r<p>Volume Type: Zeta</p>\r"; + + metadataFolder += "<p>Path: "; + metadataFolder += cDirStr[dirIndx]; + metadataFolder += "</p>\r"; + + const Kernel::SizeT metadataSz = kNewFSSectorSz; + + auto catalogSystem = fNewFS->GetParser()->GetCatalog(cDirStr[dirIndx]); + + fNewFS->GetParser()->CreateFork(catalogSystem, theFork); + + fNewFS->GetParser()->WriteCatalog( + catalogSystem, true, (Kernel::VoidPtr)(metadataFolder.CData()), + metadataSz, cFolderInfo); + + delete catalogSystem; + } + } + + NFS_CATALOG_STRUCT* catalogDisk = + this->fNewFS->GetParser()->GetCatalog("\\Mount\\NUL:"); + + const Kernel::Char* cSrcName = "DISK-INF"; + + if (catalogDisk) + { + delete catalogDisk; + } + else + { + catalogDisk = + (NFS_CATALOG_STRUCT*)this->Leak()->CreateAlias("\\Mount\\NUL:"); + + Kernel::StringView diskFolder(kNewFSSectorSz); + + diskFolder += + "<!properties/><p>Kind: alias to NULL.</p>\r<p>Created by: system</p>\r<p>Edited " + "by: " + "system</p>\r<p>Volume Type: NULL.</p>\r"; + + diskFolder += "<p>Root: NUL"; + diskFolder += "</p>\r"; + + NFS_FORK_STRUCT theDiskFork{0}; + + Kernel::rt_copy_memory((Kernel::VoidPtr)(cSrcName), theDiskFork.ForkName, + Kernel::rt_string_len(cSrcName)); + + Kernel::rt_copy_memory((Kernel::VoidPtr)(catalogDisk->Name), + theDiskFork.CatalogName, + Kernel::rt_string_len(catalogDisk->Name)); + + theDiskFork.DataSize = kNewFSForkSize; + theDiskFork.ResourceId = 0; + theDiskFork.ResourceKind = Kernel::kNewFSRsrcForkKind; + theDiskFork.Kind = Kernel::kNewFSDataForkKind; + + fNewFS->GetParser()->CreateFork(catalogDisk, theDiskFork); + fNewFS->GetParser()->WriteCatalog(catalogDisk, + true, + (Kernel::VoidPtr)diskFolder.CData(), + kNewFSSectorSz, cSrcName); + + delete catalogDisk; + } + } + + ~FilesystemInstaller() = default; + + NEWOS_COPY_DEFAULT(FilesystemInstaller); + + /// @brief Grab the disk's NewFS reference. + /// @return NewFilesystemManager the filesystem interface + Kernel::NewFilesystemManager* Leak() + { + return fNewFS; + } + }; +} // namespace Kernel::Detail + +/// @brief Application entrypoint. +/// @param Void +/// @return Void +EXTERN_C Kernel::Void KeMain(Kernel::Void) +{ + /// Now run kernel loop, until no process are running. + Kernel::Detail::FilesystemInstaller(); // automatic filesystem creation. +} diff --git a/dev/ZKA/Sources/DriveManager.cxx b/dev/ZKA/Sources/DriveManager.cxx index c4cebc3f..48a61f41 100644 --- a/dev/ZKA/Sources/DriveManager.cxx +++ b/dev/ZKA/Sources/DriveManager.cxx @@ -131,7 +131,7 @@ namespace Kernel { DriveTrait trait; - rt_copy_memory((VoidPtr) "MainDisk", trait.fName, rt_string_len("MainDisk")); + rt_copy_memory((VoidPtr) "\\Mount\\NUL:", trait.fName, rt_string_len("\\Mount\\NUL:")); trait.fKind = kMassStorage; trait.fInput = ke_drv_input; diff --git a/dev/ZKA/Sources/FS/NewFS.cxx b/dev/ZKA/Sources/FS/NewFS.cxx index 36e0755e..8f9ef8ef 100644 --- a/dev/ZKA/Sources/FS/NewFS.cxx +++ b/dev/ZKA/Sources/FS/NewFS.cxx @@ -486,13 +486,15 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL BOOT_BLOCK_STRUCT* epmBoot = (BOOT_BLOCK_STRUCT*)bufEpmHdr; + // EPM header. + constexpr auto cFsName = "NewFS"; constexpr auto cBlockName = "ZKA:"; rt_copy_memory(reinterpret_cast<VoidPtr>(const_cast<Char*>(cFsName)), epmBoot->Fs, rt_string_len(cFsName)); epmBoot->FsVersion = kNewFSVersionInteger; - epmBoot->LbaStart = 0; + epmBoot->LbaStart = start; epmBoot->SectorSz = kNewFSSectorSz; rt_copy_memory(reinterpret_cast<VoidPtr>(const_cast<Char*>(cBlockName)), epmBoot->Name, rt_string_len(cBlockName)); |
