seabios.git
13 years agoseabios: pciinit: use pci device initializer helper function.
Kevin O'Connor [Sat, 10 Jul 2010 17:12:37 +0000 (13:12 -0400)]
seabios: pciinit: use pci device initializer helper function.

This patch makes use of pci device initialization helper function
to convert if/switch clause to table driven.
So this makes it easier to add q35 initialization code.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
13 years agoseabios: pci: introduce helper function to initialize a given device.
Isaku Yamahata [Wed, 7 Jul 2010 03:14:01 +0000 (12:14 +0900)]
seabios: pci: introduce helper function to initialize a given device.

introduce helper function to initialize a given device,
This will be used later.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
13 years agovirtio: Clear interrupt status register in virtio-blk
Stefan Hajnoczi [Wed, 7 Jul 2010 12:34:22 +0000 (13:34 +0100)]
virtio: Clear interrupt status register in virtio-blk

The VRING_AVAIL_F_NO_INTERRUPT flag is a hint that interrupts should be
suppressed.  It does not guarantee that interrupts will not be raised.
Therefore, make sure to clear the interrupt after each virtio-blk read.
This avoids a stuck interrupt interfering with the OS loaded later in
the boot process.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoseabios: pciinit: initialize pci bridge filtering registers.
Isaku Yamahata [Tue, 22 Jun 2010 08:57:53 +0000 (17:57 +0900)]
seabios: pciinit: initialize pci bridge filtering registers.

initialize pci bridge filtering registers.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
13 years agoseabios: pciinit: pci bridge bus initialization.
Isaku Yamahata [Tue, 22 Jun 2010 08:57:52 +0000 (17:57 +0900)]
seabios: pciinit: pci bridge bus initialization.

pci bridge bus initialization.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
13 years agoseabios: pciinit: make bar offset calculation pci bridge aware.
Isaku Yamahata [Tue, 22 Jun 2010 08:57:51 +0000 (17:57 +0900)]
seabios: pciinit: make bar offset calculation pci bridge aware.

This patch makes pci bar offset calculation pci bridge aware.
The offset of pci bridge rom is different from normal device.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
13 years agoseabios: pciinit: factor out bar offset calculation.
Isaku Yamahata [Tue, 22 Jun 2010 08:57:50 +0000 (17:57 +0900)]
seabios: pciinit: factor out bar offset calculation.

This patch factors out bar offset calculation.
Later the calculation logic will be enhanced.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
13 years agoseabios: pciinit: make pci bar assigner preferchable memory aware.
Isaku Yamahata [Tue, 22 Jun 2010 08:57:49 +0000 (17:57 +0900)]
seabios: pciinit: make pci bar assigner preferchable memory aware.

Make pci bar assigner preferchable memory aware.
This is needed for PCI bridge support because memory space and
prefetchable memory space is filtered independently based on
memory base/limit and prefetchable memory base/limit of pci bridge.
On bus 0, such a distinction isn't necessary so keep existing behavior
by checking bus=0.

With this patch, pci mem assignment area has been decreased.
To make seabios behave as before for compatible reason,
define CONFIG_OLD_PCIMEM_ASSIGNMENT.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
13 years agoseabios: pciinit: make pci memory space assignment 64bit aware.
Isaku Yamahata [Tue, 22 Jun 2010 08:57:48 +0000 (17:57 +0900)]
seabios: pciinit: make pci memory space assignment 64bit aware.

make pci memory space assignment 64bit aware.
If 64bit memory space is found while assigning pci memory space,
clear higher bit and skip to next bar.

This patch is preparation for q35 chipset initialization which
has 64bit bar.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
13 years agoseabios: pciinit: factor out pci bar region allocation logic.
Isaku Yamahata [Tue, 22 Jun 2010 08:57:47 +0000 (17:57 +0900)]
seabios: pciinit: factor out pci bar region allocation logic.

factor out pci bar region allocation logic.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
13 years agoseabios: pci: introduce foreachpci_in_bus() helper macro.
Isaku Yamahata [Tue, 22 Jun 2010 08:57:46 +0000 (17:57 +0900)]
seabios: pci: introduce foreachpci_in_bus() helper macro.

This patch introduces foreachpci_in_bus() helper macro for
depth first recursion. foreachpci() is for width first recursion.
The macro will be used later to initialize pci bridge
that requires depth first recursion.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
13 years agoAdd romfile_size() wrapper for accessing cbfs/qemu_cfg files.
Kevin O'Connor [Sun, 4 Jul 2010 12:32:38 +0000 (08:32 -0400)]
Add romfile_size() wrapper for accessing cbfs/qemu_cfg files.

