diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-11-09 10:30:58 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-11-09 10:30:58 +0100 |
| commit | 67716b2871b1117510b26bc1aaf6fce7195272dc (patch) | |
| tree | 4bbc0a51e0d8cb6234a830baa713377dad3de325 /dev | |
| parent | a2013145412c7cf7eb461833f7853d80caa88723 (diff) | |
META: Important refactors and include SCIKit.dylib when building bootloader.
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/Modules/AHCI/AHCI.h | 2 | ||||
| -rw-r--r-- | dev/SCIKit/Foundation.h | 4 | ||||
| -rw-r--r-- | dev/SCIKit/ReadMe.md | 5 | ||||
| -rw-r--r-- | dev/SCIKit/doc/SCIKit.drawio (renamed from dev/SCIKit/SCIKit.drawio) | 0 | ||||
| -rw-r--r-- | dev/SCIKit/sci.json (renamed from dev/SCIKit/build.json) | 2 | ||||
| -rw-r--r-- | dev/SCIKit/src/DispatchSysCalls.asm | 4 | ||||
| -rw-r--r-- | dev/SCIKit/src/Makefile | 10 | ||||
| -rw-r--r-- | dev/SCIKit/src/MemoryMgr.cc (renamed from dev/SCIKit/src/Foundation.cc) | 4 | ||||
| -rw-r--r-- | dev/ZBAKit/BootKit/BootKit.h | 10 | ||||
| -rw-r--r-- | dev/ZBAKit/Modules/NetBoot/Boot.S | 2 | ||||
| -rw-r--r-- | dev/ZBAKit/Modules/SysChk/Boot.S | 2 | ||||
| -rw-r--r-- | dev/ZBAKit/amd64-efi.make | 2 | ||||
| -rw-r--r-- | dev/ZBAKit/src/HEL/AMD64/BootMain.cc | 12 | ||||
| -rw-r--r-- | dev/ZBAKit/src/HEL/AMD64/BootSATA.cc (renamed from dev/ZBAKit/src/HEL/AMD64/BootAHCI.cc) | 0 | ||||
| -rw-r--r-- | dev/ZKAKit/HALKit/AMD64/Storage/AHCI.cc | 48 | ||||
| -rw-r--r-- | dev/ZKAKit/doc/Explicit Partition Map.pdf | bin | 12326 -> 12364 bytes | |||
| -rw-r--r-- | dev/ZKAKit/doc/SPECIFICATION.md | 1 |
17 files changed, 61 insertions, 47 deletions
diff --git a/dev/Modules/AHCI/AHCI.h b/dev/Modules/AHCI/AHCI.h index b9ce4a5b..b6e3e706 100644 --- a/dev/Modules/AHCI/AHCI.h +++ b/dev/Modules/AHCI/AHCI.h @@ -325,7 +325,7 @@ typedef struct HbaCmdTbl final Kernel::UInt8 Cfis[64]; // Command FIS Kernel::UInt8 Acmd[16]; // ATAPI command, 12 or 16 bytes Kernel::UInt8 Rsv[48]; // Reserved - struct HbaPrdtEntry prdtEntries[1]; // Physical region descriptor table entries, 0 ~ 65535 + struct HbaPrdtEntry PrdtEntries[1]; // Physical region descriptor table entries, 0 ~ 65535 } HbaCmdTbl; #if defined(__AHCI__) diff --git a/dev/SCIKit/Foundation.h b/dev/SCIKit/Foundation.h index ce61413f..4a283992 100644 --- a/dev/SCIKit/Foundation.h +++ b/dev/SCIKit/Foundation.h @@ -39,13 +39,13 @@ IMPORT_C Void LdrCloseDLLHandle(_Input SCIObject* dll_handle); /// @brief Opens a file from a drive.
/// @param fs_path the filesystem path.
-/// @param drive_letter drive name, use NULL to use default one.
+/// @param drive_letter drive name, use NULL to use default drive location.
/// @return the file descriptor of the file.
IMPORT_C SCIObject IoOpenFile(const Char* fs_path, const Char* drive_letter);
/// @brief Closes a file and flushes its content.
/// @param file_desc the file descriptor.
-/// @return void.
+/// @return Function doesn't return a type.
IMPORT_C Void IoCloseFile(_Input SCIObject file_desc);
/// @brief Write data to a file.
diff --git a/dev/SCIKit/ReadMe.md b/dev/SCIKit/ReadMe.md deleted file mode 100644 index 26e3c220..00000000 --- a/dev/SCIKit/ReadMe.md +++ /dev/null @@ -1,5 +0,0 @@ -# ZKA's SCI.
-
-System Call and Component Interface, used maninly to communicate with Kernel and registered objects.
-
-###### (c) Amlal EL Mahrouss, all rights reserved.
diff --git a/dev/SCIKit/SCIKit.drawio b/dev/SCIKit/doc/SCIKit.drawio index 9b58cc72..9b58cc72 100644 --- a/dev/SCIKit/SCIKit.drawio +++ b/dev/SCIKit/doc/SCIKit.drawio diff --git a/dev/SCIKit/build.json b/dev/SCIKit/sci.json index 12390d73..eb8bece9 100644 --- a/dev/SCIKit/build.json +++ b/dev/SCIKit/sci.json @@ -3,7 +3,7 @@ "compiler_std": "c++20", "headers_path": ["../"], "sources_path": ["src/*.cc", "src/*.obj"], - "output_name": "SCIKit.dll", + "output_name": "SCIKit.dylib", "compiler_flags": [ "-fPIC", "-ffreestanding", diff --git a/dev/SCIKit/src/DispatchSysCalls.asm b/dev/SCIKit/src/DispatchSysCalls.asm index f1668e21..d56f283f 100644 --- a/dev/SCIKit/src/DispatchSysCalls.asm +++ b/dev/SCIKit/src/DispatchSysCalls.asm @@ -1,7 +1,7 @@ ;; /* ;; * ======================================================== ;; * -;; * ZKA +;; * SCI ;; * Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved., all rights reserved. ;; * ;; * ======================================================== @@ -9,6 +9,8 @@ [bits 64] +section .text + global sci_syscall_arg_1 global sci_syscall_arg_2 global sci_syscall_arg_3 diff --git a/dev/SCIKit/src/Makefile b/dev/SCIKit/src/Makefile index 68a6407b..90da7b01 100644 --- a/dev/SCIKit/src/Makefile +++ b/dev/SCIKit/src/Makefile @@ -1,3 +1,11 @@ +################################################## +# (c) Amlal EL Mahrouss, all rights reserved. +# This is the bootloader makefile. +################################################## + +ASM=nasm +FLAGS=-f win64 + .PHONY: syscall_unit syscall_unit: - nasm -f win64 DispatchSysCalls.asm -o DispatchSysCalls.obj + $(ASM) $(FLAGS) DispatchSysCalls.asm -o DispatchSysCalls.obj diff --git a/dev/SCIKit/src/Foundation.cc b/dev/SCIKit/src/MemoryMgr.cc index e280aab8..bf8e1142 100644 --- a/dev/SCIKit/src/Foundation.cc +++ b/dev/SCIKit/src/MemoryMgr.cc @@ -6,8 +6,8 @@ #include <SCIKit/Foundation.h>
-/// @file Foundation.cc
-/// @brief Foundation source file for SCI Kit.
+/// @file MemoryMgr.cc
+/// @brief Source file for the memory functions.
/// @brief Copy memory region.
IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len)
diff --git a/dev/ZBAKit/BootKit/BootKit.h b/dev/ZBAKit/BootKit/BootKit.h index 3d2e3c0f..e1825570 100644 --- a/dev/ZBAKit/BootKit/BootKit.h +++ b/dev/ZBAKit/BootKit/BootKit.h @@ -209,10 +209,10 @@ namespace Boot ZKA_COPY_DELETE(BDiskFormatFactory); - /// @brief Format disk. - /// @param Partition Name - /// @param Blobs. - /// @param Number of blobs. + /// @brief Format disk using partition name and fileBlobs. + /// @param Partition partName the target partition name. + /// @param fileBlobs blobs array. + /// @param blobCount blobs array count. /// @retval True disk has been formatted. /// @retval False failed to format. Boolean Format(const Char* partName, BFileDescriptor* fileBlobs, SizeT blobCount); @@ -377,7 +377,7 @@ namespace Boot } else { - EFI::ThrowError(L"Filesystem-Failure-Part", L"Filesystem couldn't be partitioned."); + EFI::ThrowError(L"Filesystem-Failure-Part", L"Filesystem couldn't be partitioned, this drive cannot be formatted as an explicit partition map."); } return false; diff --git a/dev/ZBAKit/Modules/NetBoot/Boot.S b/dev/ZBAKit/Modules/NetBoot/Boot.S index ec17f347..1c4a8f69 100644 --- a/dev/ZBAKit/Modules/NetBoot/Boot.S +++ b/dev/ZBAKit/Modules/NetBoot/Boot.S @@ -1,7 +1,7 @@ ;; /* ;; * ======================================================== ;; * -;; * ZKA +;; * ZBA ;; * Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved., all rights reserved. ;; * ;; * ======================================================== diff --git a/dev/ZBAKit/Modules/SysChk/Boot.S b/dev/ZBAKit/Modules/SysChk/Boot.S index 08bd332a..b7df05a9 100644 --- a/dev/ZBAKit/Modules/SysChk/Boot.S +++ b/dev/ZBAKit/Modules/SysChk/Boot.S @@ -1,7 +1,7 @@ ;; /* ;; * ======================================================== ;; * -;; * ZKA +;; * ZBA ;; * Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved., all rights reserved. ;; * ;; * ======================================================== diff --git a/dev/ZBAKit/amd64-efi.make b/dev/ZBAKit/amd64-efi.make index 4c14da25..1121060f 100644 --- a/dev/ZBAKit/amd64-efi.make +++ b/dev/ZBAKit/amd64-efi.make @@ -53,6 +53,7 @@ BOOTLOADER=zbaosldr.exe KERNEL=minoskrnl.exe SYSCHK=syschk.sys STARTUP=startup.sys +SCIKIT=SCIKit.dylib .PHONY: invalid-recipe invalid-recipe: @@ -67,6 +68,7 @@ all: compile-amd64 $(COPY) src/$(BOOTLOADER) src/Root/EFI/BOOT/ZBAOSLDR.EFI $(COPY) ../ZKAKit/$(KERNEL) src/Root/$(KERNEL) $(COPY) ./Modules/SysChk/$(SYSCHK) src/Root/$(SYSCHK) + $(COPY) ../SCIKit/$(SCIKIT) src/Root/$(SCIKIT) $(COPY) src/$(BOOTLOADER) src/Root/$(BOOTLOADER) ifneq ($(DEBUG_SUPPORT), ) diff --git a/dev/ZBAKit/src/HEL/AMD64/BootMain.cc b/dev/ZBAKit/src/HEL/AMD64/BootMain.cc index ac06ee71..7bd861b1 100644 --- a/dev/ZBAKit/src/HEL/AMD64/BootMain.cc +++ b/dev/ZBAKit/src/HEL/AMD64/BootMain.cc @@ -173,7 +173,7 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr ImageHandle, #ifdef ZKA_AUTO_FORMAT if (!partition_factory.IsPartitionValid()) { - CGDrawString("FORMATTING EPM DISK...", 20, 10, RGB(0xFF, 0xFF, 0xFF)); + CGDrawString("Formatting EPM disk...", 20, 10, RGB(0xFF, 0xFF, 0xFF)); Boot::BDiskFormatFactory<BootDeviceATA>::BFileDescriptor root; root.fFileName[0] = kNeFSRoot[0]; @@ -187,7 +187,7 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr ImageHandle, } else { - CGDrawString("BOOTING FROM EPM DISK...", 20, 10, RGB(0xFF, 0xFF, 0xFF)); + CGDrawString("Booting from EPM disk...", 20, 10, RGB(0xFF, 0xFF, 0xFF)); } #endif // ZKA_AUTO_FORMAT @@ -243,7 +243,7 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr ImageHandle, if (reader_syschk.Blob()) { syschk_thread = new Boot::BThread(reader_syschk.Blob()); - syschk_thread->SetName("System Check (ZBA Driver)"); + syschk_thread->SetName("System Check (ZBA EFI Driver)"); } syschk_thread->Start(handover_hdr); @@ -287,7 +287,7 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr ImageHandle, else { #ifdef ZBA_USE_FB - CGDrawString("ZBA: PLEASE RECOVER YOUR KERNEL IMAGE.", 30, 10, RGB(0xFF, 0xFF, 0xFF)); + CGDrawString("ZBA: Please recover your kernel image.", 30, 10, RGB(0xFF, 0xFF, 0xFF)); #endif // ZBA_USE_FB EFI::Stop(); @@ -312,7 +312,7 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr ImageHandle, else { #ifdef ZBA_USE_FB - CGDrawString("ZBA: ONE OR MORE SYSTEM COMPONENTS ARE MISSING, PLEASE REINSTALL THE OS.", 30, 10, RGB(0xFF, 0xFF, 0xFF)); + CGDrawString("ZBA: OS resources are not present, please reinstall the OS.", 30, 10, RGB(0xFF, 0xFF, 0xFF)); #endif // ZBA_USE_FB EFI::Stop(); @@ -321,7 +321,7 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr ImageHandle, EFI::ExitBootServices(map_key, ImageHandle); // ---------------------------------------------------- // - // Finally load the operating system kernel. + // Finally load the OS kernel. // ---------------------------------------------------- // kernel_thread->Start(handover_hdr); diff --git a/dev/ZBAKit/src/HEL/AMD64/BootAHCI.cc b/dev/ZBAKit/src/HEL/AMD64/BootSATA.cc index 765870b0..765870b0 100644 --- a/dev/ZBAKit/src/HEL/AMD64/BootAHCI.cc +++ b/dev/ZBAKit/src/HEL/AMD64/BootSATA.cc diff --git a/dev/ZKAKit/HALKit/AMD64/Storage/AHCI.cc b/dev/ZKAKit/HALKit/AMD64/Storage/AHCI.cc index 4d513ffd..2ca2b625 100644 --- a/dev/ZKAKit/HALKit/AMD64/Storage/AHCI.cc +++ b/dev/ZKAKit/HALKit/AMD64/Storage/AHCI.cc @@ -20,9 +20,12 @@ #include <NewKit/Utils.h> #include <KernelKit/LockDelegate.h> +#ifdef __AHCI__ #define kMaxAhciPoll (100000U) -#ifdef __AHCI__ +#define kCmdOrCtrlCmd 1 +#define kCmdOrCtrlCtrl 0 + enum { kSATAProgIfAHCI = 0x01, @@ -69,14 +72,14 @@ Kernel::Boolean drv_std_init(Kernel::UInt16& PortsImplemented) { if (ports_implemented) { - kcout << "Port is implemented by Host.\r"; + kcout << "Port is implemented by host.\r"; Kernel::UInt8 ipm = (mem_ahci->Ports[ahci_index].Ssts >> 8) & 0x0F; Kernel::UInt8 det = mem_ahci->Ports[ahci_index].Ssts & 0x0F; if (mem_ahci->Ports[ahci_index].Sig == kSATASignature) { - kcout << "Found AHCI controller.\r"; + kcout << "Port is AHCI controller.\r"; detected = true; @@ -113,6 +116,8 @@ Kernel::Void drv_std_read(Kernel::UInt64 Lba, Kernel::Char* Buf, Kernel::SizeT S if (kSlotIsUsed) return; + // Slot is now used, OS uses slot 0, driver must not use slot 0. + kSlotIsUsed = Yes; Kernel::Int64 free_slot = 0; @@ -135,27 +140,27 @@ Kernel::Void drv_std_read(Kernel::UInt64 Lba, Kernel::Char* Buf, Kernel::SizeT S Kernel::UInt64 size = Size * kAHCISectorSize; Kernel::Int64 index_byte = 0L; - for (index_byte = 0; index_byte < cmd_header->Prdtl - 1; index_byte++) + for (index_byte = 0; index_byte < (cmd_header->Prdtl - 1); ++index_byte) { - cmd_tbl->prdtEntries[index_byte].Dba = (Kernel::UInt32)(Kernel::UIntPtr)Buf; - cmd_tbl->prdtEntries[index_byte].Dbc = (8 * 1024) - 1; // 8KB Buf size - cmd_tbl->prdtEntries[index_byte].InterruptBit = 1; // Interrupt on completion + cmd_tbl->PrdtEntries[index_byte].Dba = (Kernel::UInt32)(Kernel::UIntPtr)Buf; + cmd_tbl->PrdtEntries[index_byte].Dbc = (8 * 1024) - 1; // 8KB Buf size + cmd_tbl->PrdtEntries[index_byte].InterruptBit = 1; // Interrupt on completion Size -= 8 * 1024; Buf += 4 * 1024; // Move the Buf pointer forward } // Last PRDT entry - cmd_tbl->prdtEntries[index_byte].Dba = (Kernel::UInt32)(Kernel::UIntPtr)Buf; - cmd_tbl->prdtEntries[index_byte].Dbc = Size - 1; // Byte count left - cmd_tbl->prdtEntries[index_byte].InterruptBit = 1; + cmd_tbl->PrdtEntries[index_byte].Dba = (Kernel::UInt32)(Kernel::UIntPtr)Buf; + cmd_tbl->PrdtEntries[index_byte].Dbc = Size - 1; // Byte count left + cmd_tbl->PrdtEntries[index_byte].InterruptBit = 1; // 5. Prepare the command FIS (Frame Information Structure) FisRegH2D* cmd_fis = (FisRegH2D*)(&cmd_tbl->Cfis); Kernel::rt_set_memory(cmd_fis, 0, sizeof(FisRegH2D)); cmd_fis->FisType = kFISTypeRegH2D; - cmd_fis->CmdOrCtrl = 1; // Command + cmd_fis->CmdOrCtrl = kCmdOrCtrlCmd; // Command cmd_fis->Command = kAHCICmdReadDmaEx; cmd_fis->Lba0 = (Kernel::UInt8)Lba; @@ -170,7 +175,7 @@ Kernel::Void drv_std_read(Kernel::UInt64 Lba, Kernel::Char* Buf, Kernel::SizeT S cmd_fis->CountLow = Size & 0xFF; cmd_fis->CountHigh = (Size >> 8) & 0xFF; - // 6. Issue the command by writing to the kAhciPort's command issue register (CI) + // 6. Issue the command by writing to the port's command issue register (CI) kAhciPort->Ci = 1 << free_slot; // 7. Wait for the command to complete (simple spinlock, no need for an object here) @@ -218,27 +223,27 @@ Kernel::Void drv_std_write(Kernel::UInt64 Lba, Kernel::Char* Buf, Kernel::SizeT Kernel::UInt64 size = Size * kAHCISectorSize; Kernel::Int64 index_byte = 0L; - for (index_byte = 0; index_byte < cmd_header->Prdtl - 1; index_byte++) + for (index_byte = 0; index_byte < (cmd_header->Prdtl - 1); ++index_byte) { - cmd_tbl->prdtEntries[index_byte].Dba = (Kernel::UInt32)(Kernel::UIntPtr)Buf; - cmd_tbl->prdtEntries[index_byte].Dbc = (8 * 1024) - 1; // 8KB Buf size - cmd_tbl->prdtEntries[index_byte].InterruptBit = 1; // Interrupt on completion + cmd_tbl->PrdtEntries[index_byte].Dba = (Kernel::UInt32)(Kernel::UIntPtr)Buf; + cmd_tbl->PrdtEntries[index_byte].Dbc = (8 * 1024) - 1; // 8KB Buf size + cmd_tbl->PrdtEntries[index_byte].InterruptBit = 1; // Interrupt on completion Size -= 8 * 1024; Buf += 4 * 1024; // Move the Buf pointer forward } // Last PRDT entry - cmd_tbl->prdtEntries[index_byte].Dba = (Kernel::UInt32)(Kernel::UIntPtr)Buf; - cmd_tbl->prdtEntries[index_byte].Dbc = Size - 1; // Byte count left - cmd_tbl->prdtEntries[index_byte].InterruptBit = 1; + cmd_tbl->PrdtEntries[index_byte].Dba = (Kernel::UInt32)(Kernel::UIntPtr)Buf; + cmd_tbl->PrdtEntries[index_byte].Dbc = Size - 1; // Byte count left + cmd_tbl->PrdtEntries[index_byte].InterruptBit = 1; // 5. Prepare the command FIS (Frame Information Structure) FisRegH2D* cmd_fis = (FisRegH2D*)(&cmd_tbl->Cfis); Kernel::rt_set_memory(cmd_fis, 0, sizeof(FisRegH2D)); cmd_fis->FisType = kFISTypeRegH2D; - cmd_fis->CmdOrCtrl = 1; // Command + cmd_fis->CmdOrCtrl = kCmdOrCtrlCmd; // Command cmd_fis->Command = kAHCICmdReadDmaEx; cmd_fis->Lba0 = (Kernel::UInt8)Lba; @@ -253,7 +258,7 @@ Kernel::Void drv_std_write(Kernel::UInt64 Lba, Kernel::Char* Buf, Kernel::SizeT cmd_fis->CountLow = Size & 0xFF; cmd_fis->CountHigh = (Size >> 8) & 0xFF; - // 6. Issue the command by writing to the kAhciPort's command issue register (CI) + // 6. Issue the command by writing to the port's command issue register (CI) kAhciPort->Ci = 1 << free_slot; // 7. Wait for the command to complete (simple spinlock, no need for an object here) @@ -284,6 +289,7 @@ Kernel::SizeT drv_get_sector_count() } /// @brief Get the drive size. +/// @return Disk size in bytes. Kernel::SizeT drv_get_size() { return 0; diff --git a/dev/ZKAKit/doc/Explicit Partition Map.pdf b/dev/ZKAKit/doc/Explicit Partition Map.pdf Binary files differindex 1e2f5318..a73834cd 100644 --- a/dev/ZKAKit/doc/Explicit Partition Map.pdf +++ b/dev/ZKAKit/doc/Explicit Partition Map.pdf diff --git a/dev/ZKAKit/doc/SPECIFICATION.md b/dev/ZKAKit/doc/SPECIFICATION.md index c3d6df89..0233643a 100644 --- a/dev/ZKAKit/doc/SPECIFICATION.md +++ b/dev/ZKAKit/doc/SPECIFICATION.md @@ -48,6 +48,7 @@ - Kernel -> ke_init_x - RunTime -> rt_copy_mem - Hal -> hal_foo_bar +- Class methods -> Class::FooBar =================================== |
