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>
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).
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>
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>
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.
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.
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().
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.
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.
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.
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.
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.
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().
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Kevin O'Connor [Sun, 14 Feb 2010 02:51:47 +0000 (21:51 -0500)]
Support USB interrupt schedules on OHCI and UHCI.
The existing code always checks for USB "interrupt in" events every
millisecond. Although that's okay, it consumes extra bandwidth. This
change interrupt checks to be scheduled according to their requested
interval time.
Kevin O'Connor [Sat, 13 Feb 2010 23:49:24 +0000 (18:49 -0500)]
Add some ASSERT32FLAT() to help compiler eliminate dead code.
The function pointer passed to run_thread() can confuse the compiler
into thinking the function needs to be emitted. Add ASSERT32FLAT() to
help the compiler eliminate this code.
Kevin O'Connor [Fri, 12 Feb 2010 03:32:12 +0000 (22:32 -0500)]
Support USB keyboard auto-repeat.
Support handling of multiple keys pressed simultanously.
Support auto-repeat via USB HID Set_Idle command.
Also, add "noinline" directives to reduce stack usage of timer irq.