:: commit 4ef529b4eb99f866f8a130db2c25259a4d201a60

mintsuki <mintsuki@protonmail.com> — 2023-03-07 01:21

parents: 5bc6fbca3b

misc: Load BIOS port at 0xf000 instead of 0x8000

diff --git a/common/GNUmakefile b/common/GNUmakefile
index 1a15ff50..aaca1f28 100644
--- a/common/GNUmakefile
+++ b/common/GNUmakefile
@@ -208,7 +208,7 @@ $(call MKESCAPE,$(BUILDDIR))/stage2.bin.gz: $(call MKESCAPE,$(BUILDDIR))/stage2.
 	gzip -n -9 < '$(call SHESCAPE,$<)' > '$(call SHESCAPE,$@)'
 
 $(call MKESCAPE,$(BUILDDIR))/stage2.bin: $(call MKESCAPE,$(BUILDDIR))/limine.sys
-	dd if='$(call SHESCAPE,$<)' bs=$$(( 0x$$("$(CROSS_READELF)" -S '$(call SHESCAPE,$(BUILDDIR))/limine.elf' | $(GREP) '\.text\.stage3' | $(SED) 's/^.*] //' | $(AWK) '{print $$3}' | $(SED) 's/^0*//') - 0x8000 )) count=1 of='$(call SHESCAPE,$@)' 2>/dev/null
+	dd if='$(call SHESCAPE,$<)' bs=$$(( 0x$$("$(CROSS_READELF)" -S '$(call SHESCAPE,$(BUILDDIR))/limine.elf' | $(GREP) '\.text\.stage3' | $(SED) 's/^.*] //' | $(AWK) '{print $$3}' | $(SED) 's/^0*//') - 0xf000 )) count=1 of='$(call SHESCAPE,$@)' 2>/dev/null
 
 $(call MKESCAPE,$(BUILDDIR))/stage2.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf
 	cd '$(call SHESCAPE,$(BUILDDIR))' && \
diff --git a/common/entry.s2.c b/common/entry.s2.c
index a355781a..e9351680 100644
--- a/common/entry.s2.c
+++ b/common/entry.s2.c
@@ -58,8 +58,8 @@ static bool stage3_init(struct volume *part) {
     }
 
     fread(stage3, stage3_addr,
-          (uintptr_t)stage3_addr - 0x8000,
-          stage3->size - ((uintptr_t)stage3_addr - 0x8000));
+          (uintptr_t)stage3_addr - 0xf000,
+          stage3->size - ((uintptr_t)stage3_addr - 0xf000));
 
     fclose(stage3);
 
diff --git a/common/linker_bios.ld.in b/common/linker_bios.ld.in
index 882be123..7d4e219f 100644
--- a/common/linker_bios.ld.in
+++ b/common/linker_bios.ld.in
@@ -12,7 +12,7 @@ PHDRS
 
 SECTIONS
 {
-    . = 0x8000;
+    . = 0xf000;
 
     .text.stage2 : {
         *(.entry)
@@ -80,7 +80,7 @@ SECTIONS
 
     .note.gnu.build-id : {
         *(.note.gnu.build-id)
-        limine_sys_size = . - 0x8000;
+        limine_sys_size = . - 0xf000;
     } :data_s3
 
     .bss : {
diff --git a/decompressor/main.c b/decompressor/main.c
index bf25012f..94e8214d 100644
--- a/decompressor/main.c
+++ b/decompressor/main.c
@@ -4,18 +4,18 @@
 #include <tinf.h>
 
 noreturn void entry(uint8_t *compressed_stage2, size_t stage2_size, uint8_t boot_drive, int pxe) {
-    // The decompressor should decompress compressed_stage2 to address 0x8000.
-    uint8_t *dest = (uint8_t *)0x8000;
+    // The decompressor should decompress compressed_stage2 to address 0xf000.
+    uint8_t *dest = (uint8_t *)0xf000;
 
     tinf_gzip_uncompress(dest, compressed_stage2, stage2_size);
 
     asm volatile (
-        "movl $0x7c00, %%esp\n\t"
+        "movl $0xf000, %%esp\n\t"
         "xorl %%ebp, %%ebp\n\t"
         "pushl %1\n\t"
         "pushl %0\n\t"
         "pushl $0\n\t"
-        "pushl $0x8000\n\t"
+        "pushl $0xf000\n\t"
         "ret\n\t"
         :
         : "r" ((uint32_t)boot_drive), "r" (pxe)
tab: 248 wrap: offon