seabios.git
15 years agoFix RTC UIP timing.
Kevin O'Connor [Mon, 16 Feb 2009 15:14:10 +0000 (10:14 -0500)]
Fix RTC UIP timing.

The "Update In Progress" bit can be set for up to 2.2ms, so wait for
    up to 3ms for it to clear.

15 years agoMinor - change checksum functions to take a (void *).
Kevin O'Connor [Sun, 15 Feb 2009 20:21:10 +0000 (15:21 -0500)]
Minor - change checksum functions to take a (void *).

This reduces the casts in calling code.

15 years agoAllow ctrl+alt+delete to work when no boot device found.
Kevin O'Connor [Sun, 15 Feb 2009 18:45:48 +0000 (13:45 -0500)]
Allow ctrl+alt+delete to work when no boot device found.

Don't panic (that turns off irqs), instead spin with irqs enabled.

15 years agoClock cleanups.
Kevin O'Connor [Sun, 15 Feb 2009 18:02:56 +0000 (13:02 -0500)]
Clock cleanups.

Reset the RTC registers at boot time.
Add definitions for the RTC register bits and use consistently.
Don't use CMOS_CENTURY value on coreboot.
Minor - when waiting on the TSC wait until counter is greater than
    desired value (not greater than or equal).

15 years agoEnhance cdrom capacity/media sensing timers.
Kevin O'Connor [Fri, 13 Feb 2009 01:47:59 +0000 (20:47 -0500)]
Enhance cdrom capacity/media sensing timers.

Don't just loop 50/300 times for 5/30 seconds - use real timers.
Reorganize code - move read capacity to its own function.
Fix apparent bug - atapi_get_sense() returns zero on success.

15 years agoAdd common ata identify sequence; improve debugging.
Kevin O'Connor [Thu, 12 Feb 2009 03:46:29 +0000 (22:46 -0500)]
Add common ata identify sequence; improve debugging.

Use a single path to set variables from the identify commands.
Report contents of word0 and word2 in debug level 3.
Only show drive mappings at debug level 3.

15 years agoMinor - ata identify commands should use a u16 buffer (not u8).
Kevin O'Connor [Thu, 12 Feb 2009 03:22:15 +0000 (22:22 -0500)]
Minor - ata identify commands should use a u16 buffer (not u8).

15 years agoDon't overflow ATA.channels array on machines with > 4 controllers.
Kevin O'Connor [Thu, 12 Feb 2009 01:16:49 +0000 (20:16 -0500)]
Don't overflow ATA.channels array on machines with > 4 controllers.

15 years agoAdd support for selecting harddrive order in boot menu.
Kevin O'Connor [Mon, 9 Feb 2009 00:43:47 +0000 (19:43 -0500)]
Add support for selecting harddrive order in boot menu.

Save ATA harddrive model name so that it can be shown from menu.
Minor - use "ata0-1" not "ata0 slave".
Fill fdpt info based on BIOS drive id - not the controller id.
Add BCV support to IPL code.
Use "BCV" system to set harddrive order (for both ata and option roms).
Also, don't show floppy/cdrom in boot menu if no drives found.

15 years agoIncrease default CONFIG_MAX_BIOSTABLE setting.
Kevin O'Connor [Sun, 8 Feb 2009 22:10:48 +0000 (17:10 -0500)]
Increase default CONFIG_MAX_BIOSTABLE setting.

In an smp simulation, the smbios/mptable need more space than was allocated.

15 years agoMinor - rename BX_PANIC to panic.
Kevin O'Connor [Sun, 8 Feb 2009 22:07:29 +0000 (17:07 -0500)]
Minor - rename BX_PANIC to panic.

15 years agoSimplify boot code.
Kevin O'Connor [Sun, 8 Feb 2009 21:57:22 +0000 (16:57 -0500)]
Simplify boot code.

Make sure every IPL entry has a description.
Remove output printing helpers - have each caller output what they want.
Add strtcpy function to ensure descriptions don't go over 32 characters.
Breakup code to launch each IPL entry to its own function.

15 years agoReorganize boot code.
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.

15 years agoMinor - remove permanent_halt function.
Kevin O'Connor [Sat, 7 Feb 2009 18:25:25 +0000 (13:25 -0500)]
Minor - remove permanent_halt function.

The only caller is now in the 0xf0000 segment - so no need for it.

15 years agoMore floppy code cleanups.
Kevin O'Connor [Sat, 7 Feb 2009 16:25:29 +0000 (11:25 -0500)]
More floppy code cleanups.

Reorganize code slightly to improve readability.

15 years agoMinor floppy cleanups.
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.

