seabios.git
12 years agovgabios: Merge support for GeodeLX vga bios.
Kevin O'Connor [Sat, 24 Dec 2011 05:44:07 +0000 (00:44 -0500)]
vgabios: Merge support for GeodeLX vga bios.

GeodeLX support based on a patch sent by Chris Kindt on 20090825.  The
patch provides basic support for running the vga bios on a Geode
device.

The original patch has been updated with the following:
  * Updates to merge with the current code,
  * geode specific timings are loaded at init time
  * PCI code was dropped as the current code now supports pci
  * Updates for Kconfig
  * dropped redundant lxdprintf
  * dropped geode_demo screen writing

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agovgabios: Place a signature at offset 0x1e of the rom.
Kevin O'Connor [Sat, 24 Dec 2011 04:01:48 +0000 (23:01 -0500)]
vgabios: Place a signature at offset 0x1e of the rom.

It appears some emulators look for a signature at offset 0x1e of the
option rom.  So, port the signature from the LGPL bios.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agovgabios: Generate video_param_table at runtime.
Kevin O'Connor [Sat, 24 Dec 2011 03:41:08 +0000 (22:41 -0500)]
vgabios: Generate video_param_table at runtime.

Now that all the mode info is available in vga_modes, generate the
externally visible video_param_table data from it.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agovgabios: Use vgamode_s instead of video_param_table in code.
Kevin O'Connor [Sat, 24 Dec 2011 02:40:34 +0000 (21:40 -0500)]
vgabios: Use vgamode_s instead of video_param_table in code.

Now that all the info in video_param_table is also in vgamode_s, use
the info in vgamode_s throughout the code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agovgabios: Extend information in internal vgamode_s struct.
Kevin O'Connor [Sat, 24 Dec 2011 02:20:09 +0000 (21:20 -0500)]
vgabios: Extend information in internal vgamode_s struct.

Copy all the data in video_param_table to vga_modes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agovgabios: Minor - use segoff_s for static_functionality ptr.
Kevin O'Connor [Sat, 24 Dec 2011 02:18:49 +0000 (21:18 -0500)]
vgabios: Minor - use segoff_s for static_functionality ptr.

12 years agovgabios: Define video_save_pointer_table layout.
Kevin O'Connor [Wed, 21 Dec 2011 14:05:32 +0000 (09:05 -0500)]
vgabios: Define video_save_pointer_table layout.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agovgabios: Fix compile error due to missing include in clext.c.
Kevin O'Connor [Wed, 28 Dec 2011 02:34:33 +0000 (21:34 -0500)]
vgabios: Fix compile error due to missing include in clext.c.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoUpdates to vgabios cirrus code.
Kevin O'Connor [Wed, 21 Dec 2011 04:56:14 +0000 (23:56 -0500)]
Updates to vgabios cirrus code.

Work in progress updates to cirrus vgabios code.

12 years agoPreliminary DISPI VBE driver implementation
Julian Pidancet [Mon, 19 Dec 2011 05:08:01 +0000 (05:08 +0000)]
Preliminary DISPI VBE driver implementation

It allowed me to boot Windows 7 with Qemu BOCHS VGA emulation and it
seemed to work fine. It probably needs some further testing though.

Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
12 years agoPartially implement VBE interface, create VBE driver skeleton
Julian Pidancet [Mon, 19 Dec 2011 05:08:00 +0000 (05:08 +0000)]
Partially implement VBE interface, create VBE driver skeleton

Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
12 years agoMerge bootsplash and VGA ROM vbe structure definitions
Julian Pidancet [Mon, 19 Dec 2011 05:07:59 +0000 (05:07 +0000)]
Merge bootsplash and VGA ROM vbe structure definitions

Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
12 years agoAdd vbe_flag field in BDA
Julian Pidancet [Mon, 19 Dec 2011 05:07:58 +0000 (05:07 +0000)]
Add vbe_flag field in BDA

Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
12 years agobuildrom.py: Handle image size in PCI header
Julian Pidancet [Mon, 19 Dec 2011 05:07:57 +0000 (05:07 +0000)]
buildrom.py: Handle image size in PCI header

This patch makes buildrom.py check if a PCI is present in the ROM,
and fills in the image size field.

Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
12 years agoAdd configuration menu for the VGA ROM
Julian Pidancet [Mon, 19 Dec 2011 05:07:56 +0000 (05:07 +0000)]
Add configuration menu for the VGA ROM

This patch adds a configuration menu for the VGA ROM, it also allow
the creation of a PCI header so the ROM can be extracted from a PCI
device.

