diff options
author | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-07-06 09:09:42 +0000 |
---|---|---|
committer | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-07-06 09:09:42 +0000 |
commit | 05fbd06d913397d0fca2ba4dc9cbdb4bda08a42e (patch) | |
tree | 9436962784b14b467385cf2044bdfa6775b0a03a /IntelFrameworkModulePkg | |
parent | 911cad134a5072018dc14a1d92714ae22389ba71 (diff) | |
download | edk2-platforms-05fbd06d913397d0fca2ba4dc9cbdb4bda08a42e.tar.xz |
Add in Ps2keyboard.inf and Ps2Mouse.inf to IntelFrameworkModuelPkg
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3112 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'IntelFrameworkModulePkg')
18 files changed, 6799 insertions, 0 deletions
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/CommonHeader.h b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/CommonHeader.h new file mode 100644 index 0000000000..fd84c9321c --- /dev/null +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/CommonHeader.h @@ -0,0 +1,51 @@ +/**@file
+ Common header file shared by all source files.
+
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.
+
+ Copyright (c) 2006 - 2007, Intel Corporation.
+ All rights reserved.
+ This software and associated documentation (if any) is furnished
+ under a license and may only be used or copied in accordance
+ with the terms of the license. Except as permitted by such
+ license, no part of this software or documentation may be
+ reproduced, stored in a retrieval system, or transmitted in any
+ form or by any means without the express written consent of
+ Intel Corporation.
+**/
+
+#ifndef __COMMON_HEADER_H_
+#define __COMMON_HEADER_H_
+
+
+//
+// The package level header files this module uses
+//
+#include <PiDxe.h>
+#include <Framework/StatusCode.h>
+
+//
+// The protocols, PPI and GUID defintions for this module
+//
+#include <Protocol/SimpleTextIn.h>
+#include <Protocol/IsaIo.h>
+#include <Protocol/DevicePath.h>
+#include <Protocol/Ps2Policy.h>
+
+//
+// The Library classes this module consumes
+//
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/ReportStatusCodeLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h>
+//
+// Driver Binding Externs
+//
+extern EFI_DRIVER_BINDING_PROTOCOL gKeyboardControllerDriver;
+extern EFI_COMPONENT_NAME_PROTOCOL gPs2KeyboardComponentName;
+
+#endif
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/ComponentName.c new file mode 100644 index 0000000000..75598b0554 --- /dev/null +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/ComponentName.c @@ -0,0 +1,230 @@ +/*++
+
+Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved. <BR>
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+
+Module Name:
+
+ ComponentName.c
+
+Abstract:
+
+--*/
+
+//
+// Include common header file for this module.
+//
+#include "CommonHeader.h"
+
+#include "Ps2Keyboard.h"
+
+//
+// EFI Component Name Functions
+//
+EFI_STATUS
+EFIAPI
+Ps2KeyboardComponentNameGetDriverName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ );
+
+EFI_STATUS
+EFIAPI
+Ps2KeyboardComponentNameGetControllerName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ );
+
+//
+// EFI Component Name Protocol
+//
+EFI_COMPONENT_NAME_PROTOCOL gPs2KeyboardComponentName = {
+ Ps2KeyboardComponentNameGetDriverName,
+ Ps2KeyboardComponentNameGetControllerName,
+ "eng"
+};
+
+static EFI_UNICODE_STRING_TABLE mPs2KeyboardDriverNameTable[] = {
+ {
+ "eng",
+ L"PS/2 Keyboard Driver"
+ },
+ {
+ NULL,
+ NULL
+ }
+};
+
+EFI_STATUS
+EFIAPI
+Ps2KeyboardComponentNameGetDriverName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ )
+/*++
+
+ Routine Description:
+
+ Retrieves a Unicode string that is the user readable name of the EFI Driver.
+
+ Arguments:
+
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
+ Language - A pointer to a three character ISO 639-2 language identifier.
+ This is the language of the driver name that that the caller
+ is requesting, and it must match one of the languages specified
+ in SupportedLanguages. The number of languages supported by a
+ driver is up to the driver writer.
+ DriverName - A pointer to the Unicode string to return. This Unicode string
+ is the name of the driver specified by This in the language
+ specified by Language.
+
+ Returns:
+
+ EFI_SUCCESS - The Unicode string for the Driver specified by This
+ and the language specified by Language was returned
+ in DriverName.
+ EFI_INVALID_PARAMETER - Language is NULL.
+ EFI_INVALID_PARAMETER - DriverName is NULL.
+ EFI_UNSUPPORTED - The driver specified by This does not support the
+ language specified by Language.
+
+--*/
+{
+ return LookupUnicodeString (
+ Language,
+ gPs2KeyboardComponentName.SupportedLanguages,
+ mPs2KeyboardDriverNameTable,
+ DriverName
+ );
+}
+
+EFI_STATUS
+EFIAPI
+Ps2KeyboardComponentNameGetControllerName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ )
+/*++
+
+ Routine Description:
+
+ Retrieves a Unicode string that is the user readable name of the controller
+ that is being managed by an EFI Driver.
+
+ Arguments:
+
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
+ ControllerHandle - The handle of a controller that the driver specified by
+ This is managing. This handle specifies the controller
+ whose name is to be returned.
+ ChildHandle - The handle of the child controller to retrieve the name
+ of. This is an optional parameter that may be NULL. It
+ will be NULL for device drivers. It will also be NULL
+ for a bus drivers that wish to retrieve the name of the
+ bus controller. It will not be NULL for a bus driver
+ that wishes to retrieve the name of a child controller.
+ Language - A pointer to a three character ISO 639-2 language
+ identifier. This is the language of the controller name
+ that that the caller is requesting, and it must match one
+ of the languages specified in SupportedLanguages. The
+ number of languages supported by a driver is up to the
+ driver writer.
+ ControllerName - A pointer to the Unicode string to return. This Unicode
+ string is the name of the controller specified by
+ ControllerHandle and ChildHandle in the language specified
+ by Language from the point of view of the driver specified
+ by This.
+
+ Returns:
+
+ EFI_SUCCESS - The Unicode string for the user readable name in the
+ language specified by Language for the driver
+ specified by This was returned in DriverName.
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - Language is NULL.
+ EFI_INVALID_PARAMETER - ControllerName is NULL.
+ EFI_UNSUPPORTED - The driver specified by This is not currently managing
+ the controller specified by ControllerHandle and
+ ChildHandle.
+ EFI_UNSUPPORTED - The driver specified by This does not support the
+ language specified by Language.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
+ EFI_ISA_IO_PROTOCOL *IsaIoProtocol;
+
+ //
+ // This is a device driver, so ChildHandle must be NULL.
+ //
+ if (ChildHandle != NULL) {
+ return EFI_UNSUPPORTED;
+ }
+ //
+ // Check Controller's handle
+ //
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiIsaIoProtocolGuid,
+ (VOID **) &IsaIoProtocol,
+ gKeyboardControllerDriver.DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (!EFI_ERROR (Status)) {
+ gBS->CloseProtocol (
+ ControllerHandle,
+ &gEfiIsaIoProtocolGuid,
+ gKeyboardControllerDriver.DriverBindingHandle,
+ ControllerHandle
+ );
+
+ return EFI_UNSUPPORTED;
+ }
+
+ if (Status != EFI_ALREADY_STARTED) {
+ return EFI_UNSUPPORTED;
+ }
+ //
+ // Get the device context
+ //
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiSimpleTextInProtocolGuid,
+ (VOID **) &ConIn,
+ gKeyboardControllerDriver.DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (ConIn);
+
+ return LookupUnicodeString (
+ Language,
+ gPs2KeyboardComponentName.SupportedLanguages,
+ ConsoleIn->ControllerNameTable,
+ ControllerName
+ );
+}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/EntryPoint.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/EntryPoint.c new file mode 100644 index 0000000000..c1d3e613d4 --- /dev/null +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/EntryPoint.c @@ -0,0 +1,58 @@ +/**@file
+ Entry Point Source file.
+
+ This file contains the user entry point
+
+ Copyright (c) 2006 - 2007, Intel Corporation.
+ All rights reserved.
+ This software and associated documentation (if any) is furnished
+ under a license and may only be used or copied in accordance
+ with the terms of the license. Except as permitted by such
+ license, no part of this software or documentation may be
+ reproduced, stored in a retrieval system, or transmitted in any
+ form or by any means without the express written consent of
+ Intel Corporation.
+**/
+
+
+//
+// Include common header file for this module.
+//
+#include "CommonHeader.h"
+
+/**
+ The user Entry Point for module Ps2Keyboard. The user code starts with this function.
+
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.
+ @param[in] SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The entry point is executed successfully.
+ @retval other Some error occurs when executing this entry point.
+
+**/
+EFI_STATUS
+EFIAPI
+InitializePs2Keyboard(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Install driver model protocol(s).
+ //
+ Status = EfiLibInstallAllDriverProtocols (
+ ImageHandle,
+ SystemTable,
+ &gKeyboardControllerDriver,
+ ImageHandle,
+ &gPs2KeyboardComponentName,
+ NULL,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+
+ return Status;
+}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c new file mode 100644 index 0000000000..5980556ea3 --- /dev/null +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c @@ -0,0 +1,2076 @@ +/**@file
+ PS/2 Keyboard driver
+ Routines that access 8042 keyboard controller
+
+Copyright (c) 2006 - 2007 Intel Corporation. All rights reserved. <BR>
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+**/
+
+//
+// Include common header file for this module.
+//
+#include "CommonHeader.h"
+
+#include "Ps2Keyboard.h"
+
+//
+// Function declarations
+//
+STATIC
+UINT8
+KeyReadDataRegister (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
+ );
+
+STATIC
+VOID
+KeyWriteDataRegister (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
+ IN UINT8 Data
+ );
+
+STATIC
+VOID
+KeyWriteCommandRegister (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
+ IN UINT8 Data
+ );
+
+STATIC
+VOID
+KeyboardError (
+ IN KEYBOARD_CONSOLE_IN_DEV*ConsoleIn,
+ IN CHAR16 *ErrMsg // should be a unicode string
+ );
+
+STATIC
+EFI_STATUS
+GetScancodeBufHead (
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
+ IN UINT32 Count,
+ OUT UINT8 *Buf
+ );
+
+STATIC
+EFI_STATUS
+PopScancodeBufHead (
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
+ IN UINT32 Count,
+ OUT UINT8 *Buf
+ );
+
+STATIC
+EFI_STATUS
+KeyboardWrite (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
+ IN UINT8 Data
+ );
+
+STATIC
+EFI_STATUS
+KeyboardCommand (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
+ IN UINT8 Data
+ );
+
+STATIC
+EFI_STATUS
+KeyboardWaitForValue (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
+ IN UINT8 Value
+ );
+
+STATIC
+EFI_STATUS
+UpdateStatusLights (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
+ );
+
+//
+// Global variables
+//
+
+STATIC struct {
+ UINT8 ScanCode;
+ UINT16 EfiScanCode;
+ CHAR16 UnicodeChar;
+ CHAR16 ShiftUnicodeChar;
+}
+ConvertKeyboardScanCodeToEfiKey[] = {
+
+ {
+ 0x01, // Escape
+ SCAN_ESC,
+ 0x00,
+ 0x00
+ },
+ {
+ 0x02,
+ SCAN_NULL,
+ '1',
+ '!'
+ },
+ {
+ 0x03,
+ SCAN_NULL,
+ '2',
+ '@'
+ },
+ {
+ 0x04,
+ SCAN_NULL,
+ '3',
+ '#'
+ },
+ {
+ 0x05,
+ SCAN_NULL,
+ '4',
+ '$'
+ },
+ {
+ 0x06,
+ SCAN_NULL,
+ '5',
+ '%'
+ },
+ {
+ 0x07,
+ SCAN_NULL,
+ '6',
+ '^'
+ },
+ {
+ 0x08,
+ SCAN_NULL,
+ '7',
+ '&'
+ },
+ {
+ 0x09,
+ SCAN_NULL,
+ '8',
+ '*'
+ },
+ {
+ 0x0A,
+ SCAN_NULL,
+ '9',
+ '('
+ },
+ {
+ 0x0B,
+ SCAN_NULL,
+ '0',
+ ')'
+ },
+ {
+ 0x0C,
+ SCAN_NULL,
+ '-',
+ '_'
+ },
+ {
+ 0x0D,
+ SCAN_NULL,
+ '=',
+ '+'
+ },
+ {
+ 0x0E, // BackSpace
+ SCAN_NULL,
+ 0x08,
+ 0x08
+ },
+ {
+ 0x0F, // Tab
+ SCAN_NULL,
+ 0x09,
+ 0x09
+ },
+ {
+ 0x10,
+ SCAN_NULL,
+ 'q',
+ 'Q'
+ },
+ {
+ 0x11,
+ SCAN_NULL,
+ 'w',
+ 'W'
+ },
+ {
+ 0x12,
+ SCAN_NULL,
+ 'e',
+ 'E'
+ },
+ {
+ 0x13,
+ SCAN_NULL,
+ 'r',
+ 'R'
+ },
+ {
+ 0x14,
+ SCAN_NULL,
+ 't',
+ 'T'
+ },
+ {
+ 0x15,
+ SCAN_NULL,
+ 'y',
+ 'Y'
+ },
+ {
+ 0x16,
+ SCAN_NULL,
+ 'u',
+ 'U'
+ },
+ {
+ 0x17,
+ SCAN_NULL,
+ 'i',
+ 'I'
+ },
+ {
+ 0x18,
+ SCAN_NULL,
+ 'o',
+ 'O'
+ },
+ {
+ 0x19,
+ SCAN_NULL,
+ 'p',
+ 'P'
+ },
+ {
+ 0x1a,
+ SCAN_NULL,
+ '[',
+ '{'
+ },
+ {
+ 0x1b,
+ SCAN_NULL,
+ ']',
+ '}'
+ },
+ {
+ 0x1c, // Enter
+ SCAN_NULL,
+ 0x0d,
+ 0x0d
+ },
+ {
+ 0x1d,
+ SCAN_NULL,
+ 0x00,
+ 0x00
+ },
+ {
+ 0x1e,
+ SCAN_NULL,
+ 'a',
+ 'A'
+ },
+ {
+ 0x1f,
+ SCAN_NULL,
+ 's',
+ 'S'
+ },
+ {
+ 0x20,
+ SCAN_NULL,
+ 'd',
+ 'D'
+ },
+ {
+ 0x21,
+ SCAN_NULL,
+ 'f',
+ 'F'
+ },
+ {
+ 0x22,
+ SCAN_NULL,
+ 'g',
+ 'G'
+ },
+ {
+ 0x23,
+ SCAN_NULL,
+ 'h',
+ 'H'
+ },
+ {
+ 0x24,
+ SCAN_NULL,
+ 'j',
+ 'J'
+ },
+ {
+ 0x25,
+ SCAN_NULL,
+ 'k',
+ 'K'
+ },
+ {
+ 0x26,
+ SCAN_NULL,
+ 'l',
+ 'L'
+ },
+ {
+ 0x27,
+ SCAN_NULL,
+ ';',
+ ':'
+ },
+ {
+ 0x28,
+ SCAN_NULL,
+ '\'',
+ '"'
+ },
+ {
+ 0x29,
+ SCAN_NULL,
+ '`',
+ '~'
+ },
+ {
+ 0x2a, // Left Shift
+ SCAN_NULL,
+ 0x00,
+ 0x00
+ },
+ {
+ 0x2b,
+ SCAN_NULL,
+ '\\',
+ '|'
+ },
+ {
+ 0x2c,
+ SCAN_NULL,
+ 'z',
+ 'Z'
+ },
+ {
+ 0x2d,
+ SCAN_NULL,
+ 'x',
+ 'X'
+ },
+ {
+ 0x2e,
+ SCAN_NULL,
+ 'c',
+ 'C'
+ },
+ {
+ 0x2f,
+ SCAN_NULL,
+ 'v',
+ 'V'
+ },
+ {
+ 0x30,
+ SCAN_NULL,
+ 'b',
+ 'B'
+ },
+ {
+ 0x31,
+ SCAN_NULL,
+ 'n',
+ 'N'
+ },
+ {
+ 0x32,
+ SCAN_NULL,
+ 'm',
+ 'M'
+ },
+ {
+ 0x33,
+ SCAN_NULL,
+ ',',
+ '<'
+ },
+ {
+ 0x34,
+ SCAN_NULL,
+ '.',
+ '>'
+ },
+ {
+ 0x35,
+ SCAN_NULL,
+ '/',
+ '?'
+ },
+ {
+ 0x36, //Right Shift
+ SCAN_NULL,
+ 0x00,
+ 0x00
+ },
+ {
+ 0x37, // Numeric Keypad *
+ SCAN_NULL,
+ '*',
+ '*'
+ },
+ {
+ 0x38, //Left Alt/Extended Right Alt
+ SCAN_NULL,
+ 0x00,
+ 0x00
+ },
+ {
+ 0x39,
+ SCAN_NULL,
+ ' ',
+ ' '
+ },
+ {
+ 0x3A, //CapsLock
+ SCAN_NULL,
+ 0x00,
+ 0x00
+ },
+ {
+ 0x3B,
+ SCAN_F1,
+ 0x00,
+ 0x00
+ },
+ {
+ 0x3C,
+ SCAN_F2,
+ 0x00,
+ 0x00
+ },
+ {
+ 0x3D,
+ SCAN_F3,
+ 0x00,
+ 0x00
+ },
+ {
+ 0x3E,
+ SCAN_F4,
+ 0x00,
+ 0x00
+ },
+ {
+ 0x3F,
+ SCAN_F5,
+ 0x00,
+ 0x00
+ },
+ {
+ 0x40,
+ SCAN_F6,
+ 0x00,
+ 0x00
+ },
+ {
+ 0x41,
+ SCAN_F7,
+ 0x00,
+ 0x00
+ },
+ {
+ 0x42,
+ SCAN_F8,
+ 0x00,
+ 0x00
+ },
+ {
+ 0x43,
+ SCAN_F9,
+ 0x00,
+ 0x00
+ },
+ {
+ 0x44,
+ SCAN_F10,
+ 0x00,
+ 0x00
+ },
+ {
+ 0x45, // NumLock
+ SCAN_NULL,
+ 0x00,
+ 0x00
+ },
+ {
+ 0x46, // ScrollLock
+ SCAN_NULL,
+ 0x00,
+ 0x00
+ },
+ {
+ 0x47,
+ SCAN_HOME,
+ '7',
+ '7'
+ },
+ {
+ 0x48,
+ SCAN_UP,
+ '8',
+ '8'
+ },
+ {
+ 0x49,
+ SCAN_PAGE_UP,
+ '9',
+ '9'
+ },
+ {
+ 0x4a,
+ SCAN_NULL,
+ '-',
+ '-'
+ },
+ {
+ 0x4b,
+ SCAN_LEFT,
+ '4',
+ '4'
+ },
+ {
+ 0x4c, // Numeric Keypad 5
+ SCAN_NULL,
+ '5',
+ '5'
+ },
+ {
+ 0x4d,
+ SCAN_RIGHT,
+ '6',
+ '6'
+ },
+ {
+ 0x4e,
+ SCAN_NULL,
+ '+',
+ '+'
+ },
+ {
+ 0x4f,
+ SCAN_END,
+ '1',
+ '1'
+ },
+ {
+ 0x50,
+ SCAN_DOWN,
+ '2',
+ '2'
+ },
+ {
+ 0x51,
+ SCAN_PAGE_DOWN,
+ '3',
+ '3'
+ },
+ {
+ 0x52,
+ SCAN_INSERT,
+ '0',
+ '0'
+ },
+ {
+ 0x53,
+ SCAN_DELETE,
+ '.',
+ '.'
+ },
+ {
+ 0x57,
+ SCAN_F11,
+ 0x00,
+ 0x00
+ },
+ {
+ 0x58,
+ SCAN_F12,
+ 0x00,
+ 0x00
+ },
+ {
+ TABLE_END,
+ TABLE_END,
+ SCAN_NULL,
+ SCAN_NULL
+ },
+};
+
+
+//
+// The WaitForValue time out
+//
+STATIC UINTN mWaitForValueTimeOut = KEYBOARD_WAITFORVALUE_TIMEOUT;
+
+STATIC
+UINT8
+KeyReadDataRegister (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ ConsoleIn - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ EFI_ISA_IO_PROTOCOL *IsaIo;
+ UINT8 Data;
+
+ //
+ // Use IsaIo protocol to perform IO operations
+ //
+ IsaIo = ConsoleIn->IsaIo;
+
+ IsaIo->Io.Read (
+ IsaIo,
+ EfiIsaIoWidthUint8,
+ ConsoleIn->DataRegisterAddress,
+ 1,
+ &Data
+ );
+
+ return Data;
+}
+
+STATIC
+VOID
+KeyWriteDataRegister (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
+ IN UINT8 Data
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ ConsoleIn - GC_TODO: add argument description
+ Data - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ EFI_ISA_IO_PROTOCOL *IsaIo;
+
+ //
+ // Use IsaIo protocol to perform IO operations
+ //
+ IsaIo = ConsoleIn->IsaIo;
+
+ IsaIo->Io.Write (
+ IsaIo,
+ EfiIsaIoWidthUint8,
+ ConsoleIn->DataRegisterAddress,
+ 1,
+ &Data
+ );
+
+ //
+ // outp(ConsoleIn->DataRegisterAddress, Data);
+ //
+}
+
+UINT8
+KeyReadStatusRegister (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ ConsoleIn - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ EFI_ISA_IO_PROTOCOL *IsaIo;
+ UINT8 Data;
+
+ //
+ // Use IsaIo protocol to perform IO operations
+ //
+ IsaIo = ConsoleIn->IsaIo;
+
+ IsaIo->Io.Read (
+ IsaIo,
+ EfiIsaIoWidthUint8,
+ ConsoleIn->StatusRegisterAddress,
+ 1,
+ &Data
+ );
+
+ return Data;
+
+}
+
+STATIC
+VOID
+KeyWriteCommandRegister (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
+ IN UINT8 Data
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ ConsoleIn - GC_TODO: add argument description
+ Data - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ EFI_ISA_IO_PROTOCOL *IsaIo;
+
+ //
+ // Use IsaIo protocol to perform IO operations
+ //
+ IsaIo = ConsoleIn->IsaIo;
+
+ IsaIo->Io.Write (
+ IsaIo,
+ EfiIsaIoWidthUint8,
+ ConsoleIn->CommandRegisterAddress,
+ 1,
+ &Data
+ );
+
+}
+
+STATIC
+VOID
+KeyboardError (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
+ IN CHAR16 *ErrMsg
+ )
+/*++
+
+Routine Description:
+
+ Display error message
+
+Arguments:
+
+Returns:
+
+--*/
+// GC_TODO: ConsoleIn - add argument and description to function comment
+// GC_TODO: ErrMsg - add argument and description to function comment
+{
+ ConsoleIn->KeyboardErr = TRUE;
+
+ //
+ // gST -> ConOut -> OutputString (gST -> ConOut, L"Keyboard Driver: ");
+ // gST -> ConOut -> OutputString (gST -> ConOut, ErrMsg);
+ //
+}
+
+VOID
+EFIAPI
+KeyboardTimerHandler (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ Timer event handler: read a series of scancodes from 8042
+ and put them into memory scancode buffer.
+ it read as much scancodes to either fill
+ the memory buffer or empty the keyboard buffer.
+ It is registered as running under TPL_NOTIFY
+
+Arguments:
+
+ Event - The timer event
+ Context - A KEYBOARD_CONSOLE_IN_DEV pointer
+
+Returns:
+
+--*/
+{
+ UINT8 Data;
+ EFI_TPL OldTpl;
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
+
+ ConsoleIn = Context;
+
+ //
+ // Enter critical section
+ //
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+
+ if (((KEYBOARD_CONSOLE_IN_DEV *) Context)->KeyboardErr) {
+ //
+ // Leave critical section and return
+ //
+ gBS->RestoreTPL (OldTpl);
+ return ;
+ }
+ //
+ // To let KB driver support Hot plug, here should skip the 'resend' command for the case that
+ // KB is not connected to system. If KB is not connected to system, driver will find there's something
+ // error in the following code and wait for the input buffer empty, this waiting time shoulb be short enough since
+ // this is a NOTIFY TPL period function, or the system performance will degrade hardly when KB is not connected.
+ // Just skip the 'resend' process simply.
+ //
+
+ Data = 0;
+
+ //
+ // if there is no key present, just return
+ //
+ if ((KeyReadStatusRegister (Context) & 0x21) != 0x1) {
+ //
+ // Leave critical section and return
+ //
+ gBS->RestoreTPL (OldTpl);
+
+ return ;
+ }
+ //
+ // Read one byte of the scan code and store it into the memory buffer
+ //
+ if (ConsoleIn->ScancodeBufCount < KEYBOARD_BUFFER_MAX_COUNT) {
+
+ Data = KeyReadDataRegister (Context);
+ //
+ // put the scancode into the memory scancode buffer
+ //
+ ConsoleIn->ScancodeBufCount++;
+ ConsoleIn->ScancodeBufEndPos++;
+ if (ConsoleIn->ScancodeBufEndPos >= KEYBOARD_BUFFER_MAX_COUNT) {
+ ConsoleIn->ScancodeBufEndPos = 0;
+ }
+
+ ConsoleIn->ScancodeBuf[ConsoleIn->ScancodeBufEndPos] = Data;
+
+ //
+ // Handle Alt+Ctrl+Del Key combination
+ //
+ switch (Data) {
+ case SCANCODE_CTRL_MAKE:
+ ConsoleIn->Ctrled = TRUE;
+ break;
+
+ case SCANCODE_CTRL_BREAK:
+ ConsoleIn->Ctrled = FALSE;
+ break;
+
+ case SCANCODE_ALT_MAKE:
+ ConsoleIn->Alted = TRUE;
+ break;
+
+ case SCANCODE_ALT_BREAK:
+ ConsoleIn->Alted = FALSE;
+ break;
+ }
+ //
+ // if Alt+Ctrl+Del, Reboot the System
+ //
+ if (ConsoleIn->Ctrled && ConsoleIn->Alted && Data == 0x53) {
+ gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
+ }
+ }
+ //
+ // Leave critical section and return
+ //
+ gBS->RestoreTPL (OldTpl);
+
+ return ;
+}
+
+STATIC
+EFI_STATUS
+GetScancodeBufHead (
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
+ IN UINT32 Count,
+ OUT UINT8 *Buf
+ )
+/*++
+
+Routine Description:
+
+ Read several bytes from the scancode buffer without removing them.
+ This function is called to see if there are enough bytes of scancode
+ representing a single key.
+
+Arguments:
+
+ Count - Number of bytes to be read
+ Buf - Store the results
+
+Returns:
+
+ EFI_STATUS
+
+--*/
+// GC_TODO: ConsoleIn - add argument and description to function comment
+// GC_TODO: EFI_NOT_READY - add return value to function comment
+// GC_TODO: EFI_SUCCESS - add return value to function comment
+{
+ UINT32 Index;
+ UINT32 Pos;
+
+ Index = 0;
+ Pos = 0;
+
+ //
+ // check the valid range of parameter 'Count'
+ //
+ if (Count <= 0 || ConsoleIn->ScancodeBufCount < Count) {
+ return EFI_NOT_READY;
+ }
+ //
+ // retrieve the values
+ //
+ for (Index = 0; Index < Count; Index++) {
+
+ if (Index == 0) {
+
+ Pos = ConsoleIn->ScancodeBufStartPos;
+ } else {
+
+ Pos = Pos + 1;
+ if (Pos >= KEYBOARD_BUFFER_MAX_COUNT) {
+ Pos = 0;
+ }
+ }
+
+ Buf[Index] = ConsoleIn->ScancodeBuf[Pos];
+ }
+
+ return EFI_SUCCESS;
+}
+
+STATIC
+EFI_STATUS
+PopScancodeBufHead (
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
+ IN UINT32 Count,
+ OUT UINT8 *Buf
+ )
+/*++
+
+Routine Description:
+
+ Read & remove several bytes from the scancode buffer.
+ This function is usually called after GetScancodeBufHead()
+
+Arguments:
+
+ Count - Number of bytes to be read
+ Buf - Store the results
+
+Returns:
+
+ EFI_STATUS
+
+--*/
+// GC_TODO: ConsoleIn - add argument and description to function comment
+// GC_TODO: EFI_NOT_READY - add return value to function comment
+// GC_TODO: EFI_SUCCESS - add return value to function comment
+{
+ UINT32 Index;
+
+ Index = 0;
+
+ //
+ // Check the valid range of parameter 'Count'
+ //
+ if (Count <= 0 || ConsoleIn->ScancodeBufCount < Count) {
+ return EFI_NOT_READY;
+ }
+ //
+ // Retrieve and remove the values
+ //
+ for (Index = 0; Index < Count; Index++) {
+
+ if (Index != 0) {
+
+ ConsoleIn->ScancodeBufStartPos++;
+ if (ConsoleIn->ScancodeBufStartPos >= KEYBOARD_BUFFER_MAX_COUNT) {
+ ConsoleIn->ScancodeBufStartPos = 0;
+ }
+ }
+
+ Buf[Index] = ConsoleIn->ScancodeBuf[ConsoleIn->ScancodeBufStartPos];
+ ConsoleIn->ScancodeBufCount--;
+ }
+
+ ConsoleIn->ScancodeBufStartPos++;
+ if (ConsoleIn->ScancodeBufStartPos >= KEYBOARD_BUFFER_MAX_COUNT) {
+ ConsoleIn->ScancodeBufStartPos = 0;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+KeyboardRead (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
+ OUT UINT8 *Data
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ ConsoleIn - GC_TODO: add argument description
+ Data - GC_TODO: add argument description
+
+Returns:
+
+ EFI_TIMEOUT - GC_TODO: Add description for return value
+ EFI_SUCCESS - GC_TODO: Add description for return value
+
+--*/
+{
+ UINT32 TimeOut;
+ UINT32 RegFilled;
+
+ TimeOut = 0;
+ RegFilled = 0;
+
+ //
+ // wait till output buffer full then perform the read
+ //
+ for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {
+ if (KeyReadStatusRegister (ConsoleIn) & 0x01) {
+ RegFilled = 1;
+ *Data = KeyReadDataRegister (ConsoleIn);
+ break;
+ }
+
+ gBS->Stall (30);
+ }
+
+ if (!RegFilled) {
+ return EFI_TIMEOUT;
+ }
+
+ return EFI_SUCCESS;
+}
+
+STATIC
+EFI_STATUS
+KeyboardWrite (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
+ IN UINT8 Data
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ ConsoleIn - GC_TODO: add argument description
+ Data - GC_TODO: add argument description
+
+Returns:
+
+ EFI_TIMEOUT - GC_TODO: Add description for return value
+ EFI_SUCCESS - GC_TODO: Add description for return value
+
+--*/
+{
+ UINT32 TimeOut;
+ UINT32 RegEmptied;
+
+ TimeOut = 0;
+ RegEmptied = 0;
+
+ //
+ // wait for input buffer empty
+ //
+ for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {
+ if (!(KeyReadStatusRegister (ConsoleIn) & 0x02)) {
+ RegEmptied = 1;
+ break;
+ }
+
+ gBS->Stall (30);
+ }
+
+ if (!RegEmptied) {
+ return EFI_TIMEOUT;
+ }
+ //
+ // Write it
+ //
+ KeyWriteDataRegister (ConsoleIn, Data);
+
+ return EFI_SUCCESS;
+}
+
+STATIC
+EFI_STATUS
+KeyboardCommand (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
+ IN UINT8 Data
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ ConsoleIn - GC_TODO: add argument description
+ Data - GC_TODO: add argument description
+
+Returns:
+
+ EFI_TIMEOUT - GC_TODO: Add description for return value
+ EFI_TIMEOUT - GC_TODO: Add description for return value
+ EFI_SUCCESS - GC_TODO: Add description for return value
+
+--*/
+{
+ UINT32 TimeOut;
+ UINT32 RegEmptied;
+
+ TimeOut = 0;
+ RegEmptied = 0;
+
+ //
+ // Wait For Input Buffer Empty
+ //
+ for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {
+ if (!(KeyReadStatusRegister (ConsoleIn) & 0x02)) {
+ RegEmptied = 1;
+ break;
+ }
+
+ gBS->Stall (30);
+ }
+
+ if (!RegEmptied) {
+ return EFI_TIMEOUT;
+ }
+ //
+ // issue the command
+ //
+ KeyWriteCommandRegister (ConsoleIn, Data);
+
+ //
+ // Wait For Input Buffer Empty again
+ //
+ RegEmptied = 0;
+ for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {
+ if (!(KeyReadStatusRegister (ConsoleIn) & 0x02)) {
+ RegEmptied = 1;
+ break;
+ }
+
+ gBS->Stall (30);
+ }
+
+ if (!RegEmptied) {
+ return EFI_TIMEOUT;
+ }
+
+ return EFI_SUCCESS;
+}
+
+STATIC
+EFI_STATUS
+KeyboardWaitForValue (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
+ IN UINT8 Value
+ )
+/*++
+
+Routine Description:
+
+ wait for a specific value to be presented on
+ 8042 Data register by keyboard and then read it,
+ used in keyboard commands ack
+
+Arguments:
+
+ ConsoleIn - The KEYBOARD_CONSOLE_IN_DEV instance pointer
+ Value - The value to be waited for
+
+Returns:
+
+ EFI_STATUS
+
+--*/
+// GC_TODO: EFI_SUCCESS - add return value to function comment
+// GC_TODO: EFI_TIMEOUT - add return value to function comment
+{
+ UINT8 Data;
+ UINT32 TimeOut;
+ UINT32 SumTimeOut;
+ UINT32 GotIt;
+
+ GotIt = 0;
+ TimeOut = 0;
+ SumTimeOut = 0;
+
+ //
+ // Make sure the initial value of 'Data' is different from 'Value'
+ //
+ Data = 0;
+ if (Data == Value) {
+ Data = 1;
+ }
+ //
+ // Read from 8042 (multiple times if needed)
+ // until the expected value appears
+ // use SumTimeOut to control the iteration
+ //
+ while (1) {
+ //
+ // Perform a read
+ //
+ for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {
+ if (KeyReadStatusRegister (ConsoleIn) & 0x01) {
+ Data = KeyReadDataRegister (ConsoleIn);
+ break;
+ }
+
+ gBS->Stall (30);
+ }
+
+ SumTimeOut += TimeOut;
+
+ if (Data == Value) {
+ GotIt = 1;
+ break;
+ }
+
+ if (SumTimeOut >= mWaitForValueTimeOut) {
+ break;
+ }
+ }
+ //
+ // Check results
+ //
+ if (GotIt) {
+ return EFI_SUCCESS;
+ } else {
+ return EFI_TIMEOUT;
+ }
+
+}
+
+STATIC
+EFI_STATUS
+UpdateStatusLights (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
+ )
+/*++
+
+Routine Description:
+
+ Show keyboard status lights according to
+ indicators in ConsoleIn.
+
+Arguments:
+
+Returns:
+
+--*/
+// GC_TODO: ConsoleIn - add argument and description to function comment
+{
+ EFI_STATUS Status;
+ UINT8 Command;
+
+ //
+ // Send keyboard command
+ //
+ Status = KeyboardWrite (ConsoleIn, 0xed);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ KeyboardWaitForValue (ConsoleIn, 0xfa);
+
+ //
+ // Light configuration
+ //
+ Command = 0;
+ if (ConsoleIn->CapsLock) {
+ Command |= 4;
+ }
+
+ if (ConsoleIn->NumLock) {
+ Command |= 2;
+ }
+
+ if (ConsoleIn->ScrollLock) {
+ Command |= 1;
+ }
+
+ Status = KeyboardWrite (ConsoleIn, Command);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ KeyboardWaitForValue (ConsoleIn, 0xfa);
+ return Status;
+}
+
+EFI_STATUS
+KeyGetchar (
+ IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
+ )
+/*++
+
+Routine Description:
+
+ Get scancode from scancode buffer
+ and translate into EFI-scancode and unicode defined by EFI spec
+ The function is always called in TPL_NOTIFY
+
+Arguments:
+
+ ConsoleIn - KEYBOARD_CONSOLE_IN_DEV instance pointer
+
+Returns:
+
+ EFI_NOT_READY - Input from console not ready yet.
+ EFI_SUCCESS - Function executed successfully.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT8 ScanCode;
+ UINT8 Readed;
+ BOOLEAN Extended;
+ UINT8 ScancodeArr[4];
+ UINTN Index;
+ //
+ // 4 bytes most
+ //
+ UINT32 ScancodeArrPos;
+ //
+ // point to the current position in ScancodeArr
+ //
+
+ Readed = 0;
+ Extended = FALSE;
+ ScancodeArrPos = 0;
+
+ //
+ // Read one byte of the scan code and store it into the memory buffer
+ // This block of code is added to insert an action that is equivalent to
+ // the timer event handling function, so as to increase the frequency of
+ // detecting the availability of keys. Timer event has a max frequency of
+ // 18Hz which is insufficient
+ //
+ //
+ // To let KB driver support Hot plug, here should skip the 'resend' command for the case that
+ // KB is not connected to system. If KB is not connected to system, driver will find there's something
+ // error in the following code and wait for the input buffer empty, this waiting time shoulb be short enough since
+ // this is a NOTIFY TPL period function, or the system performance will degrade hardly when KB is not connected.
+ // Just skip the 'resend' process simply.
+ //
+
+
+ if (((KeyReadStatusRegister (ConsoleIn) & 0x21) == 0x1) && (ConsoleIn->ScancodeBufCount < KEYBOARD_BUFFER_MAX_COUNT)) {
+
+ Readed = KeyReadDataRegister (ConsoleIn);
+ //
+ // put the scancode into the memory scancode buffer
+ //
+ ConsoleIn->ScancodeBufCount++;
+ ConsoleIn->ScancodeBufEndPos++;
+ if (ConsoleIn->ScancodeBufEndPos >= KEYBOARD_BUFFER_MAX_COUNT) {
+ ConsoleIn->ScancodeBufEndPos = 0;
+ }
+
+ ConsoleIn->ScancodeBuf[ConsoleIn->ScancodeBufEndPos] = Readed;
+
+ //
+ // Handle Alt+Ctrl+Del Key combination
+ //
+ switch (Readed) {
+
+ case SCANCODE_CTRL_MAKE:
+ ConsoleIn->Ctrled = TRUE;
+ break;
+
+ case SCANCODE_CTRL_BREAK:
+ ConsoleIn->Ctrled = FALSE;
+ break;
+
+ case SCANCODE_ALT_MAKE:
+ ConsoleIn->Alted = TRUE;
+ break;
+
+ case SCANCODE_ALT_BREAK:
+ ConsoleIn->Alted = FALSE;
+ break;
+ }
+ //
+ // if Alt+Ctrl+Del, Reboot the System
+ //
+ if (ConsoleIn->Ctrled && ConsoleIn->Alted && Readed == 0x53) {
+ gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
+ }
+ }
+ //
+ // Check if there are enough bytes of scancode representing a single key
+ // available in the buffer
+ //
+ while (1) {
+
+ Status = GetScancodeBufHead (ConsoleIn, 1, ScancodeArr);
+ ScancodeArrPos = 0;
+ if (EFI_ERROR (Status)) {
+ return EFI_NOT_READY;
+ }
+
+ if (ScancodeArr[ScancodeArrPos] == SCANCODE_EXTENDED) {
+ Extended = TRUE;
+ Status = GetScancodeBufHead (ConsoleIn, 2, ScancodeArr);
+ ScancodeArrPos = 1;
+ if (EFI_ERROR (Status)) {
+ return EFI_NOT_READY;
+ }
+ }
+ //
+ // Checks for key scancode for PAUSE:E1-1D/45-E1/9D-C5
+ // if present, ignore them
+ //
+ if (ScancodeArr[ScancodeArrPos] == SCANCODE_EXTENDED1) {
+
+ Status = GetScancodeBufHead (ConsoleIn, 2, ScancodeArr);
+ ScancodeArrPos = 1;
+
+ if (EFI_ERROR (Status)) {
+ return EFI_NOT_READY;
+ }
+
+ Status = GetScancodeBufHead (ConsoleIn, 3, ScancodeArr);
+ ScancodeArrPos = 2;
+
+ if (EFI_ERROR (Status)) {
+ return EFI_NOT_READY;
+ }
+
+ PopScancodeBufHead (ConsoleIn, 3, ScancodeArr);
+ return EFI_NOT_READY;
+ }
+ //
+ // if we reach this position, scancodes for a key is in buffer now,pop them
+ //
+ Status = PopScancodeBufHead (ConsoleIn, ScancodeArrPos + 1, ScancodeArr);
+ if (EFI_ERROR (Status)) {
+ return EFI_NOT_READY;
+ }
+ //
+ // store the last available byte, this byte of scancode will be checked
+ //
+ ScanCode = ScancodeArr[ScancodeArrPos];
+
+ //
+ // Check for special keys and update the driver state.
+ //
+ switch (ScanCode) {
+
+ case SCANCODE_CTRL_MAKE:
+ ConsoleIn->Ctrl = TRUE;
+ break;
+
+ case SCANCODE_CTRL_BREAK:
+ ConsoleIn->Ctrl = FALSE;
+ break;
+
+ case SCANCODE_ALT_MAKE:
+ ConsoleIn->Alt = TRUE;
+ break;
+
+ case SCANCODE_ALT_BREAK:
+ ConsoleIn->Alt = FALSE;
+ break;
+
+ case SCANCODE_LEFT_SHIFT_MAKE:
+ case SCANCODE_RIGHT_SHIFT_MAKE:
+ if (!Extended) {
+ ConsoleIn->Shift = TRUE;
+ }
+ break;
+
+ case SCANCODE_LEFT_SHIFT_BREAK:
+ case SCANCODE_RIGHT_SHIFT_BREAK:
+ if (!Extended) {
+ ConsoleIn->Shift = FALSE;
+ }
+ break;
+
+ case SCANCODE_CAPS_LOCK_MAKE:
+ ConsoleIn->CapsLock = (BOOLEAN)!ConsoleIn->CapsLock;
+ UpdateStatusLights (ConsoleIn);
+ break;
+
+ case SCANCODE_NUM_LOCK_MAKE:
+ ConsoleIn->NumLock = (BOOLEAN)!ConsoleIn->NumLock;
+ UpdateStatusLights (ConsoleIn);
+ break;
+
+ case SCANCODE_SCROLL_LOCK_MAKE:
+ ConsoleIn->ScrollLock = (BOOLEAN)!ConsoleIn->ScrollLock;
+ UpdateStatusLights (ConsoleIn);
+ break;
+ }
+ //
+ // If this is a BREAK Key or above the valid range, ignore it
+ //
+ if (ScanCode >= SCANCODE_MAX_MAKE) {
+ continue;
+ } else {
+ break;
+ }
+ }
+ //
+ // If this is the SysRq, ignore it
+ //
+ if (Extended && ScanCode == 0x37) {
+ return EFI_NOT_READY;
+ }
+ //
+ // Treat Numeric Key Pad "/" specially
+ //
+ if (Extended && ScanCode == 0x35) {
+ ConsoleIn->Key.ScanCode = SCAN_NULL;
+ ConsoleIn->Key.UnicodeChar = '/';
+ return EFI_SUCCESS;
+ }
+ //
+ // Convert Keyboard ScanCode into an EFI Key
+ //
+ for (Index = 0; ConvertKeyboardScanCodeToEfiKey[Index].ScanCode != TABLE_END; Index += 1) {
+ if (ScanCode == ConvertKeyboardScanCodeToEfiKey[Index].ScanCode) {
+ ConsoleIn->Key.ScanCode = ConvertKeyboardScanCodeToEfiKey[Index].EfiScanCode;
+ if (ConsoleIn->Shift) {
+ ConsoleIn->Key.UnicodeChar = ConvertKeyboardScanCodeToEfiKey[Index].ShiftUnicodeChar;
+ } else {
+ ConsoleIn->Key.UnicodeChar = ConvertKeyboardScanCodeToEfiKey[Index].UnicodeChar;
+ }
+ //
+ // alphabetic key is affected by CapsLock State
+ //
+ if (ConsoleIn->CapsLock) {
+ if (ConsoleIn->Key.UnicodeChar >= 'a' && ConsoleIn->Key.UnicodeChar <= 'z') {
+ ConsoleIn->Key.UnicodeChar = ConvertKeyboardScanCodeToEfiKey[Index].ShiftUnicodeChar;
+ } else if (ConsoleIn->Key.UnicodeChar >= 'A' && ConsoleIn->Key.UnicodeChar <= 'Z') {
+ ConsoleIn->Key.UnicodeChar = ConvertKeyboardScanCodeToEfiKey[Index].UnicodeChar;
+ }
+ }
+
+ break;
+ }
+ }
+
+ //
+ // distinguish numeric key pad keys' 'up symbol' and 'down symbol'
+ //
+ if (ScanCode >= 0x47 && ScanCode <= 0x53) {
+
+ if (ConsoleIn->NumLock && !ConsoleIn->Shift && !Extended) {
+ ConsoleIn->Key.ScanCode = SCAN_NULL;
+ } else if (ScanCode != 0x4a && ScanCode != 0x4e) {
+ ConsoleIn->Key.UnicodeChar = 0x00;
+ }
+ }
+ //
+ // If the key can not be converted then just return.
+ //
+ if (ConsoleIn->Key.ScanCode == SCAN_NULL && ConsoleIn->Key.UnicodeChar == 0x00) {
+ return EFI_NOT_READY;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+InitKeyboard (
+ IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
+ IN BOOLEAN ExtendedVerification
+ )
+/*++
+
+Routine Description:
+
+ Perform 8042 controller and keyboard Initialization
+ If ExtendedVerification is TRUE, do additional test for
+ the keyboard interface
+
+Arguments:
+
+ ConsoleIn - KEYBOARD_CONSOLE_IN_DEV instance pointer
+ ExtendedVerification - indicates a thorough initialization
+
+Returns:
+
+ EFI_STATUS
+
+--*/
+// GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
+// GC_TODO: EFI_SUCCESS - add return value to function comment
+// GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
+{
+ EFI_STATUS Status;
+ EFI_STATUS Status1;
+ UINT8 CommandByte;
+ STATIC BOOLEAN EnableMouseInterface;
+ EFI_PS2_POLICY_PROTOCOL *Ps2Policy;
+
+ Status = EFI_SUCCESS;
+ EnableMouseInterface = TRUE;
+
+ //
+ // Get Ps2 policy to set this
+ //
+ Status = gBS->LocateProtocol (
+ &gEfiPs2PolicyProtocolGuid,
+ NULL,
+ (VOID **) &Ps2Policy
+ );
+
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+ EFI_PROGRESS_CODE,
+ EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_PC_CLEAR_BUFFER,
+ ConsoleIn->DevicePath
+ );
+
+ //
+ // Perform a read to cleanup the Status Register's
+ // output buffer full bits
+ //
+ while (!EFI_ERROR (Status)) {
+ Status = KeyboardRead (ConsoleIn, &CommandByte);
+ }
+ //
+ // We should disable mouse interface during the initialization process
+ // since mouse device output could block keyboard device output in the
+ // 60H port of 8042 controller.
+ //
+ // So if we are not initializing 8042 controller for the
+ // first time, we have to remember the previous mouse interface
+ // enabling state
+ //
+ // Test the system flag in to determine whether this is the first
+ // time initialization
+ //
+ if ((KeyReadStatusRegister (ConsoleIn) & 0x04)) {
+ //
+ // 8042 controller is already setup (by myself or by mouse driver):
+ // See whether mouse interface is already enabled
+ // which determines whether we should enable it later
+ //
+ //
+ // Read the command byte of 8042 controller
+ //
+ Status = KeyboardCommand (ConsoleIn, 0x20);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"\n\r");
+ goto Done;
+ }
+
+ Status = KeyboardRead (ConsoleIn, &CommandByte);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"\n\r");
+ goto Done;
+ }
+ //
+ // Test the mouse enabling bit
+ //
+ if (CommandByte & 0x20) {
+ EnableMouseInterface = FALSE;
+ } else {
+ EnableMouseInterface = TRUE;
+ }
+
+ } else {
+ //
+ // 8042 controller is not setup yet:
+ // 8042 controller selftest;
+ // Don't enable mouse interface later.
+ //
+ //
+ // Disable keyboard and mouse interfaces
+ //
+ Status = KeyboardCommand (ConsoleIn, 0xad);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"\n\r");
+ goto Done;
+ }
+
+ Status = KeyboardCommand (ConsoleIn, 0xa7);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"\n\r");
+ goto Done;
+ }
+
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+ EFI_PROGRESS_CODE,
+ EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_PC_SELF_TEST,
+ ConsoleIn->DevicePath
+ );
+ //
+ // 8042 Controller Self Test
+ //
+ Status = KeyboardCommand (ConsoleIn, 0xaa);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");
+ goto Done;
+ }
+
+ Status = KeyboardWaitForValue (ConsoleIn, 0x55);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"8042 controller self test failed!\n\r");
+ goto Done;
+ }
+ //
+ // Don't enable mouse interface later
+ //
+ EnableMouseInterface = FALSE;
+
+ }
+
+ if (Ps2Policy != NULL) {
+ Ps2Policy->Ps2InitHardware (ConsoleIn->Handle);
+ }
+ //
+ // Write 8042 Command Byte, set System Flag
+ // While at the same time:
+ // 1. disable mouse interface,
+ // 2. enable kbd interface,
+ // 3. enable PC/XT kbd translation mode
+ // 4. enable mouse and kbd interrupts
+ //
+ // ( Command Byte bits:
+ // 7: Reserved
+ // 6: PC/XT translation mode
+ // 5: Disable Auxiliary device interface
+ // 4: Disable keyboard interface
+ // 3: Reserved
+ // 2: System Flag
+ // 1: Enable Auxiliary device interrupt
+ // 0: Enable Keyboard interrupt )
+ //
+ Status = KeyboardCommand (ConsoleIn, 0x60);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");
+ goto Done;
+ }
+
+ Status = KeyboardWrite (ConsoleIn, 0x67);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"8042 controller data write error!\n\r");
+ goto Done;
+ }
+
+ //
+ // Clear Memory Scancode Buffer
+ //
+ ConsoleIn->ScancodeBufStartPos = 0;
+ ConsoleIn->ScancodeBufEndPos = KEYBOARD_BUFFER_MAX_COUNT - 1;
+ ConsoleIn->ScancodeBufCount = 0;
+ ConsoleIn->Ctrled = FALSE;
+ ConsoleIn->Alted = FALSE;
+
+ //
+ // Reset the status indicators
+ //
+ ConsoleIn->Ctrl = FALSE;
+ ConsoleIn->Alt = FALSE;
+ ConsoleIn->Shift = FALSE;
+ ConsoleIn->CapsLock = FALSE;
+ ConsoleIn->NumLock = FALSE;
+ ConsoleIn->ScrollLock = FALSE;
+
+ //
+ // For reseting keyboard is not mandatory before booting OS and sometimes keyboard responses very slow,
+ // and to support KB hot plug, we need to let the InitKB succeed no matter whether there is a KB device connected
+ // to system. So we only do the real reseting for keyboard when user asks and there is a real KB connected t system,
+ // and normally during booting an OS, it's skipped.
+ //
+ if (ExtendedVerification && CheckKeyboardConnect (ConsoleIn)) {
+ //
+ // Additional verifications for keyboard interface
+ //
+ //
+ // Keyboard Interface Test
+ //
+ Status = KeyboardCommand (ConsoleIn, 0xab);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");
+ goto Done;
+ }
+
+ Status = KeyboardWaitForValue (ConsoleIn, 0x00);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (
+ ConsoleIn,
+ L"Some specific value not aquired from 8042 controller!\n\r"
+ );
+ goto Done;
+ }
+ //
+ // Keyboard reset with a BAT(Basic Assurance Test)
+ //
+ Status = KeyboardWrite (ConsoleIn, 0xff);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"8042 controller data write error!\n\r");
+ goto Done;
+ }
+
+ Status = KeyboardWaitForValue (ConsoleIn, 0xfa);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");
+ goto Done;
+ }
+ //
+ // wait for BAT completion code
+ //
+ mWaitForValueTimeOut = KEYBOARD_BAT_TIMEOUT;
+
+ Status = KeyboardWaitForValue (ConsoleIn, 0xaa);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"Keyboard self test failed!\n\r");
+ goto Done;
+ }
+
+ mWaitForValueTimeOut = KEYBOARD_WAITFORVALUE_TIMEOUT;
+
+ //
+ // Set Keyboard to use Scan Code Set 2
+ //
+ Status = KeyboardWrite (ConsoleIn, 0xf0);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"8042 controller data write error!\n\r");
+ goto Done;
+ }
+
+ Status = KeyboardWaitForValue (ConsoleIn, 0xfa);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");
+ goto Done;
+ }
+
+ Status = KeyboardWrite (ConsoleIn, 0x02);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"8042 controller data write error!!\n\r");
+ goto Done;
+ }
+
+ Status = KeyboardWaitForValue (ConsoleIn, 0xfa);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");
+ goto Done;
+ }
+
+ //
+ // Clear Keyboard Scancode Buffer
+ //
+ Status = KeyboardWrite (ConsoleIn, 0xf4);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"8042 controller data write error!\n\r");
+ goto Done;
+ }
+
+ Status = KeyboardWaitForValue (ConsoleIn, 0xfa);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");
+ goto Done;
+ }
+ //
+ if (Ps2Policy != NULL) {
+ if ((Ps2Policy->KeyboardLight & EFI_KEYBOARD_CAPSLOCK) == EFI_KEYBOARD_CAPSLOCK) {
+ ConsoleIn->CapsLock = TRUE;
+ }
+
+ if ((Ps2Policy->KeyboardLight & EFI_KEYBOARD_NUMLOCK) == EFI_KEYBOARD_NUMLOCK) {
+ ConsoleIn->NumLock = TRUE;
+ }
+
+ if ((Ps2Policy->KeyboardLight & EFI_KEYBOARD_SCROLLLOCK) == EFI_KEYBOARD_SCROLLLOCK) {
+ ConsoleIn->ScrollLock = TRUE;
+ }
+ }
+ //
+ // Update Keyboard Lights
+ //
+ Status = UpdateStatusLights (ConsoleIn);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"Update keyboard status lights error!\n\r");
+ goto Done;
+ }
+ }
+ //
+ // At last, we can now enable the mouse interface if appropriate
+ //
+Done:
+
+ if (EnableMouseInterface) {
+ //
+ // Enable mouse interface
+ //
+ Status1 = KeyboardCommand (ConsoleIn, 0xa8);
+ if (EFI_ERROR (Status1)) {
+ KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");
+ return EFI_DEVICE_ERROR;
+ }
+ }
+
+ if (!EFI_ERROR (Status)) {
+ return EFI_SUCCESS;
+ } else {
+ return EFI_DEVICE_ERROR;
+ }
+
+}
+
+EFI_STATUS
+DisableKeyboard (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
+ )
+/*++
+
+Routine Description:
+
+ Disable the keyboard interface of the 8042 controller
+
+Arguments:
+
+ ConsoleIn - the device instance
+
+Returns:
+
+ EFI_STATUS
+
+--*/
+// GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
+{
+ EFI_STATUS Status;
+
+ //
+ // Disable keyboard interface
+ //
+ Status = KeyboardCommand (ConsoleIn, 0xad);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"\n\r");
+ return EFI_DEVICE_ERROR;
+ }
+
+ return Status;
+}
+
+/**
+ Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command
+ If Keyboard receives 0xF4, it will respond with 'ACK'. If it doesn't respond, the device
+ should not be in system.
+
+ @param[in] BiosKeyboardPrivate Keyboard Private Data Structure
+
+ @retval TRUE Keyboard in System.
+ @retval FALSE Keyboard not in System.
+**/
+BOOLEAN
+EFIAPI
+CheckKeyboardConnect (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
+ )
+{
+ EFI_STATUS Status;
+ UINTN WaitForValueTimeOutBcakup;
+
+ Status = EFI_SUCCESS;
+ //
+ // enable keyboard itself and wait for its ack
+ // If can't receive ack, Keyboard should not be connected.
+ //
+ Status = KeyboardWrite (
+ ConsoleIn,
+ KEYBOARD_KBEN
+ );
+
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+ //
+ // wait for 1s
+ //
+ WaitForValueTimeOutBcakup = mWaitForValueTimeOut;
+ mWaitForValueTimeOut = KEYBOARD_WAITFORVALUE_TIMEOUT;
+ Status = KeyboardWaitForValue (
+ ConsoleIn,
+ KEYBOARD_CMDECHO_ACK
+ );
+ mWaitForValueTimeOut = WaitForValueTimeOutBcakup;
+
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c new file mode 100644 index 0000000000..18ac83fb43 --- /dev/null +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c @@ -0,0 +1,306 @@ +/*++
+
+Copyright (c) 2006, Intel Corporation. All rights reserved. <BR>
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+
+Module Name:
+
+ Ps2KbdTextIn.c
+
+Abstract:
+
+ PS/2 Keyboard driver
+ Routines that support SIMPLE_TEXT_IN protocol
+
+Revision History
+
+--*/
+
+//
+// Include common header file for this module.
+//
+#include "CommonHeader.h"
+
+#include "Ps2Keyboard.h"
+
+//
+// function declarations
+//
+EFI_STATUS
+EFIAPI
+KeyboardEfiReset (
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
+ );
+
+EFI_STATUS
+EFIAPI
+KeyboardReadKeyStroke (
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ OUT EFI_INPUT_KEY *Key
+ );
+
+VOID
+EFIAPI
+KeyboardWaitForKey (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ );
+
+EFI_STATUS
+KeyboardCheckForKey (
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This
+ );
+
+EFI_STATUS
+EFIAPI
+KeyboardEfiReset (
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
+ )
+/*++
+
+Routine Description:
+
+ Implement SIMPLE_TEXT_IN.Reset()
+ Perform 8042 controller and keyboard initialization
+
+Arguments:
+
+Returns:
+
+--*/
+// GC_TODO: This - add argument and description to function comment
+// GC_TODO: ExtendedVerification - add argument and description to function comment
+// GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
+// GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
+// GC_TODO: EFI_SUCCESS - add return value to function comment
+{
+ EFI_STATUS Status;
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
+ EFI_TPL OldTpl;
+
+ ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);
+ if (ConsoleIn->KeyboardErr) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+ EFI_PROGRESS_CODE,
+ EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_RESET,
+ ConsoleIn->DevicePath
+ );
+
+ //
+ // Enter critical section
+ //
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+
+ //
+ // Call InitKeyboard to initialize the keyboard
+ //
+ Status = InitKeyboard (ConsoleIn, ExtendedVerification);
+ if (EFI_ERROR (Status)) {
+ //
+ // Leave critical section and return
+ //
+ gBS->RestoreTPL (OldTpl);
+ return EFI_DEVICE_ERROR;
+ }
+ //
+ // Clear the status of ConsoleIn.Key
+ //
+ ConsoleIn->Key.ScanCode = SCAN_NULL;
+ ConsoleIn->Key.UnicodeChar = 0x0000;
+
+ //
+ // Leave critical section and return
+ //
+ gBS->RestoreTPL (OldTpl);
+
+ //
+ // Report the status If a stuck key was detected
+ //
+ if (KeyReadStatusRegister (ConsoleIn) & 0x01) {
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+ EFI_ERROR_CODE | EFI_ERROR_MINOR,
+ EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_EC_STUCK_KEY,
+ ConsoleIn->DevicePath
+ );
+ }
+ //
+ // Report the status If keyboard is locked
+ //
+ if (!(KeyReadStatusRegister (ConsoleIn) & 0x10)) {
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+ EFI_ERROR_CODE | EFI_ERROR_MINOR,
+ EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_EC_LOCKED,
+ ConsoleIn->DevicePath
+ );
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+KeyboardReadKeyStroke (
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ OUT EFI_INPUT_KEY *Key
+ )
+/*++
+
+Routine Description:
+
+ Implement SIMPLE_TEXT_IN.ReadKeyStroke().
+ Retrieve key values for driver user.
+
+Arguments:
+
+Returns:
+
+--*/
+// GC_TODO: This - add argument and description to function comment
+// GC_TODO: Key - add argument and description to function comment
+// GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
+// GC_TODO: EFI_NOT_READY - add return value to function comment
+// GC_TODO: EFI_SUCCESS - add return value to function comment
+{
+ EFI_STATUS Status;
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
+ EFI_TPL OldTpl;
+
+ ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);
+
+ //
+ // Enter critical section
+ //
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+
+ if (ConsoleIn->KeyboardErr) {
+ //
+ // Leave critical section and return
+ //
+ gBS->RestoreTPL (OldTpl);
+
+ return EFI_DEVICE_ERROR;
+ }
+ //
+ // If there's no key, just return
+ //
+ Status = KeyboardCheckForKey (This);
+ if (EFI_ERROR (Status)) {
+ //
+ // Leave critical section and return
+ //
+ gBS->RestoreTPL (OldTpl);
+ return EFI_NOT_READY;
+ }
+
+ Key->ScanCode = ConsoleIn->Key.ScanCode;
+ Key->UnicodeChar = ConsoleIn->Key.UnicodeChar;
+
+ ConsoleIn->Key.ScanCode = SCAN_NULL;
+ ConsoleIn->Key.UnicodeChar = 0x0000;
+
+ //
+ // Leave critical section and return
+ //
+ gBS->RestoreTPL (OldTpl);
+
+ return EFI_SUCCESS;
+}
+
+VOID
+EFIAPI
+KeyboardWaitForKey (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ Event notification function for SIMPLE_TEXT_IN.WaitForKey event
+ Signal the event if there is key available
+
+Arguments:
+
+Returns:
+
+--*/
+// GC_TODO: Event - add argument and description to function comment
+// GC_TODO: Context - add argument and description to function comment
+{
+ EFI_TPL OldTpl;
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
+
+ ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (Context);
+
+ //
+ // Enter critical section
+ //
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+
+ if (ConsoleIn->KeyboardErr) {
+ //
+ // Leave critical section and return
+ //
+ gBS->RestoreTPL (OldTpl);
+ return ;
+ }
+ //
+ // Someone is waiting on the keyboard event, if there's
+ // a key pending, signal the event
+ //
+ if (!EFI_ERROR (KeyboardCheckForKey (Context))) {
+ gBS->SignalEvent (Event);
+ }
+ //
+ // Leave critical section and return
+ //
+ gBS->RestoreTPL (OldTpl);
+
+ return ;
+}
+
+EFI_STATUS
+KeyboardCheckForKey (
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ This - GC_TODO: add argument description
+
+Returns:
+
+ EFI_SUCCESS - GC_TODO: Add description for return value
+
+--*/
+{
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
+
+ ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);
+
+ //
+ // If ready to read next key, check it
+ //
+ if (ConsoleIn->Key.ScanCode == SCAN_NULL && ConsoleIn->Key.UnicodeChar == 0x00) {
+ return KeyGetchar (ConsoleIn);
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c new file mode 100644 index 0000000000..ef2e4a2374 --- /dev/null +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c @@ -0,0 +1,474 @@ +/*++
+
+Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved. <BR>
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+
+Module Name:
+
+ Ps2Keyboard.c
+
+Abstract:
+
+ PS/2 Keyboard driver. Routines that interacts with callers,
+ conforming to EFI driver model
+
+--*/
+
+//
+// Include common header file for this module.
+//
+#include "CommonHeader.h"
+
+#include "Ps2Keyboard.h"
+
+//
+// Function prototypes
+//
+EFI_STATUS
+EFIAPI
+KbdControllerDriverSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ );
+
+EFI_STATUS
+EFIAPI
+KbdControllerDriverStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ );
+
+EFI_STATUS
+EFIAPI
+KbdControllerDriverStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ );
+
+//
+// Global variables
+//
+//
+// DriverBinding Protocol Instance
+//
+EFI_DRIVER_BINDING_PROTOCOL gKeyboardControllerDriver = {
+ KbdControllerDriverSupported,
+ KbdControllerDriverStart,
+ KbdControllerDriverStop,
+ 0xa,
+ NULL,
+ NULL
+};
+
+EFI_STATUS
+EFIAPI
+KbdControllerDriverSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+/*++
+
+Routine Description:
+
+ ControllerDriver Protocol Method
+
+Arguments:
+
+Returns:
+
+--*/
+// GC_TODO: This - add argument and description to function comment
+// GC_TODO: Controller - add argument and description to function comment
+// GC_TODO: RemainingDevicePath - add argument and description to function comment
+{
+ EFI_STATUS Status;
+ EFI_ISA_IO_PROTOCOL *IsaIo;
+
+ //
+ // Open the IO Abstraction(s) needed to perform the supported test
+ //
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiIsaIoProtocolGuid,
+ (VOID **) &IsaIo,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Use the ISA I/O Protocol to see if Controller is the Keyboard controller
+ //
+ if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x303) || IsaIo->ResourceList->Device.UID != 0) {
+ Status = EFI_UNSUPPORTED;
+ }
+ //
+ // Close the I/O Abstraction(s) used to perform the supported test
+ //
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiIsaIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+
+ return Status;
+}
+
+EFI_STATUS
+EFIAPI
+KbdControllerDriverStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+/*++
+
+Routine Description:
+
+Arguments:
+
+Returns:
+
+--*/
+// GC_TODO: This - add argument and description to function comment
+// GC_TODO: Controller - add argument and description to function comment
+// GC_TODO: RemainingDevicePath - add argument and description to function comment
+// GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
+{
+ EFI_STATUS Status;
+ EFI_STATUS Status1;
+ EFI_ISA_IO_PROTOCOL *IsaIo;
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
+ UINT8 Data;
+ EFI_STATUS_CODE_VALUE StatusCode;
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
+
+ StatusCode = 0;
+
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **) &ParentDevicePath,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Report that the keyboard is being enabled
+ //
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+ EFI_PROGRESS_CODE,
+ EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_ENABLE,
+ ParentDevicePath
+ );
+
+ //
+ // Get the ISA I/O Protocol on Controller's handle
+ //
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiIsaIoProtocolGuid,
+ (VOID **) &IsaIo,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (EFI_ERROR (Status)) {
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Allocate private data
+ //
+ ConsoleIn = AllocateZeroPool (sizeof (KEYBOARD_CONSOLE_IN_DEV));
+ if (ConsoleIn == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;
+ goto ErrorExit;
+ }
+ //
+ // Setup the device instance
+ //
+ ConsoleIn->Signature = KEYBOARD_CONSOLE_IN_DEV_SIGNATURE;
+ ConsoleIn->Handle = Controller;
+ (ConsoleIn->ConIn).Reset = KeyboardEfiReset;
+ (ConsoleIn->ConIn).ReadKeyStroke = KeyboardReadKeyStroke;
+ ConsoleIn->DataRegisterAddress = KEYBOARD_8042_DATA_REGISTER;
+ ConsoleIn->StatusRegisterAddress = KEYBOARD_8042_STATUS_REGISTER;
+ ConsoleIn->CommandRegisterAddress = KEYBOARD_8042_COMMAND_REGISTER;
+ ConsoleIn->IsaIo = IsaIo;
+ ConsoleIn->ScancodeBufStartPos = 0;
+ ConsoleIn->ScancodeBufEndPos = KEYBOARD_BUFFER_MAX_COUNT - 1;
+ ConsoleIn->ScancodeBufCount = 0;
+ ConsoleIn->Ctrled = FALSE;
+ ConsoleIn->Alted = FALSE;
+ ConsoleIn->DevicePath = ParentDevicePath;
+
+ //
+ // Setup the WaitForKey event
+ //
+ Status = gBS->CreateEvent (
+ EVT_NOTIFY_WAIT,
+ TPL_NOTIFY,
+ KeyboardWaitForKey,
+ &(ConsoleIn->ConIn),
+ &((ConsoleIn->ConIn).WaitForKey)
+ );
+ if (EFI_ERROR (Status)) {
+ Status = EFI_OUT_OF_RESOURCES;
+ StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;
+ goto ErrorExit;
+ }
+ //
+ // Setup a periodic timer, used for reading keystrokes at a fixed interval
+ //
+ Status = gBS->CreateEvent (
+ EVT_TIMER | EVT_NOTIFY_SIGNAL,
+ TPL_NOTIFY,
+ KeyboardTimerHandler,
+ ConsoleIn,
+ &ConsoleIn->TimerEvent
+ );
+ if (EFI_ERROR (Status)) {
+ Status = EFI_OUT_OF_RESOURCES;
+ StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;
+ goto ErrorExit;
+ }
+
+ Status = gBS->SetTimer (
+ ConsoleIn->TimerEvent,
+ TimerPeriodic,
+ KEYBOARD_TIMER_INTERVAL
+ );
+ if (EFI_ERROR (Status)) {
+ Status = EFI_OUT_OF_RESOURCES;
+ StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;
+ goto ErrorExit;
+ }
+
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+ EFI_PROGRESS_CODE,
+ EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_PRESENCE_DETECT,
+ ParentDevicePath
+ );
+
+ //
+ // Reset the keyboard device
+ //
+ Status = ConsoleIn->ConIn.Reset (&ConsoleIn->ConIn, TRUE);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_DEVICE_ERROR;
+ StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_NOT_DETECTED;
+ goto ErrorExit;
+ }
+
+ ConsoleIn->ControllerNameTable = NULL;
+ AddUnicodeString (
+ "eng",
+ gPs2KeyboardComponentName.SupportedLanguages,
+ &ConsoleIn->ControllerNameTable,
+ L"PS/2 Keyboard Device"
+ );
+
+ //
+ // Install protocol interfaces for the keyboard device.
+ //
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Controller,
+ &gEfiSimpleTextInProtocolGuid,
+ &ConsoleIn->ConIn,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;
+ goto ErrorExit;
+ }
+
+ return Status;
+
+ErrorExit:
+ //
+ // Report error code
+ //
+ if (StatusCode != 0) {
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+ EFI_ERROR_CODE | EFI_ERROR_MINOR,
+ StatusCode,
+ ParentDevicePath
+ );
+ }
+
+ if ((ConsoleIn != NULL) && (ConsoleIn->ConIn.WaitForKey != NULL)) {
+ gBS->CloseEvent (ConsoleIn->ConIn.WaitForKey);
+ }
+
+ if ((ConsoleIn != NULL) && (ConsoleIn->TimerEvent != NULL)) {
+ gBS->CloseEvent (ConsoleIn->TimerEvent);
+ }
+
+ if ((ConsoleIn != NULL) && (ConsoleIn->ControllerNameTable != NULL)) {
+ FreeUnicodeStringTable (ConsoleIn->ControllerNameTable);
+ }
+ //
+ // Since there will be no timer handler for keyboard input any more,
+ // exhaust input data just in case there is still keyboard data left
+ //
+ Status1 = EFI_SUCCESS;
+ while (!EFI_ERROR (Status1)) {
+ Status1 = KeyboardRead (ConsoleIn, &Data);;
+ }
+
+ if (ConsoleIn != NULL) {
+ gBS->FreePool (ConsoleIn);
+ }
+
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiIsaIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+
+ return Status;
+}
+
+EFI_STATUS
+EFIAPI
+KbdControllerDriverStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ )
+/*++
+
+ Routine Description:
+
+ Arguments:
+
+ Returns:
+
+--*/
+// GC_TODO: This - add argument and description to function comment
+// GC_TODO: Controller - add argument and description to function comment
+// GC_TODO: NumberOfChildren - add argument and description to function comment
+// GC_TODO: ChildHandleBuffer - add argument and description to function comment
+// GC_TODO: EFI_SUCCESS - add return value to function comment
+{
+ EFI_STATUS Status;
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
+ UINT8 Data;
+
+ //
+ // Disable Keyboard
+ //
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiSimpleTextInProtocolGuid,
+ (VOID **) &ConIn,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (ConIn);
+
+ //
+ // Report that the keyboard is being disabled
+ //
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+ EFI_PROGRESS_CODE,
+ EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_DISABLE,
+ ConsoleIn->DevicePath
+ );
+
+ if (ConsoleIn->TimerEvent) {
+ gBS->CloseEvent (ConsoleIn->TimerEvent);
+ ConsoleIn->TimerEvent = NULL;
+ }
+ //
+ // Disable the keyboard interface
+ //
+ Status = DisableKeyboard (ConsoleIn);
+
+ //
+ // Since there will be no timer handler for keyboard input any more,
+ // exhaust input data just in case there is still keyboard data left
+ //
+ Status = EFI_SUCCESS;
+ while (!EFI_ERROR (Status)) {
+ Status = KeyboardRead (ConsoleIn, &Data);;
+ }
+ //
+ // Uninstall the Simple TextIn Protocol
+ //
+ Status = gBS->UninstallProtocolInterface (
+ Controller,
+ &gEfiSimpleTextInProtocolGuid,
+ &ConsoleIn->ConIn
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiIsaIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+
+ //
+ // Free other resources
+ //
+ if ((ConsoleIn->ConIn).WaitForKey) {
+ gBS->CloseEvent ((ConsoleIn->ConIn).WaitForKey);
+ (ConsoleIn->ConIn).WaitForKey = NULL;
+ }
+
+ FreeUnicodeStringTable (ConsoleIn->ControllerNameTable);
+ gBS->FreePool (ConsoleIn);
+
+ return EFI_SUCCESS;
+}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h new file mode 100644 index 0000000000..58af5ff2a6 --- /dev/null +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h @@ -0,0 +1,361 @@ +/**@file
+ PS/2 keyboard driver header file
+
+Copyright (c) 2006 - 2007 Intel Corporation. All rights reserved. <BR>
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+**/
+
+#ifndef _PS2KEYBOARD_H
+#define _PS2KEYBOARD_H
+
+//
+// Include common header file for this module.
+//
+#include "CommonHeader.h"
+
+//
+// Driver Private Data
+//
+#define KEYBOARD_BUFFER_MAX_COUNT 32
+#define KEYBOARD_CONSOLE_IN_DEV_SIGNATURE EFI_SIGNATURE_32 ('k', 'k', 'e', 'y')
+
+typedef struct {
+ UINTN Signature;
+
+ EFI_HANDLE Handle;
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL ConIn;
+ EFI_ISA_IO_PROTOCOL *IsaIo;
+
+ EFI_EVENT TimerEvent;
+
+ UINT32 DataRegisterAddress;
+ UINT32 StatusRegisterAddress;
+ UINT32 CommandRegisterAddress;
+
+ EFI_INPUT_KEY Key;
+
+ BOOLEAN Ctrl;
+ BOOLEAN Alt;
+ BOOLEAN Shift;
+ BOOLEAN CapsLock;
+ BOOLEAN NumLock;
+ BOOLEAN ScrollLock;
+
+ //
+ // Buffer storing key scancodes
+ //
+ UINT8 ScancodeBuf[KEYBOARD_BUFFER_MAX_COUNT];
+ UINT32 ScancodeBufStartPos;
+ UINT32 ScancodeBufEndPos;
+ UINT32 ScancodeBufCount;
+
+ //
+ // Indicators of the key pressing state, used in detecting Alt+Ctrl+Del
+ //
+ BOOLEAN Ctrled;
+ BOOLEAN Alted;
+
+ //
+ // Error state
+ //
+ BOOLEAN KeyboardErr;
+
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;
+
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+} KEYBOARD_CONSOLE_IN_DEV;
+
+#define KEYBOARD_CONSOLE_IN_DEV_FROM_THIS(a) CR (a, KEYBOARD_CONSOLE_IN_DEV, ConIn, KEYBOARD_CONSOLE_IN_DEV_SIGNATURE)
+
+#define TABLE_END 0x0
+
+//
+// Global Variables
+//
+extern EFI_DRIVER_BINDING_PROTOCOL gKeyboardControllerDriver;
+extern EFI_COMPONENT_NAME_PROTOCOL gPs2KeyboardComponentName;
+
+//
+// Driver entry point
+//
+EFI_STATUS
+InstallPs2KeyboardDriver (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ ImageHandle - GC_TODO: add argument description
+ SystemTable - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+#define KEYBOARD_8042_DATA_REGISTER 0x60
+#define KEYBOARD_8042_STATUS_REGISTER 0x64
+#define KEYBOARD_8042_COMMAND_REGISTER 0x64
+
+#define KEYBOARD_KBEN 0xF4
+#define KEYBOARD_CMDECHO_ACK 0xFA
+
+#define KEYBOARD_TIMEOUT 65536 // 0.07s
+#define KEYBOARD_WAITFORVALUE_TIMEOUT 1000000 // 1s
+#define KEYBOARD_BAT_TIMEOUT 4000000 // 4s
+#define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s
+#define SCANCODE_EXTENDED 0xE0
+#define SCANCODE_EXTENDED1 0xE1
+#define SCANCODE_CTRL_MAKE 0x1D
+#define SCANCODE_CTRL_BREAK 0x9D
+#define SCANCODE_ALT_MAKE 0x38
+#define SCANCODE_ALT_BREAK 0xB8
+#define SCANCODE_LEFT_SHIFT_MAKE 0x2A
+#define SCANCODE_LEFT_SHIFT_BREAK 0xAA
+#define SCANCODE_RIGHT_SHIFT_MAKE 0x36
+#define SCANCODE_RIGHT_SHIFT_BREAK 0xB6
+#define SCANCODE_CAPS_LOCK_MAKE 0x3A
+#define SCANCODE_NUM_LOCK_MAKE 0x45
+#define SCANCODE_SCROLL_LOCK_MAKE 0x46
+#define SCANCODE_MAX_MAKE 0x59
+
+//
+// Other functions that are used among .c files
+//
+EFI_STATUS
+KeyboardRead (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
+ OUT UINT8 *Data
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ ConsoleIn - GC_TODO: add argument description
+ Data - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+KeyGetchar (
+ IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ ConsoleIn - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+InitKeyboard (
+ IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
+ IN BOOLEAN ExtendedVerification
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ ConsoleIn - GC_TODO: add argument description
+ ExtendedVerification - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+DisableKeyboard (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ ConsoleIn - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+VOID
+EFIAPI
+KeyboardTimerHandler (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Event - GC_TODO: add argument description
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+KeyboardEfiReset (
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ This - GC_TODO: add argument description
+ ExtendedVerification - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+KeyboardReadKeyStroke (
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ OUT EFI_INPUT_KEY *Key
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ This - GC_TODO: add argument description
+ Key - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+VOID
+EFIAPI
+KeyboardWaitForKey (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Event - GC_TODO: add argument description
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+UINT8
+KeyReadStatusRegister (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ ConsoleIn - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+/**
+ Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command
+ If Keyboard receives 0xF4, it will respond with 'ACK'. If it doesn't respond, the device
+ should not be in system.
+
+ @param[in] BiosKeyboardPrivate Keyboard Private Data Structure
+
+ @retval TRUE Keyboard in System.
+ @retval FALSE Keyboard not in System.
+**/
+BOOLEAN
+EFIAPI
+CheckKeyboardConnect (
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
+ )
+;
+#endif
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboard.inf b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboard.inf new file mode 100644 index 0000000000..c6698902cb --- /dev/null +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboard.inf @@ -0,0 +1,108 @@ +#/** @file
+# Ps2 Keyboard Driver
+#
+# This dirver directly uses IsaIo protocol service to support KeyBoard work.
+# Copyright (c) 2006 - 2007, Intel Corporation.
+#
+# All rights reserved.
+# This software and associated documentation (if any) is furnished
+# under a license and may only be used or copied in accordance
+# with the terms of the license. Except as permitted by such
+# license, no part of this software or documentation may be
+# reproduced, stored in a retrieval system, or transmitted in any
+# form or by any means without the express written consent of
+# Intel Corporation.
+#
+#
+#**/
+
+################################################################################
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+################################################################################
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = Ps2Keyboard
+ FILE_GUID = 3DC82376-637B-40a6-A8FC-A565417F2C38
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ EDK_RELEASE_VERSION = 0x00020000
+ EFI_SPECIFICATION_VERSION = 0x00020000
+
+ ENTRY_POINT = InitializePs2Keyboard
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+# DRIVER_BINDING = gKeyboardControllerDriver
+# COMPONENT_NAME = gPs2KeyboardComponentName
+# Create Event Guid C Name: Event Type: EVENT_TYPE_RELATIVE_TIMER
+# Create Event Guid C Name: Event Type: EVENT_TYPE_PERIODIC_TIMER
+#
+# Signal Event Guid C Name: Event Type: EVENT_TYPE_PERIODIC_TIMER
+#
+#
+
+################################################################################
+#
+# Sources Section - list of files that are required for the build to succeed.
+#
+################################################################################
+
+[Sources.common]
+ ComponentName.c
+ Ps2Keyboard.h
+ Ps2KbdCtrller.c
+ Ps2KbdTextIn.c
+ Ps2Keyboard.c
+ CommonHeader.h
+ EntryPoint.c
+
+
+################################################################################
+#
+# Package Dependency Section - list of Package files that are required for
+# this module.
+#
+################################################################################
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ IntelFrameworkPkg/IntelFrameworkPkg.dec
+ IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
+
+
+################################################################################
+#
+# Library Class Section - list of Library Classes that are required for
+# this module.
+#
+################################################################################
+
+[LibraryClasses]
+ MemoryAllocationLib
+ UefiRuntimeServicesTableLib
+ DebugLib
+ ReportStatusCodeLib
+ UefiBootServicesTableLib
+ UefiLib
+ UefiDriverEntryPoint
+
+
+################################################################################
+#
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names
+# that this module uses or produces.
+#
+################################################################################
+
+[Protocols]
+ gEfiPs2PolicyProtocolGuid # PROTOCOL TO_START
+ gEfiIsaIoProtocolGuid # PROTOCOL TO_START
+ gEfiSimpleTextInProtocolGuid # PROTOCOL BY_START
+ gEfiDevicePathProtocolGuid # PROTOCOL TO_START
+
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboard.msa b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboard.msa new file mode 100644 index 0000000000..ddf62a41eb --- /dev/null +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboard.msa @@ -0,0 +1,104 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<ModuleSurfaceArea xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd" xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <MsaHeader>
+ <ModuleName>Ps2Keyboard</ModuleName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <GuidValue>3DC82376-637B-40a6-A8FC-A565417F2C38</GuidValue>
+ <Version>1.0</Version>
+ <Abstract>Ps2 Keyboard Driver</Abstract>
+ <Description>This dirver directly uses IsaIo protocol service to support KeyBoard work.</Description>
+ <Copyright>Copyright (c) 2006 - 2007, Intel Corporation.</Copyright>
+ <License>All rights reserved. + This software and associated documentation (if any) is furnished + under a license and may only be used or copied in accordance + with the terms of the license. Except as permitted by such + license, no part of this software or documentation may be + reproduced, stored in a retrieval system, or transmitted in any + form or by any means without the express written consent of + Intel Corporation.</License>
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
+ </MsaHeader>
+ <ModuleDefinitions>
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
+ <BinaryModule>false</BinaryModule>
+ <OutputFileBasename>Ps2Keyboard</OutputFileBasename>
+ </ModuleDefinitions>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>UefiDriverModelLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>UefiDriverEntryPoint</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>UefiLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>UefiBootServicesTableLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>ReportStatusCodeLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>DebugLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>UefiRuntimeServicesTableLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>MemoryAllocationLib</Keyword>
+ </LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>Ps2Keyboard.c</Filename>
+ <Filename>Ps2KbdTextIn.c</Filename>
+ <Filename>Ps2KbdCtrller.c</Filename>
+ <Filename>Ps2Keyboard.h</Filename>
+ <Filename>ComponentName.c</Filename>
+ </SourceFiles>
+ <PackageDependencies>
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+ <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+ <Package PackageGuid="bea835f9-fd62-464a-81ff-f3a806360c6b"/>
+ </PackageDependencies>
+ <Protocols>
+ <Protocol Usage="TO_START">
+ <ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>
+ </Protocol>
+ <Protocol Usage="BY_START">
+ <ProtocolCName>gEfiSimpleTextInProtocolGuid</ProtocolCName>
+ </Protocol>
+ <Protocol Usage="TO_START">
+ <ProtocolCName>gEfiIsaIoProtocolGuid</ProtocolCName>
+ </Protocol>
+ <Protocol Usage="TO_START">
+ <ProtocolCName>gEfiPs2PolicyProtocolGuid</ProtocolCName>
+ </Protocol>
+ </Protocols>
+ <Events>
+ <CreateEvents>
+ <EventTypes Usage="ALWAYS_PRODUCED">
+ <EventType>EVENT_TYPE_RELATIVE_TIMER</EventType>
+ <HelpText>Set up event in order to wait for key stroke</HelpText>
+ </EventTypes>
+ <EventTypes Usage="ALWAYS_PRODUCED">
+ <EventType>EVENT_TYPE_PERIODIC_TIMER</EventType>
+ <HelpText>Set up a periodic timer to read key strokes at a fixed interval</HelpText>
+ </EventTypes>
+ </CreateEvents>
+ <SignalEvents>
+ <EventTypes Usage="SOMETIMES_PRODUCED">
+ <EventType>EVENT_TYPE_PERIODIC_TIMER</EventType>
+ <HelpText>Signal an event wheneven there is a key pending</HelpText>
+ </EventTypes>
+ </SignalEvents>
+ </Events>
+ <Externs>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
+ <Extern>
+ <DriverBinding>gKeyboardControllerDriver</DriverBinding>
+ <ComponentName>gPs2KeyboardComponentName</ComponentName>
+ </Extern>
+ </Externs>
+</ModuleSurfaceArea>
\ No newline at end of file diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.c new file mode 100644 index 0000000000..521650471b --- /dev/null +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.c @@ -0,0 +1,1110 @@ +/*++
+
+Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved. <BR>
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+
+Module Name:
+
+ CommPs2.c
+
+Abstract:
+
+ PS2 Mouse Communication Interface
+
+
+Revision History
+
+--*/
+
+//
+// Include common header file for this module.
+//
+#include "CommonHeader.h"
+
+#include "Ps2Mouse.h"
+#include "CommPs2.h"
+
+UINT8 SampleRateTbl[MAX_SR] = { 0xa, 0x14, 0x28, 0x3c, 0x50, 0x64, 0xc8 };
+
+UINT8 ResolutionTbl[MAX_CMR] = { 0, 1, 2, 3 };
+
+EFI_STATUS
+KbcSelfTest (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+
+Returns:
+
+ EFI_DEVICE_ERROR - GC_TODO: Add description for return value
+ EFI_SUCCESS - GC_TODO: Add description for return value
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT8 Data;
+
+ //
+ // Keyboard controller self test
+ //
+ Status = Out8042Command (IsaIo, SELF_TEST);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Read return code
+ //
+ Status = In8042Data (IsaIo, &Data);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (Data != 0x55) {
+ return EFI_DEVICE_ERROR;
+ }
+ //
+ // Set system flag
+ //
+ Status = Out8042Command (IsaIo, READ_CMD_BYTE);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = In8042Data (IsaIo, &Data);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = Out8042Command (IsaIo, WRITE_CMD_BYTE);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Data |= CMD_SYS_FLAG;
+ Status = Out8042Data (IsaIo, Data);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+KbcEnableAux (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ //
+ // Send 8042 enable mouse command
+ //
+ return Out8042Command (IsaIo, ENABLE_AUX);
+}
+
+EFI_STATUS
+KbcDisableAux (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ //
+ // Send 8042 disable mouse command
+ //
+ return Out8042Command (IsaIo, DISABLE_AUX);
+}
+
+EFI_STATUS
+KbcEnableKb (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ //
+ // Send 8042 enable keyboard command
+ //
+ return Out8042Command (IsaIo, ENABLE_KB);
+}
+
+EFI_STATUS
+KbcDisableKb (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ //
+ // Send 8042 disable keyboard command
+ //
+ return Out8042Command (IsaIo, DISABLE_KB);
+}
+
+EFI_STATUS
+CheckKbStatus (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ OUT BOOLEAN *KeyboardEnable
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+ KeyboardEnable - GC_TODO: add argument description
+
+Returns:
+
+ EFI_SUCCESS - GC_TODO: Add description for return value
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT8 Data;
+
+ //
+ // Send command to read KBC command byte
+ //
+ Status = Out8042Command (IsaIo, READ_CMD_BYTE);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = In8042Data (IsaIo, &Data);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Check keyboard enable or not
+ //
+ if ((Data & CMD_KB_STS) == CMD_KB_DIS) {
+ *KeyboardEnable = FALSE;
+ } else {
+ *KeyboardEnable = TRUE;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+PS2MouseReset (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+
+Returns:
+
+ EFI_DEVICE_ERROR - GC_TODO: Add description for return value
+ EFI_DEVICE_ERROR - GC_TODO: Add description for return value
+ EFI_SUCCESS - GC_TODO: Add description for return value
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT8 Data;
+
+ Status = Out8042AuxCommand (IsaIo, RESET_CMD, FALSE);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = In8042AuxData (IsaIo, &Data);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Check BAT Complete Code
+ //
+ if (Data != PS2MOUSE_BAT1) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ Status = In8042AuxData (IsaIo, &Data);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Check BAT Complete Code
+ //
+ if (Data != PS2MOUSE_BAT2) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+PS2MouseSetSampleRate (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN MOUSE_SR SampleRate
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+ SampleRate - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ EFI_STATUS Status;
+
+ //
+ // Send auxiliary command to set mouse sample rate
+ //
+ Status = Out8042AuxCommand (IsaIo, SETSR_CMD, FALSE);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = Out8042AuxData (IsaIo, SampleRateTbl[SampleRate]);
+
+ return Status;
+}
+
+EFI_STATUS
+PS2MouseSetResolution (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN MOUSE_RE Resolution
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+ Resolution - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ EFI_STATUS Status;
+
+ //
+ // Send auxiliary command to set mouse resolution
+ //
+ Status = Out8042AuxCommand (IsaIo, SETRE_CMD, FALSE);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = Out8042AuxData (IsaIo, ResolutionTbl[Resolution]);
+
+ return Status;
+}
+
+EFI_STATUS
+PS2MouseSetScaling (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN MOUSE_SF Scaling
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+ Scaling - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ UINT8 Command;
+
+ Command = (UINT8) (Scaling == SF1 ? SETSF1_CMD : SETSF2_CMD);
+
+ //
+ // Send auxiliary command to set mouse scaling data
+ //
+ return Out8042AuxCommand (IsaIo, Command, FALSE);
+}
+
+EFI_STATUS
+PS2MouseEnable (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ //
+ // Send auxiliary command to enable mouse
+ //
+ return Out8042AuxCommand (IsaIo, ENABLE_CMD, FALSE);
+}
+
+EFI_STATUS
+PS2MouseGetPacket (
+ PS2_MOUSE_DEV *MouseDev
+ )
+/*++
+
+Routine Description:
+
+ Get mouse packet . Only care first 3 bytes
+
+Arguments:
+
+ MouseDev - Pointer of PS2 Mouse Private Data Structure
+
+Returns:
+
+ EFI_NOT_READY - Mouse Device not ready to input data packet, or some error happened during getting the packet
+ EFI_SUCCESS - The data packet is gotten successfully.
+
+--*/
+{
+ EFI_STATUS Status;
+ BOOLEAN KeyboardEnable;
+ UINT8 Packet[PS2_PACKET_LENGTH];
+ UINT8 Data;
+ UINTN Count;
+ UINTN State;
+ INT16 RelativeMovementX;
+ INT16 RelativeMovementY;
+ BOOLEAN LButton;
+ BOOLEAN RButton;
+
+ KeyboardEnable = FALSE;
+ Count = 1;
+ State = PS2_READ_BYTE_ONE;
+
+ //
+ // State machine to get mouse packet
+ //
+ while (1) {
+
+ switch (State) {
+ case PS2_READ_BYTE_ONE:
+ //
+ // Read mouse first byte data, if failed, immediately return
+ //
+ KbcDisableAux (MouseDev->IsaIo);
+ Status = PS2MouseRead (MouseDev->IsaIo, &Data, &Count, State);
+ if (EFI_ERROR (Status)) {
+ KbcEnableAux (MouseDev->IsaIo);
+ return EFI_NOT_READY;
+ }
+
+ if (Count != 1) {
+ KbcEnableAux (MouseDev->IsaIo);
+ return EFI_NOT_READY;
+ }
+
+ if (IS_PS2_SYNC_BYTE (Data)) {
+ Packet[0] = Data;
+ State = PS2_READ_DATA_BYTE;
+
+ CheckKbStatus (MouseDev->IsaIo, &KeyboardEnable);
+ KbcDisableKb (MouseDev->IsaIo);
+ KbcEnableAux (MouseDev->IsaIo);
+ }
+ break;
+
+ case PS2_READ_DATA_BYTE:
+ Count = 2;
+ Status = PS2MouseRead (MouseDev->IsaIo, (Packet + 1), &Count, State);
+ if (EFI_ERROR (Status)) {
+ if (KeyboardEnable) {
+ KbcEnableKb (MouseDev->IsaIo);
+ }
+
+ return EFI_NOT_READY;
+ }
+
+ if (Count != 2) {
+ if (KeyboardEnable) {
+ KbcEnableKb (MouseDev->IsaIo);
+ }
+
+ return EFI_NOT_READY;
+ }
+
+ State = PS2_PROCESS_PACKET;
+ break;
+
+ case PS2_PROCESS_PACKET:
+ if (KeyboardEnable) {
+ KbcEnableKb (MouseDev->IsaIo);
+ }
+ //
+ // Decode the packet
+ //
+ RelativeMovementX = Packet[1];
+ RelativeMovementY = Packet[2];
+ //
+ // Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0
+ // Byte 0 | Y overflow | X overflow | Y sign bit | X sign bit | Always 1 | Middle Btn | Right Btn | Left Btn
+ // Byte 1 | 8 bit X Movement
+ // Byte 2 | 8 bit Y Movement
+ //
+ // X sign bit + 8 bit X Movement : 9-bit signed twos complement integer that presents the relative displacement of the device in the X direction since the last data transmission.
+ // Y sign bit + 8 bit Y Movement : Same as X sign bit + 8 bit X Movement.
+ //
+ //
+ // First, Clear X and Y high 8 bits
+ //
+ RelativeMovementX = (INT16) (RelativeMovementX & 0xFF);
+ RelativeMovementY = (INT16) (RelativeMovementY & 0xFF);
+ //
+ // Second, if the 9-bit signed twos complement integer is negative, set the high 8 bit 0xff
+ //
+ if ((Packet[0] & 0x10) != 0) {
+ RelativeMovementX = (INT16) (RelativeMovementX | 0xFF00);
+ }
+ if ((Packet[0] & 0x20) != 0) {
+ RelativeMovementY = (INT16) (RelativeMovementY | 0xFF00);
+ }
+
+
+ RButton = (UINT8) (Packet[0] & 0x2);
+ LButton = (UINT8) (Packet[0] & 0x1);
+
+ //
+ // Update mouse state
+ //
+ MouseDev->State.RelativeMovementX += RelativeMovementX;
+ MouseDev->State.RelativeMovementY -= RelativeMovementY;
+ MouseDev->State.RightButton = (UINT8) (RButton ? TRUE : FALSE);
+ MouseDev->State.LeftButton = (UINT8) (LButton ? TRUE : FALSE);
+ MouseDev->StateChanged = TRUE;
+
+ return EFI_SUCCESS;
+ }
+ }
+}
+
+EFI_STATUS
+PS2MouseRead (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ OUT VOID *Buffer,
+ IN OUT UINTN *BufSize,
+ IN UINTN State
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+ Buffer - GC_TODO: add argument description
+ BufSize - GC_TODO: add argument description
+ State - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ 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;
+}
+//
+// 8042 I/O function
+//
+EFI_STATUS
+Out8042Command (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN UINT8 Command
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+ Command - GC_TODO: add argument description
+
+Returns:
+
+ EFI_SUCCESS - GC_TODO: Add description for return value
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT8 Data;
+
+ //
+ // Wait keyboard controller input buffer empty
+ //
+ Status = WaitInputEmpty (IsaIo, TIMEOUT);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Send command
+ //
+ Data = Command;
+ IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
+
+ Status = WaitInputEmpty (IsaIo, TIMEOUT);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+Out8042Data (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN UINT8 Data
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+ Data - GC_TODO: add argument description
+
+Returns:
+
+ EFI_SUCCESS - GC_TODO: Add description for return value
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT8 temp;
+ //
+ // Wait keyboard controller input buffer empty
+ //
+ Status = WaitInputEmpty (IsaIo, TIMEOUT);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ temp = Data;
+ IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &temp);
+
+ Status = WaitInputEmpty (IsaIo, TIMEOUT);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+In8042Data (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN OUT UINT8 *Data
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+ Data - GC_TODO: add argument description
+
+Returns:
+
+ EFI_TIMEOUT - GC_TODO: Add description for return value
+ EFI_SUCCESS - GC_TODO: Add description for return value
+
+--*/
+{
+ UINTN Delay;
+ UINT8 temp;
+
+ Delay = TIMEOUT / 50;
+
+ do {
+ IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &temp);
+
+ //
+ // Check keyboard controller status bit 0(output buffer status)
+ //
+ if ((temp & KBC_OUTB) == KBC_OUTB) {
+ break;
+ }
+
+ gBS->Stall (50);
+ Delay--;
+ } while (Delay);
+
+ if (Delay == 0) {
+ return EFI_TIMEOUT;
+ }
+
+ IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, Data);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+Out8042AuxCommand (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN UINT8 Command,
+ IN BOOLEAN Resend
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+ Command - GC_TODO: add argument description
+ Resend - GC_TODO: add argument description
+
+Returns:
+
+ EFI_SUCCESS - GC_TODO: Add description for return value
+ EFI_DEVICE_ERROR - GC_TODO: Add description for return value
+ EFI_DEVICE_ERROR - GC_TODO: Add description for return value
+ EFI_SUCCESS - GC_TODO: Add description for return value
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT8 Data;
+
+ //
+ // Wait keyboard controller input buffer empty
+ //
+ Status = WaitInputEmpty (IsaIo, TIMEOUT);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Send write to auxiliary device command
+ //
+ Data = WRITE_AUX_DEV;
+ IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
+
+ Status = WaitInputEmpty (IsaIo, TIMEOUT);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Send auxiliary device command
+ //
+ IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Command);
+
+ //
+ // Read return code
+ //
+ Status = In8042AuxData (IsaIo, &Data);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (Data == PS2_ACK) {
+ //
+ // Receive mouse acknowledge, command send success
+ //
+ return EFI_SUCCESS;
+
+ } else if (Resend) {
+ //
+ // Resend fail
+ //
+ return EFI_DEVICE_ERROR;
+
+ } else if (Data == PS2_RESEND) {
+ //
+ // Resend command
+ //
+ Status = Out8042AuxCommand (IsaIo, Command, TRUE);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ } else {
+ //
+ // Invalid return code
+ //
+ return EFI_DEVICE_ERROR;
+
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+Out8042AuxData (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN UINT8 Data
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+ Data - GC_TODO: add argument description
+
+Returns:
+
+ EFI_SUCCESS - GC_TODO: Add description for return value
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT8 Temp;
+ //
+ // Wait keyboard controller input buffer empty
+ //
+ Status = WaitInputEmpty (IsaIo, TIMEOUT);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Send write to auxiliary device command
+ //
+ Temp = WRITE_AUX_DEV;
+ IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Temp);
+
+ Status = WaitInputEmpty (IsaIo, TIMEOUT);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Temp = Data;
+ IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Temp);
+
+ Status = WaitInputEmpty (IsaIo, TIMEOUT);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+In8042AuxData (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN OUT UINT8 *Data
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+ Data - GC_TODO: add argument description
+
+Returns:
+
+ EFI_SUCCESS - GC_TODO: Add description for return value
+
+--*/
+{
+ 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;
+}
+
+EFI_STATUS
+CheckForInput (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+
+Returns:
+
+ EFI_NOT_READY - GC_TODO: Add description for return value
+ EFI_SUCCESS - GC_TODO: Add description for return value
+
+--*/
+{
+ UINT8 Data;
+
+ IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
+
+ //
+ // Check keyboard controller status, if it is output buffer full and for auxiliary device
+ //
+ if ((Data & (KBC_OUTB | KBC_AUXB)) != (KBC_OUTB | KBC_AUXB)) {
+ return EFI_NOT_READY;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+WaitInputEmpty (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN UINTN Timeout
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+ Timeout - GC_TODO: add argument description
+
+Returns:
+
+ EFI_TIMEOUT - GC_TODO: Add description for return value
+ EFI_SUCCESS - GC_TODO: Add description for return value
+
+--*/
+{
+ UINTN Delay;
+ UINT8 Data;
+
+ Delay = Timeout / 50;
+
+ do {
+ IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
+
+ //
+ // Check keyboard controller status bit 1(input buffer status)
+ //
+ if ((Data & KBC_INPB) == 0) {
+ break;
+ }
+
+ gBS->Stall (50);
+ Delay--;
+ } while (Delay);
+
+ if (Delay == 0) {
+ return EFI_TIMEOUT;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+WaitOutputFull (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN UINTN Timeout
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+ Timeout - GC_TODO: add argument description
+
+Returns:
+
+ EFI_TIMEOUT - GC_TODO: Add description for return value
+ EFI_SUCCESS - GC_TODO: Add description for return value
+
+--*/
+{
+ UINTN Delay;
+ UINT8 Data;
+
+ Delay = Timeout / 50;
+
+ do {
+ IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
+
+ //
+ // Check keyboard controller status bit 0(output buffer status)
+ // & bit5(output buffer for auxiliary device)
+ //
+ if ((Data & (KBC_OUTB | KBC_AUXB)) == (KBC_OUTB | KBC_AUXB)) {
+ break;
+ }
+
+ gBS->Stall (50);
+ Delay--;
+ } while (Delay);
+
+ if (Delay == 0) {
+ return EFI_TIMEOUT;
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.h b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.h new file mode 100644 index 0000000000..a997ce6246 --- /dev/null +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.h @@ -0,0 +1,445 @@ +/*++
+
+Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+
+Module Name:
+
+ CommPs2.h
+
+Abstract:
+
+ PS2 Mouse Communication Interface
+
+
+Revision History
+
+--*/
+
+#ifndef _COMMPS2_H_
+#define _COMMPS2_H_
+
+//
+// Include common header file for this module.
+//
+#include "CommonHeader.h"
+
+#define PS2_PACKET_LENGTH 3
+#define PS2_SYNC_MASK 0xc
+#define PS2_SYNC_BYTE 0x8
+
+#define IS_PS2_SYNC_BYTE(byte) ((byte & PS2_SYNC_MASK) == PS2_SYNC_BYTE)
+
+#define PS2_READ_BYTE_ONE 0
+#define PS2_READ_DATA_BYTE 1
+#define PS2_PROCESS_PACKET 2
+
+#define TIMEOUT 50000
+#define BAT_TIMEOUT 500000
+
+//
+// 8042 I/O Port
+//
+#define KBC_DATA_PORT 0x60
+#define KBC_CMD_STS_PORT 0x64
+
+//
+// 8042 Command
+//
+#define READ_CMD_BYTE 0x20
+#define WRITE_CMD_BYTE 0x60
+#define DISABLE_AUX 0xa7
+#define ENABLE_AUX 0xa8
+#define SELF_TEST 0xaa
+#define DISABLE_KB 0xad
+#define ENABLE_KB 0xae
+#define WRITE_AUX_DEV 0xd4
+
+#define CMD_SYS_FLAG 0x04
+#define CMD_KB_STS 0x10
+#define CMD_KB_DIS 0x10
+#define CMD_KB_EN 0x0
+
+//
+// 8042 Auxiliary Device Command
+//
+#define SETSF1_CMD 0xe6
+#define SETSF2_CMD 0xe7
+#define SETRE_CMD 0xe8
+#define READ_CMD 0xeb
+#define SETRM_CMD 0xf0
+#define SETSR_CMD 0xf3
+#define ENABLE_CMD 0xf4
+#define DISABLE_CMD 0xf5
+#define RESET_CMD 0xff
+
+//
+// return code
+//
+#define PS2_ACK 0xfa
+#define PS2_RESEND 0xfe
+#define PS2MOUSE_BAT1 0xaa
+#define PS2MOUSE_BAT2 0x0
+
+//
+// Keyboard Controller Status
+//
+#define KBC_PARE 0x80 // Parity Error
+#define KBC_TIM 0x40 // General Time Out
+#define KBC_AUXB 0x20 // Output buffer for auxiliary device (PS/2):
+// 0 - Holds keyboard data
+// 1 - Holds data for auxiliary device
+//
+#define KBC_KEYL 0x10 // Keyboard lock status:
+// 0 - keyboard locked
+// 1 - keyboard free
+//
+#define KBC_CD 0x08 // Command/Data:
+// 0 - data byte written via port 60h
+// 1 - command byte written via port 64h
+//
+#define KBC_SYSF 0x04 // System Flag:
+// 0 - power-on reset
+// 1 - self-test successful
+//
+#define KBC_INPB 0x02 // Input Buffer Status :
+// 0 - input buffer empty
+// 1 - CPU data in input buffer
+//
+#define KBC_OUTB 0x01 // Output Buffer Status :
+// 0 - output buffer empty
+// 1 - keyboard controller data in output buffer
+//
+EFI_STATUS
+KbcSelfTest (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+KbcEnableAux (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+KbcDisableAux (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+KbcEnableKb (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+KbcDisableKb (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+CheckKbStatus (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ OUT BOOLEAN *KeyboardEnable
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+ KeyboardEnable - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+PS2MouseReset (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+PS2MouseSetSampleRate (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN MOUSE_SR SampleRate
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+ SampleRate - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+PS2MouseSetResolution (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN MOUSE_RE Resolution
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+ Resolution - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+PS2MouseSetScaling (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN MOUSE_SF Scaling
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+ Scaling - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+PS2MouseEnable (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IsaIo - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+PS2MouseGetPacket (
+ PS2_MOUSE_DEV *MouseDev
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ MouseDev - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+PS2MouseRead (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ OUT VOID *Buffer,
+ IN OUT UINTN *BufSize,
+ IN UINTN State
+ );
+
+//
+// 8042 I/O function
+//
+EFI_STATUS
+Out8042Command (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN UINT8 Command
+ );
+
+EFI_STATUS
+In8042Data (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN OUT UINT8 *Data
+ );
+
+EFI_STATUS
+Out8042Data (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN UINT8 Data
+ );
+
+EFI_STATUS
+Out8042AuxCommand (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN UINT8 Command,
+ IN BOOLEAN Resend
+ );
+
+EFI_STATUS
+In8042AuxData (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN OUT UINT8 *Data
+ );
+
+EFI_STATUS
+Out8042AuxData (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN UINT8 Data
+ );
+
+EFI_STATUS
+CheckForInput (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo
+ );
+
+EFI_STATUS
+WaitInputEmpty (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN UINTN Timeout
+ );
+
+EFI_STATUS
+WaitOutputFull (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN UINTN Timeout
+ );
+
+#endif // _COMMPS2_H_
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommonHeader.h b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommonHeader.h new file mode 100644 index 0000000000..7130d869ad --- /dev/null +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommonHeader.h @@ -0,0 +1,48 @@ +/**@file
+ Common header file shared by all source files.
+
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.
+
+ Copyright (c) 2006 - 2007, Intel Corporation.
+ All rights reserved.
+ This software and associated documentation (if any) is furnished
+ under a license and may only be used or copied in accordance
+ with the terms of the license. Except as permitted by such
+ license, no part of this software or documentation may be
+ reproduced, stored in a retrieval system, or transmitted in any
+ form or by any means without the express written consent of
+ Intel Corporation.
+**/
+
+#ifndef __COMMON_HEADER_H_
+#define __COMMON_HEADER_H_
+
+
+//
+// The package level header files this module uses
+//
+#include <PiDxe.h>
+#include <Framework/StatusCode.h>
+//
+// The protocols, PPI and GUID defintions for this module
+//
+#include <Protocol/SimplePointer.h>
+#include <Protocol/IsaIo.h>
+#include <Protocol/DevicePath.h>
+//
+// The Library classes this module consumes
+//
+#include <Library/DebugLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/ReportStatusCodeLib.h>
+//
+// Driver Binding Externs
+//
+extern EFI_DRIVER_BINDING_PROTOCOL gPS2MouseDriver;
+extern EFI_COMPONENT_NAME_PROTOCOL gPs2MouseComponentName;
+
+#endif
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/ComponentName.c new file mode 100644 index 0000000000..bfe500f6f5 --- /dev/null +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/ComponentName.c @@ -0,0 +1,209 @@ +/*++
+
+Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved. <BR>
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+
+Module Name:
+
+ ComponentName.c
+
+Abstract:
+
+--*/
+
+//
+// Include common header file for this module.
+//
+#include "CommonHeader.h"
+
+#include "Ps2Mouse.h"
+
+//
+// EFI Component Name Protocol
+//
+EFI_COMPONENT_NAME_PROTOCOL gPs2MouseComponentName = {
+ Ps2MouseComponentNameGetDriverName,
+ Ps2MouseComponentNameGetControllerName,
+ "eng"
+};
+
+static EFI_UNICODE_STRING_TABLE mPs2MouseDriverNameTable[] = {
+ {
+ "eng",
+ L"PS/2 Mouse Driver"
+ },
+ {
+ NULL,
+ NULL
+ }
+};
+
+EFI_STATUS
+EFIAPI
+Ps2MouseComponentNameGetDriverName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ )
+/*++
+
+ Routine Description:
+
+ Retrieves a Unicode string that is the user readable name of the EFI Driver.
+
+ Arguments:
+
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
+ Language - A pointer to a three character ISO 639-2 language identifier.
+ This is the language of the driver name that that the caller
+ is requesting, and it must match one of the languages specified
+ in SupportedLanguages. The number of languages supported by a
+ driver is up to the driver writer.
+ DriverName - A pointer to the Unicode string to return. This Unicode string
+ is the name of the driver specified by This in the language
+ specified by Language.
+
+ Returns:
+
+ EFI_SUCCESS - The Unicode string for the Driver specified by This
+ and the language specified by Language was returned
+ in DriverName.
+ EFI_INVALID_PARAMETER - Language is NULL.
+ EFI_INVALID_PARAMETER - DriverName is NULL.
+ EFI_UNSUPPORTED - The driver specified by This does not support the
+ language specified by Language.
+
+--*/
+{
+ return LookupUnicodeString (
+ Language,
+ gPs2MouseComponentName.SupportedLanguages,
+ mPs2MouseDriverNameTable,
+ DriverName
+ );
+}
+
+EFI_STATUS
+EFIAPI
+Ps2MouseComponentNameGetControllerName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ )
+/*++
+
+ Routine Description:
+
+ Retrieves a Unicode string that is the user readable name of the controller
+ that is being managed by an EFI Driver.
+
+ Arguments:
+
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
+ ControllerHandle - The handle of a controller that the driver specified by
+ This is managing. This handle specifies the controller
+ whose name is to be returned.
+ ChildHandle - The handle of the child controller to retrieve the name
+ of. This is an optional parameter that may be NULL. It
+ will be NULL for device drivers. It will also be NULL
+ for a bus drivers that wish to retrieve the name of the
+ bus controller. It will not be NULL for a bus driver
+ that wishes to retrieve the name of a child controller.
+ Language - A pointer to a three character ISO 639-2 language
+ identifier. This is the language of the controller name
+ that that the caller is requesting, and it must match one
+ of the languages specified in SupportedLanguages. The
+ number of languages supported by a driver is up to the
+ driver writer.
+ ControllerName - A pointer to the Unicode string to return. This Unicode
+ string is the name of the controller specified by
+ ControllerHandle and ChildHandle in the language specified
+ by Language from the point of view of the driver specified
+ by This.
+
+ Returns:
+
+ EFI_SUCCESS - The Unicode string for the user readable name in the
+ language specified by Language for the driver
+ specified by This was returned in DriverName.
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - Language is NULL.
+ EFI_INVALID_PARAMETER - ControllerName is NULL.
+ EFI_UNSUPPORTED - The driver specified by This is not currently managing
+ the controller specified by ControllerHandle and
+ ChildHandle.
+ EFI_UNSUPPORTED - The driver specified by This does not support the
+ language specified by Language.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;
+ PS2_MOUSE_DEV *MouseDev;
+ EFI_ISA_IO_PROTOCOL *IsaIoProtocol;
+
+ //
+ // This is a device driver, so ChildHandle must be NULL.
+ //
+ if (ChildHandle != NULL) {
+ return EFI_UNSUPPORTED;
+ }
+ //
+ // Check Controller's handle
+ //
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiIsaIoProtocolGuid,
+ (VOID **) &IsaIoProtocol,
+ gPS2MouseDriver.DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (!EFI_ERROR (Status)) {
+ gBS->CloseProtocol (
+ ControllerHandle,
+ &gEfiIsaIoProtocolGuid,
+ gPS2MouseDriver.DriverBindingHandle,
+ ControllerHandle
+ );
+
+ return EFI_UNSUPPORTED;
+ }
+
+ if (Status != EFI_ALREADY_STARTED) {
+ return EFI_UNSUPPORTED;
+ }
+ //
+ // Get the device context
+ //
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiSimplePointerProtocolGuid,
+ (VOID **) &SimplePointerProtocol,
+ gPS2MouseDriver.DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ MouseDev = PS2_MOUSE_DEV_FROM_THIS (SimplePointerProtocol);
+
+ return LookupUnicodeString (
+ Language,
+ gPs2MouseComponentName.SupportedLanguages,
+ MouseDev->ControllerNameTable,
+ ControllerName
+ );
+}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/EntryPoint.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/EntryPoint.c new file mode 100644 index 0000000000..bdac890dc2 --- /dev/null +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/EntryPoint.c @@ -0,0 +1,58 @@ +/**@file
+ Entry Point Source file.
+
+ This file contains the user entry point
+
+ Copyright (c) 2006 - 2007, Intel Corporation.
+ All rights reserved.
+ This software and associated documentation (if any) is furnished
+ under a license and may only be used or copied in accordance
+ with the terms of the license. Except as permitted by such
+ license, no part of this software or documentation may be
+ reproduced, stored in a retrieval system, or transmitted in any
+ form or by any means without the express written consent of
+ Intel Corporation.
+**/
+
+
+//
+// Include common header file for this module.
+//
+#include "CommonHeader.h"
+
+/**
+ The user Entry Point for module Ps2Mouse. The user code starts with this function.
+
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.
+ @param[in] SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The entry point is executed successfully.
+ @retval other Some error occurs when executing this entry point.
+
+**/
+EFI_STATUS
+EFIAPI
+InitializePs2Mouse(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Install driver model protocol(s).
+ //
+ Status = EfiLibInstallAllDriverProtocols (
+ ImageHandle,
+ SystemTable,
+ &gPS2MouseDriver,
+ ImageHandle,
+ &gPs2MouseComponentName,
+ NULL,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+
+ return Status;
+}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.c new file mode 100644 index 0000000000..45d7a33caf --- /dev/null +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.c @@ -0,0 +1,763 @@ +/*++
+
+Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved. <BR>
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+
+Module Name:
+
+ Ps2Mouse.c
+
+Abstract:
+
+ PS/2 Mouse driver. Routines that interacts with callers,
+ conforming to EFI driver model
+
+--*/
+
+//
+// Include common header file for this module.
+//
+#include "CommonHeader.h"
+
+#include "Ps2Mouse.h"
+#include "CommPs2.h"
+
+//
+// DriverBinding Protocol Instance
+//
+EFI_DRIVER_BINDING_PROTOCOL gPS2MouseDriver = {
+ PS2MouseDriverSupported,
+ PS2MouseDriverStart,
+ PS2MouseDriverStop,
+ 0xa,
+ NULL,
+ NULL
+};
+
+EFI_STATUS
+EFIAPI
+PS2MouseDriverSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+/*++
+
+Routine Description:
+
+ ControllerDriver Protocol Method
+
+Arguments:
+
+Returns:
+
+--*/
+// GC_TODO: This - add argument and description to function comment
+// GC_TODO: Controller - add argument and description to function comment
+// GC_TODO: RemainingDevicePath - add argument and description to function comment
+{
+ EFI_STATUS Status;
+ EFI_ISA_IO_PROTOCOL *IsaIo;
+
+ Status = EFI_SUCCESS;
+
+ //
+ // Open the IO Abstraction(s) needed to perform the supported test
+ //
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiIsaIoProtocolGuid,
+ (VOID **) &IsaIo,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Use the ISA I/O Protocol to see if Controller is the Keyboard controller
+ //
+ switch (IsaIo->ResourceList->Device.HID) {
+ case EISA_PNP_ID (0xF03):
+ //
+ // Microsoft PS/2 style mouse
+ //
+ case EISA_PNP_ID (0xF13):
+ //
+ // PS/2 Port for PS/2-style Mice
+ //
+ break;
+
+ case EISA_PNP_ID (0x303):
+ //
+ // IBM Enhanced (101/102-key, PS/2 mouse support)
+ //
+ if (IsaIo->ResourceList->Device.UID == 1) {
+ break;
+ }
+
+ default:
+ Status = EFI_UNSUPPORTED;
+ break;
+ }
+ //
+ // Close the I/O Abstraction(s) used to perform the supported test
+ //
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiIsaIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+
+ return Status;
+}
+
+EFI_STATUS
+EFIAPI
+PS2MouseDriverStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+/*++
+
+Routine Description:
+ Start protocol interfaces for the mouse device handles.
+
+Arguments:
+ This - Protocol instance pointer.
+ Controller - Handle of device to bind driver to.
+ RemainingDevicePath - Not used.
+
+Returns:
+ EFI_SUCCESS - This driver is added to DeviceHandle.
+ other - Errors occurred.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_STATUS EmptyStatus;
+ EFI_ISA_IO_PROTOCOL *IsaIo;
+ PS2_MOUSE_DEV *MouseDev;
+ UINT8 Data;
+ EFI_TPL OldTpl;
+ EFI_STATUS_CODE_VALUE StatusCode;
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
+
+ StatusCode = 0;
+ MouseDev = NULL;
+ IsaIo = NULL;
+
+ //
+ // Open the device path protocol
+ //
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **) &ParentDevicePath,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Report that the keyboard is being enabled
+ //
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+ EFI_PROGRESS_CODE,
+ EFI_PERIPHERAL_MOUSE | EFI_P_PC_ENABLE,
+ ParentDevicePath
+ );
+
+ //
+ // Get the ISA I/O Protocol on Controller's handle
+ //
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiIsaIoProtocolGuid,
+ (VOID **) &IsaIo,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (EFI_ERROR (Status)) {
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Raise TPL to avoid keyboard operation impact
+ //
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+
+ //
+ // Allocate private data
+ //
+ MouseDev = AllocateZeroPool (sizeof (PS2_MOUSE_DEV));
+ if (MouseDev == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto ErrorExit;
+ }
+ //
+ // Setup the device instance
+ //
+ MouseDev->Signature = PS2_MOUSE_DEV_SIGNATURE;
+ MouseDev->Handle = Controller;
+ MouseDev->SampleRate = SSR_20;
+ MouseDev->Resolution = CMR4;
+ MouseDev->Scaling = SF1;
+ MouseDev->DataPackageSize = 3;
+ MouseDev->IsaIo = IsaIo;
+ MouseDev->DevicePath = ParentDevicePath;
+
+ //
+ // Resolution = 4 counts/mm
+ //
+ MouseDev->Mode.ResolutionX = 4;
+ MouseDev->Mode.ResolutionY = 4;
+ MouseDev->Mode.LeftButton = TRUE;
+ MouseDev->Mode.RightButton = TRUE;
+
+ MouseDev->SimplePointerProtocol.Reset = MouseReset;
+ MouseDev->SimplePointerProtocol.GetState = MouseGetState;
+ MouseDev->SimplePointerProtocol.Mode = &(MouseDev->Mode);
+
+ //
+ // Initialize keyboard controller if necessary
+ //
+ IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
+ if ((Data & KBC_SYSF) != KBC_SYSF) {
+ Status = KbcSelfTest (IsaIo);
+ if (EFI_ERROR (Status)) {
+ StatusCode = EFI_PERIPHERAL_MOUSE | EFI_P_EC_CONTROLLER_ERROR;
+ goto ErrorExit;
+ }
+ }
+
+ KbcEnableAux (IsaIo);
+
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+ EFI_PROGRESS_CODE,
+ EFI_PERIPHERAL_MOUSE | EFI_P_PC_PRESENCE_DETECT,
+ ParentDevicePath
+ );
+
+ //
+ // Reset the mouse
+ //
+ Status = MouseDev->SimplePointerProtocol.Reset (&MouseDev->SimplePointerProtocol, TRUE);
+ if (EFI_ERROR (Status)) {
+ //
+ // mouse not connected
+ //
+ Status = EFI_SUCCESS;
+ StatusCode = EFI_PERIPHERAL_MOUSE | EFI_P_EC_NOT_DETECTED;
+ goto ErrorExit;
+ }
+ //
+ // Setup the WaitForKey event
+ //
+ Status = gBS->CreateEvent (
+ EVT_NOTIFY_WAIT,
+ TPL_NOTIFY,
+ MouseWaitForInput,
+ MouseDev,
+ &((MouseDev->SimplePointerProtocol).WaitForInput)
+ );
+ if (EFI_ERROR (Status)) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto ErrorExit;
+ }
+ //
+ // Setup a periodic timer, used to poll mouse state
+ //
+ Status = gBS->CreateEvent (
+ EVT_TIMER | EVT_NOTIFY_SIGNAL,
+ TPL_NOTIFY,
+ PollMouse,
+ MouseDev,
+ &MouseDev->TimerEvent
+ );
+ if (EFI_ERROR (Status)) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto ErrorExit;
+ }
+ //
+ // Start timer to poll mouse (100 samples per second)
+ //
+ Status = gBS->SetTimer (MouseDev->TimerEvent, TimerPeriodic, 100000);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto ErrorExit;
+ }
+
+ MouseDev->ControllerNameTable = NULL;
+ AddUnicodeString (
+ "eng",
+ gPs2MouseComponentName.SupportedLanguages,
+ &MouseDev->ControllerNameTable,
+ L"PS/2 Mouse Device"
+ );
+
+ //
+ // Install protocol interfaces for the mouse device.
+ //
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Controller,
+ &gEfiSimplePointerProtocolGuid,
+ &MouseDev->SimplePointerProtocol,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ goto ErrorExit;
+ }
+
+ gBS->RestoreTPL (OldTpl);
+
+ return Status;
+
+ErrorExit:
+
+ KbcDisableAux (IsaIo);
+
+ if (StatusCode != 0) {
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+ EFI_ERROR_CODE | EFI_ERROR_MINOR,
+ StatusCode,
+ ParentDevicePath
+ );
+ }
+
+ if ((MouseDev != NULL) && (MouseDev->SimplePointerProtocol.WaitForInput != NULL)) {
+ gBS->CloseEvent (MouseDev->SimplePointerProtocol.WaitForInput);
+ }
+
+ if ((MouseDev != NULL) && (MouseDev->TimerEvent != NULL)) {
+ gBS->CloseEvent (MouseDev->TimerEvent);
+ }
+
+ if ((MouseDev != NULL) && (MouseDev->ControllerNameTable != NULL)) {
+ FreeUnicodeStringTable (MouseDev->ControllerNameTable);
+ }
+ //
+ // Since there will be no timer handler for mouse input any more,
+ // exhaust input data just in case there is still mouse data left
+ //
+ EmptyStatus = EFI_SUCCESS;
+ while (!EFI_ERROR (EmptyStatus)) {
+ EmptyStatus = In8042Data (IsaIo, &Data);
+ }
+
+ if (MouseDev != NULL) {
+ gBS->FreePool (MouseDev);
+ }
+
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiIsaIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+
+ gBS->RestoreTPL (OldTpl);
+
+ return Status;
+}
+
+EFI_STATUS
+EFIAPI
+PS2MouseDriverStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ )
+/*++
+
+ Routine Description:
+
+ Arguments:
+
+ Returns:
+
+--*/
+// GC_TODO: This - add argument and description to function comment
+// GC_TODO: Controller - add argument and description to function comment
+// GC_TODO: NumberOfChildren - add argument and description to function comment
+// GC_TODO: ChildHandleBuffer - add argument and description to function comment
+// GC_TODO: EFI_SUCCESS - add return value to function comment
+// GC_TODO: EFI_SUCCESS - add return value to function comment
+{
+ EFI_STATUS Status;
+ EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;
+ PS2_MOUSE_DEV *MouseDev;
+ UINT8 Data;
+
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiSimplePointerProtocolGuid,
+ (VOID **) &SimplePointerProtocol,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_SUCCESS;
+ }
+
+ MouseDev = PS2_MOUSE_DEV_FROM_THIS (SimplePointerProtocol);
+
+ //
+ // Report that the keyboard is being disabled
+ //
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+ EFI_PROGRESS_CODE,
+ EFI_PERIPHERAL_MOUSE | EFI_P_PC_DISABLE,
+ MouseDev->DevicePath
+ );
+
+ Status = gBS->UninstallProtocolInterface (
+ Controller,
+ &gEfiSimplePointerProtocolGuid,
+ &MouseDev->SimplePointerProtocol
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Disable mouse on keyboard controller
+ //
+ KbcDisableAux (MouseDev->IsaIo);
+
+ //
+ // Cancel mouse data polling timer, close timer event
+ //
+ gBS->SetTimer (MouseDev->TimerEvent, TimerCancel, 0);
+ gBS->CloseEvent (MouseDev->TimerEvent);
+
+ //
+ // Since there will be no timer handler for mouse input any more,
+ // exhaust input data just in case there is still mouse data left
+ //
+ Status = EFI_SUCCESS;
+ while (!EFI_ERROR (Status)) {
+ Status = In8042Data (MouseDev->IsaIo, &Data);
+ }
+
+ gBS->CloseEvent (MouseDev->SimplePointerProtocol.WaitForInput);
+ FreeUnicodeStringTable (MouseDev->ControllerNameTable);
+ gBS->FreePool (MouseDev);
+
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiIsaIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+MouseReset (
+ IN EFI_SIMPLE_POINTER_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
+ )
+/*++
+
+Routine Description:
+
+ Reset the Mouse and do BAT test for it, if ExtendedVerification isTRUE and there is a mouse device connectted to system
+
+Arguments:
+
+ This - Pointer of simple pointer Protocol.
+ ExtendedVerification - Whether configure mouse parameters. True: do; FALSE: skip.
+
+Returns:
+
+ EFI_SUCCESS - The command byte is written successfully.
+ EFI_DEVICE_ERROR - Errors occurred during reseting keyboard.
+
+--*/
+{
+ EFI_STATUS Status;
+ PS2_MOUSE_DEV *MouseDev;
+ EFI_TPL OldTpl;
+ BOOLEAN KeyboardEnable;
+ UINT8 Data;
+
+ MouseDev = PS2_MOUSE_DEV_FROM_THIS (This);
+
+ //
+ // Report reset progress code
+ //
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+ EFI_PROGRESS_CODE,
+ EFI_PERIPHERAL_MOUSE | EFI_P_PC_RESET,
+ MouseDev->DevicePath
+ );
+
+ KeyboardEnable = FALSE;
+
+ //
+ // Raise TPL to avoid keyboard operation impact
+ //
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+
+ ZeroMem (&MouseDev->State, sizeof (EFI_SIMPLE_POINTER_STATE));
+ MouseDev->StateChanged = FALSE;
+
+ //
+ // Exhaust input data
+ //
+ Status = EFI_SUCCESS;
+ while (!EFI_ERROR (Status)) {
+ Status = In8042Data (MouseDev->IsaIo, &Data);
+ }
+
+ CheckKbStatus (MouseDev->IsaIo, &KeyboardEnable);
+
+ KbcDisableKb (MouseDev->IsaIo);
+
+ MouseDev->IsaIo->Io.Read (MouseDev->IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
+
+ //
+ // if there's data block on KBC data port, read it out
+ //
+ if ((Data & KBC_OUTB) == KBC_OUTB) {
+ MouseDev->IsaIo->Io.Read (MouseDev->IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Data);
+ }
+
+ Status = EFI_SUCCESS;
+ //
+ // The PS2 mouse driver reset behavior is always successfully return no matter wheater or not there is mouse connected to system.
+ // This behavior is needed by performance speed. The following mouse command only succeessfully finish when mouse device is
+ // connected to system, so if PS2 mouse device not connect to system or user not ask for, we skip the mouse configuration and enabling
+ //
+ if (ExtendedVerification && CheckMouseConnect (MouseDev)) {
+ //
+ // Send mouse reset command and set mouse default configure
+ //
+ Status = PS2MouseReset (MouseDev->IsaIo);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_DEVICE_ERROR;
+ goto Exit;
+ }
+
+ Status = PS2MouseSetSampleRate (MouseDev->IsaIo, MouseDev->SampleRate);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_DEVICE_ERROR;
+ goto Exit;
+ }
+
+ Status = PS2MouseSetResolution (MouseDev->IsaIo, MouseDev->Resolution);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_DEVICE_ERROR;
+ goto Exit;
+ }
+
+ Status = PS2MouseSetScaling (MouseDev->IsaIo, MouseDev->Scaling);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_DEVICE_ERROR;
+ goto Exit;
+ }
+
+ Status = PS2MouseEnable (MouseDev->IsaIo);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_DEVICE_ERROR;
+ goto Exit;
+ }
+ }
+Exit:
+ gBS->RestoreTPL (OldTpl);
+
+ if (KeyboardEnable) {
+ KbcEnableKb (MouseDev->IsaIo);
+ }
+
+ return Status;
+}
+
+BOOLEAN
+CheckMouseConnect (
+ IN PS2_MOUSE_DEV *MouseDev
+ )
+/*++
+
+Routine Description:
+
+ Check whether there is Ps/2 mouse device in system
+
+Arguments:
+
+ PS2_MOUSE_DEV - Mouse Private Data Structure
+
+Returns:
+
+ TRUE - Keyboard in System.
+ FALSE - Keyboard not in System.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = PS2MouseEnable (MouseDev->IsaIo);
+ if (!EFI_ERROR (Status)) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+EFI_STATUS
+EFIAPI
+MouseGetState (
+ IN EFI_SIMPLE_POINTER_PROTOCOL *This,
+ IN OUT EFI_SIMPLE_POINTER_STATE *State
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ This - GC_TODO: add argument description
+ State - GC_TODO: add argument description
+
+Returns:
+
+ EFI_INVALID_PARAMETER - GC_TODO: Add description for return value
+ EFI_NOT_READY - GC_TODO: Add description for return value
+ EFI_SUCCESS - GC_TODO: Add description for return value
+
+--*/
+{
+ PS2_MOUSE_DEV *MouseDev;
+ EFI_TPL OldTpl;
+
+ MouseDev = PS2_MOUSE_DEV_FROM_THIS (This);
+
+ if (State == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (!MouseDev->StateChanged) {
+ return EFI_NOT_READY;
+ }
+
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ CopyMem (State, &(MouseDev->State), sizeof (EFI_SIMPLE_POINTER_STATE));
+
+ //
+ // clear mouse state
+ //
+ MouseDev->State.RelativeMovementX = 0;
+ MouseDev->State.RelativeMovementY = 0;
+ MouseDev->State.RelativeMovementZ = 0;
+ MouseDev->StateChanged = FALSE;
+ gBS->RestoreTPL (OldTpl);
+
+ return EFI_SUCCESS;
+}
+
+VOID
+EFIAPI
+MouseWaitForInput (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ Event notification function for SIMPLE_POINTER.WaitForInput event
+ Signal the event if there is input from mouse
+
+Arguments:
+
+Returns:
+
+--*/
+// GC_TODO: Event - add argument and description to function comment
+// GC_TODO: Context - add argument and description to function comment
+{
+ PS2_MOUSE_DEV *MouseDev;
+
+ MouseDev = (PS2_MOUSE_DEV *) Context;
+
+ //
+ // Someone is waiting on the mouse event, if there's
+ // input from mouse, signal the event
+ //
+ if (MouseDev->StateChanged) {
+ gBS->SignalEvent (Event);
+ }
+
+}
+
+VOID
+EFIAPI
+PollMouse (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ Event notification function for TimerEvent event
+ If mouse device is connected to system, try to get the mouse packet data
+
+Arguments:
+
+ Event - TimerEvent in PS2_MOUSE_DEV
+ Context - Pointer to PS2_MOUSE_DEV structure
+
+Returns:
+
+ None
+
+--*/
+{
+ PS2_MOUSE_DEV *MouseDev;
+
+ MouseDev = (PS2_MOUSE_DEV *) Context;
+
+ //
+ // Polling mouse packet data
+ //
+ PS2MouseGetPacket (MouseDev);
+}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.h b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.h new file mode 100644 index 0000000000..bda92e576a --- /dev/null +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.h @@ -0,0 +1,191 @@ +/*++
+
+Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+
+Module Name:
+
+ Ps2Mouse.h
+
+Abstract:
+
+ PS/2 Mouse driver header file
+
+Revision History
+
+--*/
+
+#ifndef _PS2MOUSE_H
+#define _PS2MOUSE_H
+
+//
+// Include common header file for this module.
+//
+#include "CommonHeader.h"
+
+//
+// PS/2 mouse sample rate
+//
+typedef enum {
+ SSR_10,
+ SSR_20,
+ SSR_40,
+ SSR_60,
+ SSR_80,
+ SSR_100,
+ SSR_200,
+ MAX_SR
+} MOUSE_SR;
+
+//
+// PS/2 mouse resolution
+//
+typedef enum {
+ CMR1,
+ CMR2,
+ CMR4,
+ CMR8,
+ MAX_CMR
+} MOUSE_RE;
+
+//
+// PS/2 mouse scaling
+//
+typedef enum {
+ SF1,
+ SF2
+} MOUSE_SF;
+
+//
+// Driver Private Data
+//
+#define PS2_MOUSE_DEV_SIGNATURE EFI_SIGNATURE_32 ('p', 's', '2', 'm')
+
+typedef struct {
+ UINTN Signature;
+
+ EFI_HANDLE Handle;
+ EFI_SIMPLE_POINTER_PROTOCOL SimplePointerProtocol;
+ EFI_SIMPLE_POINTER_STATE State;
+ EFI_SIMPLE_POINTER_MODE Mode;
+ BOOLEAN StateChanged;
+
+ //
+ // PS2 Mouse device specific information
+ //
+ MOUSE_SR SampleRate;
+ MOUSE_RE Resolution;
+ MOUSE_SF Scaling;
+ UINT8 DataPackageSize;
+
+ EFI_ISA_IO_PROTOCOL *IsaIo;
+
+ EFI_EVENT TimerEvent;
+
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+} PS2_MOUSE_DEV;
+
+#define PS2_MOUSE_DEV_FROM_THIS(a) CR (a, PS2_MOUSE_DEV, SimplePointerProtocol, PS2_MOUSE_DEV_SIGNATURE)
+
+//
+// Global Variables
+//
+extern EFI_DRIVER_BINDING_PROTOCOL gPS2MouseDriver;
+extern EFI_COMPONENT_NAME_PROTOCOL gPs2MouseComponentName;
+
+//
+// Function prototypes
+//
+EFI_STATUS
+EFIAPI
+PS2MouseDriverSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ );
+
+EFI_STATUS
+EFIAPI
+PS2MouseDriverStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ );
+
+EFI_STATUS
+EFIAPI
+PS2MouseDriverStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ );
+
+//
+// EFI Component Name Functions
+//
+EFI_STATUS
+EFIAPI
+Ps2MouseComponentNameGetDriverName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ );
+
+EFI_STATUS
+EFIAPI
+Ps2MouseComponentNameGetControllerName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ );
+
+EFI_STATUS
+EFIAPI
+MouseReset (
+ IN EFI_SIMPLE_POINTER_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
+ );
+
+EFI_STATUS
+EFIAPI
+MouseGetState (
+ IN EFI_SIMPLE_POINTER_PROTOCOL *This,
+ IN OUT EFI_SIMPLE_POINTER_STATE *State
+ );
+
+VOID
+EFIAPI
+MouseWaitForInput (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ );
+
+VOID
+EFIAPI
+PollMouse (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ );
+
+EFI_STATUS
+In8042Data (
+ IN EFI_ISA_IO_PROTOCOL *IsaIo,
+ IN OUT UINT8 *Data
+ );
+BOOLEAN
+CheckMouseConnect (
+ IN PS2_MOUSE_DEV *MouseDev
+ );
+
+#endif
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.inf b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.inf new file mode 100644 index 0000000000..575e91bbd3 --- /dev/null +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.inf @@ -0,0 +1,107 @@ +#/** @file
+# Ps2 Mouse Driver
+#
+# This dirver directly uses IsaIo protocol service to support Ps2 mouse work.
+# Copyright (c) 2006 - 2007, Intel Corporation.
+#
+# All rights reserved.
+# This software and associated documentation (if any) is furnished
+# under a license and may only be used or copied in accordance
+# with the terms of the license. Except as permitted by such
+# license, no part of this software or documentation may be
+# reproduced, stored in a retrieval system, or transmitted in any
+# form or by any means without the express written consent of
+# Intel Corporation.
+#
+#
+#**/
+
+################################################################################
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+################################################################################
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = Ps2Mouse
+ FILE_GUID = 202A2B0E-9A31-4812-B291-8747DF152439
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ EDK_RELEASE_VERSION = 0x00020000
+ EFI_SPECIFICATION_VERSION = 0x00020000
+
+ ENTRY_POINT = InitializePs2Mouse
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+# DRIVER_BINDING = gPS2MouseDriver
+# COMPONENT_NAME = gPs2MouseComponentName
+# Create Event Guid C Name: Event Type: EVENT_TYPE_RELATIVE_TIMER
+# Create Event Guid C Name: Event Type: EVENT_TYPE_PERIODIC_TIMER
+#
+# Signal Event Guid C Name: Event Type: EVENT_TYPE_RELATIVE_TIMER
+#
+#
+
+################################################################################
+#
+# Sources Section - list of files that are required for the build to succeed.
+#
+################################################################################
+
+[Sources.common]
+ ComponentName.c
+ CommPs2.h
+ CommPs2.c
+ Ps2Mouse.h
+ Ps2Mouse.c
+ CommonHeader.h
+ EntryPoint.c
+
+
+################################################################################
+#
+# Package Dependency Section - list of Package files that are required for
+# this module.
+#
+################################################################################
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ IntelFrameworkPkg/IntelFrameworkPkg.dec
+ IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
+
+
+################################################################################
+#
+# Library Class Section - list of Library Classes that are required for
+# this module.
+#
+################################################################################
+
+[LibraryClasses]
+ ReportStatusCodeLib
+ UefiBootServicesTableLib
+ MemoryAllocationLib
+ BaseMemoryLib
+ UefiLib
+ UefiDriverEntryPoint
+ DebugLib
+
+
+################################################################################
+#
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names
+# that this module uses or produces.
+#
+################################################################################
+
+[Protocols]
+ gEfiIsaIoProtocolGuid # PROTOCOL TO_START
+ gEfiSimplePointerProtocolGuid # PROTOCOL BY_START
+ gEfiDevicePathProtocolGuid # PROTOCOL TO_START
+
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.msa b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.msa new file mode 100644 index 0000000000..e79128dc33 --- /dev/null +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.msa @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<ModuleSurfaceArea xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd" xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <MsaHeader>
+ <ModuleName>Ps2Mouse</ModuleName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <GuidValue>202A2B0E-9A31-4812-B291-8747DF152439</GuidValue>
+ <Version>1.0</Version>
+ <Abstract>Ps2 Mouse Driver</Abstract>
+ <Description>This dirver directly uses IsaIo protocol service to support Ps2 mouse work.</Description>
+ <Copyright>Copyright (c) 2006 - 2007, Intel Corporation.</Copyright>
+ <License>All rights reserved. + This software and associated documentation (if any) is furnished + under a license and may only be used or copied in accordance + with the terms of the license. Except as permitted by such + license, no part of this software or documentation may be + reproduced, stored in a retrieval system, or transmitted in any + form or by any means without the express written consent of + Intel Corporation.</License>
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
+ </MsaHeader>
+ <ModuleDefinitions>
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
+ <BinaryModule>false</BinaryModule>
+ <OutputFileBasename>Ps2Mouse</OutputFileBasename>
+ </ModuleDefinitions>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>DebugLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>UefiDriverModelLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>UefiDriverEntryPoint</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>UefiLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>BaseMemoryLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>MemoryAllocationLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>UefiBootServicesTableLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>ReportStatusCodeLib</Keyword>
+ </LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>Ps2Mouse.c</Filename>
+ <Filename>Ps2Mouse.h</Filename>
+ <Filename>CommPs2.c</Filename>
+ <Filename>CommPs2.h</Filename>
+ <Filename>ComponentName.c</Filename>
+ </SourceFiles>
+ <PackageDependencies>
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+ <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+ </PackageDependencies>
+ <Protocols>
+ <Protocol Usage="TO_START">
+ <ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>
+ </Protocol>
+ <Protocol Usage="BY_START">
+ <ProtocolCName>gEfiSimplePointerProtocolGuid</ProtocolCName>
+ </Protocol>
+ <Protocol Usage="TO_START">
+ <ProtocolCName>gEfiIsaIoProtocolGuid</ProtocolCName>
+ </Protocol>
+ </Protocols>
+ <Events>
+ <CreateEvents>
+ <EventTypes Usage="ALWAYS_PRODUCED">
+ <EventType>EVENT_TYPE_RELATIVE_TIMER</EventType>
+ <HelpText>Set up a time event to wait for the mouse input</HelpText>
+ </EventTypes>
+ <EventTypes Usage="ALWAYS_PRODUCED">
+ <EventType>EVENT_TYPE_PERIODIC_TIMER</EventType>
+ <HelpText>Set up a periodic timer to poll mouse state at a fixed interval</HelpText>
+ </EventTypes>
+ </CreateEvents>
+ <SignalEvents>
+ <EventTypes Usage="SOMETIMES_PRODUCED">
+ <EventType>EVENT_TYPE_RELATIVE_TIMER</EventType>
+ <HelpText>Signal an event whenever these is a pending event from mouse input</HelpText>
+ </EventTypes>
+ </SignalEvents>
+ </Events>
+ <Externs>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
+ <Extern>
+ <DriverBinding>gPS2MouseDriver</DriverBinding>
+ <ComponentName>gPs2MouseComponentName</ComponentName>
+ </Extern>
+ </Externs>
+</ModuleSurfaceArea>
\ No newline at end of file |