]> xenbits.xensource.com Git - people/andrewcoop/seabios.git/log
people/andrewcoop/seabios.git
8 years agosmp: restore MSRs on S3 resume 1.9-stable
Paolo Bonzini [Thu, 7 Jul 2016 14:00:40 +0000 (16:00 +0200)]
smp: restore MSRs on S3 resume

Currently the MTRRs and MSR_IA32_FEATURE_CONTROL are not restored on S3
resume.  Because these have to be applied to all processors, SMP setup
has to be added to S3 resume.

There are two differences between the boot and resume paths.  First,
romfile_* is not usable in the resume paths so we separate out the
remaining common code to a new smp_scan function.  Second, smp_msr has
to be walked on the BSP as well, so we extract that out of handle_smp
and into a new function smp_write_msrs.  Then, resume can call
smp_write_msrs on the BSP followed by smp_scan to initialize the APs.

Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
(cherry picked from commit 54e3a88609da074aaae2f04e592026ebf82169dc)

8 years agofw/msr_feature_control: add support to set MSR_IA32_FEATURE_CONTROL rel-1.9.3
Haozhong Zhang [Wed, 22 Jun 2016 06:53:24 +0000 (14:53 +0800)]
fw/msr_feature_control: add support to set MSR_IA32_FEATURE_CONTROL

OS usually expects BIOS to set certain bits in MSR_IA32_FEATURE_CONTROL
for some features (e.g. VMX and LMCE). QEMU provides a fw_cfg file
"etc/msr_feature_control" to advise bits that should be set in
MSR_IA32_FEATURE_CONTROL. If this file exists, SeaBIOS will set the
advised bits in that MSR.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 20160622065324.23812-1-haozhong.zhang@intel.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 20f83d5c7c0f9ae5f775b6701c205349abe003fb)

8 years agofw/pci: Add support for mapping Intel IGD via QEMU
Alex Williamson [Tue, 17 May 2016 20:44:32 +0000 (14:44 -0600)]
fw/pci: Add support for mapping Intel IGD via QEMU

QEMU provides two fw_cfg files to support IGD.  The first holds the
OpRegion data which holds the Video BIOS Table (VBT).  This needs to
be copied into reserved memory and the address stored in the ASL
Storage register of the device at 0xFC offset in PCI config space.
The OpRegion is generally 8KB.  This file is named "etc/igd-opregion".

The second file tells us the required size of the stolen memory space
for the device.  This space requires 1MB alignment and is generally
either 1MB to 8MB depending on hardware config, but may be hundreds of
MB for user specified stolen memory.  The base address of the reserved
memory allocated for this is written back to the Base Data of Stolen
Memory register (BDSM) at PCI config offset 0x5C on the device.  This
file is named "etc/igd-bdsm-size".

QEMU documents these fw_cfg entries in docs/igd-assign.txt.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Message-id: 20160517203151.6996.95545.stgit@gimli.home
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 04259c5817edc6d23f0aed76fd20ab220efcddc6)

9 years agofw/pci: add Q35 S3 support rel-1.9.2
Marcel Apfelbaum [Tue, 1 Mar 2016 14:06:45 +0000 (16:06 +0200)]
fw/pci: add Q35 S3 support

Following the i440fx example, save the LPC, SMBUS and PCIEXBAR bdfs
between OS sleeps and use them to re-configure the
corresponding registers.

Tested-by: Gal Hammer <ghammer@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
(cherry picked from commit dce99e01b6bfc51175bdf32612fd4f2738e5c3c8)

9 years agobuild: fix .text section address alignment
Kevin O'Connor [Sat, 20 Feb 2016 02:34:16 +0000 (21:34 -0500)]
build: fix .text section address alignment

Some linkers verify that sections have a start address that is aligned
with the minimum alignment of that section.  Add extra padding to the
".text" section to ensure it is always aligned with the maximum
alignment of any section placed in ".text".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reported by: Ed Maste <emaste@FreeBSD.org>

(cherry picked from commit 3910de0dee216d5b5bf23cfa29bfc80d082b2ee7)

9 years agobiostables: Support SMBIOS 2.6+ UUID format rel-1.9.1
Cole Robinson [Fri, 15 Jan 2016 15:49:32 +0000 (10:49 -0500)]
biostables: Support SMBIOS 2.6+ UUID format

SMBIOS 2.6+ stores the UUID in a different format, with the first 3
fields in little endian format. This is what modern qemu delivers
and what dmidecode also handles, so let's follow suit too.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
(cherry picked from commit 2e11d582b5e14759b3c1482d7e317b4a7257e77d)

9 years agofw/pci: do not automatically allocate IO region for PCIe bridges
Marcel Apfelbaum [Mon, 7 Dec 2015 12:05:14 +0000 (14:05 +0200)]
fw/pci: do not automatically allocate IO region for PCIe bridges