13 years agoInitial bootsplash support.
Kevin O'Connor [Mon, 28 Jun 2010 11:34:53 +0000 (07:34 -0400)]
Initial bootsplash support.

Support displaying a jpeg file (stored in cbfs) during bootup.

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
13 years agoUpdate TODO
Kevin O'Connor [Sat, 19 Jun 2010 16:07:57 +0000 (12:07 -0400)]
Update TODO

Remove already completed items.

13 years agoFix bvprintf() to respect padding for hex printing.
Kevin O'Connor [Sat, 19 Jun 2010 16:05:57 +0000 (12:05 -0400)]
Fix bvprintf() to respect padding for hex printing.

Fix bvprintf to respect space padding when printing hex numbers
and the caller specifies alignment without zero padding, eg. %2x
as opposed to %02x

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
13 years agoUnify optionrom cbfs/qemu_cfg rom pulling code.
Kevin O'Connor [Sun, 13 Jun 2010 20:05:17 +0000 (16:05 -0400)]
Unify optionrom cbfs/qemu_cfg rom pulling code.

Make the qemu_cfg optionrom extraction code use an interface more
similar to the cbfs file interface.

Introduce a set of "romfile_" wrappers that select between cbfs and
qemu cfg interface.  Use these new wrappers in the optionrom code.

13 years agoSeaBIOS VGA hooks
Stefan Reinauer [Wed, 9 Jun 2010 07:45:28 +0000 (09:45 +0200)]
SeaBIOS VGA hooks

Add VGA hooks to operate the following mainboards with coreboot + SeaBIOS:
- Kontron 986LCD-M
- Getac P470 (Laptop)
- Roda RK886EX (Laptop)

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
13 years agoSeaBIOS CD/DVD abbreviations
Stefan Reinauer [Wed, 9 Jun 2010 19:10:13 +0000 (21:10 +0200)]
SeaBIOS CD/DVD abbreviations

- Use the same description text for CD and DVD drives all over the tree.
- Mention DVD first as it's more likely these days

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
13 years agoseabios: remove iasl output file when error.
Isaku Yamahata [Mon, 7 Jun 2010 08:19:27 +0000 (17:19 +0900)]
seabios: remove iasl output file when error.

Surprisingly iasl creates output file even when compilation error.
So typing make after an error will succeed.
This patch prevents it by removing the output file when error.
And adds related dependencies to compile when .hex is missing.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
13 years agoAllocate cdemu buffer in low mem instead of ebda.
Kevin O'Connor [Sun, 6 Jun 2010 20:18:03 +0000 (16:18 -0400)]
Allocate cdemu buffer in low mem instead of ebda.

Using the low memory buffer gives more flexibility with the final
location of the buffer.

Don't allocate the buffer at all if no cdrom drives are present.

13 years agoIntroduce memcpy_fl - a memcpy on "flat" pointers.
Kevin O'Connor [Sun, 6 Jun 2010 20:11:45 +0000 (16:11 -0400)]
Introduce memcpy_fl - a memcpy on "flat" pointers.

13 years agoRework malloc to use a "first fit" algorithm.
Kevin O'Connor [Sun, 6 Jun 2010 15:10:24 +0000 (11:10 -0400)]
Rework malloc to use a "first fit" algorithm.

The existing malloc implementation effectively uses a stack - all new
allocations come from the top of the stack.  When allocating memory
with a large alignment, the pad used to align the new memory is
unavailable to other users.  Also, memory released by calling free()
is only available to other users when all memory allocated after it is
also freed.

This new malloc scheme uses a first fit approach to finding available
memory.  It makes it possible to use alignment padding and freed space
for new allocations.

This helps reduce the required memory in the permanent memory zones
(ZoneHigh and ZoneLow) where users have the need to allocate
structures with high alignment (eg, virtio and usb).

13 years agoMinor mptable changes.
Kevin O'Connor [Sun, 6 Jun 2010 15:07:08 +0000 (11:07 -0400)]
Minor mptable changes.

Simplify entrycount tracking.

Allow mptable generation to work even if there is no high mem available.

13 years agovirtio: clean up memory barrier usage
Michael S. Tsirkin [Thu, 20 May 2010 13:36:32 +0000 (16:36 +0300)]
virtio: clean up memory barrier usage

cleanup memory barrier usage bringing it
in sync with what linux guest does.
The rules are simple:
- read barrier after index read
- write barrier before index write
Also, call macros smp_rmb/smp_wmb to stress
we are not syncing with a real io device here.

While I don't think compiler is crazy/powerful
enough to reorder these, anyway, the bogus
barriers we currently have in code will confuse
anyone who tries to copy/reuse it.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
13 years agovirtio: remove NO_NOTIFY optimization
Michael S. Tsirkin [Thu, 20 May 2010 13:24:48 +0000 (16:24 +0300)]
virtio: remove NO_NOTIFY optimization

