Kevin O'Connor [Mon, 24 Mar 2014 16:49:44 +0000 (12:49 -0400)]
vgabios: Rewrite vgafb.c graphics operations to set of 4 standard operators.
The vgabios graphics manipulations can all be implemented on top of 4
basic primitives: read 8 pixels, write 8 pixels, move pixels, and
clear pixels. Implement these four operators for all the graphics
modes and rewrite the graphics functions in vgafb.c to use them. This
simplifies the graphics code as the high level logic no longer needs
to be implemented for each graphical framebuffer type.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Fri, 21 Mar 2014 01:16:28 +0000 (21:16 -0400)]
vgabios: Split vgafb_scroll() into separate move and clear functions.
Rewrite the low-level scroll code so that it is implemented using two
basic operations: move text and clear text. This simplifies the
low-level code as it no longer needs to handle up scrolling vs down
scrolling. Determining the direction of the scroll is now done in the
higher level (vgabios.c) code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Mon, 7 Apr 2014 21:31:43 +0000 (17:31 -0400)]
apm: Remove old Bochs mechanism for shutdown/suspend/standby.
Remove the old mechanism that used port 0x8900 to send apm signals.
Recent versions of QEMU no longer support this port. Bochs and QEMU
only ever supported shutdown anyway, and shutdown is already available
via an ACPI mechanism.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Mon, 7 Apr 2014 20:02:22 +0000 (16:02 -0400)]
Document no new changes to pirtable.c, mptable.c, acpi.c, and smbios.c.
Add a note to the code that generates the pir, mptable, smbios, and
smbios tables that no new changes are expected. Going forward, it is
expected that if any changes are needed to these bios tables that
SeaBIOS will get the tables passed in from upstream.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Mon, 7 Apr 2014 20:35:18 +0000 (16:35 -0400)]
Use biostables.c for copying bios tables even when generating them.
Use the biostables.c copy_pir(), copy_smbios(), copy_acpi_rsdp(), and
copy_mptable() code even when using the legacy bios table generation
code. This unifies the final bios table deployment code between qemu,
coreboot, and csm.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Mon, 7 Apr 2014 19:48:12 +0000 (15:48 -0400)]
smbios: Move smbios parsing logic from smbios.c to biostables.c.
After this change, src/fw/smbios.c only contains the legacy code for
generating SMBIOS tables. This change only contains code movement -
no logic is changed.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Mon, 7 Apr 2014 19:42:04 +0000 (15:42 -0400)]
acpi: Move acpi parsing logic from acpi.c to biostables.c / paravirt.c.
After this change, src/fw/acpi.c only contains the legacy code for
generating ACPI tables. This change only contains code movement - no
logic is changed.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Mon, 7 Apr 2014 16:15:34 +0000 (12:15 -0400)]
Replace CONFIG_THREAD_OPTIONROMS with a runtime config setting.
Replace the CONFIG_THREAD_OPTIONROMS option with the CBFS (or fw_cfg)
file "etc/threads". This allows for the "threads during optionrom"
capability to be enabled/disabled without requiring SeaBIOS to be
recompiled. A value of "2" in this file will enable threads to run
during option rom execution.
This change also allows for all threads to be disabled via the same
runtime config file. Setting the file to a value of "0" will cause
SeaBIOS to perform all hardware initialization serially.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Eric Northup [Wed, 12 Mar 2014 20:42:36 +0000 (13:42 -0700)]
vp_init_simple: enable PCI bus-mastering before relying on DMA.
An analogous change was made in the LSI scsi driver, commit 7d052575258ad2fc487ca3f9a6b62eff1b767900. Qemu works around guests that don't
correctly enable PCI bus mastering before using virtio queues' DMA (search for
VIRTIO_PCI_BUG_BUS_MASTER / VIRTIO_PCI_FLAG_BUS_MASTER_BUG ), but it'd be
better to be correct.
Signed-off-by: Eric Northup <digitaleric@google.com>
Kevin O'Connor [Tue, 11 Mar 2014 15:46:42 +0000 (11:46 -0400)]
smbios: Default all values to zero.
Make sure to initialize the entire smbios area to zero so that any
field not explicitly initialized does not have random values. (It was
found that the memory_error_information_handle field in smbios_type_17
was not being set.)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Tue, 18 Feb 2014 18:48:09 +0000 (13:48 -0500)]
vgabios: Fix PMM allocation request size.
The size of a PMM memory request is in "paragraphs" so the size needs
to be divided by 16. Fix the request so only the desired 512 bytes is
allocated instead of 8K.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Fri, 17 Jan 2014 17:11:49 +0000 (12:11 -0500)]
coreboot: Add support for a "links" file to have aliases in CBFS.
The "links" file is a newline separated list where each line is a
"link name" followed by a "destination name" separated by a space
character. For each line, SeaBIOS will consider each "link name" to
be a CBFS file that has the contents found in the CBFS file with
"destination name".
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Sat, 8 Feb 2014 21:43:30 +0000 (16:43 -0500)]
vgabios: Refactor write_teletype and write_chars.
Factor out the common code of writing to the screen and advancing the
cursor position to a new function write_char(). Eliminate
write_chars() and then simplify write_teletype(). Also, eliminate the
separate scroll_one() function as it no longer reduces stack space.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Sat, 8 Feb 2014 17:29:20 +0000 (12:29 -0500)]
vgabios: Don't interpret TAB character.
Several sources document that the Bell, Backspace, newline, and
carriage return characters are interpreted by int 10/0e. There does
not seem to be any references to that function interpreting tab. The
original "lgpl vgabios" has code for interpreting tab, but the code is
incorrect. Finally, tests on an ATI vgabios indicate that tab is not
interpreted.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Thu, 6 Feb 2014 03:47:29 +0000 (22:47 -0500)]
vgabios: Attempt to detect old x86emu and force a fault.
Check for cases where the leal instruction does not work. This
instruction is known to not be emulated properly on old versions of
x86emu. If a broken version of x86emu is found, force a fault that
x86emu will easily detect. This should help prevent soft failures
when running old software.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Thu, 6 Feb 2014 00:29:08 +0000 (19:29 -0500)]
vgabios: Simplify the bios save state area.
The structure of the "bios save state area" as returned by
handle_101c() and vbe_104f04() does not follow any particular order.
(And there does not appear to be any documentation that would require
it to follow a particular order.)
So, rearrange the layout of the struct to make save and restore
simpler.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Wed, 5 Feb 2014 23:49:44 +0000 (18:49 -0500)]
vgabios: Make sure exported structs use PACKED.
Commit ca668640 introduced structs for data returned from the
handle_101b and handle_101c calls. However, the structs were not
declared as packed and that caused incorrect behavior for
handle_101b. This was seen to break some old DOS programs (Win3 setup
and DISPLAY.SYS). This patch adds in the necessary PACKED declaration
to the structs.
The 'struct saveBDAstate' remains un-packed, as it does not appear
that its contents are documented. (And, its format already differs
from what was in the previous "lgpl vgabios".)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Mon, 20 Jan 2014 16:47:43 +0000 (11:47 -0500)]
Increase maximum size of permanent high memory area.
Some XHCI controllers can request a significant chunk of reserved
memory for scratch pad buffers. (At least one controller Intel
Haswell based controller has been seen to request 64KiB.) Unused
memory is returned after POST completes, so it should be okay to
increase the maximum permanent high memory zone from 64K to 256K.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>