Kevin O'Connor [Sun, 8 Feb 2009 20:44:08 +0000 (15:44 -0500)]
Reorganize boot code.
Simplify keyboard handling in post_menu.c, and move to util.c.
Move remaining functions in post_menu.c to boot.c; remove post_menu.c.
Also, remove broken check for F12 when in boot menu.
Move BEV setup code from post.c to boot.c.
Move option rom BEV adding code from optionroms.c to boot.c.
Avoid calling BX_PANIC during boot if there is an alternative.
Kevin O'Connor [Sat, 7 Feb 2009 06:21:00 +0000 (01:21 -0500)]
Minor floppy cleanups.
Determine floppy count/types during setup and store for later use.
Don't panic on controller errors - just return an error code.
In COREBOOT case - don't modify CMOS_FLOPPY_DRIVE_TYPE.
Define and use a struct for the master boot record.
Simplify cdrom emulation chs setting code.
Fix an apparent bug in harddrive chs setting - it wasn't properly
masking the spt/cyl fields.
Kevin O'Connor [Sat, 7 Feb 2009 03:36:53 +0000 (22:36 -0500)]
Cleanup ATA code; get SATA drives working on real hardware.
Simplify await_ide code.
Only check for drq/err after device reports non-bsy.
Rewrite ata reset code. Use latest spec. Add logic for resets on
slaves without a master.
Set DH register slave bit in send_cmd - so callers don't have to set it.
There is no need for an mdelay(50) after a drive change.
Do check for non-bsy before and after drive changes.
Show error register in debug messages when ERR bit is set.
Don't check for RDY bit in ata_transfer -- ATAPI devices may not set it.
Don't use signatures to detect drive type - instead issue both
IDENTIFY_DEVICE_PACKET and IDENTIFY_DEVICE, and see which succeeds.
Be sure to wait for RDY before issuing IDENTIFY_DEVICE.
Don't reset slave if reset was just done for master.
Kevin O'Connor [Fri, 6 Feb 2009 02:23:39 +0000 (21:23 -0500)]
Don't mask irqs in default hardware irq handler.
The latest PCI spec requires option roms to call default bios
handler. So, the bios must not mask irqs.
Also, make the default hw irq handlers less verbose.
Kevin O'Connor [Mon, 19 Jan 2009 20:44:44 +0000 (15:44 -0500)]
Rename MAKE_FARPTR (and similar) to MAKE_FLATPTR.
The term "far pointer" is used in many 16bit specs, and it is
different from what MAKE_FARPTR creates. So, use the term "flat
pointer" in the code to distinguish between the two meanings.
Also, use the suffix "_fl" consistently when working with "flat
pointers".
Kevin O'Connor [Sun, 18 Jan 2009 04:30:01 +0000 (23:30 -0500)]
Cleanup keyboard reset handling.
Use custom timeouts when issuing a reset.
Handle 1-byte returns from reset in ps2 code.
Do full keyboard reset even in coreboot mode.
Send set scan mode command during reset.
Kevin O'Connor [Sun, 18 Jan 2009 02:54:16 +0000 (21:54 -0500)]
Add extra test for CONFIG_ATA in src/disk.c.
All the paths to send_disk_op apparently confuses gcc into always
emitting __send_disk_op even when it can't be called. Add an
extra exlicit check to help gcc out.
Kevin O'Connor [Sun, 18 Jan 2009 01:07:09 +0000 (20:07 -0500)]
Reserve space for buffers in f-segment; don't allocate from freespace.
Define the e820list as a regular array.
Define a buffer for run-time built bios tables.
Reserving the space in advance should help prevent run-time errors
when space becomes tight.
Kevin O'Connor [Sat, 17 Jan 2009 23:49:20 +0000 (18:49 -0500)]
Move variables from assembler to C code.
Define macro VAR16FIXED for declaring a variable at a fixed location.
Introduce new file src/misc.c, and move non int15 calls from system.c
to it.
Implement all fixed location variables in C code.
Move IDT/GDT defs to misc.c. Remove unused gdt entry 1.
Kevin O'Connor [Sat, 17 Jan 2009 20:17:34 +0000 (15:17 -0500)]
Try to automatically fit sections into open spaces in the fixed area.
Enhance layoutrom.py script to find and locate sections into fixed area.
Have layoutrom.py create output file instead of using redirect from make.
Don't use freespace2 for bios tables in f segment - freespace in fixed
area is now automatically filled.
Change checkrom script to test final_code16_end instead of _start -
this improves catching of alignment errors.
Don't align gdt to 8 bytes - it causes whole section to be aligned,
which causes entry point to be misaligned.
Explicitly reserve space for variables in fixed area so that the space
for them is not auto-filled.
Kevin O'Connor [Sat, 17 Jan 2009 15:41:28 +0000 (10:41 -0500)]
Layout fixed area using linker instead of assembler.
The fixed offset requirements of the 16bit code can be done using
multiple sections and a linker script. Using the linker allows
for more flexibility.
Also, have the 16bit code generate sections for every function and
variable definition.
Kevin O'Connor [Fri, 16 Jan 2009 01:52:58 +0000 (20:52 -0500)]
Change license from GPLv3 to LGPLv3.
Change license of contributions from Kevin O'Connor from GPLv3 to
LGPLv3 (or later). Since the work as a whole is based on Kevin's
contributions and the "bochs bios" which has a license of LGPL (v2 or
later), this effectively makes the work as a whole available under
LGPLv3 (or later).
Encode lineno and return code into one u32 parameter. This reduces
the number of functions arguments to 3 - which gcc does a better
job of scheduling.
Also, consistently place *regs parameter in the first arg.
Kevin O'Connor [Fri, 2 Jan 2009 02:00:59 +0000 (21:00 -0500)]
Reduce stack usage of hw irq handlers.
Avoid using call16_int() -- it consumes too much stack space.
Instead, use a new function (call16_simpint). This assumes that
the handler wont corrupt regs - which should be a safe assumption,
because if they did corrupt regs they wouldn't work on any bios.
Avoid enabling irqs in the hw irq handlers - there are no loops in the
handlers that could cause any notable latency.
Kevin O'Connor [Wed, 31 Dec 2008 05:31:03 +0000 (00:31 -0500)]
Use new 'struct disk_op_s' to issue ata requests.
Using the struct at all callers reduces the parameter assignments.
Replace ata_op_s with new disk_op_s and update all users.
Unify basic/extended_access methods to use new send_disk_op() func.
Remove cdrom_read_emu -- integrate logic into callers.
Remove ata.h -- move all defs to disk.h
Kevin O'Connor [Wed, 31 Dec 2008 05:09:28 +0000 (00:09 -0500)]
Return CDEMU parameters to ebda segment (instead of using globals).
The cdemu is setup in the boot stage after globals are made
read-only. So, globals can't be used.
Also, move hdcount from a global to BDA (it should be in BDA).
Don't attempt to set blksize/sector count in atapi_is_ready() - it's
not useful.
Kevin O'Connor [Tue, 30 Dec 2008 01:42:40 +0000 (20:42 -0500)]
Add more linker protections around variables accessed from 16bit mode.
Rename VAR16 to VAR16_32 -- that macro supports accesses from both
16bit and 32bit mode.
Introduce a new macro VAR16 that must be present on all global
variables accessed from 16bit mode.
Kevin O'Connor [Mon, 29 Dec 2008 02:37:27 +0000 (21:37 -0500)]
Add linker magic to ensure 16bit variables aren't repeated in 32bit code.
Add VAR16 macro to enable a variable to be available in both 32bit and
16bit code. This reduces the occurrences of "#if MODE16".
Also add ASM16 macro to reduce occurrences of "#if MODE16".
Kevin O'Connor [Fri, 26 Dec 2008 18:01:23 +0000 (13:01 -0500)]
Enhance via vga hooks (based on patch from Rudolf Marek)
The VIA Unichrome and OpenChrome drivers need the memory size of
framebuffer and also the memory speed. Attept to autodetect those
values in int 0x15/5f18 handler.
Kevin O'Connor [Sat, 20 Dec 2008 18:10:00 +0000 (13:10 -0500)]
Rework default hwirq handler so there is no confusion on which pic to eoi.
Introduce two default handlers (hwpic1 and hwpic2) and register them
accordingly. This ensures the proper pic always gets an eoi.
Also, use DEBUG_ISR_hwpic1/2 to determine debugging level.
Kevin O'Connor [Fri, 19 Dec 2008 02:57:33 +0000 (21:57 -0500)]
Add initial S3 resume support.
Update ACPI DSDT tables with S3 info.
Change acpi table signatures to use integers.
Save location of rsdp table (so that S3 resume can easily find it later).
Kevin O'Connor [Wed, 17 Dec 2008 04:50:52 +0000 (23:50 -0500)]
Don't turn off apic after smp detect; use cmos for smp count on emulators.
Don't restor the APIC_SVR value - doing so confuses kvm.
When running on an emulator, get the smp count from cmos (timing on an
emulator - especially when simulating large cpu counts - is too
unreliable to do a count based on timers.)
Kevin O'Connor [Sat, 13 Dec 2008 23:33:05 +0000 (18:33 -0500)]
Cleanup of fixed space addresses.
The BIOS_CONFIG_TABLE must be aligned to 1 (or gcc may change it).
Consistently use __aligned(x) wrapper throughout C code.
Register the official fixed address handlers - even if it is only a
jump to the real handler.
Declare .type of data objects - it improves disassembler output.
Put labels at all fixed addresses - it improves disassembler output.
entry_hwirq should be calling 'cli' - use regular entry macro.
int1D is a data table, not code - so don't put an iretw there.
Kevin O'Connor [Thu, 11 Dec 2008 01:40:13 +0000 (20:40 -0500)]
Improve support for old 16bit resume handlers.
Detect a non-standard CMOS shutdown code during post and run a
separate resume handler.
Set aside space in the EBDA for the resume handler stack.
Add support for several of the code supported in bochs bios.
Kevin O'Connor [Sun, 7 Dec 2008 04:11:56 +0000 (23:11 -0500)]
Don't overwrite memory on smm init.
Save/restore memory changed during smm init - this is based on a patch
committed to bochs bios.
Also, clean up ioport and base memory address definitions for smm.
Kevin O'Connor [Sun, 7 Dec 2008 00:37:56 +0000 (19:37 -0500)]
Execute smp detect code in place instead of copying it.
Compile the smp detect handler with the rest of the 16bit code.
Implement a simple ljmpw trampoline so the main code can run in place.
Restore memory afterwards to prevent memory corruption.
Kevin O'Connor [Sat, 6 Dec 2008 23:56:19 +0000 (18:56 -0500)]
Makefile cleanups.
Don't assemble romlayout16.S with debugging on - gcc gets confused
when multiple files with debugging are included.
Be more consistent in status messages.
Use ccode instead of blob/romlayout32 -- it's more accurate.
Kevin O'Connor [Sat, 6 Dec 2008 16:57:45 +0000 (11:57 -0500)]
Add additional PCI option rom checks.
PCI_ROM_ADDRESS is only valid for PCI_HEADER_TYPE_NORMAL devices.
Don't attempt to run a rom with address less than 16MiB.
Don't run roms for IDE code when native IDE support is available.
Also, move hardcode option rom defs to config.h.
Also, add some minor code cleanups.
Kevin O'Connor [Fri, 5 Dec 2008 00:39:10 +0000 (19:39 -0500)]
Don't allow start_bdf with new auto max bus detection code.
It's not valid to set a "start bdf" when search for a device now,
because we wont be able to properly detect the maximum bus unless
we start at the beginning.
Change callers that need to resume a search to use foreachpci() macro.
Update all callers so that they don't pass in the now unused start_bdf.
Kevin O'Connor [Sun, 30 Nov 2008 01:39:06 +0000 (20:39 -0500)]
Enance support for PCI option roms.
Scan for the PCI option rom structure on each PCI card.
Support multiple images in an option rom.
Don't map to area just above memory - assume card is already
programmed with a valid address.
Kevin O'Connor [Sun, 30 Nov 2008 01:31:49 +0000 (20:31 -0500)]
Only touch PCI functions > 0 on multi-function devices; rescan max pci each time.
Some single-function devices will respond to all sub-functions - and
this confuses things. So, when scanning the PCI bus make sure to
only touch function 0 on single-function devices.
Since the bus scanning code is necessarily complex now, we might as
well implement max bus detection inline with all pci scans. So,
there is no need to scan for the max bus at startup.
Kevin O'Connor [Fri, 28 Nov 2008 16:56:37 +0000 (11:56 -0500)]
Fix bug - bios writes must be enabled before max PCI bus detected.
The max pci bus is stored in the bios segment, so it must be writable.
So, use a default max size (1 pci bus) for the initial write enable
device scan and then do the full max bus check after write is
enabled.
Kevin O'Connor [Wed, 26 Nov 2008 22:02:43 +0000 (17:02 -0500)]
Enable a default hw irq handler.
Also, only route hw irqs to their handlers when they are enabled.
(This ensures that if a subsystem is disabled that the default
hwirq handler will be used.)
Add helper macros to declare the extern asm handlers.
Always enable the RTC hwirq at startup (as opposed to when it is first
used).
Fix bug in default handler - wrong bit was used for checking the
cascaded irq.
Kevin O'Connor [Sun, 16 Nov 2008 14:17:02 +0000 (09:17 -0500)]
Cleanup a20 code.
Fix two apparent bugs - set_a20() returned new status instead of old
status and handle_152402() checked wrong bit.
Add bit definition for the a20 enable bit: A20_ENABLE_BIT
Allow ioport.h #defines to be used in romlayout.S.