NO_NOTIFY is an optimization to reduce the number of exits,
but using it requires careful synchronization with host,
forcing read/write ordering for the CPU. Otherwise we
risk not kicking a host when it is waiting for more buffers,
resulting in a deadlock.

Let's just always kick, it's way simpler.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
13 years agoDon't use RTC to time boot menu delay.
Kevin O'Connor [Sun, 23 May 2010 16:40:40 +0000 (12:40 -0400)]
Don't use RTC to time boot menu delay.

It appears real machines sometimes have a flaky RTC, so avoid using
the RTC irq during boot.  Instead, use a delay based on the standard
timer irq.

This also optimizes CONFIG_THREAD_OPTIONROMS users as it is no longer
necessary to use preemption - the wait_irq() call handles task
switching natively.

13 years agoGeneralize timer based delay code.
Kevin O'Connor [Sun, 23 May 2010 15:38:53 +0000 (11:38 -0400)]
Generalize timer based delay code.

Move the timer based counting code in serial.c to clock.c.

Rework the interface to make it similar to the tsc based timers.

13 years agoRename check_time() to check_tsc().
Kevin O'Connor [Sun, 23 May 2010 14:46:49 +0000 (10:46 -0400)]
Rename check_time() to check_tsc().

13 years agoAllow wait_irq to be called in 32bit code.
Kevin O'Connor [Sun, 23 May 2010 14:24:22 +0000 (10:24 -0400)]
Allow wait_irq to be called in 32bit code.

If wait_irq() is called from 32bit code, then jump to 16bit mode for
the wait.

Have wait_irq check for threads, and have it use yield if threads are
pending.  This ensures threads aren't delayed if anything calls
wait_irq.

Use wait_irq() in 32bit mode during a failed boot.

13 years agoImprove optionrom debugging statements.
Kevin O'Connor [Sun, 23 May 2010 14:22:23 +0000 (10:22 -0400)]
Improve optionrom debugging statements.

Display device/vendor ids in traditional format.

13 years agoMinor - compile out usb-msc code if CONFIG_USB_MSC not set.
Kevin O'Connor [Sun, 23 May 2010 14:21:00 +0000 (10:21 -0400)]
Minor - compile out usb-msc code if CONFIG_USB_MSC not set.

13 years agoMinor ata cleanups.
Kevin O'Connor [Sun, 23 May 2010 14:20:04 +0000 (10:20 -0400)]
Minor ata cleanups.

Eliminate process_atapi_op() code if CONFIG_ATA not set.
Use PCI_BASE_ADDRESS_IO_MASK instead of hardcoding it.

13 years agoMake sure virtio-blk is fully compiled out if not wanted.
Kevin O'Connor [Sun, 23 May 2010 14:19:03 +0000 (10:19 -0400)]
Make sure virtio-blk is fully compiled out if not wanted.

Add check for CONFIG_VIRTIO_BLK in process_virtio_op.
Don't enable virtio when coreboot enabled.

14 years agoMinor - split up virtio_blk_setup().
Kevin O'Connor [Thu, 20 May 2010 04:22:02 +0000 (00:22 -0400)]
Minor - split up virtio_blk_setup().

Split function to make it more readable.

Also, report all found virtio devices at debug level 1.

14 years agofix two issues with virtio-blk
Gleb Natapov [Mon, 17 May 2010 13:27:27 +0000 (16:27 +0300)]
fix two issues with virtio-blk

1. Check if blk_size is valid in virtio_blk config.
2. Disable interrupt otherwise interrupt may stuck
   with some guests.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
ChangeLog:
 v1->v2:
  - Treat sector size not equal to 512 bytes as error.

14 years agoMinor improvements to virtio (allow irqs, allocate page aligned).
Kevin O'Connor [Sun, 16 May 2010 15:34:38 +0000 (11:34 -0400)]
Minor improvements to virtio (allow irqs, allocate page aligned).

Allow irqs to be handled while waiting for virtio reads to complete.

Use native page aligned allocations instead of manually aligning the
data.  This reduces the amount of low memory virtio requires.

Also, some minor white space cleanups.

14 years agoFix virtio compile errors on various gcc versions.
Kevin O'Connor [Tue, 11 May 2010 01:51:38 +0000 (21:51 -0400)]
Fix virtio compile errors on various gcc versions.

Gcc 3.4 doesn't like __FUNCTION__ for some reason - use __func__
instead.

Gcc 4.5 compiles each .c file independently, so make sure includes are
correct for each .c file.

14 years agoSupport for booting from virtio disks
Gleb Natapov [Mon, 10 May 2010 08:36:37 +0000 (11:36 +0300)]
Support for booting from virtio disks