PCIe downstream ports (Root Ports and switches Downstream Ports) appear
to firmware as PCI-PCI bridges and a 4K IO space is allocated for them
even if there is no device behind them requesting IO space,
all that for hotplug purpose.

However, PCIe devices can work without IO, so there is no need
to allocate IO space for hotplug.

Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
(cherry picked from commit 76327b9f32a009245c215f4a3c5d58a01b5310ae)

9 years agocoreboot: Check for unaligned cbfs header
Kevin O'Connor [Tue, 12 Jan 2016 18:36:50 +0000 (13:36 -0500)]
coreboot: Check for unaligned cbfs header

If the CBFS header is invalid and points to 0xffffffff it could cause
SeaBIOS to read past the 4GB boundary and cause an exception.  Check
the alignment of the header pointer before attempting to access fields
within the header.

Reported-by: "Alex G." <mr.nuke.me@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
(cherry picked from commit 3e8d75f3bef0f36a807303d58523ef5eba4a386f)

9 years agoscsi: Do not call printf() from scsi_is_ready()
Kevin O'Connor [Wed, 23 Dec 2015 20:37:51 +0000 (15:37 -0500)]
scsi: Do not call printf() from scsi_is_ready()

The scsi_is_ready() function may be called from a thread, and it is
not valid to call printf() from a thread.  Convert printf() to
dprintf() to avoid this possibility.

This does mean that cdrom detection (from cdrom_boot() ) may not give
notification of slow cdrom drives to a user.  However, the extra
medium detection time is unlikely to be large anyway.

Reported-by: Tobias Diedrich <tobiasdiedrich@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
(cherry picked from commit 82f327976865ba151153a04b584fc5d0a1fc5d9b)

9 years agonmi: Don't try to switch onto extra stack in NMI handler
Kevin O'Connor [Wed, 23 Dec 2015 20:33:02 +0000 (15:33 -0500)]
nmi: Don't try to switch onto extra stack in NMI handler

The NMI could occur when already on the extra stack, which would
corrupt it.  Always use the current stack on an NMI to avoid this.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
(cherry picked from commit 0c5a6077fc569d27aeadde690810f820b3256fbd)

9 years agosdcard: fix typo causing 32bit write to 16bit block_size field
Kevin O'Connor [Tue, 17 Nov 2015 19:54:11 +0000 (14:54 -0500)]
sdcard: fix typo causing 32bit write to 16bit block_size field

The block_size field is 16bits and only 16bit writes should be used
with it.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
(cherry picked from commit 8f7dc5ab820beac980f0d40f3934a5ae04771349)

9 years agosdcard: Only enable error_irq_enable for bits defined in SDHCI v1 spec
Kevin O'Connor [Tue, 17 Nov 2015 19:52:23 +0000 (14:52 -0500)]
sdcard: Only enable error_irq_enable for bits defined in SDHCI v1 spec

The SDHCI v1 spec only defines the first 9 error_irq_enable bits and
reserves other bits in the field.  Don't enable the 10th bit (which
was defined in the v2 spec) as it's not needed anyway.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
(cherry picked from commit 460e9aac4e1ef88b14a7d44876c43ecfc94f8848)

9 years agoxhci: Wait for port enable even for USB3 devices
Kevin O'Connor [Sun, 13 Dec 2015 19:49:41 +0000 (14:49 -0500)]
xhci: Wait for port enable even for USB3 devices

Some USB3 controllers (and/or devices) need additional time after the
device is detected to place the port in an enabled state.  Wait for
the controller to report enabled before proceeding.  This fixes
several reports of devices that showed a "stall" error (cc 4) during
set address.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
(cherry picked from commit c01b41c5c68c197fe0124078261b48942f2919bd)

9 years agoxhci: Check for device disconnects during USB2 reset polling
Kevin O'Connor [Tue, 10 Nov 2015 13:50:52 +0000 (08:50 -0500)]
xhci: Check for device disconnects during USB2 reset polling

Some XHCI controllers register super-speed devices on high-speed ports
and then disconnect them when the super-speed detection completes.
Make sure to recognize these disconnect events during the reset
process.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
(cherry picked from commit aa34e4e52fb65abb4ef8539660f05b4d52fb1f6f)

9 years agobuild: fix typo in buildversion.py
Roger Pau Monne [Mon, 28 Dec 2015 12:50:41 +0000 (13:50 +0100)]
build: fix typo in buildversion.py

Fixes the following build error:

  Building ld scripts