15 years agoIntroduce MBR struct; simplify cdrom emulation code.
Kevin O'Connor [Sat, 7 Feb 2009 05:04:57 +0000 (00:04 -0500)]
Introduce MBR struct; simplify cdrom emulation code.

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.

15 years agoSuppress initialized variable compile warning in ata.c.
Kevin O'Connor [Sat, 7 Feb 2009 05:03:11 +0000 (00:03 -0500)]
Suppress initialized variable compile warning in ata.c.

15 years agoCleanup ATA code; get SATA drives working on real hardware.
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.

15 years agoDon't mask irqs in default hardware irq handler.
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.

15 years agoAdd pci_to_bdf() helper function.
Kevin O'Connor [Fri, 6 Feb 2009 02:16:39 +0000 (21:16 -0500)]
Add pci_to_bdf() helper function.

This function is useful when setting the OPTIONROM_BDF_1/2 defs.

15 years agoUpdates to README file.
Kevin O'Connor [Fri, 6 Feb 2009 01:32:41 +0000 (20:32 -0500)]
Updates to README file.

15 years agoMake sure to clear global variables before use.
Kevin O'Connor [Fri, 6 Feb 2009 00:51:12 +0000 (19:51 -0500)]
Make sure to clear global variables before use.

On reset, the global variables may not be zero - so zero them explicitly.

15 years agoTODO list updates.
Kevin O'Connor [Fri, 6 Feb 2009 00:35:11 +0000 (19:35 -0500)]
TODO list updates.

15 years agoDon't declare a handler for int 0x1c - the default handler is sufficient.
Kevin O'Connor [Fri, 30 Jan 2009 01:35:34 +0000 (20:35 -0500)]
Don't declare a handler for int 0x1c - the default handler is sufficient.

15 years agoEnhance makefile to autodetect if AVOIDCOMBINE is needed.
Kevin O'Connor [Sun, 25 Jan 2009 21:11:27 +0000 (16:11 -0500)]
Enhance makefile to autodetect if AVOIDCOMBINE is needed.

15 years agoMinor - use a struct when working with pcibios 1ab10e param.
Kevin O'Connor [Thu, 22 Jan 2009 00:14:49 +0000 (19:14 -0500)]
Minor - use a struct when working with pcibios 1ab10e param.

15 years agoMinor enhancement - kbd reset should set 0x1234 in BDA reset flag.
Kevin O'Connor [Thu, 22 Jan 2009 00:14:20 +0000 (19:14 -0500)]
Minor enhancement - kbd reset should set 0x1234 in BDA reset flag.

15 years agoFix apparent bug in int1348 -- checksum didn't have regs->si offset.
Kevin O'Connor [Thu, 22 Jan 2009 00:13:21 +0000 (19:13 -0500)]
Fix apparent bug in int1348 -- checksum didn't have regs->si offset.

15 years agoMinor - call16 should not assume %cs==SEG_BIOS.
Kevin O'Connor [Tue, 20 Jan 2009 00:56:07 +0000 (19:56 -0500)]
Minor - call16 should not assume %cs==SEG_BIOS.

Should be slightly more compatible with protected mode accesses.

15 years agoImplement memcpy_far and checksum_far, and replace _fl variants.
Kevin O'Connor [Tue, 20 Jan 2009 00:25:21 +0000 (19:25 -0500)]
Implement memcpy_far and checksum_far, and replace _fl variants.

The "flat" mode variants work in real mode, but will not work in
    protected mode.  So, replace with versions that take explicit
    segments.

15 years agoAllow GET/SET_SEG asm to access memory or a register.
Kevin O'Connor [Mon, 19 Jan 2009 22:58:54 +0000 (17:58 -0500)]
Allow GET/SET_SEG asm to access memory or a register.

This is a minor optimization that can improve gcc code generation.

15 years agoRename MAKE_FARPTR (and similar) to MAKE_FLATPTR.
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".

15 years agoMinor - streamline SET_GLOBAL macro - reduce #if usage.
Kevin O'Connor [Mon, 19 Jan 2009 20:33:49 +0000 (15:33 -0500)]
Minor - streamline SET_GLOBAL macro - reduce #if usage.

15 years agoMinor - always set %esp immediately after setting %ss.
Kevin O'Connor [Mon, 19 Jan 2009 18:29:36 +0000 (13:29 -0500)]
Minor - always set %esp immediately after setting %ss.

Setting %ss/%esp in sequence is guaranteed to be atomic.  So, always
    set them in this order to ensure irqs and nmis see a consistent
    stack.

