Support 32bit entry point and an elf wrapped binary.
authorKevin O'Connor <kevin@koconnor.net>
Fri, 9 May 2008 01:47:33 +0000 (21:47 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Fri, 9 May 2008 01:47:33 +0000 (21:47 -0400)
src/post.c
tools/buildrom.py

index 36fc2e9d50ee8bede8fe0cb148ece5dd7b3271d0..f69773f71f77f64ac1fae06f74aea28a25f1def1 100644 (file)
@@ -265,3 +265,15 @@ _start()
 
     post();
 }
+
+// Externally visible 32bit entry point.
+asm(
+    ".global post32\n"
+    "post32:\n"
+    "cli\n"
+    "cld\n"
+    "lidtl " __stringify(0xf0000 | OFFSET_pmode_IDT_info) "\n"
+    "lgdtl " __stringify(0xf0000 | OFFSET_rombios32_gdt_48) "\n"
+    "movl $" __stringify(CONFIG_STACK_OFFSET) ", %esp\n"
+    "jmp _start\n"
+    );
index fd490761e2bcae1f3ccf87c1bbaec8f67ce6023e..83bedde57a07e01ba21fcc9bf391f4400860f4e2 100755 (executable)
@@ -7,6 +7,7 @@
 
 import sys
 import struct
+import os
 
 ROM16='out/rom16.bin'
 ROM32='out/rom32.bin'
@@ -78,5 +79,11 @@ def main():
     f.write(outrom)
     f.close()
 
+    # Build elf file with 32bit entry point
+    os.system(
+        "objcopy -I binary -O elf32-i386 -B i386"
+        " --change-addresses 0xf0000 --set-start %s %s %s" %(
+            int(o32['OFFSET_post32'], 16) - 0xf0000, OUT, OUT+".o"))
+
 if __name__ == '__main__':
     main()