===================================================================
@@ -82,7 +82,7 @@ DEPS := $(patsubst %.o,%.d,$(OBJS))
# Exclude BIOS object files from header dependencies.
OBJS += bios.o
-OBJS += bios/bios.o
+OBJS += bios/bios-rom.o
LIBS += -lrt
LIBS += -lpthread
@@ -165,20 +165,27 @@ BIOS_CFLAGS += -m32
BIOS_CFLAGS += -march=i386
BIOS_CFLAGS += -mregparm=3
-bios.o: bios/bios-rom.bin
-bios/bios.o: bios/bios.S bios/bios-rom.bin
- $(E) " CC " $@
- $(Q) $(CC) -c $(CFLAGS) bios/bios.S -o bios/bios.o
-
-bios/bios-rom.bin: bios/bios-rom.S bios/e820.c
- $(E) " CC " $@
+bios.o: bios/bios.bin bios/bios-rom.h
+
+bios/bios.bin.elf: bios/bios.S bios/e820.c bios/int10.c bios/rom.ld.S
+ $(E) " CC bios/e820.o"
$(Q) $(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c -s bios/e820.c -o bios/e820.o
+ $(E) " CC bios/int10.o"
$(Q) $(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c -s bios/int10.c -o bios/int10.o
- $(Q) $(CC) $(CFLAGS) $(BIOS_CFLAGS) -c -s bios/bios-rom.S -o bios/bios-rom.o
+ $(E) " CC bios/bios.o"
+ $(Q) $(CC) $(CFLAGS) $(BIOS_CFLAGS) -c -s bios/bios.S -o bios/bios.o
$(E) " LD " $@
- $(Q) ld -T bios/rom.ld.S -o bios/bios-rom.bin.elf bios/bios-rom.o bios/e820.o bios/int10.o
+ $(Q) ld -T bios/rom.ld.S -o bios/bios.bin.elf bios/bios.o bios/e820.o bios/int10.o
+
+bios/bios.bin: bios/bios.bin.elf
$(E) " OBJCOPY " $@
- $(Q) objcopy -O binary -j .text bios/bios-rom.bin.elf bios/bios-rom.bin
+ $(Q) objcopy -O binary -j .text bios/bios.bin.elf bios/bios.bin
+
+bios/bios-rom.o: bios/bios-rom.S bios/bios.bin bios/bios-rom.h
+ $(E) " CC " $@
+ $(Q) $(CC) -c $(CFLAGS) bios/bios-rom.S -o bios/bios-rom.o
+
+bios/bios-rom.h: bios/bios.bin.elf
$(E) " NM " $@
$(Q) cd bios && sh gen-offsets.sh > bios-rom.h && cd ..
===================================================================
@@ -1,89 +1,12 @@
-/*
- * Our pretty trivial BIOS emulation
- */
-
-#include <kvm/bios.h>
#include <kvm/assembly.h>
.org 0
- .code16gcc
-
-#include "macro.S"
-
-/*
- * fake interrupt handler, nothing can be faster ever
- */
-ENTRY(bios_intfake)
- IRET
-ENTRY_END(bios_intfake)
-
-/*
- * int 10 - video - service
- */
-ENTRY(bios_int10)
- pushw %fs
- pushl %es
- pushl %edi
- pushl %esi
- pushl %ebp
- pushl %esp
- pushl %edx
- pushl %ecx
- pushl %ebx
- pushl %eax
-
- movl %esp, %eax
- /* this is way easier than doing it in assembly */
- /* just push all the regs and jump to a C handler */
- call int10_handler
-
- popl %eax
- popl %ebx
- popl %ecx
- popl %edx
- popl %esp
- popl %ebp
- popl %esi
- popl %edi
- popl %es
- popw %fs
-
- IRET
-ENTRY_END(bios_int10)
-
-#define EFLAGS_CF (1 << 0)
-
-ENTRY(bios_int15)
- cmp $0xE820, %eax
- jne 1f
-
- pushw %fs
-
- pushl %edx
- pushl %ecx
- pushl %edi
- pushl %ebx
- pushl %eax
-
- movl %esp, %eax # it's bioscall case
- call e820_query_map
-
- popl %eax
- popl %ebx
- popl %edi
- popl %ecx
- popl %edx
-
- popw %fs
-
- /* Clear CF */
- andl $~EFLAGS_CF, 0x4(%esp)
-1:
- IRET
-ENTRY_END(bios_int15)
-
-GLOBAL(__locals)
-
-#include "local.S"
-
-END(__locals)
+#ifdef CONFIG_X86_64
+ .code64
+#else
+ .code32
+#endif
+
+GLOBAL(bios_rom)
+ .incbin "bios/bios.bin"
+END(bios_rom)
===================================================================
@@ -1,12 +1,89 @@
+/*
+ * Our pretty trivial BIOS emulation
+ */
+
+#include <kvm/bios.h>
#include <kvm/assembly.h>
.org 0
-#ifdef CONFIG_X86_64
- .code64
-#else
- .code32
-#endif
-
-GLOBAL(bios_rom)
- .incbin "bios/bios-rom.bin"
-END(bios_rom)
+ .code16gcc
+
+#include "macro.S"
+
+/*
+ * fake interrupt handler, nothing can be faster ever
+ */
+ENTRY(bios_intfake)
+ IRET
+ENTRY_END(bios_intfake)
+
+/*
+ * int 10 - video - service
+ */
+ENTRY(bios_int10)
+ pushw %fs
+ pushl %es
+ pushl %edi
+ pushl %esi
+ pushl %ebp
+ pushl %esp
+ pushl %edx
+ pushl %ecx
+ pushl %ebx
+ pushl %eax
+
+ movl %esp, %eax
+ /* this is way easier than doing it in assembly */
+ /* just push all the regs and jump to a C handler */
+ call int10_handler
+
+ popl %eax
+ popl %ebx
+ popl %ecx
+ popl %edx
+ popl %esp
+ popl %ebp
+ popl %esi
+ popl %edi
+ popl %es
+ popw %fs
+
+ IRET
+ENTRY_END(bios_int10)
+
+#define EFLAGS_CF (1 << 0)
+
+ENTRY(bios_int15)
+ cmp $0xE820, %eax
+ jne 1f
+
+ pushw %fs
+
+ pushl %edx
+ pushl %ecx
+ pushl %edi
+ pushl %ebx
+ pushl %eax
+
+ movl %esp, %eax # it's bioscall case
+ call e820_query_map
+
+ popl %eax
+ popl %ebx
+ popl %edi
+ popl %ecx
+ popl %edx
+
+ popw %fs
+
+ /* Clear CF */
+ andl $~EFLAGS_CF, 0x4(%esp)
+1:
+ IRET
+ENTRY_END(bios_int15)
+
+GLOBAL(__locals)
+
+#include "local.S"
+
+END(__locals)
===================================================================
@@ -8,6 +8,7 @@ echo ""
echo "#define BIOS_ENTRY_SIZE(name) (name##_end - name)"
echo ""
-nm bios-rom.bin.elf | grep ' [Tt] ' | awk '{ print "#define BIOS_OFFSET__" $3 " 0x" $1; }'
+nm bios.bin.elf | grep ' [Tt] ' | awk '{ print "#define BIOS_OFFSET__" $3 " 0x" $1; }'
+echo ""
echo "#endif"
Put bios code into bios.s and adjust makefile rules accordingly. It's more natural than bios-rom.S (which is now simply a container over real bios code). Also improve bios deps in Makefile. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> --- tools/kvm/Makefile | 29 +++++++----- tools/kvm/bios/bios-rom.S | 95 +++--------------------------------------- tools/kvm/bios/bios.S | 95 ++++++++++++++++++++++++++++++++++++++---- tools/kvm/bios/gen-offsets.sh | 3 - 4 files changed, 115 insertions(+), 107 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html