aboutsummaryrefslogtreecommitdiff
path: root/src/kbd.c
AgeCommit message (Collapse)AuthorFilesLines
2023-10-09fix lasi keyboard in graphics modeHelge Deller1-1/+1
2017-09-22kbd: make enqueue_key public, add ascii_to_keycodeGerd Hoffmann1-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>
2016-09-15kbd: Move extended and release events out of special key detection switchKevin O'Connor1-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>
2016-09-12kbd: Generate interrupt events for SysReq, PrtScr, and BreakKevin O'Connor1-5/+50
Generate the appropriate interrupt events for the given keys. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-09-12kbd: Ignore fake shift keysKevin O'Connor1-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>
2016-09-12kbd: Move checking for special keys in __process_keys() into switchKevin O'Connor1-65/+71
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-09-12kbd: Extract out shift flag setting into new functionKevin O'Connor1-62/+43
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-09-12kbd: Merge bda->kbd_flag0 and bda->kbd_flag1Kevin O'Connor1-56/+31
Merge the two consecutive u8 fields into a single u16 field. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-09-12kbd: Suppress keys without mappingsKevin O'Connor1-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>
2016-09-12kbd: Implement extended keycode mappings for keypad-enter and keypad-/Kevin O'Connor1-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>
2016-09-12kbd: Implement 101-key keyboard keycode mappingKevin O'Connor1-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>
2016-01-14kbd: Refactor capslock and numlock handlingKevin O'Connor1-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>
2016-01-14kbd: Don't treat scancode and asciicode as separate valuesKevin O'Connor1-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>
2014-09-30Revert "Use the extra stack for 16bit USB and PS2 keyboard/mouse commands."Kevin O'Connor1-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>
2014-06-06Abstract reset call (and possible 16bit mode switch) into reset() function.Kevin O'Connor1-1/+1
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18Move function definitions for output.c from util.h to new file output.h.Kevin O'Connor1-2/+3
Also, sort the order of include files in the c files. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18Move stacks.c definitions from util.h to new file stacks.h.Kevin O'Connor1-0/+1
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18Rename util.c to string.c and introduce string.h.Kevin O'Connor1-0/+1
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-02Move code centered around specific hardware devices to src/hw/Kevin O'Connor1-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>
2013-02-05Normalize POST initialization function name suffixes.Kevin O'Connor1-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>
2012-05-30Set noinline on kbd.c interface functions that take stack variable pointers.Kevin O'Connor1-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>
2012-05-30Remove "noinline" declarations from keyboard/mouse driver code.Kevin O'Connor1-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>
2012-05-30Use the extra stack for 16bit USB and PS2 keyboard/mouse commands.Kevin O'Connor1-3/+3
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-05-30Run all hardware irq handlers on the extra stack.Kevin O'Connor1-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>
2012-05-28Rename wait_irq to yield_toirq.Kevin O'Connor1-1/+1
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2010-05-01When USB keyboard active, don't send keyboard commands to ps2 port.Kevin O'Connor1-1/+10
Route keyboard commands to a USB handler when USB keyboard is active. Add a GETID handler for USB keyboards.
2010-03-13Enable irqs in kbd/clock calls that caller might "spin" on.Kevin O'Connor1-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.
2010-03-13Revert "Rework disabling of ps2 port irqs."Kevin O'Connor1-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.
2010-01-28Rework disabling of ps2 port irqs.Kevin O'Connor1-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.
2010-01-03Be sure to add "void" to all function prototypes that take no args.Kevin O'Connor1-2/+2
Omitting "void" leads to a K&R style declaration which was not intended.
2009-12-13Distinguish between debug reports for unimplemented vs invalid calls.Kevin O'Connor1-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.
2009-12-09Move ps2 specific keyboard and mouse code to ps2port.c.Kevin O'Connor1-99/+4
2009-10-24Add simple cooperative threading scheme to allow parallel hw init.Kevin O'Connor1-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.
2009-10-24Replace irq_enable() regions with explicit calls to check for irqs.Kevin O'Connor1-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.
2009-09-28Initial support for USB, UHCI, and USB Keyboards.Kevin O'Connor1-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.
2009-09-20Support sleeping until an irq fires, and use where applicable.Kevin O'Connor1-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.
2009-09-11Separate out pause key processing in process_key().Kevin O'Connor1-20/+18
2009-09-11Define bit names for keyboard shift flags.Kevin O'Connor1-133/+136
Also, move setting of bit flags to the end of process_key().
2009-01-21Minor enhancement - kbd reset should set 0x1234 in BDA reset flag.Kevin O'Connor1-1/+3
2009-01-17Cleanup keyboard reset handling.Kevin O'Connor1-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.
2009-01-15Change license from GPLv3 to LGPLv3.Kevin O'Connor1-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).
2009-01-04Make sure ps2 port command reads are from the desired device.Kevin O'Connor1-2/+2
Discard reads from real-time events or from a different device. Also, improve the kbd/mouse diagnostic messages.
2009-01-02The BDA is at segment 0x0040 not 0x0000.Kevin O'Connor1-5/+5
The interrupt vector table is technically at 0x0000.
2009-01-01Reduce stack usage of hw irq handlers.Kevin O'Connor1-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.
2008-12-29Add more linker protections around variables accessed from 16bit mode.Kevin O'Connor1-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.
2008-12-21Fix bug in dequeue_key() refactor.Kevin O'Connor1-1/+1
Clearing of Z_FL occurs on the !incr path.
2008-12-16Refactor dequeue_key() in keyboard code.Kevin O'Connor1-39/+18
All 4 callers of dequeue_key are very similar - move the redundant logic into dequeue_key() itself.
2008-12-13Implement GET/SET_GLOBAL(...) instead of using GET/SET_VAR(CS, ...)Kevin O'Connor1-15/+15
2008-12-10Improve support for old 16bit resume handlers.Kevin O'Connor1-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.
2008-11-29Detect keyboard ctrl-alt-delete and try to reset machine.Kevin O'Connor1-3/+9