Traceback (most recent call last):
  File "./scripts/buildversion.py", line 134, in <module>
    main()
  File "./scripts/buildversion.py", line 114, in main
    cleanbuild, toolstr = tool_versions(options.tools)
  File "./scripts/buildversion.py", line 90, in tool_versions
    vers[isbinutils] = "mixed"
NameError: global name 'vers' is not defined
Makefile:160: recipe for target 'out/romlayout16.lds' failed

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
(cherry picked from commit 3b8c5378dfe24ca8dfeabbcc435c7eb9e2d8d769)

9 years agodocs: Note v1.9.0 release rel-1.9.0
Kevin O'Connor [Tue, 17 Nov 2015 14:18:44 +0000 (09:18 -0500)]
docs: Note v1.9.0 release

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agobuildversion: Add debugging messages
Kevin O'Connor [Tue, 10 Nov 2015 14:26:52 +0000 (09:26 -0500)]
buildversion: Add debugging messages

Add ability to output debug messages from the buildversion.py build
script.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agobuildversion: Avoid subprocess.check_output() as that requires python2.7
Kevin O'Connor [Mon, 9 Nov 2015 14:23:26 +0000 (09:23 -0500)]
buildversion: Avoid subprocess.check_output() as that requires python2.7

Don't require python2.7 in buildversion.py.  Also, ignore only those
exceptions that are known to be possible.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoPCI SDHCI driver: Fix base address
Kyösti Mälkki [Wed, 4 Nov 2015 05:40:12 +0000 (07:40 +0200)]
PCI SDHCI driver: Fix base address

MMIO register space was off by 4 bytes, bottom bits of
PCI BAR registers are not part of the address.

Test boot on real hardware:

PCI device 00:14.7 (vd=3D1022:7813 c=3D0805)

