]> xenbits.xensource.com Git - people/andrewcoop/seabios.git/commitdiff
vgabios: Add config option for assembler fixups
authorKevin O'Connor <kevin@koconnor.net>
Thu, 9 Apr 2015 21:15:23 +0000 (17:15 -0400)
committerGerd Hoffmann <kraxel@redhat.com>
Fri, 12 Jun 2015 06:50:33 +0000 (08:50 +0200)
Add a kconfig build option (CONFIG_VGA_FIXUP_ASM) to allow users to
build the vgabios without the complex assembler fixups that work
around emulator bugs.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
(cherry picked from commit 799b20b0db45891845e2d820368a66af538d5664)

Makefile
vgasrc/Kconfig
vgasrc/vgaentry.S

index a84a5f7eb75b7a45bf144142e5313a959866dcf7..a4d945c23c3d4010f8721bfa0f78aaafea16a560 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -56,7 +56,7 @@ COMMONCFLAGS := -I$(OUT) -Isrc -Os -MD -g \
     -Wall -Wno-strict-aliasing -Wold-style-definition \
     $(call cc-option,$(CC),-Wtype-limits,) \
     -m32 -march=i386 -mregparm=3 -mpreferred-stack-boundary=2 \
-    -minline-all-stringops \
+    -minline-all-stringops -fomit-frame-pointer \
     -freg-struct-return -ffreestanding -fno-delete-null-pointer-checks \
     -ffunction-sections -fdata-sections -fno-common -fno-merge-constants
 COMMONCFLAGS += $(call cc-option,$(CC),-nopie,)
@@ -64,15 +64,14 @@ COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
 COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
 COMMA := ,
 
-CFLAGS32FLAT := $(COMMONCFLAGS) -DMODE16=0 -DMODESEGMENT=0 -fomit-frame-pointer
+CFLAGS32FLAT := $(COMMONCFLAGS) -DMODE16=0 -DMODESEGMENT=0
 CFLAGSSEG := $(COMMONCFLAGS) -DMODESEGMENT=1 -fno-defer-pop \
     $(call cc-option,$(CC),-fno-jump-tables,-DMANUAL_NO_JUMP_TABLE) \
     $(call cc-option,$(CC),-fno-tree-switch-conversion,)
-CFLAGS32SEG := $(CFLAGSSEG) -DMODE16=0 -fomit-frame-pointer
-CFLAGS16INC := $(CFLAGSSEG) -DMODE16=1 \
+CFLAGS32SEG := $(CFLAGSSEG) -DMODE16=0
+CFLAGS16 := $(CFLAGSSEG) -DMODE16=1 \
     $(call cc-option,$(CC),-m16,-Wa$(COMMA)src/code16gcc.s) \
     $(call cc-option,$(CC),--param large-stack-frame=4,-fno-inline)
-CFLAGS16 := $(CFLAGS16INC) -fomit-frame-pointer
 
 # Run with "make V=1" to see the actual compile commands
 ifdef V
@@ -210,23 +209,25 @@ SRCVGA=src/output.c src/string.c src/hw/pci.c src/hw/serialio.c \
     vgasrc/clext.c vgasrc/bochsvga.c vgasrc/geodevga.c \
     src/fw/coreboot.c vgasrc/cbvga.c
 
-CFLAGS16VGA = $(CFLAGS16INC) -Isrc
-
-$(OUT)vgaccode16.raw.s: $(OUT)autoconf.h $(patsubst %.c, $(OUT)%.o,$(SRCVGA)) ; $(call whole-compile, $(CFLAGS16VGA) -S, $(SRCVGA),$@)
+ifeq "$(CONFIG_VGA_FIXUP_ASM)" "y"
+$(OUT)vgaccode16.raw.s: $(OUT)autoconf.h $(patsubst %.c, $(OUT)%.o,$(SRCVGA)) ; $(call whole-compile, $(filter-out -fomit-frame-pointer,$(CFLAGS16)) -fno-omit-frame-pointer -S -Isrc, $(SRCVGA),$@)
 
 $(OUT)vgaccode16.o: $(OUT)vgaccode16.raw.s scripts/vgafixup.py
        @echo "  Fixup VGA rom assembler"
        $(Q)$(PYTHON) ./scripts/vgafixup.py $< $(OUT)vgaccode16.s
        $(Q)$(AS) --32 src/code16gcc.s $(OUT)vgaccode16.s -o $@
+else
+$(OUT)vgaccode16.o: $(OUT)autoconf.h $(patsubst %.c, $(OUT)%.o,$(SRCVGA)) ; $(call whole-compile, $(CFLAGS16) -Isrc, $(SRCVGA),$@)
+endif
 
 $(OUT)vgaentry.o: vgasrc/vgaentry.S $(OUT)autoconf.h $(OUT)asm-offsets.h
        @echo "  Compiling (16bit) $@"
-       $(Q)$(CC) $(CFLAGS16VGA) -c -D__ASSEMBLY__ $< -o $@
+       $(Q)$(CC) $(CFLAGS16) -c -D__ASSEMBLY__ $< -o $@
 
 $(OUT)vgarom.o: $(OUT)vgaccode16.o $(OUT)vgaentry.o $(OUT)vgasrc/vgalayout.lds scripts/buildversion.sh
        @echo "  Linking $@"
        $(Q)./scripts/buildversion.sh $(OUT)vgaversion.c VAR16
-       $(Q)$(CC) $(CFLAGS16VGA) -c $(OUT)vgaversion.c -o $(OUT)vgaversion.o
+       $(Q)$(CC) $(CFLAGS16) -c $(OUT)vgaversion.c -o $(OUT)vgaversion.o
        $(Q)$(LD) --gc-sections -T $(OUT)vgasrc/vgalayout.lds $(OUT)vgaccode16.o $(OUT)vgaentry.o $(OUT)vgaversion.o -o $@
 
 $(OUT)vgabios.bin.raw: $(OUT)vgarom.o
index 400e8da6f9e9ac9b09f350e78ba823b4aafacfcc..27a24c95d84c31175cd8323c56f75930c76498dc 100644 (file)
@@ -90,6 +90,16 @@ menu "VGA ROM"
             Support emulating text mode features when only a
             framebuffer is available.
 
+    config VGA_FIXUP_ASM
+        bool "Fixup assembler to work with broken emulators"
+        default y
+        help
+            This option will cause the build to attempt to avoid
+            certain x86 machine instructions that are known to confuse
+            some emulators.  In particular, it works around
+            deficiencies in the Windows vgabios emulator and the
+            x86emu vgabios emulator (frequently used in Xorg).
+
     config VGA_ALLOCATE_EXTRA_STACK
         depends on BUILD_VGABIOS
         bool "Allocate an internal stack for 16bit interrupt entry point"
index f9cf6568988566b883c2c3b6e5db6ab5cda48f38..dbb75e439e5251335ea81bca57ebd009db94ae1f 100644 (file)
@@ -64,6 +64,7 @@ x86emu_fault:
         // This macro implements a call while avoiding instructions
         // that old versions of x86emu have problems with.
         .macro VGA_CALLL cfunc
+#if CONFIG_VGA_FIXUP_ASM
         // Make sure leal instruction works.
         movl $0x8000, %ecx
         leal (%ecx, %ecx, 1), %ecx
@@ -72,6 +73,9 @@ x86emu_fault:
         // Use callw instead of calll
         push %ax
         callw \cfunc
+#else
+        calll \cfunc
+#endif
         .endm
 
         // This macro is the same as ENTRY_ARG except VGA_CALLL is used.