This patch adds native support for booting from virtio disks to Seabios.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
14 years agosmbios: avoid counting io hole as ram
Alex Williamson [Fri, 7 May 2010 19:38:55 +0000 (13:38 -0600)]
smbios: avoid counting io hole as ram

Avoid counting the io hole as part of ram, a vm started with 4G
should report 4G in smbios, not 4.5G.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
14 years agoFix error causing USB HID "boot" protocol to not be enabled.
Kevin O'Connor [Sun, 2 May 2010 02:45:56 +0000 (22:45 -0400)]
Fix error causing USB HID "boot" protocol to not be enabled.

To enable the "boot" protocol wValue must be 0, not 1.

14 years agoAdd support for USB mice.
Kevin O'Connor [Sun, 2 May 2010 02:14:40 +0000 (22:14 -0400)]
Add support for USB mice.

Initial support for USB mice that follow the "boot" protocol.

14 years agoWhen USB keyboard active, don't send keyboard commands to ps2 port.
Kevin O'Connor [Sat, 1 May 2010 23:59:34 +0000 (19:59 -0400)]
When USB keyboard active, don't send keyboard commands to ps2 port.

Route keyboard commands to a USB handler when USB keyboard is active.

Add a GETID handler for USB keyboards.

14 years agoDocument usb-hid.c functions.
Kevin O'Connor [Sat, 1 May 2010 23:25:41 +0000 (19:25 -0400)]
Document usb-hid.c functions.

14 years agoFurther parallelize init when using CONFIG_THREAD_OPTIONROMS.
Kevin O'Connor [Sat, 1 May 2010 16:20:33 +0000 (12:20 -0400)]
Further parallelize init when using CONFIG_THREAD_OPTIONROMS.

When optionrom threading is enabled, allow hardware init to run in
parallel with boot menu key press delay and with the smp detection.

Also, run qemu_cfg_port_probe() before ram_probe().

14 years agoHandle unknown function addresses in tools/checkstack.py.
Kevin O'Connor [Sat, 1 May 2010 15:03:10 +0000 (11:03 -0400)]
Handle unknown function addresses in tools/checkstack.py.

Handle cases where objdump shows an call to an unknown address.

Also, simplify implemention of orderfuncs() - use funcion addreses
instead of function names as keys.

14 years agoSimplify build by manually resolving external symbols in layoutrom.py.
Kevin O'Connor [Sat, 1 May 2010 13:50:13 +0000 (09:50 -0400)]
Simplify build by manually resolving external symbols in layoutrom.py.

Enhance tools/layoutrom.py to explicitly set those symbols that
resolve to a different code chunk (eg, 16, 32seg, 32flat).  This
eliminates the need to link the code chunks multiple times.

This patch reduces the dependency on binutils behavior and makes the
build simpler to understand.

14 years agoUSB EHCI should yield() whil waiting for controller to ack reset.
Kevin O'Connor [Sat, 17 Apr 2010 20:59:12 +0000 (16:59 -0400)]
USB EHCI should yield() whil waiting for controller to ack reset.

14 years agoAdd __attribute__((__malloc__)) declaration to internal malloc funcs.
Kevin O'Connor [Sat, 17 Apr 2010 20:58:32 +0000 (16:58 -0400)]
Add __attribute__((__malloc__)) declaration to internal malloc funcs.

14 years agoMinor - remove redundant check from ata_try_dma.
Kevin O'Connor [Sat, 17 Apr 2010 20:57:57 +0000 (16:57 -0400)]
Minor - remove redundant check from ata_try_dma.

14 years agoFix possible unitialized variable issue in usb msc.
Kevin O'Connor [Fri, 9 Apr 2010 00:40:47 +0000 (20:40 -0400)]
Fix possible unitialized variable issue in usb msc.

On an error path, desc and udrive_g may not be initialized.

14 years agoSome improvements to optionrom preemption support.
Kevin O'Connor [Fri, 2 Apr 2010 17:13:23 +0000 (13:13 -0400)]
Some improvements to optionrom preemption support.

Enable preemption during VGA mode switch call - this call can take
several milliseconds on real hardware.

Call yield() in finish_preempt() - when preemption is configured it
allows threads in wait_preempt() to run; when not configured it gives
an opportunity for threads to execute after the implicit delay from
optionrom execution.

Don't penalize priority in run_thread().  The run_thread() code would
implicitly yield because it created the new thread on the list after
the current thread and then jumped to it.  When in a preemption event,
a yield effectively waits approximately one millisecond (to the next
rtc irq).  The implicit yielding in run_thread thus limited the number
of threads one could launch during preemption to 1 per millisecond.
So, change the code so that the new thread is created prior to the
current thread - thus eliminating the effective yield from
run_thread().