V2: Default Device IDs and Vendor IDs values for Cirrus and Bochs are now set
    by Kconfig.

Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
12 years agoAdd a PCI header to the VGA ROM if needed
Julian Pidancet [Mon, 19 Dec 2011 05:07:55 +0000 (05:07 +0000)]
Add a PCI header to the VGA ROM if needed

Allows the ROM to be extracted from a PCI device.

V2: * Declare the PCI header in C
    * Replace #ifdef CONFIG_VGA_PCI with #if CONFIG_VGA_PCI == 1

Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
12 years agoMove optionroms definitions into a separate header
Julian Pidancet [Mon, 19 Dec 2011 05:07:54 +0000 (05:07 +0000)]
Move optionroms definitions into a separate header

Create optionroms.h so the VGA rom can reuse the definitions.

Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
12 years agoRename CONFIG_VBE in CONFIG_VGA_BOCHS and CONFIG_CIRRUS in CONFIG_VGA_CIRRUS
Julian Pidancet [Mon, 19 Dec 2011 05:07:53 +0000 (05:07 +0000)]
Rename CONFIG_VBE in CONFIG_VGA_BOCHS and CONFIG_CIRRUS in CONFIG_VGA_CIRRUS

Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
12 years agoDon't use -fomit-frame-pointer when building VGA bios.
Kevin O'Connor [Sun, 18 Dec 2011 15:51:19 +0000 (10:51 -0500)]
Don't use -fomit-frame-pointer when building VGA bios.

The real-mode emulator that Windows 7 uses to execute the vga bios rom
becomes very confused when the code tries to dereference the stack
pointer instead of using the frame pointer, leading to corruption of
parameters passed on the stack from one function to another.

Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoMinor - change indent of continued lines in Makefile.
Kevin O'Connor [Sun, 18 Dec 2011 15:48:44 +0000 (10:48 -0500)]
Minor - change indent of continued lines in Makefile.

12 years agoFix broken _DIS and _SRS methods in ACPI AML irq routing.
Kevin O'Connor [Sat, 17 Dec 2011 15:26:17 +0000 (10:26 -0500)]
Fix broken _DIS and _SRS methods in ACPI AML irq routing.

The RefOf() operator doesn't do what was expected (at least on Linux)
- issuing "Store(1, RefOf(PRQ0))" doesn't write to the PRQ0 Field
defined on the OperationRegion.  Instead, it seems to redefine PRQ0 to
be an integer.

Fix this by defining the _DIS and _SRS methods as pre-processor
macros.  This way the RefOf() operator isn't needed.

12 years agofix make help
Sebastian Herbszt [Thu, 24 Nov 2011 16:20:36 +0000 (17:20 +0100)]
fix make help

Add help target to top-level makefile.

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
12 years agoacpi: remove _RMV
Michael S. Tsirkin [Sun, 20 Nov 2011 17:57:12 +0000 (19:57 +0200)]
acpi: remove _RMV

The macro gen_pci_device is used to add _RMV
method to a slot device so it is no longer needed:
presence of _EJ0 now indicates that the slot is ejectable.
It is also placing two devices with the same _ADR
on the same bus, which isn't defined by the ACPI spec.
So let's remove it.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agoacpi: EJ0 method name patching
Michael S. Tsirkin [Sun, 20 Nov 2011 17:57:05 +0000 (19:57 +0200)]
acpi: EJ0 method name patching

Modify ACPI to only supply _EJ0 methods for PCI slots that support hotplug.

This is done by runtime patching:
- Instrument SSDT ASL code with ACPI_EXTRACT directives
  tagging _EJ0 and _ADR fields.
- At compile time, tools/acpi_extract.py looks for these methods
  in ASL source finds the matching AML, and stores the offsets
  of these methods in tables named aml_ej0_name and aml_adr_dword.
- At run time, go over aml_ej0_name, use aml_adr_dword
  to get slot information and check which slots support hotplug.

  If hotplug is disabled, we patch the _EJ0 NameString in ACPI table,
  replacing _EJ0 with EJ0_.

  Note that this has the same checksum, but is ignored by OSPM.

Note: the method used is robust in that we don't need
to change any offsets manually in case of ASL code changes.
As all parsing is done at compile time, any unexpected input causes
build failure, not a runtime failure.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agoacpi: add ssdt for pci hotplug
Michael S. Tsirkin [Sun, 20 Nov 2011 17:56:59 +0000 (19:56 +0200)]
acpi: add ssdt for pci hotplug

The point of this split is to make runtime patching easier.

