diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-04-10 09:45:02 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-10 09:45:02 +0200 |
| commit | 8988b6f166d1087615b21229df651e0bcc0fa048 (patch) | |
| tree | f9a526d927e9b73a588e9c7db5cd99bf1622ca23 /dev/boot | |
| parent | 29828ef52df7a51e22057b4557b8d9a3d5550839 (diff) | |
| parent | e50f871e6852beacb53986f930ed2d5dead84838 (diff) | |
Merge pull request #13 from amlel-el-mahrouss/dev
dev: Last AHCI patches.
Diffstat (limited to 'dev/boot')
| -rw-r--r-- | dev/boot/modules/BootNet/amd64.json | 2 | ||||
| -rw-r--r-- | dev/boot/modules/SysChk/SysChk.cc | 18 | ||||
| -rw-r--r-- | dev/boot/modules/SysChk/amd64-ahci.json (renamed from dev/boot/modules/SysChk/amd64.json) | 3 | ||||
| -rw-r--r-- | dev/boot/modules/SysChk/amd64-pio.json | 25 | ||||
| -rw-r--r-- | dev/boot/src/HEL/AMD64/BootEFI.cc | 72 |
5 files changed, 70 insertions, 50 deletions
diff --git a/dev/boot/modules/BootNet/amd64.json b/dev/boot/modules/BootNet/amd64.json index 86143e6a..da4a15f0 100644 --- a/dev/boot/modules/BootNet/amd64.json +++ b/dev/boot/modules/BootNet/amd64.json @@ -10,7 +10,7 @@ "-fPIC", "-fno-rtti", "-fno-exceptions", - "-Wl,--subsystem=17,--image-base,0x1000000,-e,BootNetModuleMain" + "-Wl,--subsystem=17,--image-base,0x10000000,-e,BootNetModuleMain" ], "cpp_macros": [ "__NEOSKRNL__", diff --git a/dev/boot/modules/SysChk/SysChk.cc b/dev/boot/modules/SysChk/SysChk.cc index f9af8517..3086cdc6 100644 --- a/dev/boot/modules/SysChk/SysChk.cc +++ b/dev/boot/modules/SysChk/SysChk.cc @@ -21,14 +21,30 @@ #include <BootKit/BootThread.h> #include <modules/CoreGfx/CoreGfx.h> +// Makes the compiler shut up. +#ifndef kMachineModel +#define kMachineModel "Ne" +#endif // !kMachineModel + EXTERN_C Int32 SysChkModuleMain(Kernel::HEL::BootInfoHeader* handover) { -#ifdef __NE_AMD64__ +#ifdef __ATA_PIO__ Boot::BDiskFormatFactory<BootDeviceATA> partition_factory; if (partition_factory.IsPartitionValid()) return kEfiOk; + Boot::BDiskFormatFactory<BootDeviceATA>::BFileDescriptor desc{}; + + desc.fFileName[0] = '/'; + desc.fFileName[1] = 0; + desc.fKind = kNeFSCatalogKindDir; + + partition_factory.Format(kMachineModel, &desc, 1); + + if (partition_factory.IsPartitionValid()) + return kEfiOk; + return kEfiFail; #else return kEfiOk; diff --git a/dev/boot/modules/SysChk/amd64.json b/dev/boot/modules/SysChk/amd64-ahci.json index 3b5bab6f..527e79f9 100644 --- a/dev/boot/modules/SysChk/amd64.json +++ b/dev/boot/modules/SysChk/amd64-ahci.json @@ -10,13 +10,14 @@ "-fPIC", "-fno-rtti", "-fno-exceptions", - "-Wl,--subsystem=17,--image-base,0x1000000,-e,SysChkModuleMain" + "-Wl,--subsystem=17,--image-base,0x10000000,-e,SysChkModuleMain" ], "cpp_macros": [ "__NEOSKRNL__", "__BOOTZ__", "__BOOTZ_STANDALONE__", "__NE_AMD64__", + "__AHCI__", "kChkVersionHighest=0x0100", "kChkVersionLowest=0x0100", "kChkVersion=0x0100" diff --git a/dev/boot/modules/SysChk/amd64-pio.json b/dev/boot/modules/SysChk/amd64-pio.json new file mode 100644 index 00000000..de3195ce --- /dev/null +++ b/dev/boot/modules/SysChk/amd64-pio.json @@ -0,0 +1,25 @@ +{ + "compiler_path": "x86_64-w64-mingw32-g++", + "compiler_std": "c++20", + "headers_path": ["../", "../../", "../../../kernel", "../../../", "./"], + "sources_path": ["*.cc", "*.S", "../../src/HEL/AMD64/*.cc", "../../src/HEL/AMD64/*.S", "../../src/*.cc"], + "output_name": "chk.efi", + "compiler_flags": [ + "-nostdlib", + "-std=c++20", + "-fPIC", + "-fno-rtti", + "-fno-exceptions", + "-Wl,--subsystem=17,--image-base,0x10000000,-e,SysChkModuleMain" + ], + "cpp_macros": [ + "__NEOSKRNL__", + "__BOOTZ__", + "__BOOTZ_STANDALONE__", + "__NE_AMD64__", + "__ATA_PIO__", + "kChkVersionHighest=0x0100", + "kChkVersionLowest=0x0100", + "kChkVersion=0x0100" + ] +} diff --git a/dev/boot/src/HEL/AMD64/BootEFI.cc b/dev/boot/src/HEL/AMD64/BootEFI.cc index bd1c7860..57651016 100644 --- a/dev/boot/src/HEL/AMD64/BootEFI.cc +++ b/dev/boot/src/HEL/AMD64/BootEFI.cc @@ -18,11 +18,6 @@ #include <BootKit/BootThread.h> #include <modules/CoreGfx/CoreGfx.h> -// Makes the compiler shut up. -#ifndef kMachineModel -#define kMachineModel "NeKernel" -#endif // !kMachineModel - #ifndef kExpectedWidth #define kExpectedWidth (800) #endif @@ -170,58 +165,39 @@ EFI_EXTERN_C EFI_API Int32 ModuleMain(EfiHandlePtr image_handle, // Fill handover header now. - // ---------------------------------------------------- // - // The following checks for an exisiting partition - // inside the disk, if it doesn't have one, - // format the disk. - // ---------------------------------------------------- // - Boot::BootTextWriter writer; - auto ret = BS->GetMemoryMap(&size_struct_ptr, struct_ptr, &map_key, &sz_desc, &rev_desc); - - if (ret == kEfiFail) - { - writer.Write("BootZ: GetMemoryMap failed (x1)\r"); - Boot::Stop(); - } - - size_struct_ptr += sz_desc * 2; - BS->AllocatePool(EfiMemoryType::EfiBootServicesData, size_struct_ptr, reinterpret_cast<VoidPtr*>(&struct_ptr)); + //-------------------------------------------------------------// + // Update handover file specific table and phyiscal start field. + //-------------------------------------------------------------// - ret = BS->GetMemoryMap(&size_struct_ptr, struct_ptr, &map_key, &sz_desc, &rev_desc); + handover_hdr->f_BitMapSize = gib_cast(4); /* Size of bitmap in bytes. */ + Int32 trials = 5 * 10000000; - if (ret == kEfiFail) + while (BS->AllocatePool(EfiLoaderData, handover_hdr->f_BitMapSize, &handover_hdr->f_BitMapStart) != kEfiOk) { - writer.Write("BootZ: GetMemoryMap failed (x2)\r"); - Boot::Stop(); - } + --trials; - //-----------------------------------------------------------// - // A simple loop which finds a usable memory region for us. - //-----------------------------------------------------------// + if (!trials) + { + writer.Write("BootZ: Unable to allocate sufficent memory, trying again with 2GB...\r"); - SizeT lookup_index = 0UL; - SizeT entry_count = size_struct_ptr / sz_desc; + trials = 3 * 10000000; - for (; lookup_index < entry_count; ++lookup_index) - { - if (struct_ptr[lookup_index].Kind == EfiMemoryType::EfiConventionalMemory) - break; - } - - if (lookup_index > entry_count) - { - writer.Write("BootZ: No usable entries.\r"); - Boot::Stop(); - } + handover_hdr->f_BitMapSize = gib_cast(2); /* Size of bitmap in bytes. */ - //-------------------------------------------------------------// - // Update handover file specific table and phyiscal start field. - //-------------------------------------------------------------// + while (BS->AllocatePool(EfiLoaderData, handover_hdr->f_BitMapSize, &handover_hdr->f_BitMapStart) != kEfiOk) + { + --trials; - handover_hdr->f_BitMapStart = (VoidPtr)(struct_ptr[lookup_index].VirtualStart); /* Start of bitmap. */ - handover_hdr->f_BitMapSize = struct_ptr[lookup_index].NumberOfPages * kib_cast(4); /* Size of bitmap in bytes. */ + if (!trials) + { + writer.Write("BootZ: Unable to allocate sufficent memory, aborting...\r"); + Boot::Stop(); + } + } + } + } handover_hdr->f_FirmwareCustomTables[0] = (VoidPtr)BS; handover_hdr->f_FirmwareCustomTables[1] = (VoidPtr)ST; @@ -249,6 +225,8 @@ EFI_EXTERN_C EFI_API Int32 ModuleMain(EfiHandlePtr image_handle, FBDrawBitMapInRegion(zka_has_disk, NE_HAS_DISK_WIDTH, NE_HAS_DISK_HEIGHT, (kHandoverHeader->f_GOP.f_Width - NE_HAS_DISK_WIDTH) / 2, (kHandoverHeader->f_GOP.f_Height - NE_HAS_DISK_HEIGHT) / 2); fb_clear(); + + Boot::Stop(); } } |