14 years agoRefactor USB hub code.
Kevin O'Connor [Sun, 28 Mar 2010 19:11:19 +0000 (15:11 -0400)]
Refactor USB hub code.

All four implementations of hubs (and root hubs) were very similar.
Replace them with a single implementation that uses callbacks for the
three custom parts (detect, reset, disconnect) of each type of hub.

14 years agoPrep version for next release.
Kevin O'Connor [Sun, 28 Mar 2010 17:53:40 +0000 (13:53 -0400)]
Prep version for next release.

14 years agoUpdate version to 0.6.0.
Kevin O'Connor [Sat, 27 Mar 2010 01:32:15 +0000 (21:32 -0400)]
Update version to 0.6.0.

14 years agoImprove USB EHCI timing.
Kevin O'Connor [Sun, 21 Mar 2010 03:25:11 +0000 (23:25 -0400)]
Improve USB EHCI timing.

Add a small delay even in non-power-switching mode to ensure device
detect completes.

Start companion controllers as soon as all port detects are complete -
don't wait for ehci device config to complete.  This ensure critical
high/low speed devices (eg, usb keyboards) are initialized quickly.

Also, be sure to disable port on a failed reset.

14 years agoDisable inlining on old compilers.
Kevin O'Connor [Sun, 21 Mar 2010 00:21:13 +0000 (20:21 -0400)]
Disable inlining on old compilers.

If the compiler can't restrict inlining by stack usage, then disable
inlining in 16bit mode.  Otherwise, old compilers produce code that
uses too much stack space.

14 years agoForce use of indirect function calls in inline assembler.
Kevin O'Connor [Sun, 21 Mar 2010 00:41:38 +0000 (20:41 -0400)]
Force use of indirect function calls in inline assembler.

For indirect calls, place function address in a register and call it.
This is less optimal when gcc can inline the code and the destination
address is known at compile time.  However, older gcc compilers don't
do as well with inlining, and they then mess up the code generation.
There doesn't seem to be a way to tell gcc how to emit the code
correctly for both immediate addresses and register addresses, so fall
back to a safe way.

Also, reduce params to stack_hop to avoid register assignment issues.

14 years agoDon't move EBDA while an optionrom is running (CONFIG_THREAD_OPTIONROMS).
Kevin O'Connor [Sat, 20 Mar 2010 22:17:19 +0000 (18:17 -0400)]
Don't move EBDA while an optionrom is running (CONFIG_THREAD_OPTIONROMS).

Moving the ebda while an optionrom is running could confuse it.  So,
avoid doing that.

14 years agoCall to int1552 (from int1346) should set regs->dl.
Kevin O'Connor [Sat, 20 Mar 2010 21:53:40 +0000 (17:53 -0400)]
Call to int1552 (from int1346) should set regs->dl.

14 years agoAdjust debug levels of device discovery.
Kevin O'Connor [Sat, 20 Mar 2010 21:53:03 +0000 (17:53 -0400)]
Adjust debug levels of device discovery.

Be sure to print at debug level 1 all devices found.

14 years agoDefault CONFIG_COREBOOT_FLASH on; make depend on CONFIG_COREBOOT.
Kevin O'Connor [Sat, 20 Mar 2010 15:00:45 +0000 (11:00 -0400)]
Default CONFIG_COREBOOT_FLASH on; make depend on CONFIG_COREBOOT.

Coreboot users will almost certainly want CBFS support, and
non-coreboot users have no use for it.  So, make that the default
behaviour.

14 years agoRestore segment limits in handle_1589 code.
Kevin O'Connor [Mon, 15 Mar 2010 23:58:55 +0000 (19:58 -0400)]
Restore segment limits in handle_1589 code.

Before transitioning back to real mode, the segment registers should
be reloaded so that the hidden register limits are updated.

14 years agoExtend time for rtc to be ready.
Kevin O'Connor [Sun, 14 Mar 2010 04:04:41 +0000 (23:04 -0500)]
Extend time for rtc to be ready.

Increase the time waiting for rtc from 3ms to 15ms - only 3ms is
needed on real hardware, but scheduling delays on qemu can make this
longer.  Extending the time prevents annoying debugging messages.

14 years agoBackup and restore registers when calling out to user funcs.
Kevin O'Connor [Sun, 14 Mar 2010 03:29:55 +0000 (22:29 -0500)]
Backup and restore registers when calling out to user funcs.

Make sure to fully backup and restore register state when calling out
to other interrupts and functions.  Some old DOS programs don't fully
restore state.

Also, make sure to enable irqs in call16_simpint().

