Kevin O'Connor [Sat, 11 Oct 2014 17:16:12 +0000 (13:16 -0400)]
Move a20 code from system.c and ps2port.h to x86.h
Although the a20 functionality was originally implemented in the ps2
controller, that is just a historical artifact. It's a core feature
of modern x86 cpus and the code is better located in the x86.h header.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Fri, 11 Apr 2014 15:20:41 +0000 (11:20 -0400)]
Implement call32 mechanism using SMIs.
Add support for jumping into 32bit mode using a System Management Mode
(SMM) handler. When available, this allows SeaBIOS to transition to
32bit mode even when called in vm86 mode. It will also prevent the
clobbering of the segment registers.
Currently, the SMM mode is only supported in QEMU when running in TCG
mode. Also, QEMU v2.1 (or later) is needed for it to work when in
vm86 mode.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Tue, 30 Sep 2014 16:55:54 +0000 (12:55 -0400)]
Fully restore 16bit state during call16_sloppy()
When transitioning back to 16bit mode from within call32(), restore
the full state (cmos index, gdt, fs/gs) in addition to restoring the
original stack.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Wed, 24 Sep 2014 21:48:28 +0000 (17:48 -0400)]
Move call16() functions from romlayout.S to inline assembler in stacks.c
Use inline assembler in call16 type functions instead of using
__call16() in romlayout.S.
Since call16() and call16big() are now only called with %ss==0 they do
not need to update the stack pointer. Only call16_sloppy() requires
the stack manipulation code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Wed, 24 Sep 2014 19:58:12 +0000 (15:58 -0400)]
build: Support declaring 32bit C functions that must reside in the f-segment
Add support for a FUNCFSEG macro that will force a "32bit flat" C
function to be located in the f-segment. This is useful for 32bit
code with inline assembler that thunks to 16bit mode.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Tue, 30 Sep 2014 04:11:38 +0000 (00:11 -0400)]
Simplify farcall16 code
With this change, farcall16() is only used for external API calls and
is only invoked from a 32bit mode entered directly via transition32.
farcall16big() is also only used for external API calls and is only
invoked from a 32bit mode entered directly via transition32.
call16_int() now calls _farcall16() directly, and it will use normal
16bit mode or big real mode as required.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Tue, 30 Sep 2014 03:59:47 +0000 (23:59 -0400)]
Track when entering via call32() and use the same mode for stack_hop_back()
If 32bit mode is entered directly via transition32, then use a simple
call16() when hopping back to 16bit mode. Use only call16big() during
post and when entering 32bit mode via call32().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Tue, 30 Sep 2014 13:37:26 +0000 (09:37 -0400)]
pmm: Fix entry point to support non-zero %ss
If the pmm entry point was called with a non-zero stack segment, the
pointer to the arguments on the stack would not be valid once the
code transitioned to 32bit mode. Fix by adding the stack segment
offset into the args pointer.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Tue, 30 Sep 2014 13:17:14 +0000 (09:17 -0400)]
Revert "Use the extra stack for 16bit USB and PS2 keyboard/mouse commands."
It's not valid to pass a pointer to a stack variable through the
stack_hop() call (because the call changes the stack segment). This
bug was probably not noticed before because by default
(CONFIG_ENTRY_EXTRASTACK) SeaBIOS uses the extra stack on all 16bit
entry points, and the internal stack_hop() with that config option is
effectively a no-op.
Kevin O'Connor [Wed, 10 Sep 2014 15:33:01 +0000 (11:33 -0400)]
usb: Perform device detect polling on all usb controllers.
Move the 100ms (USB_TIME_SIGATT) device detect polling from the
ohci/uhci/usb-hub code to the generic usb_hub_port_setup() code. This
extends the 100ms polling to ehci and xhci controllers. The code in
usb_hub_port_setup() now compares USB_TIME_SIGATT to the start of
usb_enumerate(), which may make boots faster when threads are
disabled.
This patch also changes the meaning of the return code for
hub->op->detect() calls. Now 1 indicates device found, 0 indicates
device not found, and -1 indicates permanent failure.
Also, the xhci controller generic delay of 100ms is replaced with a
20ms root hub power stabilize time. This in combination with the
100ms for USB_TIME_SIGATT should be closer to the USB2 spec (the USB3
spec does not seem to declare an equivalent of USB_TIME_SIGATT).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Wed, 10 Sep 2014 15:04:26 +0000 (11:04 -0400)]
ehci: Stall uhci/ohci init only until default port routing is done.
Now that uhci and ohci will continually poll for a device connect, the
ehci controller only needs to ensure that the default routing is setup
properly before allowing uhci and ohci to be initialized.
This also fixes two error paths in configure_ehci() that were not
properly updating PendingEHCIPorts.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Wed, 10 Sep 2014 14:37:52 +0000 (10:37 -0400)]
ohci: Repeatedly poll for device detect for 100ms.
According to the USB2 specification, a device may take up to 100ms
(USB_TIME_SIGATT) after port power stabilizes to be detected. So,
continually recheck for a device connection event.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Wed, 10 Sep 2014 14:33:36 +0000 (10:33 -0400)]
uhci: Repeatedly poll for device detect for 100ms.
According to the USB2 specification, a device may take up to 100ms
(USB_TIME_SIGATT) after port power stabilizes to be detected. So,
continually recheck for a device connection event.
Technically, the uhci root hub ports are always powered up, but it's
not possible to know how long the machine has been on, so it's better
to be safe here.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Wed, 10 Sep 2014 14:24:04 +0000 (10:24 -0400)]
xhci: Change xhci_hub_detect() to use connect status instead of link state.
Use the connect status bit to determine if a device is connected
instead of the port link state state machine status. This makes the
driver more similar to the other drivers and may help diagnose devices
that take longer to boot up.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Wed, 10 Sep 2014 14:18:02 +0000 (10:18 -0400)]
usb-hub: Enable power to all ports prior to calling usb_enumerate().
Don't perform port power up in the detect code. Instead do it prior
to calling usb_enumerate(). This makes the code more similar to the
usb root hub drivers. It can also reduce the total boot time when
threads are disabled.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Wed, 10 Sep 2014 14:02:20 +0000 (10:02 -0400)]
ehci: Move port power up from ehci_hub_detect() to check_ehci_ports().
Don't perform port power up in the detect code. Instead do it prior
to calling usb_enumerate(). This makes the code more similar to the
ohci and xhci drivers. It can also reduce the total boot time when
threads are disabled.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Wed, 10 Sep 2014 13:10:42 +0000 (09:10 -0400)]
xhci: Add xhci_check_ports() and xhci_free_pipes() functions.
Add these two functions so that the xhci code is more similar to the
other USB controllers. Also, store the temporary hub structure on the
stack instead of in struct usb_xhci_s.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Tue, 9 Sep 2014 22:24:00 +0000 (18:24 -0400)]
usb: Fix usb_xfer_time() to work when called in 16bit mode.
Make sure to wrap accesses to the usb_pipe struct with GET_LOWFLAT so
that it works in 16bit mode. This bug impacts both ehci and uhci usb
controllers (it should not impact ohci and xhci as those never call
the function in 16bit mode).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Sun, 24 Aug 2014 02:06:21 +0000 (22:06 -0400)]
build: Update kconfig to version in Linux 3.16.
Update kconfig (from Linux v3.13) to the latest version (Linux v3.16).
This copies kconfig from Linux with only the changes necessary to work
with the SeaBIOS build (the equivalent of the earlier SeaBIOS 0da7bfdf
commit) and the changes necessary to always emit symbols (SeaBIOS b623e7c5 commit).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Fri, 15 Aug 2014 13:52:43 +0000 (09:52 -0400)]
boot: Change ":rom%d" boot order rom instance to ":rom%x"
Use hex numbers for the rom instance count in boot order open firmware
device naming. The ":rom" suffix isn't part of a standard and it's
highly unlikely any rom would have 10 or more drives on it, but this
change makes the code more similar to the numbering of other boot
order devices.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net> Reviewed-by: Markus Armbruster <armbru@redhat.com>
We identify devices by their Open Firmware device paths. The path
component for the logical unit on a bus is incorrect:
bootprio_find_scsi_device() and bootprio_find_usb() format target
(a.k.a. SCSI ID) and lun in decimal, while QEMU uses hexadecimal.
Bootorder list entries with target, lun > 9 aren't found (lucky case),
or attributed to the wrong logical unit (unlucky case).
The relevant spec[*] agrees with QEMU (and OVMF, for that matter).
Change %d to %x.
No actual impact on USB, because QEMU only uses LUN 0 there.
Kevin O'Connor [Tue, 1 Jul 2014 13:50:04 +0000 (09:50 -0400)]
vgabios: Fix broken build resulting from e5749978.
The e5749978 commit added -fno-merge-constants to the compile flag.
That option changes the names of ".rodata" sections. Update
vgalayout.lds.S so that the vgabios can continue to build.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Sat, 14 Jun 2014 16:25:17 +0000 (12:25 -0400)]
xhci: Update the times for usb command timeouts.
The xhci controller had a hardcoded 1 second timeout for both bulk and
control transfers. The 1 second bulk timeout is too small for some
real devices.
Increase both times to 5.1 seconds - according to the USB spec, the
maximum time a command should take is 5 seconds. However, have the
set_address command only wait for 150ms (spec says set_address should
take no more than 50ms).
Introduce usb_xfer_time() to calculate maximum command time.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Wed, 11 Jun 2014 18:00:21 +0000 (14:00 -0400)]
build: Get fixed address variables from 32bit compile pass (not 16bit)
Update the layoutrom.py build script so that fixed address sections
can come from the 32bit compiled C code. Update the C code so that
all VAR16FIXED variables instead use the new VARFSEGFIXED which is
defined in 32bit mode.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Tue, 10 Jun 2014 21:59:53 +0000 (17:59 -0400)]
build: Use fileid instead of category to write sections in layoutrom.py.
The 'category' really determines the memory location while the
'fileid' determines which link stage the section is in. So, use
'fileid' when writing the linker scripts.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Mon, 9 Jun 2014 18:37:23 +0000 (14:37 -0400)]
build: Use customized entry point for each type of build.
Set an appropriate elf entry point (entry_elf, entry_csm,
reset_vector) for each type of build (coreboot, csm, qemu). Use that
entry point when determining which sections to keep.
Also, remove the '.export.' mechanism to keep a section in the final
binary - it is no longer used.
This allows the build to slightly reduce the overall size as entry_elf
is no longer needed on non-coreboot builds and entry_csm is no longer
needed on non-csm builds.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
David Woodhouse [Tue, 3 Jun 2014 16:28:58 +0000 (17:28 +0100)]
vgabios: Use .code16 not .code16gcc
There's no need to use .code16gcc where we are writing assembler code
explicitly. It only affects word-size-ambiguous instructions, and we
should just be explicit. And we are.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
David Woodhouse [Tue, 3 Jun 2014 16:28:49 +0000 (17:28 +0100)]
romlayout: Use .code16 not .code16gcc
There's no need to use .code16gcc where we are writing assembler code
explicitly. It only affects word-size-ambiguous instructions, and we
should just be explicit. And we are.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
David Woodhouse [Tue, 3 Jun 2014 16:28:22 +0000 (17:28 +0100)]
build: use -m16 where available instead of asm(".code16gcc")
GCC 4.9 and clang 3.5 support the -m16 option on the command line which
supersedes the hackish ".code16gcc" assembler directive. Use it where
possible.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Kevin O'Connor [Tue, 3 Jun 2014 19:22:31 +0000 (15:22 -0400)]
build: Avoid absolute paths during "whole-program" compiling.
The build currently does a textual include of all files in order to
use the -fwhole-compile optimization. Update it to use relative file
paths instead of absolute file paths. This makes the section names in
the resulting binary more readable. It also makes the build easier on
some Windows hosts.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Sat, 24 May 2014 14:49:50 +0000 (10:49 -0400)]
smp: Replace QEMU SMP init assembler code with C; run only in 32bit mode.
Change the multi-processor init code to trampoline into 32bit mode on
each of the additional processors. Implement an atomic lock so that
each processor performs its initialization serially.
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Mon, 7 Apr 2014 23:49:12 +0000 (19:49 -0400)]
smm: Replace SMI assembler code with C code.
Convert the SMI handler from assembly to C. This makes the handler
easier to understand and enhance.
The new handler will use references to the reserved memory at
0xf0000-0x100000. If the physical memory in that range is modified at
runtime, then the SMI handler will cease to function properly (and may
allow unintended code to run in SMM mode). However, that area is
marked as reserved and is normally made read-only at runtime, so there
is little risk in relying on it.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Paolo Bonzini [Thu, 15 May 2014 11:22:29 +0000 (13:22 +0200)]
smm: unify SMM handlers
The next patch will add shared code between the initial handler for
SMBASE relocation and the actual SMI handler. Combine the code of
the two handlers for simplicity.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Kevin O'Connor [Sat, 10 May 2014 05:20:46 +0000 (01:20 -0400)]
cdemu: store internal cdemu fields in standard "el-torito" spec format.
Store the fields necessary to export the "el-torito" spec information
directly in an internal copy of the "el-torito" struct. This
simplifies the interface and obviates the need for an internal home
grown struct with the same info.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Sat, 10 May 2014 15:54:48 +0000 (11:54 -0400)]
edd: Use sectors==-1 to detect removable media.
Don't look for DTYPE_ATA_ATAPI to determine if a removable media (such
as a cdrom) is present, instead look for a -1 in the sector count.
This improves the results for cdroms on controllers other than ATA
ATAPI.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
David Woodhouse [Mon, 2 Jun 2014 13:00:14 +0000 (14:00 +0100)]
Update EFI_COMPATIBILITY16_TABLE to match 0.98 spec update
Unless CONFIG_MALLOC_UPPERMEMORY is turned off, we expect to use the
space between the top of option ROMs and the bottom of our own BIOS code
as a stack. OVMF was previously marking the whole region from 0xC0000 to
0xFFFFF read-only before invoking our Legacy16Boot method. Read-only
stack considered harmful.
Version 0.98 of the CSM spec adds the UmaAddress and UmaSize fields which
allow the CSM to specify a memory region that needs to be writeable, so
provide that information.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Kevin O'Connor [Thu, 22 May 2014 20:59:16 +0000 (16:59 -0400)]
python3 fixes for vgabios and csm builds.
Avoid using chr() as this produces unicode strings on python3. Make
sure to only use ord() on slices as the python3 bytearray type returns
an integer on a non-slice array access.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Gerd Hoffmann [Tue, 13 May 2014 12:09:00 +0000 (14:09 +0200)]
Allow using full io region on q35.
If qemu is new enough to support acpi table loading,
then go move pmbase out of the way. This allows to
use the whole 0x1000 -> 0xffff io address space on q35.
piix has hotplug ports in the 0xa000 -> 0xafff area,
so we can't do the same there.
Kevin O'Connor [Thu, 8 May 2014 22:32:32 +0000 (18:32 -0400)]
Fix int 1589 calls when CONFIG_ENTRY_EXTRASTACK is enabled.
The int 1589 call is entered in real mode and returns in protected
mode. However, the code to use the "extra stack" does not support
that. Fix this by never using the "extra stack" on int 1589 calls.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Sat, 19 Apr 2014 16:22:22 +0000 (12:22 -0400)]
If an int 1587 call is made from an option rom, stay in bigreal mode.
Modify the int 1587 handler to check if the POST phase is still
running. If it is, use bigreal mode segment limits so that the caller
remains in bigreal mode when the 1587 handler completes. This helps
with SeaVGABIOS' use of "direct" framebuffer accesses (an option rom
may attempt to display text during its option rom execution which can
cause SeaVGABIOS to make the int 1587 calls).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Gabriel L. Somlo [Wed, 23 Apr 2014 19:04:49 +0000 (15:04 -0400)]
SMBIOS: Check for aggregate tables & entry point in fw_cfg
Check fw_cfg for the presence of an aggregate set of smbios
tables (etc/smbios/smbios-tables) and an entry point structure
(etc/smbios/smbios-anchor), and, if found, use them instead of
generating entries locally.
We ensure the presence of a type 0 (bios information) structure
by generating it locally if necessary, which is expected to be
the common case.
Signed-off-by: Gabriel L. Somlo <somlo@cmu.edu> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/pci: check if pci2pci bridges implement optional limit registers
<I/O Base Register, I/O Limit Register> pair and
<Prefetchable Memory Base Register, Prefetchable Memory Limit Register> pair
are both optional.
Do not reserve ranges if the above registers are not implemented.
hw/pci: reserve IO and mem for pci-2-pci bridges with no devices attached
If a pci-2-pci bridge supports hot-plug functionality but there are no devices
connected to it, reserve IO/mem in order to be able to attach devices
later. Do not waste space, use minimum allowed.
Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
Kevin O'Connor [Sun, 6 Apr 2014 22:48:39 +0000 (18:48 -0400)]
vgabios: PMM scan was incorrectly depending on a zero %ds segment.
Make sure the PMM scanning code uses the GET_FARVAR macro. (The
existing code only worked because SeaBIOS happens to call the vgabios
in bigreal mode with %ds == %ss = 0.) Also, the scan doesn't require
bigreal mode - use accesses relative to the SEG_BIOS segment so that
the scan can work in regular real mode.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>