diff options
author | Yonghee Han <onstudy@samsung.com> | 2016-07-27 16:40:17 +0900 |
---|---|---|
committer | Yonghee Han <onstudy@samsung.com> | 2016-07-27 00:53:56 -0700 |
commit | 3158f4a51894e46ecb593bffbfd12824e1d6534a (patch) | |
tree | 2bef7f0238e687c5de65f48b5995ee124a95d157 /roms | |
parent | a3b133b0ea0696e42fd876b9a803e28bc6ef5299 (diff) | |
download | qemu-3158f4a51894e46ecb593bffbfd12824e1d6534a.tar.gz qemu-3158f4a51894e46ecb593bffbfd12824e1d6534a.tar.bz2 qemu-3158f4a51894e46ecb593bffbfd12824e1d6534a.zip |
Imported Upstream version 2.4.1upstream/2.4.1
Change-Id: I0b584f569cb0e0f4eac13cdb79e110c2dbc34bfc
Diffstat (limited to 'roms')
35 files changed, 239 insertions, 206 deletions
diff --git a/roms/Makefile b/roms/Makefile index 610b53462..7b3f15632 100644 --- a/roms/Makefile +++ b/roms/Makefile @@ -1,5 +1,5 @@ -vgabios_variants := stdvga cirrus vmware qxl isavga +vgabios_variants := stdvga cirrus vmware qxl isavga virtio vgabios_targets := $(subst -isavga,,$(patsubst %,vgabios-%.bin,$(vgabios_variants))) pxerom_variants := e1000 eepro100 ne2k_pci pcnet rtl8139 virtio pxerom_targets := 8086100e 80861209 10500940 10222000 10ec8139 1af41000 @@ -34,6 +34,9 @@ powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64) powerpc_cross_prefix := $(call find-cross-prefix,powerpc) x86_64_cross_prefix := $(call find-cross-prefix,x86_64) +# tag our seabios builds +SEABIOS_VERSION="$(shell cd seabios; git describe --tags --long) by qemu-project.org" + # # EfiRom utility is shipped with edk2 / tianocore, in BaseTools/ # @@ -75,10 +78,12 @@ build-seabios-config-%: config.% mkdir -p seabios/builds/$* cp $< seabios/builds/$*/.config $(MAKE) -C seabios \ + VERSION=$(SEABIOS_VERSION) \ CROSS_COMPILE=$(x86_64_cross_prefix) \ KCONFIG_CONFIG=$(CURDIR)/seabios/builds/$*/.config \ OUT=$(CURDIR)/seabios/builds/$*/ oldnoconfig $(MAKE) -C seabios \ + VERSION=$(SEABIOS_VERSION) \ CROSS_COMPILE=$(x86_64_cross_prefix) \ KCONFIG_CONFIG=$(CURDIR)/seabios/builds/$*/.config \ OUT=$(CURDIR)/seabios/builds/$*/ all diff --git a/roms/SLOF/VERSION b/roms/SLOF/VERSION index ea0dd137c..20bdb2eb7 100644 --- a/roms/SLOF/VERSION +++ b/roms/SLOF/VERSION @@ -1 +1 @@ -20150313 +20150429 diff --git a/roms/SLOF/board-qemu/slof/pci-phb.fs b/roms/SLOF/board-qemu/slof/pci-phb.fs index 529772f4e..a8fb7ca5e 100644 --- a/roms/SLOF/board-qemu/slof/pci-phb.fs +++ b/roms/SLOF/board-qemu/slof/pci-phb.fs @@ -282,6 +282,41 @@ setup-puid THEN ; +: phb-pci-walk-bridge ( -- ) + phb-debug? IF ." Calling pci-walk-bridge " pwd cr THEN + + get-node child ?dup 0= IF EXIT THEN \ get and check if we have children + 0 to pci-device-slots \ reset slot array to unpoppulated + BEGIN + dup \ Continue as long as there are children + WHILE + dup set-node \ Set child node as current node + my-space pci-set-slot \ set the slot bit + my-space pci-htype@ \ read HEADER-Type + 7f and \ Mask bit 7 - multifunction device + CASE + 0 OF my-space pci-device-setup ENDOF \ | set up the device + 1 OF my-space pci-bridge-setup ENDOF \ | set up the bridge + dup OF my-space pci-htype@ pci-out ENDOF + ENDCASE + peer + REPEAT drop + get-parent set-node +; + +\ Landing routing to probe the popuated device tree +: phb-pci-probe-bus ( busnr -- ) + drop phb-pci-walk-bridge +; + +\ Stub routine, as qemu has enumerated, we already have the device +\ properties set. +: phb-pci-device-props ( addr -- ) + dup pci-class-name device-name + dup pci-device-assigned-addresses-prop + drop +; + \ Scan the child nodes of the pci root node to assign bars, fixup \ properties etc. : phb-setup-children @@ -289,7 +324,14 @@ setup-puid my-puid TO puid \ Set current puid phb-parse-ranges 1 TO pci-hotplug-enabled - 1 0 (probe-pci-host-bridge) + s" qemu,phb-enumerated" get-node get-property 0<> IF + 1 0 (probe-pci-host-bridge) + ELSE + 2drop + ['] phb-pci-probe-bus TO func-pci-probe-bus + ['] phb-pci-device-props TO func-pci-device-props + phb-pci-walk-bridge \ PHB device tree is already populated. + THEN r> TO puid \ Restore previous puid ; phb-setup-children diff --git a/roms/SLOF/lib/libbcm/Makefile b/roms/SLOF/lib/libbcm/Makefile index b17e58889..1aead4c5e 100644 --- a/roms/SLOF/lib/libbcm/Makefile +++ b/roms/SLOF/lib/libbcm/Makefile @@ -12,6 +12,8 @@ TOPCMNDIR ?= ../.. +include $(TOPCMNDIR)/make.rules + CPPFLAGS = -I../libc/include $(CPUARCHDEF) -I$(INCLBRDDIR) \ -I$(INCLCMNDIR) -I$(INCLCMNDIR)/$(CPUARCH) diff --git a/roms/SLOF/lib/libbootmsg/Makefile b/roms/SLOF/lib/libbootmsg/Makefile index 891987ea6..642c970ac 100644 --- a/roms/SLOF/lib/libbootmsg/Makefile +++ b/roms/SLOF/lib/libbootmsg/Makefile @@ -12,6 +12,8 @@ TOPCMNDIR ?= ../.. +include $(TOPCMNDIR)/make.rules + ASFLAGS = $(FLAG) $(RELEASE) $(CPUARCHDEF) -Wa,-mregnames CPPFLAGS = -I../libc/include $(CPUARCHDEF) -I$(INCLBRDDIR) -I. -I../../include LDFLAGS = -nostdlib diff --git a/roms/SLOF/lib/libe1k/Makefile b/roms/SLOF/lib/libe1k/Makefile index 24cddc7f2..0c3169f02 100644 --- a/roms/SLOF/lib/libe1k/Makefile +++ b/roms/SLOF/lib/libe1k/Makefile @@ -12,6 +12,8 @@ TOPCMNDIR ?= ../.. +include $(TOPCMNDIR)/make.rules + CPPFLAGS = -I../libc/include $(CPUARCHDEF) -I$(INCLBRDDIR) \ -I$(INCLCMNDIR) -I$(INCLCMNDIR)/$(CPUARCH) diff --git a/roms/SLOF/lib/libhvcall/Makefile b/roms/SLOF/lib/libhvcall/Makefile index af7fbc359..2a9b2d7d1 100644 --- a/roms/SLOF/lib/libhvcall/Makefile +++ b/roms/SLOF/lib/libhvcall/Makefile @@ -12,6 +12,8 @@ TOPCMNDIR ?= ../.. +include $(TOPCMNDIR)/make.rules + ASFLAGS = $(FLAG) $(RELEASE) $(CPUARCHDEF) -Wa,-mregnames CPPFLAGS = -I../libc/include $(CPUARCHDEF) -I$(INCLBRDDIR) \ -I$(INCLCMNDIR) -I$(INCLCMNDIR)/$(CPUARCH) diff --git a/roms/SLOF/lib/libusb/Makefile b/roms/SLOF/lib/libusb/Makefile index ee065be48..0780489ea 100644 --- a/roms/SLOF/lib/libusb/Makefile +++ b/roms/SLOF/lib/libusb/Makefile @@ -12,6 +12,8 @@ TOPCMNDIR ?= ../.. +include $(TOPCMNDIR)/make.rules + ASFLAGS = $(FLAG) $(RELEASE) $(CPUARCHDEF) -Wa,-mregnames CPPFLAGS = -I../libc/include $(CPUARCHDEF) -I$(INCLBRDDIR) \ -I$(INCLCMNDIR) -I$(INCLCMNDIR)/$(CPUARCH) -I$(SLOFCMNDIR) diff --git a/roms/SLOF/lib/libusb/usb-hid.c b/roms/SLOF/lib/libusb/usb-hid.c index 28022d0eb..f0cab8a69 100644 --- a/roms/SLOF/lib/libusb/usb-hid.c +++ b/roms/SLOF/lib/libusb/usb-hid.c @@ -416,9 +416,26 @@ int usb_hid_kbd_exit(struct usb_dev *dev) return true; } +static int usb_poll_key(void *vdev) +{ + struct usb_dev *dev = vdev; + uint8_t key[8]; + int rc; + + memset(key, 0, 8); + rc = usb_poll_intr(dev->intr, key); + if (rc) + check_key_code(key); + return rc; +} + unsigned char usb_key_available(void *dev) { - if (dev && r_ptr != w_ptr) + if (!dev) + return false; + + usb_poll_key(dev); + if (r_ptr != w_ptr) return true; else return false; @@ -426,16 +443,11 @@ unsigned char usb_key_available(void *dev) unsigned char usb_read_keyb(void *vdev) { - struct usb_dev *dev = vdev; - uint8_t key[8]; - - if (!dev) + if (!vdev) return false; - memset(key, 0, 8); - while (usb_poll_intr(dev->intr, key)) { - check_key_code(key); - memset(key, 0, 8); + while (usb_poll_key(vdev)) { + /* loop for all pending keys */ } return read_key(); } diff --git a/roms/SLOF/lib/libveth/Makefile b/roms/SLOF/lib/libveth/Makefile index 455611051..dd1234af1 100644 --- a/roms/SLOF/lib/libveth/Makefile +++ b/roms/SLOF/lib/libveth/Makefile @@ -12,6 +12,8 @@ TOPCMNDIR ?= ../.. +include $(TOPCMNDIR)/make.rules + CPPFLAGS = -I../libc/include $(CPUARCHDEF) -I$(INCLBRDDIR) \ -I$(INCLCMNDIR) -I$(INCLCMNDIR)/$(CPUARCH) CPPFLAGS += -I../libhvcall diff --git a/roms/SLOF/lib/libvirtio/Makefile b/roms/SLOF/lib/libvirtio/Makefile index 430f9a73d..bd6a1fae4 100644 --- a/roms/SLOF/lib/libvirtio/Makefile +++ b/roms/SLOF/lib/libvirtio/Makefile @@ -12,6 +12,8 @@ TOPCMNDIR ?= ../.. +include $(TOPCMNDIR)/make.rules + ASFLAGS = $(FLAG) $(RELEASE) $(CPUARCHDEF) -Wa,-mregnames CPPFLAGS = -I../libc/include $(CPUARCHDEF) -I$(INCLBRDDIR) \ -I$(INCLCMNDIR) -I$(INCLCMNDIR)/$(CPUARCH) diff --git a/roms/SLOF/slof/fs/devices/pci-class_0c.fs b/roms/SLOF/slof/fs/devices/pci-class_0c.fs index 9c4732535..39453fbc0 100644 --- a/roms/SLOF/slof/fs/devices/pci-class_0c.fs +++ b/roms/SLOF/slof/fs/devices/pci-class_0c.fs @@ -25,8 +25,14 @@ CONSTANT /hci-dev : usb-setup-hcidev ( num hci-dev -- ) >r - 10 config-l@ translate-my-address - 3 not AND + 10 config-l@ F AND case + 0 OF 10 config-l@ translate-my-address ENDOF \ 32-bit memory space + 4 OF \ 64-bit memory space + 14 config-l@ 20 lshift \ Read two bars + 10 config-l@ OR translate-my-address + ENDOF + ENDCASE + F not AND ( io-base ) r@ hcd>base ! 08 config-l@ 8 rshift 0000000F0 AND 4 rshift ( usb-type ) r@ hcd>type ! diff --git a/roms/SLOF/slof/fs/packages.fs b/roms/SLOF/slof/fs/packages.fs index a31be2eb8..f640d8f61 100644 --- a/roms/SLOF/slof/fs/packages.fs +++ b/roms/SLOF/slof/fs/packages.fs @@ -1,5 +1,5 @@ \ ***************************************************************************** -\ * Copyright (c) 2004, 2008 IBM Corporation +\ * Copyright (c) 2004, 2015 IBM Corporation \ * All rights reserved. \ * This program and the accompanying materials \ * are made available under the terms of the BSD License @@ -50,13 +50,3 @@ finish-device new-device #include "packages/iso-9660.fs" finish-device - -\ new-device -\ #include "packages/scsi.fs" -\ finish-device - -new-device -#include "packages/bulk.fs" -finish-device - - diff --git a/roms/SLOF/slof/fs/packages/bulk.fs b/roms/SLOF/slof/fs/packages/bulk.fs deleted file mode 100644 index 06d7eaecc..000000000 --- a/roms/SLOF/slof/fs/packages/bulk.fs +++ /dev/null @@ -1,87 +0,0 @@ -\ ***************************************************************************** -\ * Copyright (c) 2004, 2008 IBM Corporation -\ * All rights reserved. -\ * This program and the accompanying materials -\ * are made available under the terms of the BSD License -\ * which accompanies this distribution, and is available at -\ * http://www.opensource.org/licenses/bsd-license.php -\ * -\ * Contributors: -\ * IBM Corporation - initial implementation -\ ****************************************************************************/ - - -s" bulk" device-name - - -\ standard open firmare method - - -: open true ; - -\ standard open firmare method - - -: close ; - - -\ ------------------------------------------------- -\ Locals -\ ------------------------------------------------ - - -8 chars alloc-mem VALUE setup-packet - - -\ -------------------------------------------------- -\ signature --->4bytes offset --->0 -\ tag --->4bytes offset --->4 -\ trans-len --->4bytes offset --->8 -\ dir-flag --->1byte offset --->c -\ lun --->1byte offset --->d -\ comm-len --->1byte offset --->e -\ -------------------------------------------------- - - -0 VALUE cbw-addr -: build-cbw ( address tag transfer-len direction lun command-len -- ) - 5 pick TO cbw-addr ( address tag transfer-len direction lun command-len ) - cbw-addr 0f erase ( address tag transfer-len direction lun command-len ) - cbw-addr e + c! ( address tag transfer-len direction lun ) - cbw-addr d + c! ( address tag transfer-len direction ) - cbw-addr c + c! ( address tag transfer-len ) - cbw-addr 8 + l!-le ( address tag ) - cbw-addr 4 + l!-le ( address ) - 43425355 cbw-addr l!-le ( address ) - drop ; - - -\ --------------------------------------------------- -\ signature --->4bytes offset --->0 -\ tag --->4bytes offset --->4 -\ residue --->4bytes offset --->8 -\ status --->1byte offset --->c -\ --------------------------------------------------- - - -0 VALUE csw-addr -: analyze-csw ( address -- residue tag true|reason false ) - TO csw-addr - csw-addr l@-le 53425355 = IF - csw-addr c + c@ dup 0= IF ( reason ) - drop - csw-addr 8 + l@-le ( residue ) - csw-addr 4 + l@-le ( residue tag ) \ command block tag - TRUE ( residue tag TRUE ) - ELSE - FALSE ( reason FALSE ) - THEN - ELSE - FALSE ( FALSE ) - THEN - csw-addr 0c erase -; - -: bulk-reset-recovery-procedure ( bulk-out-endp bulk-in-endp usb-addr -- ) - s" bulk-reset-recovery-procedure" $call-parent -; diff --git a/roms/SLOF/slof/fs/pci-properties.fs b/roms/SLOF/slof/fs/pci-properties.fs index 9efa87e65..4f134024f 100644 --- a/roms/SLOF/slof/fs/pci-properties.fs +++ b/roms/SLOF/slof/fs/pci-properties.fs @@ -651,6 +651,8 @@ r> TO pci-device-slots \ and reset the slot array ; +DEFER func-pci-device-props + \ used for an gerneric device set up \ if a device has no special handling for setup \ the device file (pci-device_VENDOR_DEVICE.fs) can call @@ -659,6 +661,8 @@ dup assign-all-device-bars \ calc all BARs dup pci-set-irq-line \ set the interrupt pin dup pci-set-capabilities \ set up the capabilities - dup pci-device-props \ and generate all properties + dup func-pci-device-props \ and generate all properties drop \ forget the config-addr ; + +' pci-device-props TO func-pci-device-props diff --git a/roms/SLOF/slof/fs/pci-scan.fs b/roms/SLOF/slof/fs/pci-scan.fs index 15d0c8e64..b8b9fe61f 100644 --- a/roms/SLOF/slof/fs/pci-scan.fs +++ b/roms/SLOF/slof/fs/pci-scan.fs @@ -87,7 +87,7 @@ here 100 allot CONSTANT pci-device-vec pci-next-mmio @ 100000 #aligned \ read the current Value and align to 1MB boundary dup 100000 + pci-next-mmio ! \ and write back with 1MB for bridge 10 rshift \ mmio-base reg is only the upper 16 bits - pci-max-mmio @ FFFF0000 and or \ and Insert mmio Limit (set it to max) + pci-max-mmio @ 1- FFFF0000 and or \ and Insert mmio Limit (set it to max) swap 20 + rtas-config-l! \ and write it into the bridge ; @@ -116,7 +116,7 @@ here 100 allot CONSTANT pci-device-vec 2 pick 2C + rtas-config-l! \ | and set the Limit THEN \ FI 10 rshift \ keep upper 16 bits - pci-max-mem @ FFFF0000 and or \ and Insert mmem Limit (set it to max) + pci-max-mem @ 1- FFFF0000 and or \ and Insert mmem Limit (set it to max) swap 24 + rtas-config-l! \ and write it into the bridge ; @@ -150,7 +150,7 @@ here 100 allot CONSTANT pci-device-vec swap 30 + rtas-config-l! \ | and write it into the Base-Upper16-bits THEN \ FI 8 rshift 000000FF and \ keep upper 8 bits - pci-max-io @ 0000FF00 and or \ insert upper 8 bits of Max-Limit + pci-max-io @ 1- 0000FF00 and or \ insert upper 8 bits of Max-Limit over rtas-config-l@ FFFF0000 and \ fetch original Value or swap 1C + rtas-config-l! \ and write it into the bridge ; diff --git a/roms/SLOF/slof/fs/scsi-probe-helpers.fs b/roms/SLOF/slof/fs/scsi-probe-helpers.fs index 262d157d6..6aec8b159 100644 --- a/roms/SLOF/slof/fs/scsi-probe-helpers.fs +++ b/roms/SLOF/slof/fs/scsi-probe-helpers.fs @@ -27,7 +27,7 @@ dup 8 + dup alloc-mem ( devarray devcur ndev lunarray size size+ mem ) dup rot 0 fill ( devarray devcur ndev lunarray size mem ) dup >r swap move r> ( devarray devcur ndev mem ) - dup sector l@ 3 >> 0 DO ( devarray devcur ndev mem memcur ) + dup sector l@ 3 >> 0 ?DO ( devarray devcur ndev mem memcur ) dup dup scsi-read-lun IF j swap dev-generate-srplun swap x! 8 + ELSE diff --git a/roms/SLOF/slof/fs/translate.fs b/roms/SLOF/slof/fs/translate.fs index e2633e592..9654f242f 100644 --- a/roms/SLOF/slof/fs/translate.fs +++ b/roms/SLOF/slof/fs/translate.fs @@ -33,11 +33,9 @@ dup l@ FF AND 0<> ( prop_type address data cfgspace_offset? ) 3 pick 0= ( prop_type address data cfgspace_offset? reg_prop? ) AND NOT IF - 2dup 8 + ( prop_type address data address data' ) - 2dup l@ 2 pick 8 + l@ + <= -rot l@ >= and IF + 2dup 4 + ( prop_type address data address data' ) + 2dup @ 2 pick 8 + @ + <= -rot @ >= and IF l@ 03000000 and 18 rshift nip - \ no 64bit translations supported pretend it is 32bit - dup 3 = IF 1- THEN ( prop_type type ) swap drop ( type ) UNLOOP EXIT diff --git a/roms/config.vga-virtio b/roms/config.vga-virtio new file mode 100644 index 000000000..aa7a15ba1 --- /dev/null +++ b/roms/config.vga-virtio @@ -0,0 +1,6 @@ +CONFIG_BUILD_VGABIOS=y +CONFIG_VGA_BOCHS=y +CONFIG_VGA_PCI=y +CONFIG_OVERRIDE_PCI_ID=y +CONFIG_VGA_VID=0x1af4 +CONFIG_VGA_DID=0x1050 diff --git a/roms/openbios/arch/ppc/qemu/ofmem.c b/roms/openbios/arch/ppc/qemu/ofmem.c index e03beaa44..6f346a3d4 100644 --- a/roms/openbios/arch/ppc/qemu/ofmem.c +++ b/roms/openbios/arch/ppc/qemu/ofmem.c @@ -117,13 +117,6 @@ ucell ofmem_arch_get_virt_top(void) return IO_BASE; } -phys_addr_t ofmem_arch_get_phys_top(void) -{ - ofmem_t *ofmem = ofmem_arch_get_private(); - - return ofmem->ramsize; -} - void ofmem_arch_unmap_pages(ucell virt, ucell size) { /* kill page mappings in provided range */ diff --git a/roms/openbios/arch/sparc32/ofmem_sparc32.c b/roms/openbios/arch/sparc32/ofmem_sparc32.c index d2935a8ba..f7af75366 100644 --- a/roms/openbios/arch/sparc32/ofmem_sparc32.c +++ b/roms/openbios/arch/sparc32/ofmem_sparc32.c @@ -30,6 +30,8 @@ static union { #define OFMEM (&s_ofmem_data.ofmem) #define TOP_OF_RAM (s_ofmem_data.memory + MEMSIZE) +#define OFMEM_PHYS_RESERVED 0x1000000 + translation_t **g_ofmem_translations = &s_ofmem_data.ofmem.trans; extern uint32_t qemu_mem_size; @@ -64,13 +66,6 @@ ucell ofmem_arch_get_virt_top(void) return (ucell)OFMEM_VIRT_TOP; } -phys_addr_t ofmem_arch_get_phys_top(void) -{ - ofmem_t *ofmem = ofmem_arch_get_private(); - - return (uintptr_t)ofmem->ramsize - 0x1000000; -} - ucell ofmem_arch_get_iomem_base(void) { return pointer2cell(&_end); @@ -251,8 +246,8 @@ void ofmem_init( void ) ofmem_claim_virt(0, PAGE_SIZE, 0); /* Claim reserved physical addresses at top of RAM */ - ofmem_claim_phys(ofmem_arch_get_phys_top(), s_ofmem_data.ofmem.ramsize - ofmem_arch_get_phys_top(), 0); + ofmem_claim_phys(s_ofmem_data.ofmem.ramsize - OFMEM_PHYS_RESERVED, OFMEM_PHYS_RESERVED, 0); /* Claim OpenBIOS reserved space */ - ofmem_claim_virt(0xffd00000, 0x300000, 0); + ofmem_claim_virt(0xffd00000, 0x200000, 0); } diff --git a/roms/openbios/arch/sparc64/ofmem_sparc64.c b/roms/openbios/arch/sparc64/ofmem_sparc64.c index 6e1bb0581..bdfaf5636 100644 --- a/roms/openbios/arch/sparc64/ofmem_sparc64.c +++ b/roms/openbios/arch/sparc64/ofmem_sparc64.c @@ -65,13 +65,6 @@ ucell ofmem_arch_get_virt_top(void) return (ucell)TOP_OF_RAM; } -phys_addr_t ofmem_arch_get_phys_top(void) -{ - ofmem_t *ofmem = ofmem_arch_get_private(); - - return ofmem->ramsize; -} - ucell ofmem_arch_get_iomem_base(void) { /* Currently unused */ diff --git a/roms/openbios/config/scripts/switch-arch b/roms/openbios/config/scripts/switch-arch index 868eae626..d5e2f7710 100755 --- a/roms/openbios/config/scripts/switch-arch +++ b/roms/openbios/config/scripts/switch-arch @@ -99,7 +99,13 @@ archname() select_prefix() { - for TARGET in ${1}-unknown-linux-gnu- ${1}-linux-gnu- ${1}-linux- ${1}-elf- ${1}-eabi- + TARGETS="${1}-unknown-linux-gnu- ${1}-linux-gnu- ${1}-linux- ${1}-elf- ${1}-eabi-" + + if [ x"$CROSS_COMPILE" != "x" ]; then + TARGETS=$CROSS_COMPILE + fi + + for TARGET in $TARGETS do if type ${TARGET}gcc > /dev/null 2>&1 then diff --git a/roms/openbios/include/libopenbios/ofmem.h b/roms/openbios/include/libopenbios/ofmem.h index f2445e707..0b19db1ca 100644 --- a/roms/openbios/include/libopenbios/ofmem.h +++ b/roms/openbios/include/libopenbios/ofmem.h @@ -63,7 +63,6 @@ extern ofmem_t* ofmem_arch_get_private(void); extern void* ofmem_arch_get_malloc_base(void); extern ucell ofmem_arch_get_heap_top(void); extern ucell ofmem_arch_get_virt_top(void); -extern phys_addr_t ofmem_arch_get_phys_top(void); extern ucell ofmem_arch_get_iomem_base(void); extern ucell ofmem_arch_get_iomem_top(void); extern retain_t* ofmem_arch_get_retained(void); diff --git a/roms/openbios/libopenbios/ofmem_common.c b/roms/openbios/libopenbios/ofmem_common.c index 3b8ca152f..052aa2f4d 100644 --- a/roms/openbios/libopenbios/ofmem_common.c +++ b/roms/openbios/libopenbios/ofmem_common.c @@ -334,8 +334,8 @@ static void ofmem_update_memory_available( phandle_t ph, range_t *range, } /* tail */ - if (start < top_address) { - ofmem_arch_create_available_entry(ph, &prop[ncells], start, top_address - start); + if ((start - 1) < top_address) { + ofmem_arch_create_available_entry(ph, &prop[ncells], start, top_address - start + 1); ncells += ofmem_arch_get_available_entry_size(ph); } @@ -348,7 +348,7 @@ static void ofmem_update_translations( void ) ofmem_t *ofmem = ofmem_arch_get_private(); ofmem_update_memory_available(s_phandle_memory, ofmem->phys_range, - &phys_range_prop, &phys_range_prop_size, &phys_range_prop_used, ofmem_arch_get_phys_top()); + &phys_range_prop, &phys_range_prop_size, &phys_range_prop_used, get_ram_size() - 1); ofmem_update_memory_available(s_phandle_mmu, ofmem->virt_range, &virt_range_prop, &virt_range_prop_size, &virt_range_prop_used, (ucell)-1); ofmem_update_mmu_translations(); @@ -521,7 +521,7 @@ phys_addr_t ofmem_claim_phys( phys_addr_t phys, ucell size, ucell align ) " align=" FMT_ucellx "\n", phys, size, align); - return ofmem_claim_phys_( phys, size, align, 0, ofmem_arch_get_phys_top(), 1 ); + return ofmem_claim_phys_( phys, size, align, 0, get_ram_size(), 1 ); } static ucell ofmem_claim_virt_( ucell virt, ucell size, ucell align, @@ -634,7 +634,7 @@ ucell ofmem_claim( ucell addr, ucell size, ucell align ) } else { if( align < PAGE_SIZE ) align = PAGE_SIZE; - phys = ofmem_claim_phys_( -1, size, align, 0, ofmem_arch_get_phys_top(), 1 /* reverse */ ); + phys = ofmem_claim_phys_( -1, size, align, 0, get_ram_size(), 1 /* reverse */ ); virt = ofmem_claim_virt_( phys, size, 0, 0, 0, 0 ); if( phys == -1 || virt == -1 ) { OFMEM_TRACE("ofmem_claim failed\n"); diff --git a/roms/seabios/.version b/roms/seabios/.version index 98a67e17c..a96337339 100644 --- a/roms/seabios/.version +++ b/roms/seabios/.version @@ -1 +1 @@ -rel-1.8.1-0-g4adadbd +rel-1.8.2-0-g33fbe13 diff --git a/roms/seabios/Makefile b/roms/seabios/Makefile index a84a5f7eb..83cdff377 100644 --- a/roms/seabios/Makefile +++ b/roms/seabios/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 @@ -155,7 +154,7 @@ $(OUT)romlayout.o: src/romlayout.S $(OUT)autoconf.h $(OUT)asm-offsets.h $(OUT)romlayout16.lds: $(OUT)ccode32flat.o $(OUT)code32seg.o $(OUT)ccode16.o $(OUT)romlayout.o scripts/layoutrom.py scripts/buildversion.sh @echo " Building ld scripts" - $(Q)./scripts/buildversion.sh $(OUT)version.c + $(Q)BUILD_VERSION="$(VERSION)" ./scripts/buildversion.sh $(OUT)version.c $(Q)$(CC) $(CFLAGS32FLAT) -c $(OUT)version.c -o $(OUT)version.o $(Q)$(LD) $(LD32BIT_FLAG) -r $(OUT)ccode32flat.o $(OUT)version.o -o $(OUT)code32flat.o $(Q)$(LD) $(LD32BIT_FLAG) -r $(OUT)ccode16.o $(OUT)romlayout.o -o $(OUT)code16.o @@ -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)BUILD_VERSION="$(VERSION)" ./scripts/buildversion.sh $(OUT)vgaversion.c VAR16 + $(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/roms/seabios/scripts/buildversion.sh b/roms/seabios/scripts/buildversion.sh index e5ce96c6a..516aff5b2 100755 --- a/roms/seabios/scripts/buildversion.sh +++ b/roms/seabios/scripts/buildversion.sh @@ -4,14 +4,18 @@ OUTFILE="$1" VAR16MODE="$2" # Extract version info -if [ -d .git -o -f .git ]; then - VERSION="`git describe --tags --long --dirty`" -elif [ -f .version ]; then - VERSION="`cat .version`" +if [ -z "$BUILD_VERSION" ]; then + if [ -d .git -o -f .git ]; then + VERSION="`git describe --tags --long --dirty`" + elif [ -f .version ]; then + VERSION="`cat .version`" + else + VERSION="?" + fi + VERSION="${VERSION}-`date +"%Y%m%d_%H%M%S"`-`hostname`" else - VERSION="?" + VERSION="$BUILD_VERSION" fi -VERSION="${VERSION}-`date +"%Y%m%d_%H%M%S"`-`hostname`" echo "Version: ${VERSION}" # Build header file diff --git a/roms/seabios/scripts/vgafixup.py b/roms/seabios/scripts/vgafixup.py index a981bbf95..2053cd5d7 100644 --- a/roms/seabios/scripts/vgafixup.py +++ b/roms/seabios/scripts/vgafixup.py @@ -7,8 +7,8 @@ # The x86emu code widely used in Linux distributions when running Xorg # in vesamode is known to have issues with "retl", "leavel", "entryl", -# and some variants of "calll". This code modifies those instructions -# (ret and leave) that are known to be generated by gcc to avoid +# "leal", and some variants of "calll". This code modifies those +# instructions that are known to be generated by gcc to avoid # triggering the x86emu bugs. # It is also known that the Windows vgabios emulator has issues with @@ -16,7 +16,59 @@ # worked around by not using the gcc parameter "-fomit-frame-pointer" # when compiling. -import sys +import sys, re + +# leal parameter regex - example string: -3(%edx,%eax,8), %eax +re_leal = re.compile( + r'^\s*(?P<offset>[^(]*?)\s*' + r'\(\s*(?P<base>[^,)]*?)\s*(?:,\s*(?P<index>[^,)]*?)\s*)?' + r'(?:,\s*(?P<scale>[^,)]*?)\s*)?\)\s*' + r',\s*(?P<dest>.*?)\s*$') + +# Find an alternate set of instructions for a given "leal" instruction +def handle_leal(sline): + m = re_leal.match(sline[5:]) + if m is None or m.group('index') == '%esp': + print("Unable to fixup leal instruction: %s" % (sline,)) + sys.exit(-1) + offset, base, index, scale, dest = m.group( + 'offset', 'base', 'index', 'scale', 'dest') + if dest == '%esp': + # If destination is %esp then just use 16bit leaw instead + return 'leaw %s\n' % (sline[5:].replace('%e', '%'),) + if not scale: + scale = '1' + scale = {1: 0, 2: 1, 4: 2, 8: 3}[int(scale, 0)] + # Try to rearrange arguments to simplify 'base' (to improve code gen) + if not scale and base == index: + base, index, scale = '', index, 1 + elif not index or (not scale and base in (dest, '%esp') and index != dest): + base, index, scale = index, base, 0 + # Produce instructions to calculate "leal" + insns = ['pushfw'] + if base != dest: + # Calculate "leal" directly in dest register + if index != dest: + insns.insert(0, 'movl %s, %s' % (index, dest)) + if scale: + insns.append('shll $%d, %s' % (scale, dest)) + if base: + if base == '%esp': + offset += '+2' + insns.append('addl %s, %s' % (base, dest)) + elif base == index: + # Use "imull" method + insns.append('imull $%d, %s' % ((1<<scale)+1, dest)) + else: + # Backup/restore index register and do scaling in index register + insns.append('pushl %s' % (index,)) + insns.append('shll $%d, %s' % (scale, index)) + insns.append('addl %s, %s' % (index, dest)) + insns.append('popl %s' % (index,)) + if offset and offset != '0': + insns.append('addl $%s, %s' % (offset, dest)) + insns.append('popfw\n') + return ' ; '.join(insns) def main(): infilename, outfilename = sys.argv[1:] @@ -30,6 +82,9 @@ def main(): out.append('movl %ebp, %esp ; popl %ebp\n') elif sline.startswith('call'): out.append('pushw %ax ; callw' + sline[4:] + '\n') + elif sline.startswith('leal'): + out.append(handle_leal(sline)) + #print("-> %s\n %s" % (sline, out[-1].strip())) else: out.append(line) infile.close() diff --git a/roms/seabios/src/fw/smm.c b/roms/seabios/src/fw/smm.c index dabc67744..6cb484e7e 100644 --- a/roms/seabios/src/fw/smm.c +++ b/roms/seabios/src/fw/smm.c @@ -18,8 +18,14 @@ #include "util.h" // smm_setup #include "x86.h" // wbinvd -#define SMM_REV_I32 0x00020000 -#define SMM_REV_I64 0x00020064 +/* + * Check SMM state save area format (bits 0-15) and require support + * for SMBASE relocation. + */ +#define SMM_REV_MASK 0x0002ffff + +#define SMM_REV_I32 0x00020000 +#define SMM_REV_I64 0x00020064 struct smm_state { union { @@ -62,9 +68,10 @@ handle_smi(u16 cs) if (smm == (void*)BUILD_SMM_INIT_ADDR) { // relocate SMBASE to 0xa0000 - if (smm->cpu.i32.smm_rev == SMM_REV_I32) { + u32 rev = smm->cpu.i32.smm_rev & SMM_REV_MASK; + if (rev == SMM_REV_I32) { smm->cpu.i32.smm_base = BUILD_SMM_ADDR; - } else if (smm->cpu.i64.smm_rev == SMM_REV_I64) { + } else if (rev == SMM_REV_I64) { smm->cpu.i64.smm_base = BUILD_SMM_ADDR; } else { warn_internalerror(); diff --git a/roms/seabios/src/hw/ahci.c b/roms/seabios/src/hw/ahci.c index ff5d5f9ee..3193d81a6 100644 --- a/roms/seabios/src/hw/ahci.c +++ b/roms/seabios/src/hw/ahci.c @@ -601,7 +601,7 @@ ahci_controller_setup(struct pci_device *pci) dprintf(2, "AHCI: cap 0x%x, ports_impl 0x%x\n", ctrl->caps, ctrl->ports); - max = ctrl->caps & 0x1f; + max = 0x1f; for (pnr = 0; pnr <= max; pnr++) { if (!(ctrl->ports & (1 << pnr))) continue; diff --git a/roms/seabios/vgasrc/Kconfig b/roms/seabios/vgasrc/Kconfig index 400e8da6f..91d590ae2 100644 --- a/roms/seabios/vgasrc/Kconfig +++ b/roms/seabios/vgasrc/Kconfig @@ -90,6 +90,17 @@ menu "VGA ROM" Support emulating text mode features when only a framebuffer is available. + config VGA_FIXUP_ASM + depends on BUILD_VGABIOS + 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/roms/seabios/vgasrc/bochsvga.c b/roms/seabios/vgasrc/bochsvga.c index ee6f43731..aa82fc5a5 100644 --- a/roms/seabios/vgasrc/bochsvga.c +++ b/roms/seabios/vgasrc/bochsvga.c @@ -403,10 +403,7 @@ bochsvga_setup(void) case 0x15ad: /* qemu vmware vga */ barid = 1; break; - case 0x1af4: /* virtio-vga */ - barid = 2; - break; - default: /* stdvga, qxl */ + default: /* stdvga, qxl, virtio */ barid = 0; break; } diff --git a/roms/seabios/vgasrc/vgabios.c b/roms/seabios/vgasrc/vgabios.c index f5abda6ac..4aa50e1c1 100644 --- a/roms/seabios/vgasrc/vgabios.c +++ b/roms/seabios/vgasrc/vgabios.c @@ -259,7 +259,7 @@ bda_save_restore(int cmd, u16 seg, void *data) , sizeof(info->bda_0x84)); u16 vbe_mode = GET_FARVAR(seg, info->vbe_mode); SET_BDA_EXT(vbe_mode, vbe_mode); - struct vgamode_s *vmode_g = vgahw_find_mode(vbe_mode); + struct vgamode_s *vmode_g = vgahw_find_mode(vbe_mode & ~MF_VBEFLAGS); SET_BDA_EXT(vgamode_offset, (u32)vmode_g); SET_IVT(0x1f, GET_FARVAR(seg, info->font0)); SET_IVT(0x43, GET_FARVAR(seg, info->font1)); diff --git a/roms/seabios/vgasrc/vgaentry.S b/roms/seabios/vgasrc/vgaentry.S index f9cf65689..d9ebdb93c 100644 --- a/roms/seabios/vgasrc/vgaentry.S +++ b/roms/seabios/vgasrc/vgaentry.S @@ -45,33 +45,15 @@ _rom_header_signature: * Entry points ****************************************************************/ - // Force a fault if found to be running on broken x86emu versions. - DECLFUNC x86emu_fault -msg: .ascii "SeaVGABIOS: x86emu leal trap!\n" -x86emu_fault: -#if CONFIG_DEBUG_IO - movw %cs:DebugOutputPort, %dx - movw $msg, %si -1: movb %cs:(%si), %al - outb %al, (%dx) - incw %si - cmpw $x86emu_fault, %si - jl 1b -#endif -1: hlt - jmp 1b - // This macro implements a call while avoiding instructions // that old versions of x86emu have problems with. .macro VGA_CALLL cfunc - // Make sure leal instruction works. - movl $0x8000, %ecx - leal (%ecx, %ecx, 1), %ecx - cmpl $0x10000, %ecx - jne x86emu_fault - // Use callw instead of calll - push %ax +#if CONFIG_VGA_FIXUP_ASM + pushw %ax callw \cfunc +#else + calll \cfunc +#endif .endm // This macro is the same as ENTRY_ARG except VGA_CALLL is used. |