aboutsummaryrefslogtreecommitdiff
path: root/src/ps2port.c
AgeCommit message (Collapse)AuthorFilesLines
2013-09-02Move code centered around specific hardware devices to src/hw/Kevin O'Connor1-504/+0
Move many C files from the src/ directory to the new src/hw/ directory. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-07-21Rename check_tsc() (and similar) to timer_check() and use u32.Kevin O'Connor1-4/+4
Rename the check_tsc() function to timer_check(). The CPU TSC is often not the basis of the timer, so use a more appropriate name. Convert all callers that were using u64 for the timers to use u32. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-07-14PIC code cleanups.Kevin O'Connor1-3/+3
Preface PIC functions with a pic_ to provide a more consistent naming. Convert the irqmask code to a more consistent pic_irqmask_read/write/mask form. Move code from pic.h to pic.c. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-02-05Normalize POST initialization function name suffixes.Kevin O'Connor1-2/+2
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-06-02Fix winxp boot regression introduced in ecdc655a.Kevin O'Connor1-4/+4
The winxp boot loader does something curious - it sets an int 0x1c handler, records the stack location, and then spins in place with irqs enabled. The 0x1c handler alters the memory just past the stack pointer so that when the timer irq returns the code jumps to a new location and stop spinning. The winxp code relies on the fact that a hw irq will always place 6 bytes at a specific location and that it can alter those bytes. The ecdc655a patch does a full backup/restore of the register state. Unfortunately, the restore overwrites the changes made by the winxp 0x1c handler. This patch reverts much of ecdc655a. Hardware irqs are still handled on the extra stack, but only the essential register state is backed up and restored. Also, stack_hop_back is changed to only use %sp when changing states - this enables the entry code to store just %esp instead of both %esp and %sp. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-06-02Cache romfile entries.Kevin O'Connor1-1/+0
Create a 'struct romfile_s' and populate a list of all romfiles at start of init. Caching the romfiles both simplifies the code and makes it more efficient. Also, convert the ramdisk code to use romfile helpers instead of directly accessing cbfs. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-05-30Run all hardware irq handlers on the extra stack.Kevin O'Connor1-4/+4
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-20Convert ps2 code EBDA variables to VARLOW variables.Kevin O'Connor1-9/+10
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-03-11ps2: Enable keyboard at end of PS2 port irq.Kevin O'Connor1-0/+3
Looks like some old programs expect the keyboard irq to enable the keyboard port at the end of the irq. This behavior was seen on an image of "Concurrent DOS". Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-01Check for CONFIG_PS2PORT on all entry ps2 function entry points.Kevin O'Connor1-0/+7
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2011-07-05Replace CONFIG_PS2_KEYBOARD_SPINUP with "etc/ps2-keyboard-spinup" file.Kevin O'Connor1-2/+4
2011-05-28Add option to handle PS2 keyboards that have a slow power up.Kevin O'Connor1-3/+12
Add PS2_KEYBOARD_SPINUP option to give certain keyboards more time to initialize. Based on report and feedback from: Sven Schnelle <svens@stackframe.org> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2011-05-07Move ps2ctr manipulation from mouse.c to ps2port.c.Kevin O'Connor1-0/+11
This simplifies the mouse.c code. It also prevents USB mouse interaction from changing the ps2 port setup.
2010-09-15Try to hard-reboot processor on rerun of post under coreboot.Kevin O'Connor1-2/+14
Add several methods for rebooting a processor. Detect a rerun of POST under coreboot and attempt to reboot the processor.
2010-07-28Add FUNC16() helper macro for converting a 16bit func to a segoff_s.Kevin O'Connor1-2/+2
2010-05-23Rename check_time() to check_tsc().Kevin O'Connor1-1/+1
2010-05-01When USB keyboard active, don't send keyboard commands to ps2 port.Kevin O'Connor1-17/+19
Route keyboard commands to a USB handler when USB keyboard is active. Add a GETID handler for USB keyboards.
2010-03-13Process event on ps2 keyboard irq even if event already read.Kevin O'Connor1-19/+27
Some old DOS programs will hook the keyboard irq, read the keyboard data on irq, and then call the BIOS handler expecting it to continue process the event. So, the BIOS can't assume it is the first to read the data from the ps2 port. Also, reduce window where a ps2 command could conflict with incoming data. Disable all data during interrupt flushing, and only re-enable the desired port just prior to sending the command. Also, discard data from any interrupts if init hasn't completed.
2010-03-13Revert "Unify ps2 port data processing."Kevin O'Connor1-32/+26
This reverts commit 84f7b801ba8c0806fac568e59e85af281c0df207. It's not possible to unify ps2 port irq processing because old DOS apps could hook one or both of the kbd/mouse ps2 irqs.
2010-03-13Handle variable length return of ps2 port GETID command.Kevin O'Connor1-1/+24
Sometimes GETID returns two bytes, and sometimes one byte. Handle that properly. This fixes a failure with an msdos mouse driver.
2010-03-13Prevent ps2 irqs from messing up ps2 init.Kevin O'Connor1-0/+3
This is an alternate to 6f702dd6987b22e9bce472fe61910392af17416a. After disabling ps2 irqs, enable irqs to flush any queued irqs. This should prevent irqs from triggering in the middle of the init process.
2010-03-13Revert "Rework disabling of ps2 port irqs."Kevin O'Connor1-31/+26
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-02-28Prefer passing a USB "pipe" structure over a USB endp encoding.Kevin O'Connor1-1/+1
Instead of passing the "u32 endp" encoding of the usb endpoint, allocate a "struct usb_pipe" for each end point and pass that. Allocate a control pipe for every device found. Support freeing the pipes after they are done. Implement pipe allocation and freeing for both UHCI and OHCI controllers. Also, don't define every UHCI qh to include a pipe - create a separate structure "struct uhci_pipe". Also, be sure to clear the USBControllers on reset. Also, convert usb_hub_init to return 0 on success. Also, cleanup some of the USB debug messages to make them more consistent.
2010-02-14Introduce standard warnings for allocation failures and timeouts.Kevin O'Connor1-4/+6
There is no need for custom warnings for many common failures. Introduce a common warning which is consistent and more visible.
2010-02-13Add some ASSERT32FLAT() to help compiler eliminate dead code.Kevin O'Connor1-0/+1
The function pointer passed to run_thread() can confuse the compiler into thinking the function needs to be emitted. Add ASSERT32FLAT() to help the compiler eliminate this code.
2010-01-28Rework disabling of ps2 port irqs.Kevin O'Connor1-26/+31
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-5/+5
Omitting "void" leads to a K&R style declaration which was not intended.
2009-12-09Unify ps2 port data processing.Kevin O'Connor1-26/+32
Unify the code for mouse and keyboard irq handling. Support case where mouse irq fires but keyboard data present and vice-versa. Support data in i8042 queue while ps2 command being processed.
2009-12-09Move ps2 specific keyboard and mouse code to ps2port.c.Kevin O'Connor1-0/+138
2009-12-02Fail PS2 port commands when receiving a NAK.Kevin O'Connor1-1/+3
Fail the command on a nak - don't ignore it.
2009-10-24Replace irq_enable() regions with explicit calls to check for irqs.Kevin O'Connor1-33/+22
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-10-22Handle tsc rollover.Kevin O'Connor1-1/+1
Handle case where timetamp counter overflows while waiting.
2009-05-06Detect ps2 nak response.Kevin O'Connor1-6/+11
For now, just ignore the nak.
2009-02-15Clock cleanups.Kevin O'Connor1-1/+1
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).
2009-01-18Cleanup ps2 port reset handling.Kevin O'Connor1-30/+36
Separate out reset code - it has special timeouts throughout.
2009-01-17Cleanup keyboard reset handling.Kevin O'Connor1-7/+19
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-17Fix minor bug in ps2port.c - can't check for -1 with unsigned return type.Kevin O'Connor1-1/+1
2009-01-17Misc fixes.Kevin O'Connor1-2/+2
The pnp bios string can't be const and VAR16_32. Show ps2 port status when discarding data.
2009-01-15Change license from GPLv3 to LGPLv3.Kevin O'Connor1-2/+2
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-11/+35
Discard reads from real-time events or from a different device. Also, improve the kbd/mouse diagnostic messages.
2008-11-29Fix bug on keyboard LED set.Kevin O'Connor1-1/+9
The ps2_command() function had a cut-and-paste error. Also, add some additional debugging functions to ps2 port code.
2008-11-28Implement tsc based delay timers, and use them throughout code.Kevin O'Connor1-7/+0
Calibrate the timestamp-counter using the PIT timer2 mechanism. Implement ndelay/udelay/mdelay using tsc. Remove obsolete sleeping mechanisms.
2008-07-21Support ps2 port RESET commands that respond with 1 or 2 bytes.Kevin O'Connor1-3/+7
Some devices only respond with 1 byte - if they timeout reading the second byte, don't fail the whole operation - just continue and handle the 1 byte.
2008-07-20Rewrite ps2 port (keyboard/mouse) handling.Kevin O'Connor1-0/+240
Use command sending code for communicating with the ps2 port.