diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-03-14 22:26:42 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-03-14 22:26:42 +0100 |
| commit | 6bbf5ad2058db4020ae20d6aba8f5b099dadc85f (patch) | |
| tree | ad39f25f27938729261f733d2addf839e8a110b3 | |
| parent | 1c4f8ae3804be72d947b0b96f90b9300515399bc (diff) | |
TQ-24 && TQ-16: Add build scripts for MBCI, MBCI+Flash, and UFS.
META: Along other tweaks and important ARM64 patches.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
25 files changed, 135 insertions, 47 deletions
@@ -1,4 +1,4 @@ -# BootZ, LibSCI and NeKernel are owned by Amlal.
+# Boot, LibSCI, and Kernel are owned by Amlal.
/dev/Kernel/ @amlel-el-mahrouss
/dev/Boot/ @amlel-el-mahrouss
/dev/LibSCI/ @amlel-el-mahrouss
diff --git a/debug_ahci.sh b/debug_ahci.sh index fe0b1b72..67b62a90 100755 --- a/debug_ahci.sh +++ b/debug_ahci.sh @@ -2,6 +2,7 @@ export AHCI_SUPPORT=1 export ATA_PIO_SUPPORT= +export ATA_DMA_SUPPORT= export DEBUG_SUPPORT=1 cd dev/Kernel diff --git a/debug_mbci.sh b/debug_mbci.sh new file mode 100755 index 00000000..1742baa7 --- /dev/null +++ b/debug_mbci.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +export MBCI_SUPPORT=1 +export UFS_SUPPORT= +export AHCI_SUPPORT= +export ATA_DMA_SUPPORT= +export ATA_PIO_SUPPORT= +export DEBUG_SUPPORT=1 + +cd kernel +make -f arm64-desktop.make all +cd ../boot +make -f arm64-desktop.make all +make -f arm64-desktop.make run
\ No newline at end of file diff --git a/debug_ufs.sh b/debug_ufs.sh new file mode 100755 index 00000000..904f3121 --- /dev/null +++ b/debug_ufs.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +export UFS_SUPPORT=1 +export AHCI_SUPPORT= +export ATA_DMA_SUPPORT= +export ATA_PIO_SUPPORT= +export DEBUG_SUPPORT=1 + +cd kernel +make -f arm64-mobile.make all +cd ../boot +make -f arm64-mobile.make all +make -f arm64-mobile.make run
\ No newline at end of file diff --git a/dev/Boot/BootKit/Shared/base.h b/dev/Boot/BootKit/Shared/base.h index 1270b36a..88459ec3 100644 --- a/dev/Boot/BootKit/Shared/base.h +++ b/dev/Boot/BootKit/Shared/base.h @@ -1,9 +1,9 @@ #ifndef UTL_BASE_H #define UTL_BASE_H -#include <cstdint> -#include <cstddef> -#include <cmath> +#include <stdint.h> +#include <stddef.h> +#include <math.h> namespace utl { diff --git a/dev/Boot/Mod/NetBoot/build.json b/dev/Boot/Mod/NetBoot/build.json index 6c9e3045..6f6d575f 100644 --- a/dev/Boot/Mod/NetBoot/build.json +++ b/dev/Boot/Mod/NetBoot/build.json @@ -7,7 +7,7 @@ "compiler_flags": [ "-ffreestanding", "-nostdlib", - "-std=c++23", + "-std=c++20", "-fPIC", "-fno-rtti", "-fno-exceptions", diff --git a/dev/Boot/Mod/SysChk/arm64.json b/dev/Boot/Mod/SysChk/arm64.json index 77500bcd..09d86309 100644 --- a/dev/Boot/Mod/SysChk/arm64.json +++ b/dev/Boot/Mod/SysChk/arm64.json @@ -7,7 +7,7 @@ "compiler_flags": [ "-ffreestanding", "-nostdlib", - "-std=c++23", + "-std=c++20", "-fno-rtti", "-fno-exceptions", "-fuse-ld=lld", diff --git a/dev/Boot/amd64-desktop.make b/dev/Boot/amd64-desktop.make index 2802c5e1..2a67f2f2 100644 --- a/dev/Boot/amd64-desktop.make +++ b/dev/Boot/amd64-desktop.make @@ -69,7 +69,7 @@ REM_FLAG=-f FLAG_ASM=-f win64 FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mno-red-zone -D__NEOSKRNL__ -D__BOOTZ__ \ -DEFI_FUNCTION_WRAPPER -I./ -I../Kernel $(DISK_DRV) -I../ -c -nostdlib -fno-rtti -fno-exceptions \ - -std=c++23 -DBOOTZ_GPT_SUPPORT -DBOOTZ_EPM_SUPPORT -D__HAVE_NE_APIS__ -DZBA_USE_FB -D__NE_AMD64__ -D__NE__ -DNE_AUTO_FORMAT + -std=c++20 -DBOOTZ_GPT_SUPPORT -DBOOTZ_EPM_SUPPORT -D__HAVE_NE_APIS__ -DZBA_USE_FB -D__NE_AMD64__ -D__NE__ -DNE_AUTO_FORMAT BOOTLOADER=bootz.exe KERNEL=neoskrnl.exe diff --git a/dev/Boot/arm64-desktop.make b/dev/Boot/arm64-desktop.make index ce797b4d..7470a9fc 100644 --- a/dev/Boot/arm64-desktop.make +++ b/dev/Boot/arm64-desktop.make @@ -45,7 +45,7 @@ REM_FLAG=-f FLAG_ASM=-f win64 FLAG_GNU=-fshort-wchar -c -ffreestanding -MMD -mno-red-zone -D__NE_ARM64__ -fno-rtti -fno-exceptions -I./ \ -target aarch64-unknown-windows \ - -std=c++23 -DBOOTZ_EPM_SUPPORT -DZBA_USE_FB -D__FSKIT_USE_NEFS__ -D__BOOTLDR_STANDALONE__ -D__NEOSKRNL__ -D__BOOTZ__ -D__HAVE_NE_APIS__ -D__NE__ -I../ -I../Kernel + -std=c++20 -DBOOTZ_EPM_SUPPORT -DZBA_USE_FB -D__FSKIT_USE_NEFS__ -D__BOOTLDR_STANDALONE__ -D__NEOSKRNL__ -D__BOOTZ__ -D__HAVE_NE_APIS__ -D__NE__ -I../ -I../Kernel BOOT_LOADER=bootz.exe KERNEL=neoskrnl.exe diff --git a/dev/Boot/arm64-mobile.make b/dev/Boot/arm64-mobile.make index d5d419d4..c4522e52 100644 --- a/dev/Boot/arm64-mobile.make +++ b/dev/Boot/arm64-mobile.make @@ -46,7 +46,7 @@ REM_FLAG=-f FLAG_ASM=-f win64 FLAG_GNU=-fshort-wchar -c -ffreestanding -MMD -mno-red-zone -D__NE_ARM64__ -fno-rtti -fno-exceptions -I./ \ -target aarch64-unknown-windows \ - -std=c++23 -DBOOTZ_EPM_SUPPORT -DkExpectedWidth=320 -DkExpectedHeight=480 -D__FSKIT_USE_NEFS__ -D__BOOTLDR_STANDALONE__ -D__NEOSKRNL__ -D__BOOTZ__ -D__HAVE_NE_APIS__ -D__NE__ -I../ -I../Kernel + -std=c++20 -DBOOTZ_EPM_SUPPORT -DkExpectedWidth=320 -DkExpectedHeight=480 -D__FSKIT_USE_NEFS__ -D__BOOTLDR_STANDALONE__ -D__NEOSKRNL__ -D__BOOTZ__ -D__HAVE_NE_APIS__ -D__NE__ -I../ -I../Kernel BOOT_LOADER=bootz.exe KERNEL=neoskrnl.exe diff --git a/dev/Kernel/FirmwareKit/EFI/API.h b/dev/Kernel/FirmwareKit/EFI/API.h index 03b79019..50b6ea19 100644 --- a/dev/Kernel/FirmwareKit/EFI/API.h +++ b/dev/Kernel/FirmwareKit/EFI/API.h @@ -11,10 +11,9 @@ #include <FirmwareKit/Handover.h> #include <KernelKit/MSDOS.h> #include <KernelKit/PE.h> -#include <BootKit/Qr.h> -#define kNeKernelSubsystem (17) -#define kNeWebsiteMacro "https://vswirl.com/help" +#define kNeWebsiteMacro "https://aker.com/help" +#define kNeKernelSubsystem (StrLen(kNeWebsiteMacro)) #ifdef __BOOTZ__ // forward decl. @@ -80,23 +79,6 @@ Bascially frees everything we have in the EFI side. ST->ConOut->OutputString(ST->ConOut, L" ***\r"); - constexpr auto ver = 4; - auto ecc = qr::Ecc::H; - auto input = kNeWebsiteMacro; - auto len = StrLen(kNeWebsiteMacro); - - qr::Qr<ver> encoder; - qr::QrDelegate del; - - encoder.encode(input, len, ecc, 0); // Manual mask 0 - - constexpr auto whereX = 10; - constexpr auto whereY = 10; - - /// tell delegate to draw encoded QR. - del.draw<ver>(encoder, whereX, - whereY); - EFI::Stop(); } } // namespace EFI diff --git a/dev/Kernel/HALKit/AMD64/Storage/AHCI.cc b/dev/Kernel/HALKit/AMD64/Storage/AHCI+Generic.cc index 874b7012..874b7012 100644 --- a/dev/Kernel/HALKit/AMD64/Storage/AHCI.cc +++ b/dev/Kernel/HALKit/AMD64/Storage/AHCI+Generic.cc diff --git a/dev/Kernel/HALKit/AMD64/Storage/DMA.cc b/dev/Kernel/HALKit/AMD64/Storage/DMA+Generic.cc index 109b55af..109b55af 100644 --- a/dev/Kernel/HALKit/AMD64/Storage/DMA.cc +++ b/dev/Kernel/HALKit/AMD64/Storage/DMA+Generic.cc diff --git a/dev/Kernel/HALKit/AMD64/Storage/PIO.cc b/dev/Kernel/HALKit/AMD64/Storage/PIO+Generic.cc index 62791aee..62791aee 100644 --- a/dev/Kernel/HALKit/AMD64/Storage/PIO.cc +++ b/dev/Kernel/HALKit/AMD64/Storage/PIO+Generic.cc diff --git a/dev/Kernel/HALKit/ARM64/HalACPIFactoryInterface.cc b/dev/Kernel/HALKit/ARM64/HalACPIFactoryInterface.cc index 6dcfa9a2..8ca9ac06 100644 --- a/dev/Kernel/HALKit/ARM64/HalACPIFactoryInterface.cc +++ b/dev/Kernel/HALKit/ARM64/HalACPIFactoryInterface.cc @@ -17,9 +17,10 @@ namespace NeOS { } - Void ACPIFactoryInterface::Shutdown() + BOOL ACPIFactoryInterface::Shutdown() { apm_send_io_command(kAPMPowerCommandShutdown, 0); + return NO; } /// @brief Reboot machine in either ACPI or by triple faulting. diff --git a/dev/Kernel/HALKit/ARM64/HalDebugOutput.cc b/dev/Kernel/HALKit/ARM64/HalDebugOutput.cc index 97621e23..8d54739f 100644 --- a/dev/Kernel/HALKit/ARM64/HalDebugOutput.cc +++ b/dev/Kernel/HALKit/ARM64/HalDebugOutput.cc @@ -11,7 +11,7 @@ namespace NeOS { - EXTERN_C void ke_io_write(const Char* bytes) + EXTERN_C void ke_io_write(IDeviceObject<const Char*>* self, const Char* bytes) { #ifdef __DEBUG__ if (*bytes == 0) @@ -38,7 +38,7 @@ namespace NeOS TerminalDevice::~TerminalDevice() = default; - EXTERN_C void ke_io_read(const Char* bytes) + EXTERN_C void ke_io_read(IDeviceObject<const Char*>* self, const Char* bytes) { #ifdef __DEBUG__ SizeT index = 0; diff --git a/dev/Kernel/HALKit/ARM64/HalPageInternal.S b/dev/Kernel/HALKit/ARM64/HalFlushTLB.S index 8fcf40ff..8fcf40ff 100644 --- a/dev/Kernel/HALKit/ARM64/HalPageInternal.S +++ b/dev/Kernel/HALKit/ARM64/HalFlushTLB.S diff --git a/dev/Kernel/HALKit/ARM64/HalKernelMain.cc b/dev/Kernel/HALKit/ARM64/HalKernelMain.cc index afb1cc0e..5a6d0dc2 100644 --- a/dev/Kernel/HALKit/ARM64/HalKernelMain.cc +++ b/dev/Kernel/HALKit/ARM64/HalKernelMain.cc @@ -18,6 +18,8 @@ #include <HALKit/ARM64/Processor.h> #include <CFKit/Property.h> +#include <HALKit/ARM64/ApplicationProcessor.h> + EXTERN_C void hal_init_platform( NeOS::HEL::BootInfoHeader* handover_hdr) { diff --git a/dev/Kernel/HALKit/ARM64/HalPagingMgrARM64.cc b/dev/Kernel/HALKit/ARM64/HalPagingMgrARM64.cc index e04b77cd..4ec45b51 100644 --- a/dev/Kernel/HALKit/ARM64/HalPagingMgrARM64.cc +++ b/dev/Kernel/HALKit/ARM64/HalPagingMgrARM64.cc @@ -45,7 +45,7 @@ namespace NeOS::HAL /// @param phys_addr point to physical address. /// @param flags the flags to put on the page. /// @return Status code of page manipulation process. - EXTERN_C Int32 mm_map_page(VoidPtr virtual_address, UInt32 flags) + EXTERN_C Int32 mm_map_page(VoidPtr virtual_address, VoidPtr physical_address, UInt32 flags) { if (!virtual_address || !flags) @@ -73,7 +73,7 @@ namespace NeOS::HAL { NE_PAGE_STORE& page_store = NE_PAGE_STORE::The(); - // Update Internal store. + // Update internal store. page_store.fInternalStore.fPde = nullptr; page_store.fInternalStore.fPte = pt_entry; diff --git a/dev/Kernel/HALKit/ARM64/Processor.h b/dev/Kernel/HALKit/ARM64/Processor.h index 4dba5a8b..e79a99c7 100644 --- a/dev/Kernel/HALKit/ARM64/Processor.h +++ b/dev/Kernel/HALKit/ARM64/Processor.h @@ -36,7 +36,7 @@ namespace NeOS::HAL /// @param phys_addr point to physical address. /// @param flags the flags to put on the page. /// @return Status code of page manip. - EXTERN_C Int32 mm_map_page(VoidPtr virt_addr, UInt32 flags); + EXTERN_C Int32 mm_map_page(VoidPtr virtual_address, VoidPtr physical_address, UInt32 flags); typedef UIntPtr Reg; typedef Register64 Register; diff --git a/dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc b/dev/Kernel/HALKit/ARM64/Storage/MBCI+Flash+IO+Generic.cc index 1335a9e4..3ccca867 100644 --- a/dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc +++ b/dev/Kernel/HALKit/ARM64/Storage/MBCI+Flash+IO+Generic.cc @@ -11,10 +11,10 @@ #include <Mod/MFlash/MFlash.h> #include <Mod/MBCI/MBCI.h> -/// @file MFlash.cc +/// @file MBCI+Flash.cc /// @brief MBCI Flash support. -#define kMaxFlashSlots (8U) +#define MBCI_MAX_SLOTS (8U) namespace NeOS { @@ -23,10 +23,10 @@ namespace NeOS constexpr auto kFlashBridgeRevision = 1; STATIC BOOL kFlashEnabled = NO; - STATIC SizeT kFlashSize[kMaxFlashSlots] = {}; - STATIC SizeT kFlashSectorSz[kMaxFlashSlots] = {}; - STATIC IMBCIHost* kFlashMetaPackets[kMaxFlashSlots] = {}; - STATIC IMBCIHost* kFlashDataPackets[kMaxFlashSlots] = {}; + STATIC SizeT kFlashSize[MBCI_MAX_SLOTS] = {}; + STATIC SizeT kFlashSectorSz[MBCI_MAX_SLOTS] = {}; + STATIC IMBCIHost* kFlashMetaPackets[MBCI_MAX_SLOTS] = {}; + STATIC IMBCIHost* kFlashDataPackets[MBCI_MAX_SLOTS] = {}; STATIC Void drv_std_io(Int32 slot, UInt64 lba, Char* buf, SizeT sector_sz, SizeT buf_sz); @@ -40,7 +40,7 @@ namespace NeOS /// @return slot sector count. SizeT drv_get_sector_count(Int32 slot) { - if (slot > kMaxFlashSlots) + if (slot > MBCI_MAX_SLOTS) return 0; return kFlashSectorSz[slot]; @@ -50,7 +50,7 @@ namespace NeOS /// @return drive slot size SizeT drv_get_size(Int32 slot) { - if (slot > kMaxFlashSlots) + if (slot > MBCI_MAX_SLOTS) return 0; return kFlashSize[slot]; @@ -59,7 +59,7 @@ namespace NeOS /// @brief Enable flash memory at slot. BOOL drv_enable_at(Int32 slot) { - if (slot > kMaxFlashSlots) + if (slot > MBCI_MAX_SLOTS) return NO; kFlashMetaPackets[slot]->InterruptEnable = YES; @@ -72,7 +72,7 @@ namespace NeOS /// @brief Disable flash memory at slot. BOOL drv_disable_at(Int32 slot) { - if (slot > kMaxFlashSlots) + if (slot > MBCI_MAX_SLOTS) return NO; kFlashMetaPackets[slot]->InterruptEnable = NO; diff --git a/dev/Kernel/HALKit/ARM64/Storage/UFS+Generic.cc b/dev/Kernel/HALKit/ARM64/Storage/UFS+Generic.cc new file mode 100644 index 00000000..20d06671 --- /dev/null +++ b/dev/Kernel/HALKit/ARM64/Storage/UFS+Generic.cc @@ -0,0 +1,11 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved. + +------------------------------------------- */ + +/// @file UFS.cc +/// @brief UFS Flash Memory support. + +#define UFS_PCI_VENDOR_ID (0x01001) /* AKER */ +#define UFS_PCI_DEVICE_ID (0xAEAEA) /* AKER */
\ No newline at end of file diff --git a/dev/Kernel/amd64-desktop.make b/dev/Kernel/amd64-desktop.make index 56017c8e..3e8040c0 100644 --- a/dev/Kernel/amd64-desktop.make +++ b/dev/Kernel/amd64-desktop.make @@ -5,7 +5,7 @@ CXX = x86_64-w64-mingw32-g++ LD = x86_64-w64-mingw32-ld -CCFLAGS = -fshort-wchar -c -D__NE_AMD64__ -mno-red-zone -fno-rtti -fno-exceptions -std=c++23 -D__NE_SUPPORT_NX__ -O0 -I../Vendor -D__FSKIT_INCLUDES_NEFS__ -D__NEOSKRNL__ -D__HAVE_NE_APIS__ -D__FREESTANDING__ -D__NE_VIRTUAL_MEMORY_SUPPORT__ -D__NE_AUTO_FORMAT__ -D__NE__ -I./ -I../ -I../zba +CCFLAGS = -fshort-wchar -c -D__NE_AMD64__ -mno-red-zone -fno-rtti -fno-exceptions -std=c++20 -D__NE_SUPPORT_NX__ -O0 -I../Vendor -D__FSKIT_INCLUDES_NEFS__ -D__NEOSKRNL__ -D__HAVE_NE_APIS__ -D__FREESTANDING__ -D__NE_VIRTUAL_MEMORY_SUPPORT__ -D__NE_AUTO_FORMAT__ -D__NE__ -I./ -I../ -I../zba ASM = nasm diff --git a/dev/Kernel/arm64-desktop.make b/dev/Kernel/arm64-desktop.make index 3d23ad08..1b3521d5 100644 --- a/dev/Kernel/arm64-desktop.make +++ b/dev/Kernel/arm64-desktop.make @@ -7,7 +7,7 @@ CC = clang++ LD = lld-link CCFLAGS = -fshort-wchar -c -ffreestanding -MMD -mno-red-zone -D__NE_ARM64__ -fno-rtti -fno-exceptions -I./ \ -target aarch64-unknown-windows \ - -std=c++23 -O3 -D__NEOSKRNL__ -D__NE_MINIMAL_OS__ -D__NE_NO_BUILTIN__ -D__HAVE_NE_APIS__ -D__NE__ -I../ + -std=c++20 -O3 -D__NEOSKRNL__ -D__NE_MINIMAL_OS__ -D__NE_NO_BUILTIN__ -D__HAVE_NE_APIS__ -D__NE__ -I../ ASM = clang++ diff --git a/dev/Kernel/arm64-mobile.make b/dev/Kernel/arm64-mobile.make new file mode 100644 index 00000000..1b3521d5 --- /dev/null +++ b/dev/Kernel/arm64-mobile.make @@ -0,0 +1,64 @@ +################################################## +# (c) Amlal EL Mahrouss, all rights reserved. +# This is the microKernel makefile. +################################################## + +CC = clang++ +LD = lld-link +CCFLAGS = -fshort-wchar -c -ffreestanding -MMD -mno-red-zone -D__NE_ARM64__ -fno-rtti -fno-exceptions -I./ \ + -target aarch64-unknown-windows \ + -std=c++20 -O3 -D__NEOSKRNL__ -D__NE_MINIMAL_OS__ -D__NE_NO_BUILTIN__ -D__HAVE_NE_APIS__ -D__NE__ -I../ + +ASM = clang++ + +DISKDRIVER = -D__USE_FLASH_MEM__ + +ifneq ($(DEBUG_SUPPORT), ) +DEBUG = -D__DEBUG__ +endif + +COPY = cp + +LDFLAGS = -subsystem:efi_application -entry:hal_init_platform /nodefaultlib +LDOBJ = obj/*.obj + +# This file is the Kernel, responsible of task management and memory. +KERNEL = neoskrnl.exe + +.PHONY: error +error: + @echo "=== ERROR ===" + @echo "=> Use a specific target." + +MOVEALL=./MoveAll.ARM64.sh + +.PHONY: newos-arm64-epm +newos-arm64-epm: clean + $(CC) $(CCFLAGS) $(DISKDRIVER) $(DEBUG) $(wildcard src/*.cc) \ + $(wildcard src/FS/*.cc) $(wildcard HALKit/ARM64/Storage/*.cc) \ + $(wildcard HALKit/ARM64/PCI/*.cc) $(wildcard src/Network/*.cc) $(wildcard src/Storage/*.cc) \ + $(wildcard HALKit/ARM64/*.cc) $(wildcard HALKit/ARM64/*.cpp) \ + $(wildcard HALKit/ARM64/*.s) $(wildcard HALKit/ARM64/APM/*.cc) + + $(MOVEALL) + +OBJCOPY=x86_64-w64-mingw32-objcopy + +.PHONY: link-arm64-epm +link-arm64-epm: + $(LD) $(LDFLAGS) $(LDOBJ) /out:$(KERNEL) + +.PHONY: all +all: newos-arm64-epm link-arm64-epm + @echo "Kernel => OK." + +.PHONY: help +help: + @echo "=== HELP ===" + @echo "all: Build Kernel and link it." + @echo "link-arm64-epm: Link Kernel for EPM based disks." + @echo "newos-arm64-epm: Build Kernel for EPM based disks." + +.PHONY: clean +clean: + rm -f $(LDOBJ) $(wildcard *.o) $(KERNEL) |