14 years agoEnable irqs in kbd/clock calls that caller might "spin" on.
Kevin O'Connor [Sun, 14 Mar 2010 03:23:44 +0000 (22:23 -0500)]
Enable irqs in kbd/clock calls that caller might "spin" on.

Some old programs will spin on a clock/keyboard call with irqs
disabled.  They assume the BIOS will enable irqs and allow key events
and clock events to occur.

So, enable irqs in those functions that a caller might "spin" on.

14 years agoProcess event on ps2 keyboard irq even if event already read.
Kevin O'Connor [Sun, 14 Mar 2010 02:05:12 +0000 (21:05 -0500)]
Process event on ps2 keyboard irq even if event already read.

Some old DOS programs will hook the keyboard irq, read the keyboard
data on irq, and then call the BIOS handler expecting it to continue
process the event.  So, the BIOS can't assume it is the first to read
the data from the ps2 port.

Also, reduce window where a ps2 command could conflict with incoming
data.  Disable all data during interrupt flushing, and only re-enable
the desired port just prior to sending the command.

Also, discard data from any interrupts if init hasn't completed.

14 years agoRevert "Unify ps2 port data processing."
Kevin O'Connor [Sun, 14 Mar 2010 01:06:34 +0000 (20:06 -0500)]
Revert "Unify ps2 port data processing."

This reverts commit 84f7b801ba8c0806fac568e59e85af281c0df207.

It's not possible to unify ps2 port irq processing because old DOS
apps could hook one or both of the kbd/mouse ps2 irqs.

14 years agoHandle variable length return of ps2 port GETID command.
Kevin O'Connor [Sun, 14 Mar 2010 00:59:24 +0000 (19:59 -0500)]
Handle variable length return of ps2 port GETID command.

Sometimes GETID returns two bytes, and sometimes one byte.  Handle
that properly.

This fixes a failure with an msdos mouse driver.

14 years agoPrevent ps2 irqs from messing up ps2 init.
Kevin O'Connor [Sun, 14 Mar 2010 00:00:02 +0000 (19:00 -0500)]
Prevent ps2 irqs from messing up ps2 init.

This is an alternate to 6f702dd6987b22e9bce472fe61910392af17416a.

After disabling ps2 irqs, enable irqs to flush any queued irqs.  This
should prevent irqs from triggering in the middle of the init process.

14 years agoRevert "Rework disabling of ps2 port irqs."
Kevin O'Connor [Sat, 13 Mar 2010 23:51:46 +0000 (18:51 -0500)]
Revert "Rework disabling of ps2 port irqs."

This reverts commit 6f702dd6987b22e9bce472fe61910392af17416a.

That patch introduced a regression by enabling mouse interrupts by
default.  It also appears that disabling interrupts by software alone
will not work well with some old DOS programs that hook the keyboard
irq.

14 years agoFix smp cpu detect on gcc 4.5.
Kevin O'Connor [Thu, 11 Mar 2010 03:32:26 +0000 (22:32 -0500)]
Fix smp cpu detect on gcc 4.5.

Bruce Rogers <brogers@novell.com> observed new compiler optimizing
away memory assign in smp detect.  Add barrier() to code to ensure gcc
knows the SIPI can read/write memory.

14 years agoImprovements to tools/checkstack.py.
Kevin O'Connor [Wed, 10 Mar 2010 01:01:35 +0000 (20:01 -0500)]
Improvements to tools/checkstack.py.

Add explicit tracking of functions that switch stacks.

Add new tracking of "yield" points -- areas in the code that appear to
hand control to third-party code which may use arbitrary stack space.

Try to arrange the output so that functions that call each other are
near each other.

14 years agoAdd USB EHCI controller support.
Kevin O'Connor [Wed, 10 Mar 2010 00:43:52 +0000 (19:43 -0500)]
Add USB EHCI controller support.

Initial support for EHCI high-speed USB controllers.

14 years agoSome USB UHCI and OHCI fixes and cleanups.
Kevin O'Connor [Wed, 10 Mar 2010 00:33:22 +0000 (19:33 -0500)]
Some USB UHCI and OHCI fixes and cleanups.

Don't send a data packet on OHCI if no data to be sent.
Add some barrier() calls where needed.
Move toggle definition from generic pipe struct to uhci pipe struct.
Check for malloc failure on ohci and uhci "tds" request.
Be sure to always allocate an even number of intr tds on uhci - toggle
    setting depends on it.

14 years agoMinor - USB OHCI interrupt queue should be one larger.
Kevin O'Connor [Sun, 28 Feb 2010 07:36:32 +0000 (02:36 -0500)]
Minor - USB OHCI interrupt queue should be one larger.

One of the entries in the queue can't be used, so the total queue size
needs to be one larger than it currently is.

