From 8fa30a396f39ba950fa8a5251e1356368cdcf5d1 Mon Sep 17 00:00:00 2001 From: TomAwezome Date: Mon, 29 Aug 2022 00:24:45 -0400 Subject: [PATCH] Unhardcode BOOT_RAM_LIMIT, patch via kernel headers. --- src/Kernel/KStart16.ZC | 2 ++ src/Kernel/KStart32.ZC | 2 +- src/Kernel/KStart64.ZC | 2 +- src/Kernel/KernelA.HH | 1 + zealbooter/zealbooter.c | 3 +++ 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Kernel/KStart16.ZC b/src/Kernel/KStart16.ZC index 12185d1d..858b9dde 100755 --- a/src/Kernel/KStart16.ZC +++ b/src/Kernel/KStart16.ZC @@ -60,6 +60,8 @@ SYS_SMBIOS_ENTRY:: DU64 0; SYS_DISK_UUID:: DU64 0, 0; +SYS_BOOT_STACK:: DU32 BOOT_RAM_LIMIT; + #assert $$ - SYS_KERNEL == sizeof(CKernel) - sizeof(CZXE) REQUESTED_SCREEN_WIDTH: DU16 1024; diff --git a/src/Kernel/KStart32.ZC b/src/Kernel/KStart32.ZC index 5893d605..5d2ae18b 100755 --- a/src/Kernel/KStart32.ZC +++ b/src/Kernel/KStart32.ZC @@ -88,6 +88,7 @@ CORE0_32BIT_INIT:: //Entry point for $LK,"BootRAM",A="MN:BootRAM"$. BTS U32 [SYS_RUN_LEVEL], RLf_32BIT MOV ESI, U32 [SYS_BOOT_PATCH_TABLE_BASE] MOV EDI, U32 [MEM_BOOT_BASE] + MOV ESP, U32 [SYS_BOOT_STACK] MOV AX, CGDT.ds MOV DS, AX @@ -95,7 +96,6 @@ CORE0_32BIT_INIT:: //Entry point for $LK,"BootRAM",A="MN:BootRAM"$. MOV FS, AX MOV GS, AX MOV SS, AX - MOV ESP, BOOT_RAM_LIMIT //Tmp Stack JMP @@02 diff --git a/src/Kernel/KStart64.ZC b/src/Kernel/KStart64.ZC index e4317bf0..f814e440 100755 --- a/src/Kernel/KStart64.ZC +++ b/src/Kernel/KStart64.ZC @@ -83,7 +83,7 @@ USE64 //************************************ SYS_RAM_REBOOT:: //This gets copied high. $LK,"SYS_RAM_REBOOT",A="FF:::/System/Boot/BootRAM.ZC,SYS_RAM_REBOOT:2"$ PUSH U32 CGDT.ds //stack seg - PUSH U32 BOOT_RAM_LIMIT //stack + PUSH U32 [SYS_BOOT_STACK]//stack PUSH U32 0 //flags PUSH U32 CGDT.cs32 LEA RAX, [@@10] diff --git a/src/Kernel/KernelA.HH b/src/Kernel/KernelA.HH index 6ebdd8b9..56e6fd03 100755 --- a/src/Kernel/KernelA.HH +++ b/src/Kernel/KernelA.HH @@ -563,6 +563,7 @@ class CKernel U8 sys_framebuffer_bpp; U64 sys_smbios_entry; U64 sys_disk_uuid[2]; + U32 sys_boot_stack; }; //Run-Levels diff --git a/zealbooter/zealbooter.c b/zealbooter/zealbooter.c index bec0d050..57c76084 100644 --- a/zealbooter/zealbooter.c +++ b/zealbooter/zealbooter.c @@ -111,6 +111,7 @@ struct CKernel { uint16_t sys_disk_uuid_b; uint16_t sys_disk_uuid_c; uint8_t sys_disk_uuid_d[8]; + uint32_t sys_boot_stack; } __attribute__((packed)); #define BOOT_SRC_RAM 2 @@ -266,6 +267,8 @@ void _start(void) { uintptr_t boot_stack = ALIGN_UP(final_address + kernel->size + trampoline_size, 16) + boot_stack_size; + CKernel->sys_boot_stack = boot_stack; + memcpy(trampoline_phys, trampoline, trampoline_size); memcpy((void *)final_address, CKernel, kernel->size);