DSDT is required to supply: PCI0 - PCI root device object;
PCEJ - Method object to eject a PCI slot.
Additionally, SSDT is required to supply PCNT - Method object to notify
OSPM of a PCI slot event.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agovirtio-pci: include pci.h and pci_regs.h
Sebastian Herbszt [Mon, 21 Nov 2011 11:23:20 +0000 (12:23 +0100)]
virtio-pci: include pci.h and pci_regs.h

Include pci.h and pci_regs.h.

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
12 years agousb: fix boot paths
Paolo Bonzini [Fri, 18 Nov 2011 14:59:24 +0000 (15:59 +0100)]
usb: fix boot paths

The fw paths for USB devices that SeaBIOS computes are off-by-one,
because QEMU builds those paths with a numbering that starts from one
(see usb_fill_port and usb_hub_initfn in QEMU).  Fix that so that
the numbering agrees.

12 years agousb-ehci: Fix races with controller on updates to QH.
Kevin O'Connor [Sat, 19 Nov 2011 19:21:51 +0000 (14:21 -0500)]
usb-ehci: Fix races with controller on updates to QH.

The EHCI controller writes to the TD after writing to the QH, so the
driver must wait for all the TDs to be complete before considering the
transfer completed.  (The previous implementation was particularly bad
as it only checked that the last TD was in progress before considering
the transfer complete.)

Also, avoid writing to the qh.token field when starting a transfer to
eliminate a potential race.  Place the qh.token in an available state
by default - that way only the qtd_next field needs to be updated to
start the transfer.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agousb-uhci: Be sure to wrap pipe->iobase in GET_FLATPTR().
Kevin O'Connor [Fri, 18 Nov 2011 03:05:53 +0000 (22:05 -0500)]
usb-uhci: Be sure to wrap pipe->iobase in GET_FLATPTR().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agovirtio-pci: allocate vq in vp_find_vq
Paolo Bonzini [Wed, 16 Nov 2011 12:02:57 +0000 (13:02 +0100)]
virtio-pci: allocate vq in vp_find_vq

Another common bit that can be made generic.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agovirtio-pci: introduce vp_init_simple
Paolo Bonzini [Wed, 16 Nov 2011 12:02:56 +0000 (13:02 +0100)]
virtio-pci: introduce vp_init_simple

Put together the common parts of all virtio device initialization.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoalways specify virtio-blk rather than virtio
Paolo Bonzini [Wed, 16 Nov 2011 12:02:55 +0000 (13:02 +0100)]
always specify virtio-blk rather than virtio

Avoid ambiguity when virtio-scsi will be introduced.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi: get physical chs geometry from mode page 0x04
Paolo Bonzini [Wed, 16 Nov 2011 12:02:54 +0000 (13:02 +0100)]
scsi: get physical chs geometry from mode page 0x04

The mode page is marked as obsolete, but QEMU can provide the information.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agousb-msc: move cdb dispatch to block.c
Paolo Bonzini [Wed, 16 Nov 2011 12:02:53 +0000 (13:02 +0100)]
usb-msc: move cdb dispatch to block.c

virtio-scsi's low-level dispatch code is exactly the same as USB's,
since in the end both are actually SCSI HBAs.  Move it to common code.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agousb-msc: move common scsi code to blockcmd.c
Paolo Bonzini [Thu, 17 Nov 2011 09:23:02 +0000 (10:23 +0100)]
usb-msc: move common scsi code to blockcmd.c

Finally move the INQUIRY/TEST UNIT READY/READ CAPACITY sequence to
generic code, so that virtio-scsi will be able to use it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agousb-msc: go through TEST UNIT READY for hard disks.
Paolo Bonzini [Wed, 16 Nov 2011 12:02:51 +0000 (13:02 +0100)]
usb-msc: go through TEST UNIT READY for hard disks.

Add the wait loop that CDs are already using to usb-msc in the HD
case, to cope with a NOT READY or UNIT ATTENTION condition.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agousb-msc: rename INQUIRY types
Paolo Bonzini [Wed, 16 Nov 2011 12:02:50 +0000 (13:02 +0100)]
usb-msc: rename INQUIRY types

They are generic SCSI constants, rename them as such.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agousb-msc: pass drive to setup_drive_*
Paolo Bonzini [Wed, 16 Nov 2011 12:02:49 +0000 (13:02 +0100)]
usb-msc: pass drive to setup_drive_*