14 years agoReduce size of USB 'struct uhci_td'.
Kevin O'Connor [Sun, 28 Feb 2010 04:50:48 +0000 (23:50 -0500)]
Reduce size of USB 'struct uhci_td'.

Reduce the size to make arrays of tds smaller.  For interrupt in
pipes, allocate the data space separately.

14 years agoDynamically allocate USB controller structures.
Kevin O'Connor [Sun, 28 Feb 2010 07:23:19 +0000 (02:23 -0500)]
Dynamically allocate USB controller structures.

Have each controller type allocate its own data structure.

Also, implement freeing of unused uhci controller structures.

14 years agoReplace USB encoded 'u32 endp' scheme with explicit struct fields.
Kevin O'Connor [Sun, 28 Feb 2010 07:17:28 +0000 (02:17 -0500)]
Replace USB encoded 'u32 endp' scheme with explicit struct fields.

Expand 'struct usb_pipe' with all the fields that are needed from the
encoded 'u32 endp' field.

14 years agoFurther parallelize USB init by launching a thread per usb port.
Kevin O'Connor [Wed, 10 Mar 2010 00:58:23 +0000 (19:58 -0500)]
Further parallelize USB init by launching a thread per usb port.

Run a thread per usb port in addition to the existing thread per usb
controller.  This can reduce total boot time by allowing multiple USB
devices on the same controller to initialize in parallel.  It also
makes startup time for critical devices (eg, the keyboard) less
dependent on which port they are plugged into.

14 years agoIntroduce simple "mutex" locking code.
Kevin O'Connor [Sat, 27 Feb 2010 18:49:47 +0000 (13:49 -0500)]
Introduce simple "mutex" locking code.

Locks are not normally necessary because SeaBIOS uses a cooperative
multitasking system.  However, occasionally it is necessary to be able
to lock a resource across yield calls.  This patch introduces a simple
mechanism for doing that.

14 years agoOnly compile usb-hub.c and paravirt.c with 32bit code.
Kevin O'Connor [Sat, 27 Feb 2010 18:43:47 +0000 (13:43 -0500)]
Only compile usb-hub.c and paravirt.c with 32bit code.

Those files are only used by 32bit code, so don't bother including
them with the 16bit code.

14 years agoPrefer passing a USB "pipe" structure over a USB endp encoding.
Kevin O'Connor [Fri, 26 Feb 2010 13:57:13 +0000 (08:57 -0500)]
Prefer passing a USB "pipe" structure over a USB endp encoding.

Instead of passing the "u32 endp" encoding of the usb endpoint,
allocate a "struct usb_pipe" for each end point and pass that.
Allocate a control pipe for every device found.  Support freeing the
pipes after they are done.

Implement pipe allocation and freeing for both UHCI and OHCI
controllers.

Also, don't define every UHCI qh to include a pipe - create a separate
structure "struct uhci_pipe".  Also, be sure to clear the
USBControllers on reset.  Also, convert usb_hub_init to return 0 on
success.  Also, cleanup some of the USB debug messages to make them
more consistent.

14 years agoAdd a generic "internal error" warning function.
Kevin O'Connor [Fri, 26 Feb 2010 13:45:00 +0000 (08:45 -0500)]
Add a generic "internal error" warning function.

14 years agoDynamically allocate ata_channel info; introduce custom atadrive_s struct.
Kevin O'Connor [Sun, 28 Feb 2010 06:28:11 +0000 (01:28 -0500)]
Dynamically allocate ata_channel info; introduce custom atadrive_s struct.

Don't limit the number of ATA controllers supported - just dynamically
allocate the structs.

Create an atadrive_s struct that extends the standard 'struct drive_s'
and have the new struct store a pointer to the ata channel info.

Also, prefer storing drive_s pointers as 32bit "flat" pointers -
adjust them as needed in the 16bit code.

14 years agoCleanup - build drive description in temp memory during init.
Kevin O'Connor [Mon, 22 Feb 2010 04:20:10 +0000 (23:20 -0500)]
Cleanup - build drive description in temp memory during init.

Remove describe_drive() mechanism for calling printf with a drive
description.  Instead, have each drive build a description in
temporary ram during drive initialization.

Also, remove fields now unneeded from 'struct disk_s' - model and
cntl_info.

14 years agoSeabios e820 reservation portion v3
Jes Sorensen [Tue, 16 Feb 2010 08:46:08 +0000 (09:46 +0100)]
Seabios e820 reservation portion v3

On 02/16/10 01:43, Kevin O'Connor wrote:
> On Mon, Feb 15, 2010 at 06:33:59PM +0100, Jes Sorensen wrote:
>> Hi,
>>
>> This is the Seabios part to match my e820 reservation via fw_cfg patch.
>
> This still has 'struct e820_entry' which is too similar to 'struct
> e820entry' in memmap.h.  Otherwise, it looks good to me.

