Kevin O'Connor [Sat, 28 Dec 2013 02:09:53 +0000 (21:09 -0500)]
xhci: Eliminate 'struct xhci_device'.
Eliminate the xhci_device struct by storing the slotid in usbdevice_s
and in xhci_pipe. The remaining storage in that struct (xhci_devctx)
is available from xhci->devs.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Gerd Hoffmann [Thu, 23 Jan 2014 14:48:19 +0000 (15:48 +0100)]
pci: improve io address space allocation
This patch improves the io address space allocation. It adds a check
that the region above 0xc000 which is traditionally used for pci io
is actually big enougth. If it isn't it tries the larger window at
0x1000. If that is to small too it errors out.
When creating guests with multiple pci-pci bridges (and devices with
io regions behind them) the 0xc000 -> 0xffff region quickly becomes
too small.
While being at it document the io address space layout used by
qemu/seabios.
Kevin O'Connor [Wed, 15 Jan 2014 18:42:50 +0000 (13:42 -0500)]
debug: Only call serial_debug_preinit() at startup.
The serial_debug_preinit() function disables serial interrupts so that
the OS doesn't get confused by "transmit buffer empty" interrupts
caused when seabios writes to the serial port. It's unnecessary
paranoia to keep rechecking that interrupts are disabled.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Wed, 15 Jan 2014 18:34:19 +0000 (13:34 -0500)]
debug: Add runtime option to not report the debug serial port to the OS.
DOS resets the serial ports reported by the BIOS. This can mess up
debugging and timing when the serial baud rate changes on the debug
port. The new "etc/advertise-serial-debug-port" option allows one to
suppress the debug serial port from the normal list of serial ports
the BIOS reports to DOS.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Sat, 18 Jan 2014 01:21:20 +0000 (20:21 -0500)]
coreboot: Support alternative locations for CBFS.
The Google builds of SeaBIOS place the CBFS data in a non-standard
location. Add a config parameter to support non-standard locations.
This is based on a patch from Stefan Reinauer <reinauer@chromium.org>
in the Chromium seabios repo (commit 60534ec785).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Mon, 20 Jan 2014 16:53:12 +0000 (11:53 -0500)]
build: Update kconfig to version in Linux 3.13.
Update kconfig (from Linux v3.11-rc6) to the latest version (Linux
v3.13).
This copyies 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>
Gerd Hoffmann [Mon, 20 Jan 2014 13:32:54 +0000 (14:32 +0100)]
smbios: catch zero-length strings
qemu may pass us zero-length strings for smbios fields, when starting
qemu this way ...
qemu -smbios type=1,version=,serial=test
... for example.
Today we don't specifically handle them and simply append them to the
string list. Therefore we get two string-terminating zeros in a row.
Result is that we by accident create a end-of-entry marker in the middle
of the entry.
Fix this by handling zero-length strings like non-present strings.
Kevin O'Connor [Fri, 17 Jan 2014 23:43:10 +0000 (18:43 -0500)]
ehci: memset the qTD structures in ehci_alloc_intr_pipe
The qTD structures were not being cleared in ehci_alloc_intr_pipe()
and it was possible that garbage could have been in some of the
fields. Also, memset the data array for sanity purposes.
A similar fix is in the Chromium seabios repo (3e711dc261).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Laszlo Ersek [Wed, 15 Jan 2014 01:48:40 +0000 (02:48 +0100)]
init_virtio_scsi(): reset the HBA before freeing its virtio ring
When init_virtio_scsi() finds no SCSI targets connected to the HBA, it
frees the virtio ring. Other code in SeaBIOS proceeds to overwrite the
area. However, the ring is in use by qemu at that point -- not only did we
report the (ACK|DRIVER|DRIVER_OK) status earlier, we even communicated
over the ring.
Of course SeaBIOS doesn't "kick" the HBA ever again, hence qemu has no
reason to look at the ring. However, when qemu uses KVM acceleration, and
ioeventfd is enabled for the HBA, then a vmstate change to "running"
(including stop->cont monitor commands and incoming migration) "forces" a
kick (see qemu commit 25db9ebe). Qemu then tries to interpret whatever
unrelated guest data is in the HBA's original ring area, as virtio
protocol. Qemu exits upon seeing the garbage.
init_virtio_scsi() should reset the HBA before allowing the virtio ring
memory to be reused. Device reset causes the hypervisor to drop its
references.
This change is justified / underpinned by pure virtio-spec compliance as
well.
Related RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1013418
Marcel Apfelbaum [Wed, 15 Jan 2014 12:20:06 +0000 (14:20 +0200)]
resume: restore piix pm config registers after resume
On resume, the OS queries the power management event that
caused it. In order to complete this task, it executes some
reads to the piix pm io space. This all happens before the
OS has a chance to restore the PCI config space for devices,
so it is bios's responsibility to make sure the pm IO space
is configured correctly. (During suspend, the piix pm
configuration space is lost).
Note: For 'ordinary' pci devices the config space is
saved by the OS on sleep and restored on resume.
Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com>
Kevin O'Connor [Thu, 5 Dec 2013 23:43:20 +0000 (18:43 -0500)]
usb: Replace EHCI to UHCI/OHCI synchronization with new scheme.
The previous code attempts to correlate which UHCI and OHCI
controllers correlate with which EHCI controllers so that it can
ensure high speed devices are handled by the EHCI code while low/full
speed devices are handled by the UHCI/OHCI code. Replace this logic
by initializing all EHCI controllers first, and then initializing all
UHCI and OHCI controllers. This simplifies the code and improves
support for some hardware devices that don't follow the OHCI/UHCI to
EHCI correlation standard.
Also, remove the unused usb->busid field.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Mon, 23 Dec 2013 03:44:08 +0000 (22:44 -0500)]
Always perform thread cleanup on MainThread stack.
The thread cleanup was being performed on whatever thread stack was
next in the list. However, with high debugging this causes spurious
_free() debug messages to show up in random threads which can be
confusing when analyzing the debug output. So, always run
__end_thread() on the MainThread stack to prevent this confusion.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Tue, 17 Dec 2013 22:57:48 +0000 (17:57 -0500)]
Clear the total block transfer count on error.
The total number of blocks transferred is part of the return status of
the BIOS API. This is normally the total number of blocks requested.
However, in an error it is possible for this count to be less. Add a
global check to ensure that on an error event the block count is
updated - if it hasn't been updated, assume that no blocks have been
transferred successfully (the common case).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Sat, 14 Dec 2013 18:14:02 +0000 (13:14 -0500)]
Remove the pmm handle argument from _malloc().
The PMM handle argument will almost always be 0xffffffff. Use
separate code for the few rare cases where it may not be the default
value. Gcc produces better code if _malloc() only requires three
parameters.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Mon, 23 Dec 2013 18:44:59 +0000 (13:44 -0500)]
build: Don't trash the .config file when src/Kconfig changes.
Revision 5325e91e introduced a change to force the rebuild of the
.config file when the src/Kconfig (or vgasrc/Kconfig) file changes.
However, this was causing a complete rebuild of the user's .config
file which would throw away the user's current settings.
On a rebuild, use the kbuild olddefconfig rule instead of defconfig to
attempt to keep the user's current settings.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Thu, 12 Dec 2013 00:38:15 +0000 (19:38 -0500)]
floppy: Implement cylinder seeking when accessing a different cylinder.
It appears that on real hardware, floppies require a seek command to
move the floppy head between cylinders. So, track what cylinder is
active and issue a seek command whenever a new cylinder is requested.
This also breaks up the floppy_cmd() code so that the low-level
command functions can pass the desired cylinder directly to the
seeking code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Wed, 11 Dec 2013 23:32:12 +0000 (18:32 -0500)]
floppy: Encode command and flags into single value in floppy pio code.
Eliminate struct floppy_pio_s and change floppy_pio() to take the
command type and parameters in a single encoded value. This makes the
code similar to the ps2port.c pio code. It also reduces some of the
boilerplate code in the callers of floppy_pio().
Also, collapse pairs of floppy_select_drive() and floppy_pio() calls
into new call floppy_drive_pio().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Gerd Hoffmann [Fri, 6 Dec 2013 09:29:09 +0000 (10:29 +0100)]
change boot order load log level
Having loadBootOrder and find_prio print at different log levels (3 + 1)
doesn't make that much sense, to trouble-shoot bootorder issues it is
very useful to have both. Lets use loglevel 1.
Kevin O'Connor [Mon, 9 Dec 2013 22:27:54 +0000 (17:27 -0500)]
vgabios: Avoid memory references via %esp register in vgabios.
Win7 interprets the vgabios and it does not properly handle memory
references relative to the %esp register. Commit 4a8b58cb introduced
some of these %esp references - rework that assembler to avoid these
instructions and make win7 happy.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Sat, 7 Dec 2013 17:48:11 +0000 (12:48 -0500)]
floppy: Fix accesses to DOR register.
The DOR register is a write-only register (even though QEMU and at
least some real hardware permit read/write acess). So, do not read
from the DOR port. Introduce a VARLOW variable (FloppyDOR) to store
the current state.
When resetting the controller, make sure to enable both the controller
and interrupts. Also, make sure the controller is really reset (by
writing a 0 to DOR first) to ensure an IRQ is received on reset.
Also, add some additional dprintf statements to the floppy init path.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Sat, 7 Dec 2013 16:46:37 +0000 (11:46 -0500)]
floppy: Fix incorrect LBA to CHS translation.
The floppy LBA to CHS translation was incorrect for the last sector of
a given cylinder. This wasn't a problem under QEMU as it came to the
same results anyway, but it causes errors of real floppy controllers.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Fri, 6 Dec 2013 18:52:16 +0000 (13:52 -0500)]
Separate out sec32init sections even when not doing code relocation.
The current code does not boot on QEMU with 256K roms when code
relocation is disabled, because QEMU only maps the last 128K of the
rom to low memory. The seabios make_bios_writable() call copies the
full rom to low memory.
This patch separates out the init sections even if code relocations
are disabled. This effectively ensures that make_bios_writable() code
is in the last 128K of the rom.
This also introduces a new build symbol (final_readonly_start) which
stores the address of where the final runtime read-only memory begins.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Sun, 1 Dec 2013 00:16:15 +0000 (19:16 -0500)]
vgabios: Support allocating an extra stack for vgabios calls and default on.
Add code to allocate an extra stack for the main vgabios int 0x10
entry point. The allocation is done via the PMM spec and uses a PCI
v3 permanent low memory region request. This request will work with
SeaBIOS - it is unknown how many other main BIOS implementations
support this PMM call.
The extra stack is useful for old DOS programs that call the VGABIOS
and expect it to work with very small amounts of stack space.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Sat, 30 Nov 2013 17:52:44 +0000 (12:52 -0500)]
vgabios: Work around lack of support for "calll" in x86emu emulation.
Replace 32 bit call instructions with 16 bit call instructions in the
vgabios to workaround problems in old versions of x86emu. This change
allows fc13 and fc14 to boot. (Other x86emu emulation bugs still
prevent fc11 and fc12 from booting.)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Sat, 30 Nov 2013 15:52:45 +0000 (10:52 -0500)]
vgabios: Support custom fonts in vga framebuffer text writing.
Obtain the font data from int 0x43 and int 0x1f, and obtain the font
height from the BDA. This enables application overrides for the font
data.
This patch also unifies the variable naming between the
planar/CGA/linear character writing functions and uses the same names
that the screen scrolling functions use.
This patch also optimizes the inner loop of the CGA font writing to
reduce overall stack usage.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Gerd Hoffmann [Tue, 26 Nov 2013 13:10:25 +0000 (14:10 +0100)]
ahci: alloc structs in high memory
With ahci running in 32bit mode we can also allocate the
(ahci private) data structures in high memory. This
reduces the real mode memory footprint as we only need
to move struct ahci_port_s (which contains struct drive_s)
to fseg in case the port probe was successful.
Gerd Hoffmann [Tue, 26 Nov 2013 11:48:20 +0000 (12:48 +0100)]
pci: map 64-bit BARs at location provided by emulator
Currently 64-bit PCI BARs are unconditionally mapped by BIOS right
over 4G + RamSizeOver4G location, which doesn't allow to reserve
extra space before 64-bit PCI window. For memory hotplug an extra
RAM space might be reserved after present 64-bit RAM end and BIOS
should map 64-bit PCI BARs after it.
Introduce "etc/reserved-memory-end" romfile to provide BIOS a hint
where it should start mapping of 64-bit PCI BARs. If romfile is
missing, BIOS reverts to legacy behavior and starts mapping after
high memory.
Based-on-patch-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-By: Igor Mammedov <imammedo@redhat.com>
IASL stores it's revision in each table header it generates.
That's a problem since guests see a change each time
they move between hypervisors.
We generally fill our own info for tables,
but we forgot to do this for the built-in DSDT.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Gerd Hoffmann [Fri, 18 Oct 2013 10:22:36 +0000 (12:22 +0200)]
Add support for etc/e820 fw_cfg file
The new fw_cfg is simliar to the QEMU_CFG_E820_TABLE entry,
but carries both reservations and RAM regions, so we can use
it instead of the cmos for RAM detection.
Gerd Hoffmann [Fri, 18 Oct 2013 10:18:19 +0000 (12:18 +0200)]
Add qemu_cfg_e820 function.
Move all ram detection and e820 setup to the new function, except for
lowmem detection which must remain in preinit so we can initialize our
memory allocator properly.
Load files through romfile loader and use for acpi tables.
We need the RSDP pointer to hang the rest of the tables off it,
to detect that we simply scan all memory in FSEG.
Add an option to disable this feature (useful for old QEMU versions).
This saves about 1Kbytes.
enabled:
Total size: 134932 Fixed: 61571 Free: 127212 (used 51.5% of 256KiB rom)
disabled:
Total size: 133836 Fixed: 61563 Free: 128308 (used 51.1% of 256KiB rom)
Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
romfile_loader: utility to patch in-memory ROM files
Add ability for a ROM file to point to
it's image in memory. When file is in memory,
add utility that can patch it, storing
pointers to one file within another file.
This is not a lot of code: together with the follow-up patch to load
ACPI tables from ROM, it's about 1K extra.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Kevin O'Connor [Sat, 26 Oct 2013 15:48:06 +0000 (11:48 -0400)]
Convert op->drive_g from a 16bit pointer to a 32 bit "GLOBALFLAT" pointer.
The "drive" structure is always malloc'ed and therefore always starts
off described as a 32-bit "flat" pointer. Instead of switching
to/from 16bit pointers, make all the code use the 32bit pointer. This
eliminates the confusing 16/32 bit pointer switches.
This patch also removes the "_g" suffixes on local variables in
functions that are always called in 32bit mode.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
After changing the parameter from `NotSerialized` to `Serialized`, the
remark is indeed gone and there is no size change.
The remark was added in ACPICA version 20130517 [1] and gives the
following explanation.
If a thread blocks within the method for any reason, and another thread
enters the method, the method will fail because an attempt will be
made to create the same (named) object twice.
In this case, issue a remark that the method should be marked
serialized. ACPICA BZ 909.
vgahooks: add SM720 VGA BIOS hooks for WIN Enterprises MB-60470
Add vgahooks to support the SMI SM720 VGA BIOS used on the
WIN Enterprises MB-60470. The response from smi_157f14() is necessary
for the CRT output to turn on. The response from smi_157f02() is used
to configure which connector(s) output is routed to.
As I lack hardware to test LCD panel output, I've selected CRT-only
output on the MB-60470 as this prevents the CRT output from being scaled
to the resolution of the LCD panel.
Signed-off-by: Jonathan A. Kollasch <jakllsch@kollasch.net>
Testing was done on windows images (win 2008/2012) taken from esx with vmware
tools installed and boot disk configured to use pvscsi.
Also I've used linux (ubuntu 12.04) where pvscsi drivers are installed by
default and booted it using qemu cmd similar to this:
Kevin O'Connor [Tue, 15 Oct 2013 01:52:28 +0000 (21:52 -0400)]
Build different final files for QEMU, coreboot, and CSM.
Build out/bios.bin on QEMU, out/bios.bin.elf on coreboot, and
out/Csm16.bin for CSM. This reduces the chance that one accidentally
builds for an incorrect target.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Thu, 3 Oct 2013 01:28:08 +0000 (21:28 -0400)]
Run ahci code entirely in 32bit mode.
The ahci driver needs to jump into 32bit mode in order to access
portions of the ahci controllers PCI config space. Instead of jumping
into 32bit mode just to toggle the ahci registers, jump into 32bit
mode for all of the driver interactions. This shrinks the size of the
overall code and can lead to further cleanups.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Thu, 3 Oct 2013 00:20:03 +0000 (20:20 -0400)]
Support call16() calls after entering 32bit mode from call32().
When transitioning to 32bit via call32() track the stack segment
register and support restoring it on call16() requests. This permits
call16() to work properly.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>