The two functions do not need anymore a disk_op_s.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agousb-msc: move READ CAPACITY to usb_msc_init, fix off-by-one
Paolo Bonzini [Wed, 16 Nov 2011 12:02:48 +0000 (13:02 +0100)]
usb-msc: move READ CAPACITY to usb_msc_init, fix off-by-one

Only leave the bootprio code in setup_drive_hd, like in setup_drive_cdrom.
This is a preparatory step; later, the SCSI code in usb_msc_init will
become entirely generic.

Also, the returned number of sectors is off by one.  This will become
more important when CHS translation is added later.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agousb-msc: support WRITE commands
Paolo Bonzini [Wed, 16 Nov 2011 12:02:47 +0000 (13:02 +0100)]
usb-msc: support WRITE commands

Writes only require building the CDB and some care with the direction
in the USB packet.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agousb-msc: add usb_msc_send
Paolo Bonzini [Wed, 16 Nov 2011 12:02:46 +0000 (13:02 +0100)]
usb-msc: add usb_msc_send

This makes it a bit nicer to later introduce writes.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agousb-uhci: fix race against host controller
Paolo Bonzini [Thu, 17 Nov 2011 09:23:00 +0000 (10:23 +0100)]
usb-uhci: fix race against host controller

While processing a frame, the host controller will write to the queue
head's element link field.  The following sequence could then happen
when two consecutive sends occur to the same pipe.

    controller                      SeaBIOS
    ---------------------------------------------------------------------
                                    td->link = UHCI_PTR_TERM;
                                    td->ctrl |= TD_CTRL_ACTIVE;
    read TD from memory
                                    wait_td(td);
    td->ctrl &= ~TD_CTRL_ACTIVE;
    write back td->ctrl
                                    exit usb_send_bulk
                                    restart usb_send_bulk
                                    pipe->qh.element = &tds;
    pipe->qh.element = td->link;    ... go on and set up the first td ...
    write back pipe->qh.element
                                    td->ctrl |= TD_CTRL_ACTIVE;

Once the host controller has written UHCI_PTR_TERM to the element link,
subsequent tds would never be processed.  This is surprisingly frequent
when the two consecutive sends are in the OUT direction (and just as
surprisingly, it seems like it never happens in the IN direction).

To fix this, at the end of the processing do not wait for each single
TD to become inactive, but for the host controller to invalidate the
element link (which implies it's done with all TDs).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agousb-uhci: reorganize wait_qh into wait_pipe
Paolo Bonzini [Thu, 17 Nov 2011 09:22:59 +0000 (10:22 +0100)]
usb-uhci: reorganize wait_qh into wait_pipe

Four changes:

1) Add explicit GET_FLATPTR/SET_FLATPTR.

2) Pass the whole pipe to wait_qh so that we can get the iobase from there.

3) Clean up the pipe upon timeout, since that is the only sensible
thing to do: tds are on the stack, and leaving pointers to them in
the pipe is not a good idea.

4) Add a variable timeout argument, since bulk transfers might take more
than 500 ms.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agocdrom: use TEST UNIT READY to detect ready medium
Paolo Bonzini [Wed, 16 Nov 2011 12:02:42 +0000 (13:02 +0100)]
cdrom: use TEST UNIT READY to detect ready medium

The READ CAPACITY output is not used except for some debugging messages.
In the future, we will use this code for USB sticks too, but those
already send READ CAPACITY.  To avoid code duplication, switch to TEST
UNIT READY for this task.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agousb-msc: support commands without payload
Paolo Bonzini [Wed, 16 Nov 2011 12:02:45 +0000 (13:02 +0100)]
usb-msc: support commands without payload

This lets the usb-msc driver send TEST UNIT READY commands.

Modified to avoid divide by zero by Kevin O'Connor <kevin@koconnor.net>

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoseabios: fix mptable nmi entry
Kenji Kaneshige [Mon, 10 Oct 2011 06:06:29 +0000 (14:06 +0800)]
seabios: fix mptable nmi entry

In the current seabios MP table description, NMI is connected only to
BSP's LINT1. But usually NMI is connected to all the CPUs' LINT1 as
indicated in MP specification. This patch changes seabios MP table to
describe NMI is connected to all the CPUs' LINT1.

Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Reviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>
12 years agoseabios: Add Local APIC NMI Structure to ACPI MADT
Kenji Kaneshige [Mon, 10 Oct 2011 06:06:17 +0000 (14:06 +0800)]
seabios: Add Local APIC NMI Structure to ACPI MADT

