summaryrefslogtreecommitdiffhomepage
path: root/dev/boot/src
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-04-10 09:45:02 +0200
committerGitHub <noreply@github.com>2025-04-10 09:45:02 +0200
commit8988b6f166d1087615b21229df651e0bcc0fa048 (patch)
treef9a526d927e9b73a588e9c7db5cd99bf1622ca23 /dev/boot/src
parent29828ef52df7a51e22057b4557b8d9a3d5550839 (diff)
parente50f871e6852beacb53986f930ed2d5dead84838 (diff)
Merge pull request #13 from amlel-el-mahrouss/dev
dev: Last AHCI patches.
Diffstat (limited to 'dev/boot/src')
-rw-r--r--dev/boot/src/HEL/AMD64/BootEFI.cc72
1 files changed, 25 insertions, 47 deletions
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();
}
}