Kevin O'Connor [Sun, 20 Sep 2009 19:33:08 +0000 (15:33 -0400)]
Support sleeping until an irq fires, and use where applicable.
Add wait_irq() - it's more efficient than looping with cpu_relax().
Also, move kbd irq enables down - only kbd_command needs it.
Also, make some minor code layout improvements to kbd.c.
Kevin O'Connor [Sat, 12 Sep 2009 23:35:04 +0000 (19:35 -0400)]
Unify cd emulation access and main disk access code.
Add a new backend driver for cd emulation (DTYPE_CDEMU). This backend
driver now does the work of scheduling mis-sized reads.
Add mechanism for obtaining emulated drive geometry.
Extend disk_1308() to support cdrom emulation.
Use regular disk_13*() calls even for cdemu.
Also, unify the X_SECTOR_SIZE definitions.
Kevin O'Connor [Sat, 12 Sep 2009 17:20:14 +0000 (13:20 -0400)]
Add mechanism for describing internal drives in boot menu.
Allow each drive type to describe itself on the boot menu.
This fixes a bug where driveid was used in place of ataid in the boot
menu.
Also, expand descriptions for each drive type.
Don't overload the IPL type for BCVs - instead introduce new types.
Kevin O'Connor [Sun, 30 Aug 2009 23:31:22 +0000 (19:31 -0400)]
Ramdisk cleanups.
Use malloc code to allocate space for floppy image instead of
searching e820 map - this prevents a possible conflict with memory
allocated by pmm.
Check int 1587 return code.
Kevin O'Connor [Sun, 23 Aug 2009 15:56:55 +0000 (11:56 -0400)]
Add defines for floppy constants.
Add defines for several of the codes used in floppy.c.
Also, actually send the gap length in the floppy commands.
Also, adjust count in floppy_cmd instead of all callers.
Kevin O'Connor [Wed, 19 Aug 2009 02:38:49 +0000 (22:38 -0400)]
Merge cdrom 13xx handlers with main disk 13xx handlers.
Most of the cdrom_13 code did the same thing as disk_13 - so merge
them together.
Add definitions for 0xe0 (EXTSTART_CD) and 0x80 (EXTSTART_HD).
This changes the behavior for cdroms on 1315 and 1316 calls -
previously 1315 returned an error and set ah=2, now it sets ah=1
and doesn't return an error; previously 1316 returned ok, not it
returns EPARAM.
Kevin O'Connor [Mon, 17 Aug 2009 01:59:40 +0000 (21:59 -0400)]
Add support for using floppy images in CBFS.
Add new "ramdisk" type for disk accesses.
Extract out high-mem finding code from pmm into find_high_area().
Fix bug in GDB_BASE and GDT_LIMIT macros (wrong bit shifts).
Kevin O'Connor [Sun, 16 Aug 2009 16:21:44 +0000 (12:21 -0400)]
Enhance boot menu to allow selection of floppy to boot from.
The bootmenu can now reorder the first floppy drive.
Note - only the drive mapping is changed - floppy variables in the BDA
are still set depending on the real floppy index.
Kevin O'Connor [Sun, 16 Aug 2009 16:09:44 +0000 (12:09 -0400)]
Add floppy controllers to "drives" list also.
The Drives.drives list now contains floppies, harddrives, and cdroms.
Add mapping table for external/internal drive ids for floppies.
Rename CONFIG_FLOPPY_SUPPORT to CONFIG_FLOPPY (for consistency).
Be consistent with "driveid" and "floppyid" variable names.
Replace switch statements of drive parameters into a global array.
There are some externally visible changes with this patch:
- Some calls will now return EPARAM instead of ETIMEOUT (or ECHANGED)
- floppy_1301/1308 are now only available when regs->dl is valid
- floppy_1308/1315 return EPARAM on invalid drives
Kevin O'Connor [Wed, 12 Aug 2009 01:59:37 +0000 (21:59 -0400)]
Separate ATA code from generic disk code.
Move generic code from ata.c to new file block.c.
Rename atabits.h to ata.h and move ata header definitions from disk.h.
Rename ATA.channels to ATA_channels.
Rename ATA structure to Drives.
Support both CONFIG_DRIVES and CONFIG_ATA options.
Kevin O'Connor [Wed, 12 Aug 2009 00:43:38 +0000 (20:43 -0400)]
Densely populate ATA.devices list.
Populate ATA.devices in order of drives found; the array index no
longer correlates with the ATA.channels list.
Add cntl_id to device struct for finding the channel info.
Kevin O'Connor [Mon, 10 Aug 2009 04:06:37 +0000 (00:06 -0400)]
Misc ATA cleanups.
Remove some unused defines.
Rename ATA_TYPE_* to DTYPE_* and move from atabits.h to disk.h.
Rename ATA_TRANSLATION_* to TRANSLATION_* and move from atabits.h to disk.h.
Convert bios is-drive-ready call to use send_disk_op().
Only add atapi devices to the cdmap if they are cd/dvd roms.
Remove 'device' from struct ata_devices_s.
Kevin O'Connor [Sun, 9 Aug 2009 23:17:11 +0000 (19:17 -0400)]
Route disk_op commands by drive type - not by command.
Don't confuse op->command with low-level ata cmd->command.
Modify __send_disk_op to route commands by drive type.
Add commands for verify and seek operations.
Do ata resets via disk_op also.
Kevin O'Connor [Sun, 9 Aug 2009 22:06:40 +0000 (18:06 -0400)]
Remove unused cdemu ATA code.
Remove the low-level ATA code for short reads on cdroms now that cd
emulation is done at higher-level.
Also, remove sector_count from ebda - ata code updates op->count now.
Kevin O'Connor [Sun, 9 Aug 2009 21:25:19 +0000 (17:25 -0400)]
Implement cdrom disk emulation at high-level instead of in low-level ATA.
Add a 2K buffer to the ebda to allow for cdrom 512 byte vs 2048 byte
sector emulation.
For unaliagned cdemu reads, just make multiple cdrom reads instead of
using ata specific code for short reads.
Also, define cdemu virtual sectors using struct chs_s, and update
legacy_lba() func to take pointer to a chs_s struct.
Kevin O'Connor [Sun, 9 Aug 2009 17:08:21 +0000 (13:08 -0400)]
Separate cdemu disk accesses from regular disk accesses.
Breakup basic_access() into basic_access, cdemu_access, and legacy_lba.
Also, check for verify and seek calls in __send_disk_op instead of all
callers.
Also, send_disk_op returns sector count in dop.count instead of via ebda.
Kevin O'Connor [Sun, 9 Aug 2009 15:32:00 +0000 (11:32 -0400)]
Use regular CD reading to load initial CDROM boot image.
Use cdrom_read() instead of cdrom_read_512() for loading the initial
image. The initial image will always start on a 2K block, and it
should be okay to load extra sectors if the sector count doesn't
end on a 2K boundary.
Kevin O'Connor [Sun, 2 Aug 2009 16:33:58 +0000 (12:33 -0400)]
Fix some PMM corner-cases.
Make sure not to divide by zero when calculating usage percent in
debug messages.
Make sure high memory zones are aligned; make sure zone is big enough
even after loss due to alignment.
Be sure to reset ZoneTmpHigh and PMMAllocs on failure paths.
Fix corner case in pmm_free() where an allocation might not get freed
due to ordering of pmmalloc_s structs.
Kevin O'Connor [Sat, 1 Aug 2009 15:45:37 +0000 (11:45 -0400)]
Add Post Memory Manager (PMM) support.
Complete the initial implementation of PMM.
Default new PMM code to be enabled.
Move malloc code from memmap.c to pmm.c.
Define new malloc zones for PMM (ZoneTmpLow and ZoneTmpHigh).
Change default READ/WRITE_SEG macros to use 32bit pointers (the 16bit
PMM code use "big real" mode and requires 32bit accesses).
Allow pmm allocations to occur during bcv executions also.
Add low-memory clearing before boot.
Also, align the default f-seg memory.
Kevin O'Connor [Wed, 29 Jul 2009 23:20:03 +0000 (19:20 -0400)]
mptable and madt irq override
Implement irq override support for timer interrupts. This matches what
QEMU+BOCHS has been doing for the latest 8 months, and is also what
real hardware does.
Kevin O'Connor [Wed, 29 Jul 2009 00:46:03 +0000 (20:46 -0400)]
Fix coreboot bios table copying by delaying to after memory scan.
Delay coreboot bios table scan after memory scan and malloc setup is
complete.
Also, fix sign underflow in malloc memory available check.
Add check to ensure high bios area is big enough for zone.
Add more debug info to malloc setup/finalize.
Kevin O'Connor [Sun, 26 Jul 2009 23:16:09 +0000 (19:16 -0400)]
Add support for enabling ram in 0xc0000-0xf0000 area.
Enhance shadow ram support to enable read/write of option rom area.
This enables support for option roms that modify themselves.
Support copying the roms before enabling shadowing, to work around the
qemu implementation of ram shadowing.
Rename next_rom to RomEnd and export it.
Support locking ram being used for optionroms before booting.
Don't bother and'ing/or'ing 0x59 register - it's usage is well defined.
Kevin O'Connor [Sat, 25 Jul 2009 17:48:27 +0000 (13:48 -0400)]
Add malloc_high/fseg() and rework bios table creation to use them.
Add malloc like functions for memory management instead of open-coding
memory reservation in all callers.
Add ability for unused high ram to be returned for general purpose use.
Break up acpi table creation into multiple functions.
Also, move smbios tables into high ram (instead of f-segment).
Kevin O'Connor [Sat, 25 Jul 2009 01:49:26 +0000 (21:49 -0400)]
When enabling write access to 0xf0000, just copy from 0xffff0000.
Instead of copying the bios to temp space and then copying back to
0xf0000, just copy from the permanent location at 0xffff0000.
This should make startup slightly faster.
Kevin O'Connor [Sun, 19 Jul 2009 22:52:46 +0000 (18:52 -0400)]
Expand int155f "vgahook" detection.
Verify VGA card vendor is via before supporting via 155f calls.
Add support for future code depending on coreboot board id.
Add code for via VX855 memory size and speed detection.
Kevin O'Connor [Tue, 14 Jul 2009 00:29:07 +0000 (20:29 -0400)]
Cleanup serial and lpt timers.
Separate out the 18.2Hz timer check into its own code.
Cleanup serial return codes.
Use a real timers for lpt port.
Replace lpt "nop" call with udelay(5).
Move irq_enable() into calls that need it.
Kevin O'Connor [Sat, 4 Jul 2009 17:46:33 +0000 (13:46 -0400)]
Use "p->sum -= checksum()" style for setting checksums.
Some code cleared the original checksum and then calculated a new one,
others manipulated the checksum range to not include the old
checksum. However, this was error prone - use the "-=" syntax
consistently to reduce possible errors.
Kevin O'Connor [Sat, 4 Jul 2009 08:04:36 +0000 (04:04 -0400)]
Optionrom code cleanup.
Nearly all calers of callrom() use OPTION_ROM_INITVECTOR - make it
default.
Prefer (void*) to explicit casts.
Rename init_optionrom to init_pcirom; rename verifysize_optionrom to
init_optionrom.
Add 'isvga' parameter to init_optionrom/init_pcirom; unify vga call
path to use these functions.
Extract cbfs directory scanning into new function run_cbfs_roms().
Allow roms in "vgaroms/" to run even if no pci vga device exists.
Comment improvements.
Kevin O'Connor [Sun, 21 Jun 2009 13:10:28 +0000 (09:10 -0400)]
Forward port bochs smp changes; rename smpdetect.c to smp.c.
Rename smpdetect.c to smp.c - the code does more than just cpu detection.
Don't probe cpu count on demand - schedule it during post.
Add logic to run wrmsr on all cpus.
Don't make mtrr setup specific to kvm - do it on all machines that
have mtrr and msrs.
Detect cpu signature/features automatically in mptable.
Also, make sure acpi structures are packed.
Kevin O'Connor [Tue, 16 Jun 2009 03:03:05 +0000 (23:03 -0400)]
Unify mode16/32 compiler checks.
Add ASSERT16/ASSERT32 macros to farptr.h.
Use those macros in place of open-coded checks.
Add "noreturn" attribute to functions to reduce compiler warnings.
Add ASSERT32 to smp_probe() to eliminate 16bit assembler warnings.
Kevin O'Connor [Thu, 11 Jun 2009 02:44:06 +0000 (22:44 -0400)]
Add support for gcc v3.x compilers.
Suppress __attribute__((externally_visible)) when no -fwhole-program
Add switch hack for compilers without -fno-jump-tables
Define memcpy() function (for compilers without -minline-all-stringops).
Define call16_simpint as a macro (a param needs to be inlined).
Make sure s3_resume is only defined in 32bit mode.
Kevin O'Connor [Thu, 11 Jun 2009 01:56:01 +0000 (21:56 -0400)]
Do garbage collection of unused sections.
Implement -ffunction-sections and -fdata-sections in both 32bit and
16bit code.
Make sure all sections have unique names (even asm and discarded
sections).
Enhance tools/layoutrom.py script to find all sections reachable from
exported 16bit code - prune all other sections.
Mark sections with "export" if they can be visible outside of code -
these sections wont be dropped when pruning unused sections.
Kevin O'Connor [Mon, 1 Jun 2009 02:00:20 +0000 (22:00 -0400)]
VGA: Comment and name update.
Remove remaining "biosfn_" prefixes from functions.
Don't use register names as function parameters.
vgafb_read_pixel should return a value (instead of passing in a pointer)
Kevin O'Connor [Mon, 1 Jun 2009 01:15:33 +0000 (21:15 -0400)]
VGA: Arrange screen writing functions to minimize stack.
Pass pointer to cursor position into write_string and write_teletype.
Handle flag processing of write_string in handle_1013.
Implement a tail-recursive scroll_one() function.
Kevin O'Connor [Sun, 31 May 2009 19:25:14 +0000 (15:25 -0400)]
VGA: Further simplify scrolling code.
Introduce memcpy_stride and memset_stride functions.
Simplify the moves and fills using src and dest pointers.
Don't nest for loops - just use one loop for copies.
Kevin O'Connor [Sun, 31 May 2009 04:46:47 +0000 (00:46 -0400)]
VGA: Breakup biosfn_scroll.
Rename biosfn_scroll to vgafb_scroll.
Break function up into per-mode scroll function.
Pass row/col params in a 'struct cursorpos'.
Encode direction as sign in nblines.
Move parameter checking to callers.
Add enhancement to 'attr' for using mode specific default attribute.
Also, make get_cursor_pos local to vga.c.