aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
AgeCommit message (Collapse)AuthorFilesLines
2013-09-18Rename util.c to string.c and introduce string.h.Kevin O'Connor1-235/+0
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18Move keyboard calling code from util.c to boot.c.Kevin O'Connor1-41/+0
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18Split x86 specific functions out of util.c/h to new files x86.c/h.Kevin O'Connor1-16/+0
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-07-21Rename check_timer() function (and similar) to irqtimer_check().Kevin O'Connor1-2/+2
Rename functions to be more consistent and so they are not confused with the normal timer functions. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-03-17Set ZF prior to keyboard read call in check_for_keystroke().Kevin O'Connor1-1/+1
Set the ZF flag to make sure the keyboard interrupt is actively clearing it on a key event. This fixes a hang when CONFIG_BOOTMENU is on and CONFIG_KEYBOARD is off. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-05-30Make sure to set dependency to segment registers in inline asm.Kevin O'Connor1-5/+6
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-05-28Move farcall16 code from util.c to stacks.c and reorg stacks.c.Kevin O'Connor1-49/+0
No code changes - just code movement. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-05-28Rename call16 to farcall16.Kevin O'Connor1-6/+6
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-05-28Rename wait_irq to yield_toirq.Kevin O'Connor1-1/+1
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-01Detect CPUID instruction before using it.Kevin O'Connor1-0/+16
Enable SeaBIOS to work on 386/486 machines that don't have CPUID instruction. Based on patch by Rudolf Marek. Signed-off-by: Rudolf Marek <r.marek@assembler.cz> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2011-01-08Extract space trimming code from ATA and use in USB and bootorder code.Kevin O'Connor1-0/+10
Introduce function nullTrailingSpace() that nulls blank characters from the end of a string. Use this function in the ATA, USB MSC, and bootorder code.
2010-12-24Add strchr() function.Kevin O'Connor1-0/+9
2010-12-05util: add memset_fl()Gerd Hoffmann1-0/+9
2010-07-27Handle unaligned sizes in iomemcpy().Kevin O'Connor1-4/+7
This fixes a bug causing truncation of uncompressed files in cbfs_copyfile().
2010-06-06Introduce memcpy_fl - a memcpy on "flat" pointers.Kevin O'Connor1-0/+11
2010-05-23Don't use RTC to time boot menu delay.Kevin O'Connor1-22/+3
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.
2010-05-23Allow wait_irq to be called in 32bit code.Kevin O'Connor1-29/+0
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.
2010-05-01Further parallelize init when using CONFIG_THREAD_OPTIONROMS.Kevin O'Connor1-0/+6
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().
2010-02-17Fix off by one error in strtcpy.Kevin O'Connor1-1/+1
The strtcpy function could overrun its output buffer.
2010-01-03Be sure to add "void" to all function prototypes that take no args.Kevin O'Connor1-3/+3
Omitting "void" leads to a K&R style declaration which was not intended.
2009-12-26Introduce MODESEGMENT define; rename VISIBLE32 to VISIBLE32FLAT.Kevin O'Connor1-4/+4
Prepare for support of segmented 32bit code. Add new MODESEGMENT definition, and clarify existing 32bit mode defs.
2009-12-13Enhance experimental option rom "threading" - enable preemption.Kevin O'Connor1-2/+2
When experimental support for parallelizing option roms and hardware init (default disabled) is selected, add support for checking on hardware init progress from the RTC irq handler. Enable ability for RTC to be turned on for additional users. Allow regular option roms (not just vga option roms) to run in parallel with hardware init. Don't use stack in transition32 / transition16 until new mode is entered. Also, cleanup leaking of data handlers in usb code. Also, decrease frequency of iomemcpy checks (every 2K instead of 1K).
2009-12-10Move stack manipulation code from util.c to new file stacks.c.Kevin O'Connor1-179/+16
Move the threading and stack_hop code to a new file.
2009-12-09Clear thread info on each boot.Kevin O'Connor1-1/+8
Fix potential issue of threads being incorrect if ctrl+alt+del is pressed during POST.
2009-12-05Introduce optimized iomemcpy function for copying from io memory.Kevin O'Connor1-0/+20
Reading from IO memory (pci rom or flash) is very slow, so add iomemcpy() which will yield during copy. Use a 4 byte copy to optimize accesses. Also, decompress cbfs data files from a temp memory buffer so that ulzma doesn't read from slow IO memory.
2009-10-24Improve debugging output from threads.Kevin O'Connor1-4/+4
Show the "thread id" on each debug message sent from a thread. Also, cleanup translation dprintf() so it looks nicer withe thread output.
2009-10-24Add simple cooperative threading scheme to allow parallel hw init.Kevin O'Connor1-15/+146
Enable system for running hardware initialization in parallel. The yield() call can now round-robin between "threads". Rework ata controller init to use a thread per controller. Make sure internal drives are registered in a defined order. Run keyboard initialization in a thread. Rework usb init to use a thread per controller.
2009-10-24Replace irq_enable() regions with explicit calls to check for irqs.Kevin O'Connor1-3/+48
Add new function yield() which will permit irqs to trigger. The yield() call enables irqs to occur in 32bit mode. Add [num]sleep calls that yield instead of just spinning. Rename existing int 1586 usleep call to biosusleep. Convert many calls to mdelay to msleep.
2009-09-24Interrupts should be enabled when calling 16bit code.Kevin O'Connor1-0/+3
Set most code paths to have interrupts on when calling 16bit code. This fixes at least one optionrom that needed irqs on.
2009-09-09Replace common segment/offset pairs with struct segoff_s.Kevin O'Connor1-3/+3
Introduce 'struct segoff_s' to more places.
2009-06-15Make sure memcpy() works in 16bit mode also.Kevin O'Connor1-0/+3
Make sure %es is set before doing a "rep movs" call.
2009-06-15Unify mode16/32 compiler checks.Kevin O'Connor1-8/+2
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.
2009-06-10Add support for gcc v3.x compilers.Kevin O'Connor1-23/+16
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.
2009-05-06Minor - formatting enhancements; add memset_far funcs.Kevin O'Connor1-8/+31
Use consistent types in mtrr.c. Remove extra ';' from lds files. Report found serial and lpt ports. Remove extra newlines from inline asm. Add memset_far and memset16_far functions.
2009-04-19Fixup previous memcpy optimization.Kevin O'Connor1-14/+4
Different gcc versions handle __builtin_memcpy differently. Add -minline-all-string to force inlining of memcpy on old gcc. Always use __builtin_memcpy for all memcpy calls. Use memcpy4() for the option rom case where 4-byte accesses is important.
2009-04-19Optimize memcpy.Kevin O'Connor1-5/+17
Use __builtin_memcpy on small strings (gcc can inline these well). Use 4-byte copies when applicable - this is important when copying option roms from slow PCI space.
2009-04-18Replace memeq/streq functions with memcmp/strcmp.Kevin O'Connor1-6/+6
The standard functions are better known and not harder to implement.
2009-04-13Clear irqs in transition32 instead of callers.Kevin O'Connor1-0/+2
This moves the irq clear into transition32. Also, disable nmi before loading gdt - this prevents a race with an nmi.
2009-04-13Initial support for running CBFS payloads.Kevin O'Connor1-1/+26
Add boot menu option for CBFS payloads. Rework "override" system so that it is done per BEV. Add file prefix scanning code to CBFS. Add CBFS payload launching support.
2009-04-11Initial support for finding option roms in coreboot flash layout.Kevin O'Connor1-0/+14
Add code to search for roms in the "coreboot file system". Change hardcode option rom detection to use vendor/deviceid instead of bus/device/fn. Move streq() function to generic place so cbfs functions can use it.
2009-03-01Consistently disable irqs at start of each assembler entry point.Kevin O'Connor1-1/+1
Always disable irqs at start of each entry point. Be consistent with clearing direction flag after disabling interrupts.
2009-02-27Save/restore %ebp in __call16 instead of in caller (call16).Kevin O'Connor1-2/+2
The Ubuntu gcc compiler apparently miscompiles code when %ebp is in an assembler clobber list. Also, don't clobber %eax in transition32 - a minor cleanup.
2009-02-15Minor - change checksum functions to take a (void *).Kevin O'Connor1-3/+3
This reduces the casts in calling code.
2009-02-15Allow ctrl+alt+delete to work when no boot device found.Kevin O'Connor1-1/+1
Don't panic (that turns off irqs), instead spin with irqs enabled.
2009-02-08Simplify boot code.Kevin O'Connor1-0/+11
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.
2009-02-08Reorganize boot code.Kevin O'Connor1-0/+47
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.
2009-01-19Minor - call16 should not assume %cs==SEG_BIOS.Kevin O'Connor1-3/+5
Should be slightly more compatible with protected mode accesses.
2009-01-19Implement memcpy_far and checksum_far, and replace _fl variants.Kevin O'Connor1-14/+21
The "flat" mode variants work in real mode, but will not work in protected mode. So, replace with versions that take explicit segments.
2009-01-19Rename MAKE_FARPTR (and similar) to MAKE_FLATPTR.Kevin O'Connor1-8/+8
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".
2009-01-19Minor - always set %esp immediately after setting %ss.Kevin O'Connor1-15/+14
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.