12UINT8 SampleRateTbl[MaxSampleRate] = { 0xa, 0x14, 0x28, 0x3c, 0x50, 0x64, 0xc8 };
14UINT8 ResolutionTbl[MaxResolution] = { 0, 1, 2, 3 };
34 if (EFI_ERROR (Status)) {
42 if (EFI_ERROR (Status)) {
47 return EFI_DEVICE_ERROR;
54 if (EFI_ERROR (Status)) {
59 if (EFI_ERROR (Status)) {
64 if (EFI_ERROR (Status)) {
70 if (EFI_ERROR (Status)) {
154 OUT BOOLEAN *KeyboardEnable
164 if (EFI_ERROR (Status)) {
169 if (EFI_ERROR (Status)) {
176 if ((Data & CMD_KB_STS) == CMD_KB_DIS) {
177 *KeyboardEnable =
FALSE;
179 *KeyboardEnable =
TRUE;
199 if (EFI_ERROR (Status)) {
204 if (EFI_ERROR (Status)) {
211 if (Data != PS2MOUSE_BAT1) {
212 return EFI_DEVICE_ERROR;
216 if (EFI_ERROR (Status)) {
223 if (Data != PS2MOUSE_BAT2) {
224 return EFI_DEVICE_ERROR;
239 IN MOUSE_SR SampleRate
248 if (EFI_ERROR (Status)) {
266 IN MOUSE_RE Resolution
275 if (EFI_ERROR (Status)) {
334 BOOLEAN KeyboardEnable;
335 UINT8 Packet[PS2_PACKET_LENGTH];
339 INT16 RelativeMovementX;
340 INT16 RelativeMovementY;
344 KeyboardEnable =
FALSE;
345 State = PS2_READ_BYTE_ONE;
352 case PS2_READ_BYTE_ONE:
359 if (EFI_ERROR (Status)) {
361 return EFI_NOT_READY;
366 return EFI_NOT_READY;
369 if (IS_PS2_SYNC_BYTE (Data)) {
371 State = PS2_READ_DATA_BYTE;
380 case PS2_READ_DATA_BYTE:
383 if (EFI_ERROR (Status)) {
384 if (KeyboardEnable) {
388 return EFI_NOT_READY;
392 if (KeyboardEnable) {
396 return EFI_NOT_READY;
399 State = PS2_PROCESS_PACKET;
402 case PS2_PROCESS_PACKET:
403 if (KeyboardEnable) {
410 RelativeMovementX = Packet[1];
411 RelativeMovementY = Packet[2];
424 RelativeMovementX = (INT16)(RelativeMovementX & 0xFF);
425 RelativeMovementY = (INT16)(RelativeMovementY & 0xFF);
429 if ((Packet[0] & 0x10) != 0) {
430 RelativeMovementX = (INT16)(RelativeMovementX | 0xFF00);
433 if ((Packet[0] & 0x20) != 0) {
434 RelativeMovementY = (INT16)(RelativeMovementY | 0xFF00);
437 RButton = (UINT8)(Packet[0] & 0x2);
438 LButton = (UINT8)(Packet[0] & 0x1);
447 MouseDev->StateChanged =
TRUE;
475 if (State == PS2_READ_BYTE_ONE) {
481 if (EFI_ERROR (Status)) {
486 for (BytesRead = 0; BytesRead < *BufSize; BytesRead++) {
488 if (EFI_ERROR (Status)) {
492 Buffer[BytesRead] =
IoRead8 (KBC_DATA_PORT);
498 if ((BytesRead == 0) || (BytesRead != *BufSize)) {
499 Status = EFI_NOT_FOUND;
502 *BufSize = BytesRead;
529 if (EFI_ERROR (Status)) {
536 IoWrite8 (KBC_CMD_STS_PORT, Command);
539 if (EFI_ERROR (Status)) {
565 if (EFI_ERROR (Status)) {
588 Delay = TIMEOUT / 50;
600 }
while (Delay != 0);
606 *Data =
IoRead8 (KBC_DATA_PORT);
633 if (EFI_ERROR (Status)) {
640 IoWrite8 (KBC_CMD_STS_PORT, WRITE_AUX_DEV);
643 if (EFI_ERROR (Status)) {
656 if (EFI_ERROR (Status)) {
660 if (Data == PS2_ACK) {
669 return EFI_DEVICE_ERROR;
670 }
else if (Data == PS2_RESEND) {
675 if (EFI_ERROR (Status)) {
682 return EFI_DEVICE_ERROR;
707 if (EFI_ERROR (Status)) {
714 IoWrite8 (KBC_CMD_STS_PORT, WRITE_AUX_DEV);
717 if (EFI_ERROR (Status)) {
724 if (EFI_ERROR (Status)) {
750 if (EFI_ERROR (Status)) {
754 *Data =
IoRead8 (KBC_DATA_PORT);
772 Data =
IoRead8 (KBC_CMD_STS_PORT);
778 return EFI_NOT_READY;
800 Delay = Timeout / 50;
803 Data =
IoRead8 (KBC_CMD_STS_PORT);
814 }
while (Delay != 0);
839 Delay = Timeout / 50;
842 Data =
IoRead8 (KBC_CMD_STS_PORT);
854 }
while (Delay != 0);
EFI_STATUS PS2MouseReset(VOID)
EFI_STATUS In8042AuxData(IN OUT UINT8 *Data)
EFI_STATUS CheckKbStatus(OUT BOOLEAN *KeyboardEnable)
EFI_STATUS PS2MouseSetResolution(IN MOUSE_RE Resolution)
EFI_STATUS Out8042AuxCommand(IN UINT8 Command, IN BOOLEAN Resend)
EFI_STATUS Out8042Data(IN UINT8 Data)
EFI_STATUS Out8042AuxData(IN UINT8 Data)
EFI_STATUS PS2MouseRead(OUT UINT8 *Buffer, IN OUT UINTN *BufSize, IN UINTN State)
EFI_STATUS In8042Data(IN OUT UINT8 *Data)
EFI_STATUS KbcEnableAux(VOID)
EFI_STATUS CheckForInput(VOID)
EFI_STATUS PS2MouseSetSampleRate(IN MOUSE_SR SampleRate)
EFI_STATUS PS2MouseSetScaling(IN MOUSE_SF Scaling)
EFI_STATUS PS2MouseEnable(VOID)
EFI_STATUS PS2MouseGetPacket(PS2_MOUSE_DEV *MouseDev)
EFI_STATUS WaitInputEmpty(IN UINTN Timeout)
EFI_STATUS KbcDisableAux(VOID)
EFI_STATUS KbcSelfTest(VOID)
EFI_STATUS WaitOutputFull(IN UINTN Timeout)
EFI_STATUS KbcDisableKb(VOID)
EFI_STATUS KbcEnableKb(VOID)
EFI_STATUS Out8042Command(IN UINT8 Command)
UINT8 EFIAPI IoWrite8(IN UINTN Port, IN UINT8 Value)
UINT8 EFIAPI IoRead8(IN UINTN Port)