seabios.git
14 years agoAdd support for 32bit PCI BIOS entry.
Kevin O'Connor [Wed, 30 Dec 2009 17:14:53 +0000 (12:14 -0500)]
Add support for 32bit PCI BIOS entry.

Create a new code blob (code32seg) with support for 32bit functions
    that need to utilize explicit segment accesses.
This code blob uses global variables relative to %gs and with a
    dynamic code offset (determined by get_global_offset()).
Add BIOS32 structure and code.
Add code for 32bit PCI BIOS code.

14 years agoOnly add "addr32" to memory accesses that require them.
Kevin O'Connor [Sun, 27 Dec 2009 05:14:26 +0000 (00:14 -0500)]
Only add "addr32" to memory accesses that require them.

Extract out addr32 to a parameter to the READx/WRITEx_SEG macros.

14 years agoIntroduce MODESEGMENT define; rename VISIBLE32 to VISIBLE32FLAT.
Kevin O'Connor [Sun, 27 Dec 2009 04:32:57 +0000 (23:32 -0500)]
Introduce MODESEGMENT define; rename VISIBLE32 to VISIBLE32FLAT.

Prepare for support of segmented 32bit code.
Add new MODESEGMENT definition, and clarify existing 32bit mode defs.

14 years agoAllocate smbios in temp space and copy into final location.
Kevin O'Connor [Sun, 27 Dec 2009 04:26:44 +0000 (23:26 -0500)]
Allocate smbios in temp space and copy into final location.

This reduces memory needed in the reserved high memory area.

14 years agoClear user reserved interrupts (0x60-0x66).
Kevin O'Connor [Sun, 27 Dec 2009 04:24:52 +0000 (23:24 -0500)]
Clear user reserved interrupts (0x60-0x66).

This patch is equivalent to a patch recently committed to Bochs bios
(d8b4b998).

14 years agoRemove pci_bios_bigmem_addr; set pci_bios_mem_addr=0xe0000000
Kevin O'Connor [Sun, 27 Dec 2009 04:23:15 +0000 (23:23 -0500)]
Remove pci_bios_bigmem_addr; set pci_bios_mem_addr=0xe0000000

This patch removes pci_bios_bigmem_addr, and it changes
pci_bios_mem_addr to start at 0xe0000000.

The pci_bios_bigmem_addr was removed from bochs.  Also, the current
code looks wrong as nothing stops an address given from
pci_bios_bigmem_addr from overlapping an address given from
pci_bios_mem_addr.

The change also moves pci_bios_mem_addr back to 0xe0000000 - both the
acpi and mtrr code use 0xe0000000.

14 years agoAdd initial support for ATA DMA.
Kevin O'Connor [Sun, 27 Dec 2009 04:21:38 +0000 (23:21 -0500)]
Add initial support for ATA DMA.

Add support for detecting and using SFF 8038 compatible PCI devices.
Currently, only ATA transfers (not ATAPI) will use DMA.

14 years agoAllocate mptable in temp space and copy into final location.
Kevin O'Connor [Sat, 26 Dec 2009 16:15:31 +0000 (11:15 -0500)]
Allocate mptable in temp space and copy into final location.

Copying into the f-segment ensures no extra space is needed.

14 years agoAlso report memory over 4G during init.
Kevin O'Connor [Thu, 24 Dec 2009 16:09:30 +0000 (11:09 -0500)]
Also report memory over 4G during init.

14 years agoprovide correct pci routing information in mptable
Gleb Natapov [Thu, 24 Dec 2009 12:29:43 +0000 (14:29 +0200)]
provide correct pci routing information in mptable

OpenBSD uses irq routing from mptable, but doesn't create it correctly
for PCI bus. This patch adds PCI routing info into mptable.

14 years agoAdd symbolic definitions for MTRR code.
Kevin O'Connor [Thu, 24 Dec 2009 02:24:27 +0000 (21:24 -0500)]
Add symbolic definitions for MTRR code.

14 years agoFix yield() so it works from boot code.
Kevin O'Connor [Sun, 20 Dec 2009 18:11:17 +0000 (13:11 -0500)]
Fix yield() so it works from boot code.

In boot code, the f-segment is read-only, so make sure yield() doesn't
    rely on writes.
Easiest way to do this is to avoid stack switches when not needed.

