From 41a033fe8ae76f42756808d3681b2cd50597808a Mon Sep 17 00:00:00 2001 From: TomAwezome Date: Sat, 27 Aug 2022 05:11:55 -0400 Subject: [PATCH] Implement prekernel disk GPT UUID pass to kernel, add to headers, check in AHCIBootDVDProbeAll. --- src/Kernel/BlkDev/DiskAHCI.ZC | 12 +++++++++++- src/Kernel/KStart16.ZC | 2 ++ src/Kernel/KernelA.HH | 1 + src/Kernel/KernelB.HH | 2 ++ zealbooter/zealbooter.c | 9 +++++++++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Kernel/BlkDev/DiskAHCI.ZC b/src/Kernel/BlkDev/DiskAHCI.ZC index fa9be7f1..4382de8f 100755 --- a/src/Kernel/BlkDev/DiskAHCI.ZC +++ b/src/Kernel/BlkDev/DiskAHCI.ZC @@ -1163,7 +1163,17 @@ Bool AHCIBootDVDProbeAll(CBlkDev *bd) return TRUE; } else - "AHCI: Did not find matching sys_compile_time on Port %d\n", i; + "AHCI: Did not find matching sys_compile_time at BLK %d on Port %d\n", sys_boot_blk, i; + + "%X %X", sys_disk_uuid[0], sys_disk_uuid[1]; + AHCIAtapiBlksRead(bd, buf, 0, 1, FALSE); + if (!MemCompare(buf + 568, sys_disk_uuid, 16)) + { + "AHCI: Found sys_disk_uuid at BLK 0 byte 568 on Port %d\n", i; + "______________________\n"; + return TRUE; + } + } catch { diff --git a/src/Kernel/KStart16.ZC b/src/Kernel/KStart16.ZC index b3d9dbaf..8263d60c 100755 --- a/src/Kernel/KStart16.ZC +++ b/src/Kernel/KStart16.ZC @@ -58,6 +58,8 @@ SYS_FRAMEBUFFER_BPP:: DU16 0; SYS_SMBIOS_ENTRY:: DU64 0; +SYS_DISK_UUID:: DU64 0, 0; + #assert $$ - SYS_KERNEL == sizeof(CKernel) - sizeof(CZXE) REQUESTED_SCREEN_WIDTH: DU16 1024; diff --git a/src/Kernel/KernelA.HH b/src/Kernel/KernelA.HH index bc6946ca..c36a5066 100755 --- a/src/Kernel/KernelA.HH +++ b/src/Kernel/KernelA.HH @@ -570,6 +570,7 @@ class CKernel U64 sys_framebuffer_pitch; U16 sys_framebuffer_bpp; U64 sys_smbios_entry; + U64 sys_disk_uuid[2]; }; //Run-Levels diff --git a/src/Kernel/KernelB.HH b/src/Kernel/KernelB.HH index 8b0a5f08..13b14411 100755 --- a/src/Kernel/KernelB.HH +++ b/src/Kernel/KernelB.HH @@ -253,4 +253,6 @@ public _extern SYS_FRAMEBUFFER_BPP U16 sys_framebuffer_bpp; #help_index "Processor/SMBIOS" public _extern SYS_SMBIOS_ENTRY U8 *sys_smbios_entry; +public _extern SYS_DISK_UUID U64 sys_disk_uuid[2]; + #help_index "" diff --git a/zealbooter/zealbooter.c b/zealbooter/zealbooter.c index b7bd913e..e99337ea 100644 --- a/zealbooter/zealbooter.c +++ b/zealbooter/zealbooter.c @@ -132,6 +132,10 @@ struct CKernel { uint64_t sys_framebuffer_pitch; uint16_t sys_framebuffer_bpp; uint64_t sys_smbios_entry; + uint32_t sys_disk_uuid_a; + uint16_t sys_disk_uuid_b; + uint16_t sys_disk_uuid_c; + uint8_t sys_disk_uuid_d[8]; } __attribute__((packed)); #define BOOT_SRC_RAM 2 @@ -270,6 +274,11 @@ void _start(void) { void *sys_smbios_entry = smbios_request.response->entry_32; CKernel->sys_smbios_entry = (uintptr_t)sys_smbios_entry - hhdm_request.response->offset; + CKernel->sys_disk_uuid_a = kernel->gpt_disk_uuid.a; + CKernel->sys_disk_uuid_b = kernel->gpt_disk_uuid.b; + CKernel->sys_disk_uuid_c = kernel->gpt_disk_uuid.c; + memcpy(CKernel->sys_disk_uuid_d, kernel->gpt_disk_uuid.d, 8); + void *trampoline_phys = (void *)final_address + kernel->size; uintptr_t boot_stack = ALIGN_UP(final_address + kernel->size + trampoline_size, 16) + boot_stack_size;