Fix elf build; rename target file rom.bin to bios.bin.
authorKevin O'Connor <kevin@koconnor.net>
Sat, 10 May 2008 19:49:20 +0000 (15:49 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 10 May 2008 19:49:20 +0000 (15:49 -0400)
The main output file is now called out/bios.bin (instead of out/rom.bin).
Use ld to build final elf file and call the result out/bios.bin.elf
Make sure to long jump from external 32bit entry point.

Makefile
README
src/post.c
tools/buildrom.py

index 3d7c3e22f54c4f362d1377c23b799b66df4a2f8d..c8e68bda182eb2b74952b89863df3c35edf3f54c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,7 @@ CFLAGS16INC = $(COMMONCFLAGS) -DMODE16 -fno-jump-tables
 CFLAGS16 = $(CFLAGS16INC) -g
 
 TABLETMP=$(addprefix $(OUT), $(patsubst %.c,%.16.s,$(TABLESRC)))
-all: $(OUT) $(OUT)rom.bin $(TABLETMP)
+all: $(OUT) $(OUT)bios.bin $(TABLETMP)
 
 # Run with "make V=1" to see the actual compile commands
 ifdef V
@@ -103,7 +103,7 @@ $(OUT)rom32.o: $(OUT)romlayout32.o $(OUT)rombios32.lds
        @echo "  Linking $@"
        $(Q)ld -T $(OUT)rombios32.lds $< -o $@
 
-$(OUT)rom.bin: $(OUT)rom16.bin $(OUT)rom32.bin $(OUT)rom16.offset.auto.h $(OUT)rom32.offset.auto.h
+$(OUT)bios.bin: $(OUT)rom16.bin $(OUT)rom32.bin $(OUT)rom16.offset.auto.h $(OUT)rom32.offset.auto.h
        @echo "  Building $@"
        $(Q)./tools/buildrom.py
 
diff --git a/README b/README
index dc0a725d79e09267beb31ec2e6037e0bf8567994..fe5f601dd6bc1c0215db1240580dd30f9548b53c 100644 (file)
--- a/README
+++ b/README
@@ -2,7 +2,7 @@ This code implements an X86 legacy bios.  It is intended to be
 compiled using standard gnu tools (eg, gas and gcc).
 
 To build, one should be able to run "make" in the main directory.  The
-resulting file "out/rom.bin" contains the processed bios image.
+resulting file "out/bios.bin" contains the processed bios image.
 
 The build requires gcc v4.1 or later.  Some buggy versions of gcc have
 issues with the '-combine' compiler option - in particular, recent
@@ -15,13 +15,13 @@ Testing of images:
 To test the bios under bochs, one will need to instruct bochs to use
 the new bios image.  Use the 'romimage' option - for example:
 
-bochs -q 'floppya: 1_44=myfdimage.img' 'romimage: file=out/rom.bin'
+bochs -q 'floppya: 1_44=myfdimage.img' 'romimage: file=out/bios.bin'
 
 To test under qemu, one will need to create a directory with all the
 bios images and then overwrite the main bios image.  For example:
 
 cp /usr/share/qemu/*.bin mybiosdir/
-cp out/rom.bin mybiosdir/bios.bin
+cp out/bios.bin mybiosdir/
 
 Once this is setup, one can instruct qemu to use the newly created
 directory for rom images.  For example:
index f69773f71f77f64ac1fae06f74aea28a25f1def1..0d8f18e2d5a78bab804a0e36c93d98d6c5784239 100644 (file)
@@ -275,5 +275,5 @@ asm(
     "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"
+    "ljmp $0x10, $_start\n"
     );
index 83bedde57a07e01ba21fcc9bf391f4400860f4e2..7d48cb587cdf7126842fece9b8cf601a051145a7 100755 (executable)
@@ -13,7 +13,7 @@ ROM16='out/rom16.bin'
 ROM32='out/rom32.bin'
 OFFSETS16='out/rom16.offset.auto.h'
 OFFSETS32='out/rom32.offset.auto.h'
-OUT='out/rom.bin'
+OUT='out/bios.bin'
 
 def align(v, a):
     return (v + a - 1) // a * a
@@ -81,9 +81,8 @@ def main():
 
     # 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"))
+        "ld -melf_i386 -e %s -Ttext 0xf0000 -b binary %s -o %s" % (
+            int(o32['OFFSET_post32'], 16), OUT, OUT+".elf"))
 
 if __name__ == '__main__':
     main()