Searching bootorder for: /pci@i0cf8/*@14,7
sdhci@0xfeb25500 ver=3D1001 cap=3D31fe3fb2 2570
sdcard_set_frequency 63 400 8000
sdcard_pio command stop (code=3D1)
sdcard_set_frequency 63 25000 200
Found sdcard at 0xfeb25500: SD card SD01G 982MiB
Registering bootable: SD card SD01G 982MiB (type:2 prio:103 data:f46e0)

Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
9 years agodocs: Minor - replace seavgabios text in Build_overview.md with link
Kevin O'Connor [Mon, 26 Oct 2015 13:38:30 +0000 (09:38 -0400)]
docs: Minor - replace seavgabios text in Build_overview.md with link

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agovirtio: Minor - replace tab characters with space
Kevin O'Connor [Sun, 18 Oct 2015 15:27:50 +0000 (11:27 -0400)]
virtio: Minor - replace tab characters with space

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agobiostables: Minor - fix incorrect indentation
Kevin O'Connor [Sun, 18 Oct 2015 15:25:15 +0000 (11:25 -0400)]
biostables: Minor - fix incorrect indentation

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agocoreboot: Minor - avoid K&R style function declaration
Kevin O'Connor [Sun, 18 Oct 2015 15:24:54 +0000 (11:24 -0400)]
coreboot: Minor - avoid K&R style function declaration

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agobuild: Allow official tarball builds to be considered "clean"
Kevin O'Connor [Thu, 22 Oct 2015 15:59:47 +0000 (11:59 -0400)]
build: Allow official tarball builds to be considered "clean"

If building from an official tarball and EXTRAVERSION info is
provided, then consider the build to be "clean" (don't include
hostname/build timestamp).  This is done on the expectation that
EXTRAVERSION will have enough information to allow developers to find
the builder and build environment should a defect be reported, and
therefore the hostname/timestamp is not necessary.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agodocs: Document 'make EXTRAVERSION=xyz' and scripts/tarball.sh
Kevin O'Connor [Thu, 22 Oct 2015 15:58:16 +0000 (11:58 -0400)]
docs: Document 'make EXTRAVERSION=xyz' and scripts/tarball.sh

Document the existence of the EXTRAVERSION field and the information
expected to be present in it.  Document the use of tarball.sh in build
environments that lack git.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agobuild: Be more permissive in buildversion.py tool version scan
Kevin O'Connor [Thu, 22 Oct 2015 00:35:50 +0000 (20:35 -0400)]
build: Be more permissive in buildversion.py tool version scan

There is some variation in version strings between various tool chain
builds.  Make the version tool scan more permissive to attempt to
handle these variations.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoAdd QEMU fw_cfg DMA interface
Marc Marí [Thu, 8 Oct 2015 15:03:26 +0000 (17:03 +0200)]
Add QEMU fw_cfg DMA interface

Add support for the new fw_cfg DMA interface. The protocol is explained in
QEMU documentation.

Signed-off-by: Marc Marí <markmb@redhat.com>
9 years agomalloc: Rename csm_malloc_preinit() to malloc_csm_preinit()
Kevin O'Connor [Thu, 15 Oct 2015 17:53:04 +0000 (13:53 -0400)]
malloc: Rename csm_malloc_preinit() to malloc_csm_preinit()

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agostacks: Use macro wrappers for call32() and stack_hop_back()
Kevin O'Connor [Fri, 9 Oct 2015 15:53:02 +0000 (11:53 -0400)]
stacks: Use macro wrappers for call32() and stack_hop_back()

The C code only uses _cfuncX_ prefixes for parameters to the call32(),
stack_hop_back(), and call32_params() functions.  It's simpler to use
macro wrappers around those functions which provide the required
prefix.

This also changes the parameter order of stack_hop() and
stack_hop_back() to use the more natural (func, params) ordering.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agobuild: Generate "reproducible" version strings on "clean" builds
Kevin O'Connor [Tue, 13 Oct 2015 19:49:03 +0000 (15:49 -0400)]
build: Generate "reproducible" version strings on "clean" builds

If the build environment looks "clean" then don't add the build
hostname or build time to the version string.  This makes the default
build string reproducible across builds.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agobuild: Report gcc and binutils versions in debug log
Kevin O'Connor [Tue, 13 Oct 2015 19:44:25 +0000 (15:44 -0400)]
build: Report gcc and binutils versions in debug log

Attempt to extract the gcc and binutils versions.  Report that
information in the debug log.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agobuild: Rework version generation; don't allow make version override
Kevin O'Connor [Tue, 13 Oct 2015 19:09:40 +0000 (15:09 -0400)]
build: Rework version generation; don't allow make version override

Convert the script to generate the build version from a shell script
to a python script.

Remove the ability to override the version at build time via "make
VERSION=xyz".  Replace it with ability to add extra version
information at build time via "make EXTRAVERSION=xyz".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agomemmap: Introduce SYMBOL() macro to access linker script symbols
Kevin O'Connor [Thu, 8 Oct 2015 15:18:17 +0000 (11:18 -0400)]
memmap: Introduce SYMBOL() macro to access linker script symbols

Use a macro to define and obtain the value of a symbol introduced by
the linker scripts (scripts/layoutrom.py).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agomalloc: Don't mix virtual and physical addresses
Kevin O'Connor [Tue, 22 Sep 2015 18:45:25 +0000 (14:45 -0400)]
malloc: Don't mix virtual and physical addresses

Consistently use 'u32' for physical addresses and pointers for virtual
addresses in the malloc code.  Introduce and use memremap() where a
physical address needs to be converted to a virtual address.  Use
virt_to_phys() for the inverse.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agomalloc: Add warning if free() called on invalid memory
Kevin O'Connor [Tue, 6 Oct 2015 19:37:53 +0000 (15:37 -0400)]
malloc: Add warning if free() called on invalid memory

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agomalloc: Introduce common helper alloc_new_detail()
Kevin O'Connor [Tue, 29 Sep 2015 02:20:27 +0000 (22:20 -0400)]
malloc: Introduce common helper alloc_new_detail()

Introduce helper for finding temp space to hold an "allocation detail
struct" and use it in both alloc_add() and _malloc().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agomalloc: Use consistent naming for internal low-level "alloc" functions
Kevin O'Connor [Tue, 29 Sep 2015 01:45:38 +0000 (21:45 -0400)]
malloc: Use consistent naming for internal low-level "alloc" functions

Use the "alloc_" prefix for all the low-level allocation functions and
avoid camelCase naming.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agovirtio: Move standard definitions from virtio-ring.h to standard headers
Kevin O'Connor [Tue, 29 Sep 2015 14:14:58 +0000 (10:14 -0400)]
virtio: Move standard definitions from virtio-ring.h to standard headers

Move PAGE_SHIFT / virt_to_phys() to memmap.h and smp_[rw]mb() to
x86.h.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agovirtio: Simplify vring alignment code
Kevin O'Connor [Tue, 22 Sep 2015 15:46:48 +0000 (11:46 -0400)]
virtio: Simplify vring alignment code

Don't do phys_to_virt(virt_to_phys(vaddr)) for page alignment - page
alignment can be determined directly from the virtual address.

Use the ALIGN() macro to make the code more readable.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoe820: Update debugging messages to report 64bit values
Kevin O'Connor [Thu, 1 Oct 2015 03:00:43 +0000 (23:00 -0400)]
e820: Update debugging messages to report 64bit values

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoe820: Rename memmap.c to e820map.c and use consistent "e820_" prefix
Kevin O'Connor [Tue, 29 Sep 2015 13:40:46 +0000 (09:40 -0400)]
e820: Rename memmap.c to e820map.c and use consistent "e820_" prefix

Rename memmap.c to e820map.c as the code in that file only deals with
maintaining the e820 map.  Move all the e820 definitions to new file
e820map.h and use a consistent "e820_" prefix on all exported
functions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoe820: Introduce e820_remove() and avoid exporting E820_HOLE
Kevin O'Connor [Tue, 29 Sep 2015 12:53:38 +0000 (08:53 -0400)]
e820: Introduce e820_remove() and avoid exporting E820_HOLE

The E820_HOLE definition is used internally in the e820 manipulation
code to remove entries from the e820 map.  Introduce the e820_remove()
function so that the E820_HOLE definition does not need to be exported
from the memmap.c code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoFix typos found by codespell
Stefan Weil [Fri, 2 Oct 2015 06:46:40 +0000 (08:46 +0200)]
Fix typos found by codespell

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoAlways enable caching on transition32; backup/restore cr0 on call32
Kevin O'Connor [Tue, 22 Sep 2015 16:35:00 +0000 (12:35 -0400)]
Always enable caching on transition32; backup/restore cr0 on call32

Always enable caching at start of 32bit code and always make sure the
paging flag is off.  Because this alters the cr0 register, perform a
backup and restore of it when using call32().

Also, rename get/setcr0() to cr0_read/write() to more closely match
other register access functions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoConsolidate code16*() functions
Kevin O'Connor [Tue, 22 Sep 2015 18:38:14 +0000 (14:38 -0400)]
Consolidate code16*() functions

Introduce code16_override() for cases where call16() should not
restore the previous 16bit state.  All callers now use call16_back()
to invoke 16bit code, so rename call16_back() to call16().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoUse transition32_nmi_off from call32() and call16_back()
Kevin O'Connor [Fri, 11 Sep 2015 20:19:02 +0000 (16:19 -0400)]
Use transition32_nmi_off from call32() and call16_back()

The call32() and call16_back() functions will always disable NMI and
enable a20 (via the call32_prep() function) so it is safe to use the
_nmi_off variant of transition32.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoUnify call32_sloppy() and call32()
Kevin O'Connor [Fri, 11 Sep 2015 20:15:23 +0000 (16:15 -0400)]
Unify call32_sloppy() and call32()

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoUnify inline assembler in variants of call16 functions
Kevin O'Connor [Fri, 11 Sep 2015 20:07:59 +0000 (16:07 -0400)]
Unify inline assembler in variants of call16 functions

The assembler between call16(), call16big() and call16_sloppy() are
very similar.  Rework the functions so that a single version of the
inline assembly can be used for all variants.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoRename Call32Data to Call16Data
Kevin O'Connor [Sun, 13 Sep 2015 14:03:12 +0000 (10:03 -0400)]
Rename Call32Data to Call16Data

The variable stores information on how and what to restore during a
call to 16bit code, so Call16Data is a better name.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoUnify smm/sloppy variants of call32_prep/post and call16_helper
Kevin O'Connor [Fri, 11 Sep 2015 19:38:43 +0000 (15:38 -0400)]
Unify smm/sloppy variants of call32_prep/post and call16_helper

The "smm" and "sloppy" variants of the 16bit to 32bit trampoline
backup/restore code are very similar.  They can be unified into a
single copy of each function.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agobuild: use -fstack-check=no when available
Magnus Granberg [Fri, 11 Sep 2015 21:38:40 +0000 (17:38 -0400)]
build: use -fstack-check=no when available

Some compilers (such as the one in hardened/Gentoo) default this
option to on which leads to build failures:
src/stacks.c: In function 'call16_back':
src/stacks.c:139:5: error: 'asm' operand has impossible constraints
     asm volatile(
     ^

URL: https://bugs.gentoo.org/559980
Reported-by: Alon Bar-Lev <alonbl@gentoo.org>
Signed-off-by: Magnus Granberg <zorry@gentoo.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
9 years agodocs: Minor - add "code relocation" link to "Execution and code flow" document
Kevin O'Connor [Tue, 8 Sep 2015 18:28:19 +0000 (14:28 -0400)]
docs: Minor - add "code relocation" link to "Execution and code flow" document

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoSimplify transition16/32 assembler code
Kevin O'Connor [Thu, 3 Sep 2015 16:23:53 +0000 (12:23 -0400)]
Simplify transition16/32 assembler code

Backup and restore %eax only around code that needs to use %eax.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agominor - correct spelling error in comment
Kevin O'Connor [Thu, 3 Sep 2015 16:21:51 +0000 (12:21 -0400)]
minor - correct spelling error in comment

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agomegasas: Use outl() on MFI_IDB register
Kevin O'Connor [Thu, 3 Sep 2015 14:00:57 +0000 (10:00 -0400)]
megasas: Use outl() on MFI_IDB register

The outw() should be an outl().

Reported-by: Stefan Weil <sw@weilnetz.de>
Reported-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agomegasas: Fix outw, outl argument order
Stefan Weil [Sat, 29 Aug 2015 06:02:38 +0000 (08:02 +0200)]
megasas: Fix outw, outl argument order

The value is the first argument and the port is the second,
but the code was using the opposite order.

Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
9 years agosdcard: Obtain card capacity and report it on the boot menu
Kevin O'Connor [Mon, 24 Aug 2015 17:48:54 +0000 (13:48 -0400)]
sdcard: Obtain card capacity and report it on the boot menu

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Display sdcard product name in boot menu
Kevin O'Connor [Tue, 18 Aug 2015 16:43:04 +0000 (12:43 -0400)]
sdcard: Display sdcard product name in boot menu

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Turn card_type into a bitmap and store if card is MMC type
Kevin O'Connor [Mon, 24 Aug 2015 16:36:56 +0000 (12:36 -0400)]
sdcard: Turn card_type into a bitmap and store if card is MMC type

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Move drive registration to sdcard_card_setup()
Kevin O'Connor [Tue, 18 Aug 2015 15:44:46 +0000 (11:44 -0400)]
sdcard: Move drive registration to sdcard_card_setup()

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Move frequency setting into sdcard_card_setup()
Kevin O'Connor [Tue, 18 Aug 2015 15:33:41 +0000 (11:33 -0400)]
sdcard: Move frequency setting into sdcard_card_setup()

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Move sdcard_set_frequency()/sdcard_set_power() in sdcard.c
Kevin O'Connor [Tue, 18 Aug 2015 15:22:25 +0000 (11:22 -0400)]
sdcard: Move sdcard_set_frequency()/sdcard_set_power() in sdcard.c

Just code movement; no code changes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agortc: Disable NMI in rtc_mask()
Kevin O'Connor [Tue, 1 Sep 2015 23:43:08 +0000 (19:43 -0400)]
rtc: Disable NMI in rtc_mask()

The rtc_mask() function should make sure the NMI disable bit is set
(just as rtc_read() and rtc_write() do).

Reported-by: Tim Shearer <tim.shearer@overturenetworks.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agodocs: Don't use an add-symbol-file offset when describing gdb debugging
Kevin O'Connor [Mon, 24 Aug 2015 19:12:10 +0000 (15:12 -0400)]
docs: Don't use an add-symbol-file offset when describing gdb debugging

Recent versions of gdb will only add an offset to the '.text' section
of object files via the add-symbol-file command.  The SeaBIOS build
doesn't place code directly in a '.text' section, so update the
documentation to obtain the same result via an 'objcopy' call instead.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoxhci: Minor - add USB port type comments to xhci_hub_reset()
Kevin O'Connor [Mon, 24 Aug 2015 13:50:30 +0000 (09:50 -0400)]
xhci: Minor - add USB port type comments to xhci_hub_reset()

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Allow sdcard addresses to be specified in CBFS files
Kevin O'Connor [Mon, 10 Aug 2015 16:51:41 +0000 (12:51 -0400)]
sdcard: Allow sdcard addresses to be specified in CBFS files

Allow a hardcoded address to be specified in cbfs files with a prefix
of "etc/sdcard".  Some real-world devices have valid SDHCI controllers
that do not show up as PCI devices.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agops2: Eliminate "etc/ps2-poll-only"; use CONFIG_HARDWARE_IRQ instead
Kevin O'Connor [Mon, 10 Aug 2015 19:50:53 +0000 (15:50 -0400)]
ps2: Eliminate "etc/ps2-poll-only"; use CONFIG_HARDWARE_IRQ instead

The "etc/ps2-poll-only" runtime setting is directly tied to the new
CONFIG_HARDWARE_IRQ setting - use the compile time setting to control
both.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoAdd minimal support for machines without hardware interrupts
Kevin O'Connor [Mon, 10 Aug 2015 20:14:48 +0000 (16:14 -0400)]
Add minimal support for machines without hardware interrupts

Some Chromebooks (with Baytrail CPUs) apparently do not support
routing of legacy interrupts.  This patch adds minimal support for
running SeaBIOS in such an environment.  Even with this patch, it is
known that old operating systems and even some recent bootloaders will
not function without real hardware interrupts.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agortc: Support disabling the RTC timer irq support
Kevin O'Connor [Thu, 13 Aug 2015 15:43:27 +0000 (11:43 -0400)]
rtc: Support disabling the RTC timer irq support

Add a build time config option to remove support for RTC timer
interrupts along with the associated bios calls requiring that
support.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Allow the sdcard driver to run on real hardware
Kevin O'Connor [Mon, 10 Aug 2015 19:41:03 +0000 (15:41 -0400)]
sdcard: Allow the sdcard driver to run on real hardware

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Initial support for MMC cards
Kevin O'Connor [Tue, 11 Aug 2015 17:29:55 +0000 (13:29 -0400)]
sdcard: Initial support for MMC cards

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Check for error events during sdcard_pio()
Kevin O'Connor [Wed, 12 Aug 2015 16:07:17 +0000 (12:07 -0400)]
sdcard: Check for error events during sdcard_pio()

Check for command errors and clear the error status if an error is
found.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Perform a controller reset at start of init
Kevin O'Connor [Wed, 12 Aug 2015 16:02:16 +0000 (12:02 -0400)]
sdcard: Perform a controller reset at start of init

Ask the controller to reset itself during controller setup.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Rename waitw() to sdcard_waitw() and simplify
Kevin O'Connor [Tue, 11 Aug 2015 17:03:22 +0000 (13:03 -0400)]
sdcard: Rename waitw() to sdcard_waitw() and simplify

Calculate end timeout in code and return if any bit in the provided
mask is set.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Implement timeout on every block read in sdcard_pio_transfer()
Kevin O'Connor [Wed, 12 Aug 2015 16:58:23 +0000 (12:58 -0400)]
sdcard: Implement timeout on every block read in sdcard_pio_transfer()

The sdcard specs don't specify a maximum time for arbitrary transfers.
Instead, each block has a maximum timeout.  So, change the code to
check for a timeout on each block transferred.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: The card should never be in a busy state at start of sdcard_pio()
Kevin O'Connor [Tue, 11 Aug 2015 16:59:53 +0000 (12:59 -0400)]
sdcard: The card should never be in a busy state at start of sdcard_pio()

Return an error if the controller is busy at the start of a command
instead of waiting.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Power down controller on failure
Kevin O'Connor [Tue, 11 Aug 2015 15:59:34 +0000 (11:59 -0400)]
sdcard: Power down controller on failure

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Power controller up to maximum voltage supported
Kevin O'Connor [Tue, 11 Aug 2015 15:56:51 +0000 (11:56 -0400)]
sdcard: Power controller up to maximum voltage supported

Don't error out if the controller does not support 3.3V - instead
supply the most voltage the controller supports.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Move power setup to new function sdcard_set_power()
Kevin O'Connor [Tue, 11 Aug 2015 15:47:57 +0000 (11:47 -0400)]
sdcard: Move power setup to new function sdcard_set_power()

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Support SDHCI v3.00 spec clock setting
Kevin O'Connor [Tue, 11 Aug 2015 13:34:19 +0000 (09:34 -0400)]
sdcard: Support SDHCI v3.00 spec clock setting

The SDHCI v3 spec supports higher frequency clocks and has a different
method to configure the clock divisor.

This also fixes an error in v1/v2 clock calculation (ffs was used
instead of fls).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Fill command bits according to spec
Kevin O'Connor [Tue, 11 Aug 2015 03:40:50 +0000 (23:40 -0400)]
sdcard: Fill command bits according to spec

Set the proper command bits for each command according to the SDHCI
specification.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Fix typo - use sdcard_pio() instead of sdcard_pio_app()
Kevin O'Connor [Mon, 10 Aug 2015 23:11:15 +0000 (19:11 -0400)]
sdcard: Fix typo - use sdcard_pio() instead of sdcard_pio_app()

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoCall cpu_relax() if yielding prior to interrupts being enabled
Kevin O'Connor [Fri, 7 Aug 2015 20:13:18 +0000 (16:13 -0400)]
Call cpu_relax() if yielding prior to interrupts being enabled

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoMove CanInterrupt check to check_irqs()
Kevin O'Connor [Fri, 7 Aug 2015 20:12:02 +0000 (16:12 -0400)]
Move CanInterrupt check to check_irqs()

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoedd: Reduce parameters to fill_generic_edd()
Kevin O'Connor [Wed, 5 Aug 2015 19:02:01 +0000 (15:02 -0400)]
edd: Reduce parameters to fill_generic_edd()

Have callers of fill_generic_edd() calculate the edd iface_path
field.  Have callers determine if the bus type is PCI vs ISA.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoedd: Pass the segment/offset from int 1348 calls using a 'struct segoff_s'
Kevin O'Connor [Mon, 27 Jul 2015 14:41:41 +0000 (10:41 -0400)]
edd: Pass the segment/offset from int 1348 calls using a 'struct segoff_s'

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agooptionroms: Don't run option rom on PCI bar if CBFS/fw_cfg version exists
Kevin O'Connor [Mon, 10 Aug 2015 19:37:13 +0000 (15:37 -0400)]
optionroms: Don't run option rom on PCI bar if CBFS/fw_cfg version exists

If there exists a "pci%04x,%04x.rom" file in CBFS/fw_cfg then the code
should not attempt to run a rom found on the PCI device itself - even
if the one in CBFS/fw_cfg is not a valid rom.  This makes the code
match the documentation.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoxhci: Count new Max Scratchpad Bufs bits from XHCI 1.1
Julius Werner [Sat, 8 Aug 2015 03:07:12 +0000 (20:07 -0700)]
xhci: Count new Max Scratchpad Bufs bits from XHCI 1.1

The 1.1 revision of the XHCI specification added an extra 5 bits to the
Max Scratchpad Bufs field of HCSPARAMS2 that newer controllers make use
of. Not honoring these bits means we're not allocating as many
scratchpad buffers as the controller expects, which means it will
interpret some uninitialized values from the end of the pointer array as
scratchpad buffer pointers.

We just fixed this in libpayload and it seems to apply the same way to
SeaBIOS (I only compile-tested this, though... sorry).

Signed-off-by: Julius Werner <jwerner@chromium.org>
9 years agomptable: Don't create mptable if it is very large
Kevin O'Connor [Mon, 3 Aug 2015 14:16:39 +0000 (10:16 -0400)]
mptable: Don't create mptable if it is very large

Very large mptable structures can fill up the space in the f-segment
and cause other important f-segment allocations to fail.  Limit the
maximum size of the mptable to prevent this.

On QEMU, with the current maximum size of 600 bytes, the mptable will
not be created in configurations of ~20 cpus or more.  The mptable is
rarely used in modern OSes so this should not be a problem.

Reported-by: Huaitong Han <huaitong.han@intel.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Add proper delays during card power up
Kevin O'Connor [Tue, 4 Aug 2015 14:01:02 +0000 (10:01 -0400)]
sdcard: Add proper delays during card power up

Add card power up timing delays as specified by the sd card "Physical
Layer Simplified Specification Version 4.10".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Improve SD card initialization command sequence
Kevin O'Connor [Thu, 30 Jul 2015 14:56:00 +0000 (10:56 -0400)]
sdcard: Improve SD card initialization command sequence

Send the initialization commands that are specified for SD cards by
the "SD Host Controller Simplified Specification Version 2.00" spec.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Set timeout control register during init (to max allowed timeout)
Kevin O'Connor [Tue, 28 Jul 2015 18:15:37 +0000 (14:15 -0400)]
sdcard: Set timeout control register during init (to max allowed timeout)

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Make sure controller support 3.3V before enabling it
Kevin O'Connor [Tue, 4 Aug 2015 13:48:30 +0000 (09:48 -0400)]
sdcard: Make sure controller support 3.3V before enabling it

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Implement controller frequency setting according to sdhci spec
Kevin O'Connor [Tue, 28 Jul 2015 17:40:04 +0000 (13:40 -0400)]
sdcard: Implement controller frequency setting according to sdhci spec

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Check if card is present before sending commands to card
Kevin O'Connor [Tue, 28 Jul 2015 17:06:41 +0000 (13:06 -0400)]
sdcard: Check if card is present before sending commands to card

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agovgafb: Minor - move gfx_common() variables outside of switch statement
Kevin O'Connor [Thu, 30 Jul 2015 16:42:47 +0000 (12:42 -0400)]
vgafb: Minor - move gfx_common() variables outside of switch statement

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosmm: ignore bits 16,18-31 of SMM revision ID at runtime too
Kevin O'Connor [Thu, 30 Jul 2015 16:39:12 +0000 (12:39 -0400)]
smm: ignore bits 16,18-31 of SMM revision ID at runtime too

Check only the relevant bits of the SMM revision ID for both the init
check and during runtime checks.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosmm: fix outl argument order
Paolo Bonzini [Mon, 27 Jul 2015 10:23:58 +0000 (12:23 +0200)]
smm: fix outl argument order

The value is the first argument and the port is the second, but the code
was using the opposite order.

Reported-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9 years agoMinor - move declaration of CDRom_locks to code that uses it
Kevin O'Connor [Fri, 24 Jul 2015 17:17:38 +0000 (13:17 -0400)]
Minor - move declaration of CDRom_locks to code that uses it

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoramdisk: Allow ramdisk support (CONFIG_FLASH_FLOPPY) under QEMU
Kevin O'Connor [Thu, 23 Jul 2015 13:19:23 +0000 (09:19 -0400)]
ramdisk: Allow ramdisk support (CONFIG_FLASH_FLOPPY) under QEMU

Don't require coreboot to use CONFIG_FLASH_FLOPPY - with the latest
QEMU, it's possible to place a floppy image into fw_cfg using the qemu
command line (eg, "-fw_cfg name=floppyimg/MyFloppy,file=file.img").

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>