ACPI NMI Structure describes LINT pin (LINT0 or LINT1) information to
which NMI is connected, and it is needed by OS to initialize local APIC.

Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Reviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>
12 years agoacpi: extract aml from .lst
Michael S. Tsirkin [Wed, 26 Oct 2011 21:28:02 +0000 (23:28 +0200)]
acpi: extract aml from .lst

Add ACPI_EXTRACT_ALL_CODE directive, to support extracting
AML code from listing into a named array. Use that instead including C
file generated by iasl, this makes it possible to include multiple AML
tables without resorting to preprocessor tricks.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agoseabios: acpi: allow qemu to load dsdt as external acpi table.
Isaku Yamahata [Mon, 24 Oct 2011 08:11:08 +0000 (17:11 +0900)]
seabios: acpi: allow qemu to load dsdt as external acpi table.

allow qemu to load dsdt as external acpi table.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
12 years agoutil: add le32_to_cpu()
Isaku Yamahata [Mon, 24 Oct 2011 08:11:07 +0000 (17:11 +0900)]
util: add le32_to_cpu()

this will be used later.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
12 years agoSimplify pci_bios_init_root_regions().
Kevin O'Connor [Sat, 1 Oct 2011 16:08:57 +0000 (12:08 -0400)]
Simplify pci_bios_init_root_regions().

Add some comments and refactor out some duplicated code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoMove pciinit device init code together.
Kevin O'Connor [Sat, 15 Oct 2011 16:02:14 +0000 (12:02 -0400)]
Move pciinit device init code together.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoLocally allocate pciinit busses[] variable.
Kevin O'Connor [Sat, 15 Oct 2011 15:53:38 +0000 (11:53 -0400)]
Locally allocate pciinit busses[] variable.

No need for a global variable - only a few functions use the busses
array.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoReplace recursive pci init system with linear passes.
Kevin O'Connor [Sat, 15 Oct 2011 15:42:48 +0000 (11:42 -0400)]
Replace recursive pci init system with linear passes.

The existing PCI sizing and mapping uses a recursive algorithm to
visit every bus and its devices in order.  Replace that with an
algorithm that visits every device and then every bus.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoReplace pciinit busses_count with MaxPCIBus.
Kevin O'Connor [Sat, 15 Oct 2011 15:07:30 +0000 (11:07 -0400)]
Replace pciinit busses_count with MaxPCIBus.

Use the existing bus count instead of calculating a new one.  Also,
the MaxPCIBus is guaranteed to encompass all pci->secondary_bus
references, so no need to check for overruns.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoSimplify pci_slot_get_irq().
Kevin O'Connor [Sat, 1 Oct 2011 18:52:35 +0000 (14:52 -0400)]
Simplify pci_slot_get_irq().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoUse pci->header_type in pci_bar() to avoid unnecessary pci_config_readb.
Kevin O'Connor [Sat, 1 Oct 2011 17:13:29 +0000 (13:13 -0400)]
Use pci->header_type in pci_bar() to avoid unnecessary pci_config_readb.

Pass a 'struct pci_device' into pci_bar and update all callers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoSeparate pciinit.c into clearly delineated sections.
Kevin O'Connor [Sat, 1 Oct 2011 15:33:31 +0000 (11:33 -0400)]
Separate pciinit.c into clearly delineated sections.

There are four separate phases of the current PCI initialization code:
bus initialization, bus sizing, bar allocation, and misc device init.
Move the code exclusively called in each phase next to each other, and
clearly mark each section.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoUse standard formatting for PCI info during PCI init pass.
Kevin O'Connor [Sat, 1 Oct 2011 14:47:21 +0000 (10:47 -0400)]
Use standard formatting for PCI info during PCI init pass.

Format BDF (bus, device, fn), vendor:device, and prefmem debug output
in a more user-readable format.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoacpi: automatically generated ssdt proc
Michael S. Tsirkin [Tue, 4 Oct 2011 13:26:19 +0000 (15:26 +0200)]
acpi: automatically generated ssdt proc

Get rid of manually cut and pasted ssdt_proc,
use ssdt compiled by iasl and offsets extracted
by acpi_extract instead.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agoacpi: generate and parse mixed asl/aml listing
Michael S. Tsirkin [Tue, 4 Oct 2011 13:26:01 +0000 (15:26 +0200)]
acpi: generate and parse mixed asl/aml listing

Use iasl -l flag to produce a mixed listing, where a
source line is followed by matching AML.

Add a tool tools/acpi_extract.py to process this
listing. The tool looks for ACPI_EXTRACT tags
in the ASL source and outputs matching AML offsets
in an array.

