/** Read data via IsaIo protocol with given number. @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL @param Buffer Buffer receive data of mouse @param BufSize The size of buffer @param State Check input or read data @return status of reading mouse data. **/ EFI_STATUS PS2MouseRead ( IN EFI_ISA_IO_PROTOCOL *IsaIo, OUT VOID *Buffer, IN OUT UINTN *BufSize, IN UINTN State ) { EFI_STATUS Status; UINTN BytesRead; Status = EFI_SUCCESS; BytesRead = 0; if (State == PS2_READ_BYTE_ONE) { // // Check input for mouse // Status = CheckForInput (IsaIo); if (EFI_ERROR (Status)) { return Status; } } while (BytesRead < *BufSize) { Status = WaitOutputFull (IsaIo, TIMEOUT); if (EFI_ERROR (Status)) { break; } IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, Buffer); BytesRead++; Buffer = (UINT8 *) Buffer + 1; } // // Verify the correct number of bytes read // if (BytesRead == 0 || BytesRead != *BufSize) { Status = EFI_NOT_FOUND; } *BufSize = BytesRead; return Status; }
/** I/O work flow of in 8042 Aux data. @param Data Buffer holding return value. @retval EFI_SUCCESS Success to excute I/O work flow @retval EFI_TIMEOUT Keyboard controller time out. **/ EFI_STATUS In8042AuxData ( IN OUT UINT8 *Data ) { EFI_STATUS Status; // // wait for output data // Status = WaitOutputFull (BAT_TIMEOUT); if (EFI_ERROR (Status)) { return Status; } *Data = IoRead8 (KBC_DATA_PORT); return EFI_SUCCESS; }
/** I/O work flow of in 8042 Aux data. @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL @param Data Buffer holding return value. @retval EFI_SUCCESS Success to excute I/O work flow @retval EFI_TIMEOUT Keyboard controller time out. **/ EFI_STATUS In8042AuxData ( IN EFI_ISA_IO_PROTOCOL *IsaIo, IN OUT UINT8 *Data ) { EFI_STATUS Status; // // wait for output data // Status = WaitOutputFull (IsaIo, BAT_TIMEOUT); if (EFI_ERROR (Status)) { return Status; } IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, Data); return EFI_SUCCESS; }
/** Read data via IsaIo protocol with given number. @param Buffer Buffer receive data of mouse @param BufSize The size of buffer @param State Check input or read data @return status of reading mouse data. **/ EFI_STATUS PS2MouseRead ( OUT UINT8 *Buffer, IN OUT UINTN *BufSize, IN UINTN State ) { EFI_STATUS Status; UINTN BytesRead; Status = EFI_SUCCESS; if (State == PS2_READ_BYTE_ONE) { // // Check input for mouse // Status = CheckForInput (); if (EFI_ERROR (Status)) { return Status; } } for (BytesRead = 0; BytesRead < *BufSize; BytesRead++) { Status = WaitOutputFull (TIMEOUT); if (EFI_ERROR (Status)) { break; } Buffer[BytesRead] = IoRead8 (KBC_DATA_PORT); } // // Verify the correct number of bytes read // if (BytesRead == 0 || BytesRead != *BufSize) { Status = EFI_NOT_FOUND; } *BufSize = BytesRead; return Status; }