aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2015-04-09 17:15:23 -0400
committerGerd Hoffmann <kraxel@redhat.com>2015-06-12 08:50:33 +0200
commitc5fa0c5c38ea4965ac04b9c9328c4b47aed8a854 (patch)
tree41d0fd136bf42461e3173bb09145abd1da7b4ed2
parent4adadbde6904807de2e990c0af839ad0cc977806 (diff)
downloadseabios-c5fa0c5c38ea4965ac04b9c9328c4b47aed8a854.zip
seabios-c5fa0c5c38ea4965ac04b9c9328c4b47aed8a854.tar.gz
seabios-c5fa0c5c38ea4965ac04b9c9328c4b47aed8a854.tar.bz2
vgabios: Add config option for assembler fixups
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)
-rw-r--r--Makefile21
-rw-r--r--vgasrc/Kconfig10
-rw-r--r--vgasrc/vgaentry.S4
3 files changed, 25 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index a84a5f7..a4d945c 100644
--- 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
diff --git a/vgasrc/Kconfig b/vgasrc/Kconfig
index 400e8da..27a24c9 100644
--- a/vgasrc/Kconfig
+++ b/vgasrc/Kconfig
@@ -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"
diff --git a/vgasrc/vgaentry.S b/vgasrc/vgaentry.S
index f9cf656..dbb75e4 100644
--- a/vgasrc/vgaentry.S
+++ b/vgasrc/vgaentry.S
@@ -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.