To make these directives pass through ASL without affecting AML,
and to make it possible to match AML to source exactly,
add a preprocessing stage, which prepares input for iasl,
and puts each ACPI_EXTRACT tag within a comment,
on a line by itself.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agoConsolidate DSDT copy-and-paste PCI IRQ code into method calls.
Kevin O'Connor [Mon, 26 Sep 2011 03:08:58 +0000 (23:08 -0400)]
Consolidate DSDT copy-and-paste PCI IRQ code into method calls.

Use method calls in LNK[ABCDS] object methods - this reduces the
cut-and-paste code.  It also makes it simpler and the object size
smaller.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoMove code from PCI hotplug DSDT macros to methods.
Kevin O'Connor [Thu, 22 Sep 2011 01:19:51 +0000 (21:19 -0400)]
Move code from PCI hotplug DSDT macros to methods.

Simplify the hotplug code by moving the bulk of the logic out of the
macros and into static method definitions.  This also reduces the ACPI
DSDT code size.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoSimplify PCI hotplug acpi macros.
Kevin O'Connor [Thu, 22 Sep 2011 01:04:05 +0000 (21:04 -0400)]
Simplify PCI hotplug acpi macros.

Change the macros to pass the slot number via hex, and then remove
passing of duplicate information.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoConsolidate PCI hotplug definitions together in DSL file.
Kevin O'Connor [Thu, 22 Sep 2011 00:14:42 +0000 (20:14 -0400)]
Consolidate PCI hotplug definitions together in DSL file.

Move the PCI hotplug definitions next to each other.  This introduces
a notify method (\_SB.PCI0.PCNF) to help consolidate the code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoDelineate ACSP DSL code into sections.
Kevin O'Connor [Wed, 21 Sep 2011 23:58:42 +0000 (19:58 -0400)]
Delineate ACSP DSL code into sections.

Add comments around major sections of the DSL file.  Also, add scope
declarations where needed so that each section only contains one
scope.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoPrep version for next release.
Kevin O'Connor [Wed, 5 Oct 2011 01:43:37 +0000 (21:43 -0400)]
Prep version for next release.

12 years agoUpdate version to 1.6.3
Kevin O'Connor [Wed, 5 Oct 2011 01:14:09 +0000 (21:14 -0400)]
Update version to 1.6.3

12 years agoUpdate README file.
Kevin O'Connor [Wed, 5 Oct 2011 01:12:28 +0000 (21:12 -0400)]
Update README file.

12 years agoFix alignment bug in pci_bios_init_root_regions().
Kevin O'Connor [Sat, 1 Oct 2011 16:35:32 +0000 (12:35 -0400)]
Fix alignment bug in pci_bios_init_root_regions().

If there are no memory allocations for a given type then the "max" bar
size is zero.  However, ALIGN_DOWN does not handle an alignment of
zero properly.  Catch and handle the zero case.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoReorder build objects to work around gcc bug with -combine.
Kevin O'Connor [Sat, 1 Oct 2011 14:43:48 +0000 (10:43 -0400)]
Reorder build objects to work around gcc bug with -combine.

Some versions of gcc have difficulties with externally visible
variables that are used before they are declared.  Now that pmm.c
contains only 32bit code and has a reference to CanPreempt, make sure
the declaration of CanPreempt (in stacks.c) is compiled first.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoProbe PCI existence
Jan Kiszka [Wed, 21 Sep 2011 06:16:21 +0000 (08:16 +0200)]
Probe PCI existence

This prevents lockups when trying to allocate PCI resources on an
ISA-only system like QEMU can emulate.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
12 years agoDefine handle_post as VISIBLE32FLAT as work around for QEmu memory layout.
Kevin O'Connor [Tue, 20 Sep 2011 23:42:14 +0000 (19:42 -0400)]
Define handle_post as VISIBLE32FLAT as work around for QEmu memory layout.

QEmu only copies the top 128K of the BIOS image to low memory
(0xe0000-0xfffff).  Images over 128K are only fully mapped in high
memory (0xfff00000).  However, the SeaBIOS shadow functions
(make_bios_writable_intel) will copy up to 256K to low memory.

SeaBIOS generally works with 256K roms because they are automatically
copied to low memory during the BIOS init.  However, this only works
if the shadow function code is itself part of the bios image that is
placed in low memory by QEmu.

Defining handle_post() as VISIBLE32FLAT will make the linker scripts
more likely to place the initial shadow code in the last 128K of the
image.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoMinor - move ACPI_HPET_ADDRESS definition to config.h.
Kevin O'Connor [Tue, 20 Sep 2011 23:40:28 +0000 (19:40 -0400)]
Minor - move ACPI_HPET_ADDRESS definition to config.h.

