summaryrefslogtreecommitdiff
path: root/src/kbd.c
Commit message (Collapse)AuthorAgeFilesLines
* kbd: make enqueue_key public, add ascii_to_keycodeGerd Hoffmann2017-09-221-1/+17
| | | | | | | | serial console wants queue key events and needs to map ascii chars to the keycode, so make enqueue_key public and also exports a helper function so sercon can use the scan_to_keycode mapping table. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* kbd: Move extended and release events out of special key detection switchKevin O'Connor2016-09-151-40/+25
| | | | | | | Move checking for extended scancodes and key release to the top of __process_key(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* kbd: Generate interrupt events for SysReq, PrtScr, and BreakKevin O'Connor2016-09-121-5/+50
| | | | | | Generate the appropriate interrupt events for the given keys. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* kbd: Ignore fake shift keysKevin O'Connor2016-09-121-0/+6
| | | | | | | | AT keyboards can produce "fake" shift keys on some extended events. It's not necessary to process these artificial events as the actual extended keys are detected directly. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* kbd: Move checking for special keys in __process_keys() into switchKevin O'Connor2016-09-121-65/+71
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* kbd: Extract out shift flag setting into new functionKevin O'Connor2016-09-121-62/+43
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* kbd: Merge bda->kbd_flag0 and bda->kbd_flag1Kevin O'Connor2016-09-121-56/+31
| | | | | | Merge the two consecutive u8 fields into a single u16 field. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* kbd: Suppress keys without mappingsKevin O'Connor2016-09-121-3/+2
| | | | | | | | | Don't warn if a key without a mapping is pressed - it's known that some keys aren't mapped to keycodes. Suppress these keys instead of sending 0x0000 to the keyboard buffer - as 0x0000 can confuse some programs. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* kbd: Implement extended keycode mappings for keypad-enter and keypad-/Kevin O'Connor2016-09-121-0/+15
| | | | | | | | On a 101-key keyboard the keypad enter and keypad '/' keys have unique BIOS keycodes that are distinct from the main keyboard enter and '/' keys. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* kbd: Implement 101-key keyboard keycode mappingKevin O'Connor2016-09-121-28/+40
| | | | | | | | | The current keyboard code only supports the keycode mappings for 83-key keyboards (plus handling for alt-esc and f11/f12). Add a more complete mapping of keycodes for 101-key keyboards. This adds more alt key and ctrl key mappings. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* kbd: Refactor capslock and numlock handlingKevin O'Connor2016-01-141-101/+96
| | | | | | | Simplify the scan_to_keycode[] table by implementing numlock and capslock checking in the code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* kbd: Don't treat scancode and asciicode as separate valuesKevin O'Connor2016-01-141-38/+26
| | | | | | | The scancode/asciicode pair can be more easily handled as a single 16bit value. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Revert "Use the extra stack for 16bit USB and PS2 keyboard/mouse commands."Kevin O'Connor2014-09-301-3/+3
| | | | | | | | | | | | | It's not valid to pass a pointer to a stack variable through the stack_hop() call (because the call changes the stack segment). This bug was probably not noticed before because by default (CONFIG_ENTRY_EXTRASTACK) SeaBIOS uses the extra stack on all 16bit entry points, and the internal stack_hop() with that config option is effectively a no-op. This reverts commit d488a7683d90bf8fae7ceb8c3ad9e95fbbd92079. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Abstract reset call (and possible 16bit mode switch) into reset() function.Kevin O'Connor2014-06-061-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Move function definitions for output.c from util.h to new file output.h.Kevin O'Connor2013-09-181-2/+3
| | | | | | Also, sort the order of include files in the c files. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Move stacks.c definitions from util.h to new file stacks.h.Kevin O'Connor2013-09-181-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Rename util.c to string.c and introduce string.h.Kevin O'Connor2013-09-181-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Move code centered around specific hardware devices to src/hw/Kevin O'Connor2013-09-021-2/+2
| | | | | | Move many C files from the src/ directory to the new src/hw/ directory. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Normalize POST initialization function name suffixes.Kevin O'Connor2013-02-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The POST phase has to invoke many initialization functions, and these functions can have complex inter-dependencies. Try to categorize the functions into 4 classes: preinit - functions called very early in POST where function ordering is very important and the code has limited access to other interfaces. init - functions that initialize internal interfaces and standard external interfaces. This code is generally not dependent on particular hardware and typically does not communicate directly with any hardware devices. setup - functions which access hardware or are dependent on particular hardware or platform devices. prepboot - functions that finalize internal interfaces and that prepare for the boot phase. This patch attempts to normalize the suffixes - functions that used _init(), _setup(), _finalize(), or similar that did not follow the above pattern were renamed. Other than function name changes, there should be no code impact to this patch. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Set noinline on kbd.c interface functions that take stack variable pointers.Kevin O'Connor2012-05-301-2/+2
| | | | | | | | | Some versions of gcc have been found to inline these funcions and then cause the calling functions to use very large stack usage. Since these functions are called from 16bit mode, their stack space usage is very sensitive. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Remove "noinline" declarations from keyboard/mouse driver code.Kevin O'Connor2012-05-301-4/+2
| | | | | | | | Now that the extra stack is used for keyboard and mouse driver code, there is no reason to set noinline (which was done to try and conserve stack space). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Use the extra stack for 16bit USB and PS2 keyboard/mouse commands.Kevin O'Connor2012-05-301-3/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Run all hardware irq handlers on the extra stack.Kevin O'Connor2012-05-301-6/+8
| | | | | | | | | | | | | | | | | | | | Jump into the extra stack for all hardware irq handlers. This reduces the overall stack requirements of SeaBIOS. Replace all users of call16_simpint with call16_int. Only the hardware irq handlers used the old call, and they need to use the new call to ensure the extra stack is properly re-entrant. Also, pass in a 'struct bregs' to the hardware irq handlers now. It was not done previously to save stack space. Now that the extra stack is used, that is no longer an issue. Note that should an old OS invoke a hardware irq in 16bit protected mode, then this patch could break that OS. However, the chances of this causing a regression seem small as several existing hardware irq handlers already do not work in 16bit protected mode. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Rename wait_irq to yield_toirq.Kevin O'Connor2012-05-281-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* When USB keyboard active, don't send keyboard commands to ps2 port.Kevin O'Connor2010-05-011-1/+10
| | | | | | Route keyboard commands to a USB handler when USB keyboard is active. Add a GETID handler for USB keyboards.
* Enable irqs in kbd/clock calls that caller might "spin" on.Kevin O'Connor2010-03-131-0/+3
| | | | | | | | 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.
* Revert "Rework disabling of ps2 port irqs."Kevin O'Connor2010-03-131-2/+24
| | | | | | | | | This reverts commit 6f702dd6987b22e9bce472fe61910392af17416a. 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.
* Rework disabling of ps2 port irqs.Kevin O'Connor2010-01-281-24/+2
| | | | | | Disable the ps2 port irqs in software instead of hardware. This prevents a race where an irq could get queued and later called when not desired.
* Be sure to add "void" to all function prototypes that take no args.Kevin O'Connor2010-01-031-2/+2
| | | | Omitting "void" leads to a K&R style declaration which was not intended.
* Distinguish between debug reports for unimplemented vs invalid calls.Kevin O'Connor2009-12-131-1/+1
| | | | | | | | Don't use "fail" in the debug output - as this confuses users. When reporting on an invalid parameter - use the word "invalid". When reporting on an unimplemented call - state it is unimplemented. Add separate debug levels for unimplemented vs invalid calls. Also, increase the debug level of several entry points.
* Move ps2 specific keyboard and mouse code to ps2port.c.Kevin O'Connor2009-12-091-99/+4
|
* Add simple cooperative threading scheme to allow parallel hw init.Kevin O'Connor2009-10-241-1/+1
| | | | | | | | | 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.
* Replace irq_enable() regions with explicit calls to check for irqs.Kevin O'Connor2009-10-241-4/+0
| | | | | | | | 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.
* Initial support for USB, UHCI, and USB Keyboards.Kevin O'Connor2009-09-281-1/+1
| | | | | | | This adds preliminary support for USB controllers and keyboards. Add support for UHCI controllers. Add support for "HID" USB keyboards. Also, fix bug in hexdump() - len need not be power of 4.
* Support sleeping until an irq fires, and use where applicable.Kevin O'Connor2009-09-201-19/+36
| | | | | | 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.
* Separate out pause key processing in process_key().Kevin O'Connor2009-09-111-20/+18
|
* Define bit names for keyboard shift flags.Kevin O'Connor2009-09-111-133/+136
| | | | Also, move setting of bit flags to the end of process_key().
* Minor enhancement - kbd reset should set 0x1234 in BDA reset flag.Kevin O'Connor2009-01-211-1/+3
|
* Cleanup keyboard reset handling.Kevin O'Connor2009-01-171-6/+7
| | | | | | | 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.
* Change license from GPLv3 to LGPLv3.Kevin O'Connor2009-01-151-1/+1
| | | | | | | | 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).
* Make sure ps2 port command reads are from the desired device.Kevin O'Connor2009-01-041-2/+2
| | | | | Discard reads from real-time events or from a different device. Also, improve the kbd/mouse diagnostic messages.
* The BDA is at segment 0x0040 not 0x0000.Kevin O'Connor2009-01-021-5/+5
| | | | The interrupt vector table is technically at 0x0000.
* Reduce stack usage of hw irq handlers.Kevin O'Connor2009-01-011-12/+9
| | | | | | | | | 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.
* Add more linker protections around variables accessed from 16bit mode.Kevin O'Connor2008-12-291-10/+10
| | | | | | | 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.
* Fix bug in dequeue_key() refactor.Kevin O'Connor2008-12-211-1/+1
| | | | Clearing of Z_FL occurs on the !incr path.
* Refactor dequeue_key() in keyboard code.Kevin O'Connor2008-12-161-39/+18
| | | | | All 4 callers of dequeue_key are very similar - move the redundant logic into dequeue_key() itself.
* Implement GET/SET_GLOBAL(...) instead of using GET/SET_VAR(CS, ...)Kevin O'Connor2008-12-131-15/+15
|
* Improve support for old 16bit resume handlers.Kevin O'Connor2008-12-101-3/+0
| | | | | | | 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.
* Detect keyboard ctrl-alt-delete and try to reset machine.Kevin O'Connor2008-11-291-3/+9
|
* Enable a default hw irq handler.Kevin O'Connor2008-11-261-2/+1
| | | | | | | | | | | 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.