15 years agoMinor - improve space used reporting in tools/layoutrom.py.
Kevin O'Connor [Mon, 19 Jan 2009 18:00:42 +0000 (13:00 -0500)]
Minor - improve space used reporting in tools/layoutrom.py.

The used space calculation was slightly wrong in cases of non-zero
    section alignment.  Redo calculation using a more straight-forward
    approach.

15 years agoFix apparent bug in 16bit resume code.
Kevin O'Connor [Mon, 19 Jan 2009 17:53:54 +0000 (12:53 -0500)]
Fix apparent bug in 16bit resume code.

The BDA offsets were adding in 0x400 twice.
Also, use lss insn instead of manually setting %ss and %sp.
Also, don't force segment value into %eax.

15 years agoFix apparent bug in pci bios handle_1ab10e function.
Kevin O'Connor [Mon, 19 Jan 2009 17:53:10 +0000 (12:53 -0500)]
Fix apparent bug in pci bios handle_1ab10e function.

The PIR entry copy was copying the header instead of the slots.

15 years agoCleanup ps2 port reset handling.
Kevin O'Connor [Sun, 18 Jan 2009 17:54:51 +0000 (12:54 -0500)]
Cleanup ps2 port reset handling.

Separate out reset code - it has special timeouts throughout.

15 years agoCleanup keyboard reset handling.
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.

15 years agoAdd extra test for CONFIG_ATA in src/disk.c.
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.

15 years agoAdd CONFIG_S3_RESUME to control support for S3 resume.
Kevin O'Connor [Sun, 18 Jan 2009 02:52:52 +0000 (21:52 -0500)]
Add CONFIG_S3_RESUME to control support for S3 resume.

15 years agoDon't assume __call16_from32 and __call16 are linear in romlayout.S.
Kevin O'Connor [Sun, 18 Jan 2009 01:57:11 +0000 (20:57 -0500)]
Don't assume __call16_from32 and __call16 are linear in romlayout.S.

The rom layouts can be dynamic, so don't try to "fall through" to the
    next function.

15 years agoFix minor bug in ps2port.c - can't check for -1 with unsigned return type.
Kevin O'Connor [Sun, 18 Jan 2009 01:17:47 +0000 (20:17 -0500)]
Fix minor bug in ps2port.c - can't check for -1 with unsigned return type.

15 years agoReserve space for buffers in f-segment; don't allocate from freespace.
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.

15 years agoMinor - don't force align the 32 bss.
Kevin O'Connor [Sun, 18 Jan 2009 00:42:31 +0000 (19:42 -0500)]
Minor - don't force align the 32 bss.

The sections already carry their required alignment - the force align
    is a leftover from past code.

15 years agoPut each assembler function into its own section.
Kevin O'Connor [Sun, 18 Jan 2009 00:37:26 +0000 (19:37 -0500)]
Put each assembler function into its own section.

Don't manually place assembler functions into the fixed area - allow
    the layout script to do it.

15 years agoHave layoutrom.py show info on utilization of fixed area.
Kevin O'Connor [Sun, 18 Jan 2009 00:35:10 +0000 (19:35 -0500)]
Have layoutrom.py show info on utilization of fixed area.

Also, try harder to fit sections with alignment greater than 1.

15 years agoMove variables from assembler to C code.
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.

15 years agoRemove some unused IRQ_TRAMPOLINE definitions.
Kevin O'Connor [Sat, 17 Jan 2009 20:23:19 +0000 (15:23 -0500)]
Remove some unused IRQ_TRAMPOLINE definitions.

15 years agoTry to automatically fit sections into open spaces in the fixed area.
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.

15 years agoLayout fixed area using linker instead of assembler.
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.

15 years agoMisc fixes.
Kevin O'Connor [Sat, 17 Jan 2009 07:30:21 +0000 (02:30 -0500)]
Misc fixes.

The pnp bios string can't be const and VAR16_32.
Show ps2 port status when discarding data.

15 years agoChange license from GPLv3 to LGPLv3.
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).

15 years agoInitial KVM support.
Kevin O'Connor [Mon, 5 Jan 2009 02:48:22 +0000 (21:48 -0500)]
Initial KVM support.

Add some of the enhancements KVM has to their bochs bios tree.  This
    is only partial support for KVM - some features still do not work
    correctly.

15 years agoMake sure ps2 port command reads are from the desired device.
Kevin O'Connor [Sun, 4 Jan 2009 17:20:02 +0000 (12:20 -0500)]
Make sure ps2 port command reads are from the desired device.

Discard reads from real-time events or from a different device.
Also, improve the kbd/mouse diagnostic messages.

