OSDN Git Service

added precompiled linux boot sector
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>
Wed, 25 Feb 2004 23:54:25 +0000 (23:54 +0000)
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>
Wed, 25 Feb 2004 23:54:25 +0000 (23:54 +0000)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@652 c046a42c-6fe2-441c-8c8c-71466251a162

Makefile
Makefile.target
pc-bios/Makefile [new file with mode: 0644]
pc-bios/linux_boot.S [moved from linux_boot.S with 75% similarity]
pc-bios/linux_boot.bin [new file with mode: 0644]
vl.c

index 4c49bd4..11f7915 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -39,7 +39,8 @@ install: all
        mkdir -p $(prefix)/bin
        install -m 755 -s $(TOOLS) $(prefix)/bin
        mkdir -p $(sharedir)
-       install -m 644 pc-bios/bios.bin pc-bios/vgabios.bin $(sharedir)
+       install -m 644 pc-bios/bios.bin pc-bios/vgabios.bin \
+                       pc-bios/linux_boot.bin $(sharedir)
        mkdir -p $(mandir)/man1
        install qemu.1 $(mandir)/man1
        for d in $(TARGET_DIRS); do \
index 3f5a1ba..08d8dfc 100644 (file)
@@ -206,9 +206,6 @@ endif
 
 # must use static linking to avoid leaving stuff in virtual address space
 VL_OBJS=vl.o block.o ide.o vga.o sb16.o dma.o oss.o fdc.o osdep.o
-ifeq ($(TARGET_ARCH), i386)
-VL_OBJS+=linux_boot.o  
-endif
 ifeq ($(TARGET_ARCH), ppc)
 VL_OBJS+= hw.o
 endif
diff --git a/pc-bios/Makefile b/pc-bios/Makefile
new file mode 100644 (file)
index 0000000..7ae0ff0
--- /dev/null
@@ -0,0 +1,24 @@
+#
+# NOTE: only compilable with x86 cross compile tools
+#
+include ../config-host.mak
+
+DEFINES=
+
+TARGETS=
+ifeq ($(ARCH),i386)
+TARGETS+=linux_boot.bin
+endif
+
+all: $(TARGETS)
+
+linux_boot.bin: linux_boot.o
+       ld --oformat binary -Ttext 0 -o $@ $<
+       chmod a-x $@
+
+%.o: %.S
+       $(CC) $(DEFINES) -c -o $@ $<
+
+clean:
+       rm -f $(TARGETS) *.o *~
+
similarity index 75%
rename from linux_boot.S
rename to pc-bios/linux_boot.S
index 353052c..22fcd4b 100644 (file)
@@ -7,10 +7,9 @@
         
 .code16        
 .text
-       .globl  linux_boot_start
-       .globl  linux_boot_end
+       .globl  _start
 
-linux_boot_start:
+_start:
         cli
         cld
         mov $LOAD_SEG, %ax
@@ -23,10 +22,8 @@ linux_boot_start:
         ljmp $LOAD_SEG + 0x20, $0
 
 1:              
-        .fill 510 - (1b - linux_boot_start), 1, 0
+        .fill 510 - (1b - _start), 1, 0
 
         /* boot sector signature */
         .byte 0x55
         .byte 0xaa
-                
-linux_boot_end:
diff --git a/pc-bios/linux_boot.bin b/pc-bios/linux_boot.bin
new file mode 100644 (file)
index 0000000..80f7b5f
Binary files /dev/null and b/pc-bios/linux_boot.bin differ
diff --git a/vl.c b/vl.c
index 7e729ee..e2e1393 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -53,6 +53,7 @@
 #define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
 #define BIOS_FILENAME "bios.bin"
 #define VGABIOS_FILENAME "vgabios.bin"
+#define LINUX_BOOT_FILENAME "linux_boot.bin"
 
 //#define DEBUG_UNUSED_IOPORT
 
@@ -3463,15 +3464,21 @@ int main(int argc, char **argv)
     bochs_bios_init();
 
     if (linux_boot) {
-        extern uint8_t linux_boot_start;
-        extern uint8_t linux_boot_end;
+        uint8_t bootsect[512];
 
         if (bs_table[0] == NULL) {
             fprintf(stderr, "A disk image must be given for 'hda' when booting a Linux kernel\n");
             exit(1);
         }
-        bdrv_set_boot_sector(bs_table[0], &linux_boot_start,
-                             &linux_boot_end - &linux_boot_start);
+        snprintf(buf, sizeof(buf), "%s/%s", bios_dir, LINUX_BOOT_FILENAME);
+        ret = load_image(buf, bootsect);
+        if (ret != sizeof(bootsect)) {
+            fprintf(stderr, "qemu: could not load linux boot sector '%s'\n",
+                    buf);
+            exit(1);
+        }
+
+        bdrv_set_boot_sector(bs_table[0], bootsect, sizeof(bootsect));
 
         /* now we can load the kernel */
         ret = load_kernel(kernel_filename,