14 years agoFix potential build failure due to text16 section being too large.
Kevin O'Connor [Sat, 19 Dec 2009 16:03:40 +0000 (11:03 -0500)]
Fix potential build failure due to text16 section being too large.

A relative PC jump can't exceed 32K, but .text16 can be bigger than 32K.
Separate out .text16 into data sections (.data16) and code (.text16).
Place text and fixed sections together at end of f-segment.
This reduces 16bit text size to ~28K which fixes build errors for now.

14 years agoIncrease version in preparation for next release.
Kevin O'Connor [Sat, 19 Dec 2009 15:51:29 +0000 (10:51 -0500)]
Increase version in preparation for next release.

14 years agoUpdate version to 0.5.0.
Kevin O'Connor [Sat, 19 Dec 2009 03:21:26 +0000 (22:21 -0500)]
Update version to 0.5.0.

14 years agoqemu: add rom loading via fw_cfg
Gerd Hoffmann [Fri, 18 Dec 2009 11:16:04 +0000 (12:16 +0100)]
qemu: add rom loading via fw_cfg

Add support for loading roms using the qemu fw_cfg interface,
modeled after the existing cbfs support.  Use it to look for
vgabios (vgaroms/*) and option roms (genroms/*).

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agomove htonl() + friends to util.h
Gerd Hoffmann [Fri, 18 Dec 2009 11:16:03 +0000 (12:16 +0100)]
move htonl() + friends to util.h

As the next patch will add one more user of the macros move them
to util.h.  Also add the 16bit variants.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoDisable CONFIG_OPTIONROMS_DEPLOYED by default
Anthony Liguori [Fri, 18 Dec 2009 11:16:02 +0000 (12:16 +0100)]
Disable CONFIG_OPTIONROMS_DEPLOYED by default

Since qemu now supports loading option roms through PCI

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoDo not guard qemu shadow ram work around in CONFIG_OPTIONROMS_DEPLOYED
Anthony Liguori [Fri, 18 Dec 2009 11:16:01 +0000 (12:16 +0100)]
Do not guard qemu shadow ram work around in CONFIG_OPTIONROMS_DEPLOYED

As we are going to disable CONFIG_OPTIONROMS_DEPLOYED under QEMU so that we can
make proper use of DDIM.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoDistinguish between debug reports for unimplemented vs invalid calls.
Kevin O'Connor [Sun, 13 Dec 2009 18:04:17 +0000 (13:04 -0500)]
Distinguish between debug reports for unimplemented vs invalid calls.

Don't use "fail" in the debug output - as this confuses users.
When reporting on an invalid parameter - use the word "invalid".
When reporting on an unimplemented call - state it is unimplemented.
Add separate debug levels for unimplemented vs invalid calls.
Also, increase the debug level of several entry points.

14 years agoATA 48bit LBA should only be activated on read/write commands.
Kevin O'Connor [Sun, 13 Dec 2009 17:02:55 +0000 (12:02 -0500)]
ATA 48bit LBA should only be activated on read/write commands.

Check explicitly for an extended read/write command instead of 0x04
    bit set.  The identify command has that bit set, but doesn't need
    the 48bit lba registers set.

14 years agoExtract out new call32() function from check_preempt() code in stacks.c.
Kevin O'Connor [Sun, 13 Dec 2009 16:48:18 +0000 (11:48 -0500)]
Extract out new call32() function from check_preempt() code in stacks.c.

14 years agoEnhance experimental option rom "threading" - enable preemption.
Kevin O'Connor [Sun, 13 Dec 2009 16:25:25 +0000 (11:25 -0500)]
Enhance experimental option rom "threading" - enable preemption.

When experimental support for parallelizing option roms and hardware
   init (default disabled) is selected, add support for checking on
   hardware init progress from the RTC irq handler.
Enable ability for RTC to be turned on for additional users.
Allow regular option roms (not just vga option roms) to run in
   parallel with hardware init.
Don't use stack in transition32 / transition16 until new mode is
   entered.
Also, cleanup leaking of data handlers in usb code.
Also, decrease frequency of iomemcpy checks (every 2K instead of 1K).

14 years agoFix use before free in boot_cbfs (boot.c).
Kevin O'Connor [Sun, 13 Dec 2009 16:19:01 +0000 (11:19 -0500)]
Fix use before free in boot_cbfs (boot.c).

14 years agoEnhance readserial.py to try to account for host time offsets.
Kevin O'Connor [Sat, 12 Dec 2009 18:28:38 +0000 (13:28 -0500)]
Enhance readserial.py to try to account for host time offsets.

Try to account for time related to the host sending blocks of data to
    the script.

14 years agoMove stack manipulation code from util.c to new file stacks.c.
Kevin O'Connor [Fri, 11 Dec 2009 02:35:49 +0000 (21:35 -0500)]
Move stack manipulation code from util.c to new file stacks.c.

Move the threading and stack_hop code to a new file.

14 years agoRefactor __call16_from32 - introduce transition16.
Kevin O'Connor [Fri, 11 Dec 2009 02:16:07 +0000 (21:16 -0500)]
Refactor __call16_from32 - introduce transition16.

Add a transition16 call that just jumps into 16bit mode.
__call16_from32 (and call16big) just uses transition16 and __call16.

14 years agoMinor - use wait_irq() instead of irq_enable()/hlt() in apm.
Kevin O'Connor [Fri, 11 Dec 2009 02:15:04 +0000 (21:15 -0500)]
Minor - use wait_irq() instead of irq_enable()/hlt() in apm.

14 years agoMake SMBIOS table pass MS SVVP test
Kevin O'Connor [Fri, 11 Dec 2009 01:13:57 +0000 (20:13 -0500)]
Make SMBIOS table pass MS SVVP test

Microsoft SVVP (Server Virtualization Validation Program) expects
arbitrary SMBIOS field to have certain values otherwise it fails.
We all want to make Microsoft happy don't we? So lets put values MS
expects in there.

Values modified by the patch:
 Type 0:
  Bit 2 of byte 2 must be 1
 Type 1:
  Manufacturer/product string should not be empty
 Type 3:
  Manufacturer string should not be empty
 Type 4:
  Processor manufacturer should no be empty
  Max/current CPU speed shouldn't be unknown
 Type 16:
  Memory should have error correction.

---

v1->v2:
 Use CONFIG_APPNAME instead of open coding strings
 Use snprintf.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoUnify ps2 port data processing.
Kevin O'Connor [Thu, 10 Dec 2009 02:15:59 +0000 (21:15 -0500)]
Unify ps2 port data processing.

Unify the code for mouse and keyboard irq handling.
Support case where mouse irq fires but keyboard data present and
    vice-versa.
Support data in i8042 queue while ps2 command being processed.

14 years agoMove ps2 specific keyboard and mouse code to ps2port.c.
Kevin O'Connor [Thu, 10 Dec 2009 02:00:41 +0000 (21:00 -0500)]
Move ps2 specific keyboard and mouse code to ps2port.c.

14 years agoAdd experimental feature to run vga optionrom in parallel with init.
Kevin O'Connor [Thu, 10 Dec 2009 01:18:31 +0000 (20:18 -0500)]
Add experimental feature to run vga optionrom in parallel with init.

Add option (default disabled) that allows the vga rom to run while
    hardware init is still in progress.

14 years agoClear thread info on each boot.
Kevin O'Connor [Thu, 10 Dec 2009 01:04:54 +0000 (20:04 -0500)]
Clear thread info on each boot.

Fix potential issue of threads being incorrect if ctrl+alt+del is
    pressed during POST.

14 years agoIntroduce optimized iomemcpy function for copying from io memory.
Kevin O'Connor [Sat, 5 Dec 2009 23:51:53 +0000 (18:51 -0500)]
Introduce optimized iomemcpy function for copying from io memory.

Reading from IO memory (pci rom or flash) is very slow, so add
   iomemcpy() which will yield during copy.  Use a 4 byte copy to
   optimize accesses.
Also, decompress cbfs data files from a temp memory buffer so that
   ulzma doesn't read from slow IO memory.

14 years agoFix timing in readserial.py - use 10 bits per byte.
Kevin O'Connor [Sat, 5 Dec 2009 19:23:27 +0000 (14:23 -0500)]
Fix timing in readserial.py - use 10 bits per byte.

There is also a start bit, so 8N1 serial should use 10 bits to a byte.

14 years agoEnhance readserial.py to note when resetting timer.
Kevin O'Connor [Sat, 5 Dec 2009 18:44:39 +0000 (13:44 -0500)]
Enhance readserial.py to note when resetting timer.

14 years agoFix ATA iobase2 access on PCI native mode interfaces.
Kevin O'Connor [Sat, 5 Dec 2009 18:36:18 +0000 (13:36 -0500)]
Fix ATA iobase2 access on PCI native mode interfaces.

The ctrl register is iorange + 2 not iorange + 6.
Rework port definitions to be based on PCI offsets instead of ISA.
Also, properly define ATA irqs when in PCI compatibility mode.

14 years agoSupport ISA ATA devices for qemu's "-M isapc" mode.
Kevin O'Connor [Sat, 5 Dec 2009 16:25:09 +0000 (11:25 -0500)]
Support ISA ATA devices for qemu's "-M isapc" mode.

Add probing for ISA ATA devices when no pci devices found.
Also, add defines for common ATA ports.
Also, make sure irq and pci_bdf are defined for both pci ata controllers.

14 years agoFail PS2 port commands when receiving a NAK.
Kevin O'Connor [Thu, 3 Dec 2009 02:19:30 +0000 (21:19 -0500)]
Fail PS2 port commands when receiving a NAK.

Fail the command on a nak - don't ignore it.

14 years agoMisc updates.
Kevin O'Connor [Thu, 26 Nov 2009 00:35:01 +0000 (19:35 -0500)]
Misc updates.

Update todo list.
Fix spelling errors in acpi debug messages.
Don't call DISK_STUB() in format - use debug_stub() instead.

14 years agoReorganize main init order and add comments.
Kevin O'Connor [Thu, 26 Nov 2009 00:05:04 +0000 (19:05 -0500)]
Reorganize main init order and add comments.

Try to organize the main init by class of hardware initialized.

14 years agoClear unused parts of f-segment.
Kevin O'Connor [Wed, 25 Nov 2009 23:53:52 +0000 (18:53 -0500)]
Clear unused parts of f-segment.

On coreboot, the unused parts of the f-segment could contain leftover
    bios tables which may confuse an OS.  So clear unused parts of
    f-segment.

14 years agoClear PMMAllocs even if CONFIG_PMM not set.
Kevin O'Connor [Wed, 25 Nov 2009 23:51:46 +0000 (18:51 -0500)]
Clear PMMAllocs even if CONFIG_PMM not set.

The pmm based allocations are used for internal allocations now, so be
    sure to do a full reset even if external PMM not configured.

14 years agoAdd floppy and cdrom drives in sorted order.
Kevin O'Connor [Wed, 25 Nov 2009 23:49:06 +0000 (18:49 -0500)]
Add floppy and cdrom drives in sorted order.

With threads a cdrom could be found in random order - so always add to
    the idmap in a defined manor.

14 years agoSet MaxCountCPUs even if no APIC found.
Kevin O'Connor [Tue, 24 Nov 2009 14:41:06 +0000 (09:41 -0500)]
Set MaxCountCPUs even if no APIC found.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoUpdate snprintf to return the number of bytes used.
Kevin O'Connor [Tue, 24 Nov 2009 14:37:53 +0000 (09:37 -0500)]
Update snprintf to return the number of bytes used.

14 years agoMake sure to reenable ata interrupts even on error.
Kevin O'Connor [Fri, 20 Nov 2009 22:28:19 +0000 (17:28 -0500)]
Make sure to reenable ata interrupts even on error.

If the ata command fails, be sure to reenable errors.
This fixes a report of MS Vista not seeing a cdrom drive.

14 years agoMove SeaBIOS post/boot stack to avoid conflict with gPXE.
Kevin O'Connor [Fri, 20 Nov 2009 14:22:19 +0000 (09:22 -0500)]
Move SeaBIOS post/boot stack to avoid conflict with gPXE.

It appears gPXE also uses a stack at 0x7c00.  gPXE probably shouldn't
    do that, but for now, move SeaBIOS stack to 0x7000.

14 years agoTest for broken gcc -combine on FC12.
Kevin O'Connor [Fri, 20 Nov 2009 14:19:28 +0000 (09:19 -0500)]
Test for broken gcc -combine on FC12.

The Fedora Core 12 distro throws an internal compiler error due to a
    bug in gcc.  Look for this case and avoid using -combine if found.

14 years agoAdd MPS entries for LINT interrupts.
Kevin O'Connor [Sat, 14 Nov 2009 18:49:06 +0000 (13:49 -0500)]
Add MPS entries for LINT interrupts.

Signed-off-by: Magnus Christensson <mch@virtutech.com>
14 years agoInitialize the LINT LVTs on the local APIC of the BSP.
Kevin O'Connor [Sat, 14 Nov 2009 18:43:01 +0000 (13:43 -0500)]
Initialize the LINT LVTs on the local APIC of the BSP.

Since the APIC is enabled, we need to initialize LINT0 to ExtINT and LINT1 to NMI.
For now, only do this on non-coreboot configurations.

Signed-off-by: Magnus Christensson <mch@virtutech.com>
14 years agoFixes for mptable generation.
Kevin O'Connor [Sat, 14 Nov 2009 18:34:27 +0000 (13:34 -0500)]
Fixes for mptable generation.

Rework cpu iteration to simplify.  Also fixes sparse table generation
    when multiple cores found.
Rework entrycount generation to fix irq0override code.
Move fls() to util.h.
Add free calls when allocation fails.

14 years agoProperly mask value for MTRR mask.
Kevin O'Connor [Tue, 10 Nov 2009 00:30:17 +0000 (19:30 -0500)]
Properly mask value for MTRR mask.

Signed-off-by: Magnus Christensson <mch@virtutech.com>
14 years agoRemove cmos access from cpu detect loop to make it faster.
Kevin O'Connor [Tue, 10 Nov 2009 00:21:44 +0000 (19:21 -0500)]
Remove cmos access from cpu detect loop to make it faster.

Signed-off-by: Magnus Christensson <mch@virtutech.com>
14 years agoOnly add the first logical CPU in each physical CPU to the MPS tables.
Kevin O'Connor [Tue, 10 Nov 2009 00:20:21 +0000 (19:20 -0500)]
Only add the first logical CPU in each physical CPU to the MPS tables.

Signed-off-by: Magnus Christensson <mch@virtutech.com>
14 years agoFix cpuflag in mptable (| has higher priority than ?:)
Kevin O'Connor [Tue, 10 Nov 2009 00:18:22 +0000 (19:18 -0500)]
Fix cpuflag in mptable (| has higher priority than ?:)

Signed-off-by: Magnus Christensson <mch@virtutech.com>
14 years agoFix compiler warning in setup_translation().
Kevin O'Connor [Tue, 10 Nov 2009 00:15:50 +0000 (19:15 -0500)]
Fix compiler warning in setup_translation().

Assign 'desc' just to silence compiler warning.

14 years agoFix typo in pci_bios_init_device() causing use before set error.
Kevin O'Connor [Tue, 10 Nov 2009 00:15:08 +0000 (19:15 -0500)]
Fix typo in pci_bios_init_device() causing use before set error.

The 'val' variable is used before being set - 'old' was intended.

14 years agoVerify 16bit code doesn't rely on any "discarded" sections.
Kevin O'Connor [Wed, 4 Nov 2009 00:52:04 +0000 (19:52 -0500)]
Verify 16bit code doesn't rely on any "discarded" sections.

Add linker rule to catch cases where 16bit code tries to access a
    non-existent 32bit variable defined with VAR32VISIBLE.

14 years agoReorder source code to work around weird -combine issue.
Kevin O'Connor [Wed, 4 Nov 2009 00:50:52 +0000 (19:50 -0500)]
Reorder source code to work around weird -combine issue.

Seeing an odd issue with ZoneTmpHigh not being declared global - for
    now, work around by reordering the soruce files.
Also, remove the ".comment" section from the final .elf file.

14 years agoCall yield() while waiting for USB control transfers to complete.
Kevin O'Connor [Sat, 31 Oct 2009 17:55:59 +0000 (13:55 -0400)]
Call yield() while waiting for USB control transfers to complete.

14 years agoImprove debugging info on USB UHCI qh timeout.
Kevin O'Connor [Sat, 31 Oct 2009 03:16:07 +0000 (23:16 -0400)]
Improve debugging info on USB UHCI qh timeout.

14 years agoImprove debugging output from threads.
Kevin O'Connor [Sat, 24 Oct 2009 23:56:11 +0000 (19:56 -0400)]
Improve debugging output from threads.

Show the "thread id" on each debug message sent from a thread.
Also, cleanup translation dprintf() so it looks nicer withe thread output.

14 years agoAdd simple cooperative threading scheme to allow parallel hw init.
Kevin O'Connor [Sat, 24 Oct 2009 21:57:29 +0000 (17:57 -0400)]
Add simple cooperative threading scheme to allow parallel hw init.

Enable system for running hardware initialization in parallel.
The yield() call can now round-robin between "threads".
Rework ata controller init to use a thread per controller.
Make sure internal drives are registered in a defined order.
Run keyboard initialization in a thread.
Rework usb init to use a thread per controller.

14 years agoEnable ins/outs functions to use 32bit addresses.
Kevin O'Connor [Sat, 24 Oct 2009 21:54:06 +0000 (17:54 -0400)]
Enable ins/outs functions to use 32bit addresses.

14 years agoReplace irq_enable() regions with explicit calls to check for irqs.
Kevin O'Connor [Sat, 24 Oct 2009 15:06:08 +0000 (11:06 -0400)]
Replace irq_enable() regions with explicit calls to check for irqs.

Add new function yield() which will permit irqs to trigger.
The yield() call enables irqs to occur in 32bit mode.
Add [num]sleep calls that yield instead of just spinning.
Rename existing int 1586 usleep call to biosusleep.
Convert many calls to mdelay to msleep.

14 years agoHandle tsc rollover.
Kevin O'Connor [Fri, 23 Oct 2009 02:30:37 +0000 (22:30 -0400)]
Handle tsc rollover.

Handle case where timetamp counter overflows while waiting.

14 years agoPass 'drive_s' pointer instead of driveid.
Kevin O'Connor [Fri, 23 Oct 2009 01:48:39 +0000 (21:48 -0400)]
Pass 'drive_s' pointer instead of driveid.

Pass a pointer to the drive_s struct instead of a driveid array offset.
Don't allocate ata drive's until a real drive found.
Introduce getDrive() and allocDrive() functions.

14 years agoUpdate TODO list.
Kevin O'Connor [Tue, 20 Oct 2009 02:13:11 +0000 (22:13 -0400)]
Update TODO list.

14 years agoMove smbios definitions to header file; fix compile on older gcc.
Kevin O'Connor [Sun, 18 Oct 2009 13:49:59 +0000 (09:49 -0400)]
Move smbios definitions to header file; fix compile on older gcc.

The build with old versions of gcc can't handle duplicate struct
    definitions.  So, move smbios defs to common header.

14 years agoExpand USB OHCI support.
Kevin O'Connor [Sun, 18 Oct 2009 03:53:32 +0000 (23:53 -0400)]
Expand USB OHCI support.

Get UHCI support to point where it works with (a modified) qemu.

14 years agofix low bits in ROM and I/O sizing
Kevin O'Connor [Wed, 14 Oct 2009 23:28:04 +0000 (19:28 -0400)]
fix low bits in ROM and I/O sizing

This cleans up handling of low bits during BAR sizing,
to match PCI spec requirements, and to use symbolic
constants from pci_regs.h

Issues fixed:
For ROM BARs, bit 0 is writeable (enable bit), which we not
only don't want to set, but it will stick and make us think
it's an I/O port resource.
Further, PCI spec defines the following bits as reserved:
- bit 1 in I/O BAR
- bits 10:1 in ROM BAR
and we should be careful and preserve any values there,
and should ignore anything we read from these registers.
Bits 3:2 in I/O BAR might be writeable, so it
is wrong to mask them when calculating BAR size.

Spec references:
See 6.2.5.1 for I/O and memory, and 6.2.5.2 for ROM,
6.1 for reserved bit handling;
pages 225, 228 and 214 in PCI spec revision 3.0.

See also Qemu pcbios commit 6ddb9f5c742b2b82b1755d7ec2a127f6e20e3806

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agoUse pmm_malloc() for internal allocations.
Kevin O'Connor [Mon, 12 Oct 2009 16:54:56 +0000 (12:54 -0400)]
Use pmm_malloc() for internal allocations.

Using pmm_malloc permits free() to be used on internal allocations.
Rework low zone expanding so that it doesn't cause gcc v4.3 error.
Allow pmm_malloc to use ZoneTmpLow if ZoneTmpHigh isn't available.

14 years agoProvide correct value for QEMU_CFG_IRQ0_OVERRIDE
Kevin O'Connor [Mon, 12 Oct 2009 16:02:33 +0000 (12:02 -0400)]
Provide correct value for QEMU_CFG_IRQ0_OVERRIDE

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoenable io/memory unconditionally
Kevin O'Connor [Mon, 12 Oct 2009 14:34:51 +0000 (10:34 -0400)]
enable io/memory unconditionally

VGA adapters need to claim memory and i/o
transactions even if they do not have any
i/o or memory bars. E.g. PCI spec, page 297,
gives an example of such a device:

    Programming interface 0000 0000b
    VGA-compatible controller. Memory
    addresses 0A 0000h through 0B
    FFFFh. I/O addresses 3B0h to 3BBh
    and 3C0h to 3DFh and all aliases of
    these addresses.

While we could check for these devices and special-case them, it is
easier to fix this by enabling i/o and memory space unconditionally:
devices that do not support it will just ignore this setting.

Original-by: Michael S. Tsirkin <mst@redhat.com>
14 years agoSet the PCI base address to 0xf0000000.
Kevin O'Connor [Mon, 12 Oct 2009 14:22:45 +0000 (10:22 -0400)]
Set the PCI base address to 0xf0000000.

Qemu starts PCI hole at 0xe0000000, but lets set it to the same value as
pcbios uses for now.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoEnable power button event generation.
Kevin O'Connor [Mon, 12 Oct 2009 14:21:48 +0000 (10:21 -0400)]
Enable power button event generation.

Qemu pcbios commit 4f5a9a84ff32e2445bf1c854e33b0b32f4459428

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoGenerate mptable unconditionally.
Kevin O'Connor [Mon, 12 Oct 2009 14:20:46 +0000 (10:20 -0400)]
Generate mptable unconditionally.

VMware ESX requires an mptable even for uniprocessor guests.

Qemu pcbios commit 9869338791ca6f44e628b88e6335ffd66e1ed86b

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoAdd stubs for USB OHCI support.
Kevin O'Connor [Mon, 12 Oct 2009 14:09:15 +0000 (10:09 -0400)]
Add stubs for USB OHCI support.

Enable USB wrapper functions to call either ohci or ehci helpers.
Implement pci_config_maskw in place of pci_set_bus_master.
Introduce 'struct usb_pipe' in place of 'void *' for pipes.

14 years agoMove read/write[bwl] from smp.c to util.h.
Kevin O'Connor [Mon, 12 Oct 2009 13:49:27 +0000 (09:49 -0400)]
Move read/write[bwl] from smp.c to util.h.

Move them to the header so other code can use them.

14 years agoCleanup 'debuginfo' variable in output; add comment.
Kevin O'Connor [Mon, 12 Oct 2009 13:48:12 +0000 (09:48 -0400)]
Cleanup 'debuginfo' variable in output; add comment.

14 years agoUse MaxCountCPUs during building of per cpu tables.
Kevin O'Connor [Fri, 9 Oct 2009 13:42:11 +0000 (09:42 -0400)]
Use MaxCountCPUs during building of per cpu tables.

Preparation for hot pluggable CPUs.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoUpdate acpi-dsdt.hex with latest changes from acpi-dsdt.dsl.
Kevin O'Connor [Fri, 9 Oct 2009 02:16:04 +0000 (22:16 -0400)]
Update acpi-dsdt.hex with latest changes from acpi-dsdt.dsl.

14 years agoMove qemu cfg init before smp init.
Kevin O'Connor [Fri, 9 Oct 2009 02:14:50 +0000 (22:14 -0400)]
Move qemu cfg init before smp init.

We will need to read qemu config during smp init.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoRead max number of cpus from VM.
Kevin O'Connor [Fri, 9 Oct 2009 02:13:15 +0000 (22:13 -0400)]
Read max number of cpus from VM.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoAdd SRAT ACPI table support.
Kevin O'Connor [Fri, 9 Oct 2009 02:09:02 +0000 (22:09 -0400)]
Add SRAT ACPI table support.

Take NUMA topology info from the QEMU firmware configuration interface
(number of nodes, node for each (V)CPU and amount of memory) and build
a SRAT table describing this topology for the guest OS. Handles more than
4 GB of RAM by including a hole for 32bit PCI memory mapping.

Qemu pcbios commit 444f1226c11082d374b7e1361c6f5696e479642a

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoAdd 26 pci slots, bringing the total to 32.
Kevin O'Connor [Fri, 9 Oct 2009 02:06:06 +0000 (22:06 -0400)]
Add 26 pci slots, bringing the total to 32.

Lack of pci slots causes Windows to complain when installing too many
device.

Qemu pcbios commit 001fd46e3b551de05c62590ba5ed4cbf6cbe3510

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoHPET support.
Kevin O'Connor [Fri, 9 Oct 2009 02:05:21 +0000 (22:05 -0400)]
HPET support.

Part of qemu pcbios commit e04da91178f0e11febbbd61d9795e49cc27e9ad4

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoPci hotplug support.
Kevin O'Connor [Fri, 9 Oct 2009 02:04:05 +0000 (22:04 -0400)]
Pci hotplug support.

Qemy pcbios commit e88ec0d97b464915281d27d5714784d2215cbdef

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoProvide gpe _L0x methods.
Kevin O'Connor [Fri, 9 Oct 2009 02:03:28 +0000 (22:03 -0400)]
Provide gpe _L0x methods.

Provide methods for gpe blk 0, even though they do nothing atm.

Qemu pcbios commit 37c3845e38cb8ee4a98960bf1fc31563d071838d

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoRemove irq 9 from the pci interrupt link resources.
Kevin O'Connor [Fri, 9 Oct 2009 02:02:33 +0000 (22:02 -0400)]
Remove irq 9 from the pci interrupt link resources.

qemu can't share isa irqs (which is how the acpi sci interrupt is implemente
with the pci irqs, so remove the sci interrupt from the pci link interrupt
candidate list.

Qemu pcbios commit 713939c93b9caa1a31c49211fe83525bcbee5948

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoUse extended interrupt descriptor for pci irqs.
Kevin O'Connor [Fri, 9 Oct 2009 02:01:52 +0000 (22:01 -0400)]
Use extended interrupt descriptor for pci irqs.

This is necessary to allow freebsd to boot; freebsd chokes if a regular
interrupt descriptor specifies an active high pic irq.

Qemu pcbios commit aaff1cc0ce8de3c45eec49b9b0e7624576058eda

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoRestrict pci interrupts to irq 5/9/10/11
Kevin O'Connor [Fri, 9 Oct 2009 02:01:06 +0000 (22:01 -0400)]
Restrict pci interrupts to irq 5/9/10/11

we need to specify the pci interrupts as active high; this reduces
the number of override entries we have to add.

Qemu pcbios commit 0f79abf26ff3e61dab712dbccdbc08a04619e7c0

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoAdvertise pci irqs as active high in DSDT
Kevin O'Connor [Fri, 9 Oct 2009 01:59:51 +0000 (21:59 -0400)]
Advertise pci irqs as active high in DSDT

Now that kvm emulates the ioapic polarity correctly, we must describe
the polarity correctly in the acpi tables. Otherwise pci interrupts won't
be delivered correctly.

Qemu pcbios commit 0c8d4b40a1eec2369c016b9be1c9175607e64a4b

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoUse preprocessor for pci link routing.
Kevin O'Connor [Fri, 9 Oct 2009 01:59:13 +0000 (21:59 -0400)]
Use preprocessor for pci link routing.

Qemu pcbios commit 297a5cd68d2883215571634b2f8c627364c87f2c

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoAdd rule to compile DSDT to make file.
Kevin O'Connor [Fri, 9 Oct 2009 01:57:15 +0000 (21:57 -0400)]
Add rule to compile DSDT to make file.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoRemove CONFIG_KVM compile option.
Kevin O'Connor [Fri, 9 Oct 2009 01:52:11 +0000 (21:52 -0400)]
Remove CONFIG_KVM compile option.

Qemu and KVM should use the same bios build. All differences should be
handled in runtime.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoCheck at runtime if VM is KVM.
Kevin O'Connor [Fri, 9 Oct 2009 01:50:31 +0000 (21:50 -0400)]
Check at runtime if VM is KVM.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoirq0override provided by qemu.
Kevin O'Connor [Fri, 9 Oct 2009 01:37:21 +0000 (21:37 -0400)]
irq0override provided by qemu.

Read it instead of relying on compile time flag.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agoCorrect default pci irq links
Kevin O'Connor [Fri, 9 Oct 2009 01:34:45 +0000 (21:34 -0400)]
Correct default pci irq links

The hardware uses irqs 10 and 11, so change the bios to reflect that.

Qemu pcbios commit b0a155cfddc57e93b641a24fb198fdd8d738f143

Signed-off-by: Gleb Natapov <gleb@redhat.com>