Move ACPI_HPET_ADDRESS to BUILD_HPET_ADDRESS in config.h so that it
is listed with similar hardcoded addresses.

Also, organize the BUILD_*_ADDRESS definitions in config.h.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoMinor formatting and comment updates to acpi.c.
Kevin O'Connor [Fri, 2 Sep 2011 22:11:58 +0000 (18:11 -0400)]
Minor formatting and comment updates to acpi.c.

12 years agoProbe HPET existence
Jan Kiszka [Mon, 29 Aug 2011 15:50:10 +0000 (17:50 +0200)]
Probe HPET existence

QEMU does not provide a HPET block if it was configured with -no-hpet,
other machines SeaBIOS runs on may lack a HPET as well. Perform basic
checks the ID register for a reasonable vendor ID and a clock period
within the valid range, do not build the HPET table if that fails.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
12 years agoUse coreboot smbios table if found.
Kevin O'Connor [Sun, 28 Aug 2011 16:42:15 +0000 (12:42 -0400)]
Use coreboot smbios table if found.

The coreboot init code now looks for an existing smbios table and will
use it.  A locally generated smbios table will only be created if no
coreboot table is found.

12 years agopci: re-add isa bridge setup
Gerd Hoffmann [Tue, 9 Aug 2011 15:22:42 +0000 (17:22 +0200)]
pci: re-add isa bridge setup

The switch to the two-pass pci initialization dropped the isa bridge
initialization by accident.  That broke interrupts on FreeBSD 4.4 and
maybe also other older guests which don't use ACPI for IRQ routing
setup.  Add the bits back in.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Bjørn Mork <bjorn@mork.no>
12 years agoahci: enable by default
Gerd Hoffmann [Thu, 4 Aug 2011 18:42:16 +0000 (20:42 +0200)]
ahci: enable by default

Lack of real hardware testing was the main reason to turn it off by
default.  The AHCI has been fixed to work on both qemu and real
hardware, so lets flip the switch now.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoahci: use malloc_tmp memory for probing ports
Gerd Hoffmann [Thu, 4 Aug 2011 17:36:31 +0000 (19:36 +0200)]
ahci: use malloc_tmp memory for probing ports

Also allocate the ahci port struct itself from tmp memory for probing,
then copy to fseg memory in case we detected some device.  This way we
don't waste fseg memory for unused ports.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoahci: move device registration
Gerd Hoffmann [Thu, 4 Aug 2011 17:36:30 +0000 (19:36 +0200)]
ahci: move device registration

Stick description and boot priority into the port struct, so it
holds everything needed to register the device, so we can do
the registration after ahci_port_init returned.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoahci: ignore atapi devices which are not cdroms
Gerd Hoffmann [Thu, 4 Aug 2011 17:36:29 +0000 (19:36 +0200)]
ahci: ignore atapi devices which are not cdroms

Also simplify the code a bit further down the road
as we know iscd must be true ;)

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoahci: probe each port in its own thread
Gerd Hoffmann [Thu, 4 Aug 2011 17:36:28 +0000 (19:36 +0200)]
ahci: probe each port in its own thread

Instead if creating a single thread which probes all ports one after
another kick one thread per port, so ports are probed in parallel.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoahci/cdrom: shared bounce buffer
Gerd Hoffmann [Thu, 4 Aug 2011 17:36:27 +0000 (19:36 +0200)]
ahci/cdrom: shared bounce buffer

This patch creates a common bounce buffer in block.c which
is shared by the cdrom and ahci drivers.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoAllow allocation of SMBIOS table in f-segment if it is small.
Kevin O'Connor [Thu, 4 Aug 2011 00:45:32 +0000 (20:45 -0400)]
Allow allocation of SMBIOS table in f-segment if it is small.

If the SMBIOS is small (less than 600 bytes) allow it to be allocated
in the f-segment.  This works around a bug in JunOS - it crashes on
SMBIOS tables located in high memory.

12 years agoAllow free space in f-segment to be used by malloc_fseg().
Kevin O'Connor [Thu, 4 Aug 2011 00:15:26 +0000 (20:15 -0400)]
Allow free space in f-segment to be used by malloc_fseg().

12 years agoWarn if not enough space in smp_mtrr array.
Kevin O'Connor [Fri, 29 Jul 2011 23:21:07 +0000 (19:21 -0400)]
Warn if not enough space in smp_mtrr array.