Hmmm didn't catch that one earlier, thanks for pointing it out. I have
renamed it to struct e820_reservation to make it different.

Hope this version does the trick then.

Cheers,
Jes

Read optional table of e820 entries from qemu_cfg

Read optional table of e820 entries through qemu_cfg, allowing QEMU to
provide the location of KVM's switch area etc. rather than rely on
hard coded values.

For now, fall back to the old hard coded values for the TSS and EPT
switch page for compatibility reasons. Compatibility code could
possibly be removed in the future.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
14 years agoInitial support for booting from USB drives.
Kevin O'Connor [Thu, 18 Feb 2010 04:24:42 +0000 (23:24 -0500)]
Initial support for booting from USB drives.

This patch adds initial support for USB Mass Storage Controllers.
This includes support for bulk transfers on UHCI controllers.
Code to detect a USB MSC device is added, and wrappers for sending
    "cdb" block commands over USB are added.
The scsi "inquiry" command is also added.

14 years agoIntroduce helper functions for finding USB end-points.
Kevin O'Connor [Thu, 18 Feb 2010 04:06:52 +0000 (23:06 -0500)]
Introduce helper functions for finding USB end-points.

Introduce findEndPointDesc() and mkendpFromDesc() and refactor usb-hid
code.

14 years agoUSB UHCI cleanups.
Kevin O'Connor [Thu, 18 Feb 2010 03:59:53 +0000 (22:59 -0500)]
USB UHCI cleanups.

Add barrier() calls before memory accesses that can be seen by controller.
Fix TD_CTRL_ANY_ERROR macro definition.
Other cleanups.

14 years agoMinor - arrange struct drive_s to clarify field roles.
Kevin O'Connor [Thu, 18 Feb 2010 03:55:36 +0000 (22:55 -0500)]
Minor - arrange struct drive_s to clarify field roles.

14 years agoFix off by one error in strtcpy.
Kevin O'Connor [Thu, 18 Feb 2010 03:49:01 +0000 (22:49 -0500)]
Fix off by one error in strtcpy.

The strtcpy function could overrun its output buffer.

14 years agoDon't require a valid physical cylinders/heads/spt for logical mapping.
Kevin O'Connor [Wed, 17 Feb 2010 06:07:36 +0000 (01:07 -0500)]
Don't require a valid physical cylinders/heads/spt for logical mapping.

Modern drives don't provide a "physical" chs report - try to detect
that and force an LBA mapping in that case.

Also, don't require setup_translation be called only on ATA drives.

14 years agoMove common "command data block" functions to new file blockcmd.c.
Kevin O'Connor [Wed, 17 Feb 2010 06:01:32 +0000 (01:01 -0500)]
Move common "command data block" functions to new file blockcmd.c.

Move common "cdb" request functions to a new file.

14 years agoDynamically allocate each drive_g with malloc_fseg().
Kevin O'Connor [Tue, 16 Feb 2010 03:48:28 +0000 (22:48 -0500)]
Dynamically allocate each drive_g with malloc_fseg().

This eliminates the limit on the number of available drives.  It also
allows for each driver to allocate additional custom fields.

14 years agoAdd *.pyc to .gitignore.
Kevin O'Connor [Tue, 16 Feb 2010 00:31:23 +0000 (19:31 -0500)]
Add *.pyc to .gitignore.

14 years agoAdd common "block command" definitions and update cdrom code.
Kevin O'Connor [Mon, 15 Feb 2010 16:56:07 +0000 (11:56 -0500)]
Add common "block command" definitions and update cdrom code.

Introduce standard definitions and names for the "command data block"
commands used in the cdrom code.

14 years agoOptimize ntohl() code.
Kevin O'Connor [Mon, 15 Feb 2010 15:46:37 +0000 (10:46 -0500)]
Optimize ntohl() code.

Use the assembler bswapl instruction if the value is not constant.

14 years agoMinor - sort ATA CMD definitions.
Kevin O'Connor [Mon, 15 Feb 2010 07:21:10 +0000 (02:21 -0500)]
Minor - sort ATA CMD definitions.

14 years agoInitial support for USB hubs.
Kevin O'Connor [Mon, 15 Feb 2010 23:58:12 +0000 (18:58 -0500)]
Initial support for USB hubs.

Add support for detecting, initializing, and enumerating USB hubs.

14 years agoMinor - increase debug level of some USB debug statements.
Kevin O'Connor [Mon, 15 Feb 2010 00:07:43 +0000 (19:07 -0500)]
Minor - increase debug level of some USB debug statements.