15 years agoSilence the strict-aliasing warnings that older compilers emit.
Kevin O'Connor [Sun, 4 Jan 2009 16:15:36 +0000 (11:15 -0500)]
Silence the strict-aliasing warnings that older compilers emit.

15 years agoDon't define bda as a macro in resume.c - it confuses AVOIDCOMBINE mode.
Kevin O'Connor [Sat, 3 Jan 2009 04:35:23 +0000 (23:35 -0500)]
Don't define bda as a macro in resume.c - it confuses AVOIDCOMBINE mode.

When using AVOIDCOMBINE, macros can have global scope.  This caused
    the bda macro in resume.c to conflict with the bda variable in
    post.c.

15 years agoThe BDA is at segment 0x0040 not 0x0000.
Kevin O'Connor [Fri, 2 Jan 2009 19:19:43 +0000 (14:19 -0500)]
The BDA is at segment 0x0040 not 0x0000.

The interrupt vector table is technically at 0x0000.

15 years agoImprove set_code_fail/floppy_ret/disk_ret code generation.
Kevin O'Connor [Fri, 2 Jan 2009 18:10:58 +0000 (13:10 -0500)]
Improve set_code_fail/floppy_ret/disk_ret code generation.

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.

15 years agoFix bug in basic_access error path.
Kevin O'Connor [Fri, 2 Jan 2009 17:36:46 +0000 (12:36 -0500)]
Fix bug in basic_access error path.

A missing 'return' statement caused the error to not be returned.

15 years agoReduce stack usage of hw irq handlers.
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.

15 years agoSwitch to new stack when calling ATA function in 16bit mode.
Kevin O'Connor [Thu, 1 Jan 2009 23:31:11 +0000 (18:31 -0500)]
Switch to new stack when calling ATA function in 16bit mode.

This reduces stack usage (old dos programs don't provide much space).

15 years agoTune gcc stack growth parameter.
Kevin O'Connor [Thu, 1 Jan 2009 22:54:16 +0000 (17:54 -0500)]
Tune gcc stack growth parameter.

Use 4 instead of 8 -- latest gcc isn't doing tail-recursion
    optimizations on disk functions due to stack growth.

15 years agoUse new 'struct disk_op_s' to issue ata requests.
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

15 years agoReturn CDEMU parameters to ebda segment (instead of using globals).
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.

15 years agoIntroduce GET/SET_EBDA2() macros - they take a cached ebda seg.
Kevin O'Connor [Tue, 30 Dec 2008 02:16:31 +0000 (21:16 -0500)]
Introduce GET/SET_EBDA2() macros - they take a cached ebda seg.

For those places that repeatedly read/write to the ebda, caching the
    ebda segment improves code generation.

15 years agoAdd more linker protections around variables accessed from 16bit mode.
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.

15 years agoMove IPL definitions from ebda to global variables.
Kevin O'Connor [Mon, 29 Dec 2008 04:43:20 +0000 (23:43 -0500)]
Move IPL definitions from ebda to global variables.

The boot sequence variable remains in ebda.
Move boot specific definitions to a new header (boot.h)

15 years agoMove most of ATA and CDEMU from ebda to global variables.
Kevin O'Connor [Mon, 29 Dec 2008 04:18:57 +0000 (23:18 -0500)]
Move most of ATA and CDEMU from ebda to global variables.

The dpte, cdrom locks, and disk sector count remain in the ebda.
Also, enhance SET_GLOBAL macro to avoid unused variable warnings.

15 years agoMove ram size definitions from ebda to global variables.
Kevin O'Connor [Mon, 29 Dec 2008 03:03:17 +0000 (22:03 -0500)]
Move ram size definitions from ebda to global variables.

15 years agoMove pir table offset from ebda to a global variable.
Kevin O'Connor [Mon, 29 Dec 2008 02:50:29 +0000 (21:50 -0500)]
Move pir table offset from ebda to a global variable.

Also, make sure the pir table is defined with the 16bit code.

15 years agoAdd linker magic to ensure 16bit variables aren't repeated in 32bit code.
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".

15 years agoSupport a relocatable ebda segment.
Kevin O'Connor [Sat, 27 Dec 2008 04:50:17 +0000 (23:50 -0500)]
Support a relocatable ebda segment.

Some option roms will try to relocate the ebda.
Also fix an apparent typo in the assignment of ivecs[0x46].

15 years agoEnhance via vga hooks (based on patch from Rudolf Marek)
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.

15 years agoInitial PnP bios call support.
Kevin O'Connor [Sun, 21 Dec 2008 22:51:36 +0000 (17:51 -0500)]
Initial PnP bios call support.

This commit provides just enough PnP support for gPXE to not hook int19.

15 years agoFix bug in dequeue_key() refactor.
Kevin O'Connor [Sun, 21 Dec 2008 22:38:37 +0000 (17:38 -0500)]
Fix bug in dequeue_key() refactor.

Clearing of Z_FL occurs on the !incr path.

15 years agoSupport multiple BCVs in a single option rom.
Kevin O'Connor [Sun, 21 Dec 2008 04:32:16 +0000 (23:32 -0500)]
Support multiple BCVs in a single option rom.

15 years agoRework default hwirq handler so there is no confusion on which pic to eoi.
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.

15 years agoMake sure to manually export s3_resume() for old buggy gcc versions.
Kevin O'Connor [Fri, 19 Dec 2008 21:48:20 +0000 (16:48 -0500)]
Make sure to manually export s3_resume() for old buggy gcc versions.

15 years agoAdd initial S3 resume support.
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).