12 years agoseabios: increase smp_mtrr array size
Marcelo Tosatti [Fri, 29 Jul 2011 22:40:51 +0000 (19:40 -0300)]
seabios: increase smp_mtrr array size

Windows Server 2008 checked build complains about lack of consistency
between MTRR MSRs in SMP guests.

Problem is the smp_mtrr array is not large enough to hold all MSRs (31
entries with current qemu/kvm implementations).

Increase it to 32.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
12 years agoahci: bootprio support
Gerd Hoffmann [Thu, 14 Jul 2011 14:24:05 +0000 (16:24 +0200)]
ahci: bootprio support

Wind up bootprio support in the ahci driver so boot device ordering
works for ahci disks too.  No extra work needed on qemu side.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoahci: rework init workflow & fix timeout handling
Gerd Hoffmann [Thu, 14 Jul 2011 14:24:04 +0000 (16:24 +0200)]
ahci: rework init workflow & fix timeout handling

Rework init workflow to match suggestions in the ahci specs better,
especially remove the shortcut which tries to detect drives without
enabling FIS receiving.  This makes memory allocation a bit complicated
as we are using malloc_tmp() allocated memory now to probe the devices
so we can free it when no drive is present.  In case we detect a drive
we have to free and realloc the memory with malloc_low() so it is
available after POST when the boot loader wants read stuff via int13.

Also use TSC to calculate timeout instead of delays and loop counts.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoahci: don't expect ATA_CB_STAT_DRQ being clear
Gerd Hoffmann [Thu, 14 Jul 2011 14:24:03 +0000 (16:24 +0200)]
ahci: don't expect ATA_CB_STAT_DRQ being clear

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoahci: handle unaligned buffers.
Scott Duplichan [Thu, 14 Jul 2011 14:24:02 +0000 (16:24 +0200)]
ahci: handle unaligned buffers.

This change allows unaligned buffers to be used for reads or writes
to non-atapi devices. Currently only MS-DOS boot is known to need
unaligned buffer support.

Signed-off-by: Scott Duplichan <scott@notabs.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoahci: add error recovery code
Gerd Hoffmann [Thu, 14 Jul 2011 14:24:01 +0000 (16:24 +0200)]
ahci: add error recovery code

By Scott Duplichan.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoahci: use interrupt status register
Gerd Hoffmann [Thu, 14 Jul 2011 14:24:00 +0000 (16:24 +0200)]
ahci: use interrupt status register

Poll interrupt status register to figure when the device has updated the
status and possibly finished the request, continue polling until BSY is
clear as we might see multiple status updates per request.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoahci/sata: Fix FIS setup.
Gerd Hoffmann [Thu, 14 Jul 2011 14:23:59 +0000 (16:23 +0200)]
ahci/sata: Fix FIS setup.

FIS setup does't follow the SATA specs, fix it.

Credits go to Jonathan Kollasch and Scott Duplichan for finding those.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoxen: actually setup hypercalls.
Ian Campbell [Wed, 13 Jul 2011 10:46:40 +0000 (11:46 +0100)]
xen: actually setup hypercalls.

This was somehow dropped during the iterations of the original Xen patches.
It's actually harmless at the moment since there are no users of hypercalls but
patches are being written to support Xen PV block devices which need this.

It's not clear exactly how early this needs to be but I think it needs to be at
least before init_hw() (since that would detect disk devices).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoRemove 16bit wrappers from PMM code.
Kevin O'Connor [Sat, 16 Jul 2011 17:39:26 +0000 (13:39 -0400)]
Remove 16bit wrappers from PMM code.

Now that the PMM code is only run in 32bit mode, remove the
GET/SET_PMMVAR macros and other 16bit wrappers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agoRun option rom visible PMM code in 32bit mode instead of 16bit mode.
Kevin O'Connor [Sat, 16 Jul 2011 17:13:12 +0000 (13:13 -0400)]
Run option rom visible PMM code in 32bit mode instead of 16bit mode.

Use call32() to jump into handle_pmm().  This reduces the amount of
16bit code needed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
12 years agopci: set BUILD_PCIMEM_START to 0xe0000000
Gerd Hoffmann [Mon, 11 Jul 2011 07:20:32 +0000 (09:20 +0200)]
pci: set BUILD_PCIMEM_START to 0xe0000000

... and make it match with the declarations in acpi-dsdt.dsl.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agopci: cleanup config.h
Gerd Hoffmann [Mon, 11 Jul 2011 07:20:31 +0000 (09:20 +0200)]
pci: cleanup config.h

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>