15 years agoMake sure %ss==%ds in resume handler call.
Kevin O'Connor [Fri, 19 Dec 2008 02:56:41 +0000 (21:56 -0500)]
Make sure %ss==%ds in resume handler call.

Also, rearrange the layout in the fixed area to make more room in post area.

15 years agoUse rtc for keyboard delay instaed of tsc.
Kevin O'Connor [Wed, 17 Dec 2008 04:51:35 +0000 (23:51 -0500)]
Use rtc for keyboard delay instaed of tsc.

The rtc is likely more accurate on emulators.
Also, this allows interrupts to trigger normally while waiting the 2.5
    seconds.

15 years agoDon't turn off apic after smp detect; use cmos for smp count on emulators.
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.)

15 years agoRefactor dequeue_key() in keyboard code.
Kevin O'Connor [Wed, 17 Dec 2008 04:47:37 +0000 (23:47 -0500)]
Refactor dequeue_key() in keyboard code.

All 4 callers of dequeue_key are very similar - move the redundant
    logic into dequeue_key() itself.

15 years agoDefine and consistently use BUILD_APIC_ADDR and BUILD_IOAPIC_ADDR.
Kevin O'Connor [Sun, 14 Dec 2008 15:11:45 +0000 (10:11 -0500)]
Define and consistently use BUILD_APIC_ADDR and BUILD_IOAPIC_ADDR.

15 years agoCleanup of fixed space addresses.
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.

15 years agoImplement GET/SET_GLOBAL(...) instead of using GET/SET_VAR(CS, ...)
Kevin O'Connor [Sat, 13 Dec 2008 16:10:37 +0000 (11:10 -0500)]
Implement GET/SET_GLOBAL(...) instead of using GET/SET_VAR(CS, ...)

15 years agoImplement time based checks even when looping on an ioport.
Kevin O'Connor [Sat, 13 Dec 2008 15:45:50 +0000 (10:45 -0500)]
Implement time based checks even when looping on an ioport.

Implement real timeout code in ATA.
Implement real timeout code for RTC updating check.

15 years agoMinor - don't call smm_init() from init_bios_tables()
Kevin O'Connor [Thu, 11 Dec 2008 02:01:00 +0000 (21:01 -0500)]
Minor - don't call smm_init() from init_bios_tables()

smm is a system feature, not a memory table.

15 years agoVarious minor comment updates.
Kevin O'Connor [Thu, 11 Dec 2008 01:53:35 +0000 (20:53 -0500)]
Various minor comment updates.

15 years agoFix boot when CONFIG_CDROM_BOOT is disabled.
Kevin O'Connor [Thu, 11 Dec 2008 01:52:09 +0000 (20:52 -0500)]
Fix boot when CONFIG_CDROM_BOOT is disabled.

15 years agoImprove support for old 16bit resume handlers.
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.

15 years agoDon't overwrite memory on smm init.
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.

15 years agoExecute smp detect code in place instead of copying it.
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.

15 years agoMakefile cleanups.
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.

15 years agoCall option roms in "big real mode".
Kevin O'Connor [Sat, 6 Dec 2008 18:03:52 +0000 (13:03 -0500)]
Call option roms in "big real mode".

15 years agoAdd additional PCI option rom checks.
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.

15 years agoDon't allow start_bdf with new auto max bus detection code.
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.

15 years agoOnly support IDE devices with pci class of PCI_CLASS_STORAGE_IDE.
Kevin O'Connor [Fri, 5 Dec 2008 00:22:49 +0000 (19:22 -0500)]
Only support IDE devices with pci class of PCI_CLASS_STORAGE_IDE.

Devices of class PCI_CLASS_STORAGE_OTHER may work with some devices,
    but they are just as likely to cause a crash with other devices.