]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.c
IntelFrameworkModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / Ps2MouseDxe / CommPs2.c
index ede1d5664cc89e8fae5a475055f5ad82d267b688..89755830e2be3d89f9dc70fd165c650bd0858ad2 100644 (file)
@@ -1,29 +1,23 @@
-/**@file\r
-  PS2 Mouse Communication Interface \r
-  \r
-Copyright (c) 2006 - 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+/** @file\r
+  PS2 Mouse Communication Interface.\r
+\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
 #include "Ps2Mouse.h"\r
 #include "CommPs2.h"\r
 \r
-UINT8 SampleRateTbl[MAX_SR]   = { 0xa, 0x14, 0x28, 0x3c, 0x50, 0x64, 0xc8 };\r
+UINT8 SampleRateTbl[MaxSampleRate]   = { 0xa, 0x14, 0x28, 0x3c, 0x50, 0x64, 0xc8 };\r
 \r
-UINT8 ResolutionTbl[MAX_CMR]  = { 0, 1, 2, 3 };\r
+UINT8 ResolutionTbl[MaxResolution]  = { 0, 1, 2, 3 };\r
 \r
 /**\r
   Issue self test command via IsaIo interface.\r
-  \r
+\r
   @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  \r
+\r
   @return EFI_SUCCESS  Success to do keyboard self testing.\r
   @return others       Fail to do keyboard self testing.\r
 **/\r
@@ -82,9 +76,9 @@ KbcSelfTest (
 \r
 /**\r
   Issue command to enable keyboard AUX functionality.\r
-  \r
+\r
   @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  \r
+\r
   @return Status of command issuing.\r
 **/\r
 EFI_STATUS\r
@@ -100,9 +94,9 @@ KbcEnableAux (
 \r
 /**\r
   Issue command to disable keyboard AUX functionality.\r
-  \r
+\r
   @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  \r
+\r
   @return Status of command issuing.\r
 **/\r
 EFI_STATUS\r
@@ -118,9 +112,9 @@ KbcDisableAux (
 \r
 /**\r
   Issue command to enable keyboard.\r
-  \r
+\r
   @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  \r
+\r
   @return Status of command issuing.\r
 **/\r
 EFI_STATUS\r
@@ -136,9 +130,9 @@ KbcEnableKb (
 \r
 /**\r
   Issue command to disable keyboard.\r
-  \r
+\r
   @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  \r
+\r
   @return Status of command issuing.\r
 **/\r
 EFI_STATUS\r
@@ -154,10 +148,10 @@ KbcDisableKb (
 \r
 /**\r
   Issue command to check keyboard status.\r
-  \r
+\r
   @param IsaIo          Pointer to instance of EFI_ISA_IO_PROTOCOL\r
   @param KeyboardEnable return whether keyboard is enable.\r
-  \r
+\r
   @return Status of command issuing.\r
 **/\r
 EFI_STATUS\r
@@ -195,9 +189,9 @@ CheckKbStatus (
 \r
 /**\r
   Issue command to reset keyboard.\r
-  \r
+\r
   @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  \r
+\r
   @return Status of command issuing.\r
 **/\r
 EFI_STATUS\r
@@ -240,10 +234,10 @@ PS2MouseReset (
 \r
 /**\r
   Issue command to set mouse's sample rate\r
-  \r
+\r
   @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param SampleRate value of sample rate \r
-  \r
+  @param SampleRate value of sample rate\r
+\r
   @return Status of command issuing.\r
 **/\r
 EFI_STATUS\r
@@ -269,10 +263,10 @@ PS2MouseSetSampleRate (
 \r
 /**\r
   Issue command to set mouse's resolution.\r
-  \r
+\r
   @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
   @param Resolution value of resolution\r
-  \r
+\r
   @return Status of command issuing.\r
 **/\r
 EFI_STATUS\r
@@ -298,10 +292,10 @@ PS2MouseSetResolution (
 \r
 /**\r
   Issue command to set mouse's scaling.\r
-  \r
+\r
   @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
   @param Scaling value of scaling\r
-  \r
+\r
   @return Status of command issuing.\r
 **/\r
 EFI_STATUS\r
@@ -312,7 +306,7 @@ PS2MouseSetScaling (
 {\r
   UINT8 Command;\r
 \r
-  Command = (UINT8) (Scaling == SF1 ? SETSF1_CMD : SETSF2_CMD);\r
+  Command = (UINT8) (Scaling == Scaling1 ? SETSF1_CMD : SETSF2_CMD);\r
 \r
   //\r
   // Send auxiliary command to set mouse scaling data\r
@@ -322,9 +316,9 @@ PS2MouseSetScaling (
 \r
 /**\r
   Issue command to enable Ps2 mouse.\r
-  \r
+\r
   @param IsaIo  Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  \r
+\r
   @return Status of command issuing.\r
 **/\r
 EFI_STATUS\r
@@ -341,7 +335,7 @@ PS2MouseEnable (
 /**\r
   Get mouse packet . Only care first 3 bytes\r
 \r
-  @param MouseDev  Pointer of PS2 Mouse Private Data Structure \r
+  @param MouseDev  Pointer of PS2 Mouse Private Data Structure\r
 \r
   @retval EFI_NOT_READY  Mouse Device not ready to input data packet, or some error happened during getting the packet\r
   @retval EFI_SUCCESS    The data packet is gotten successfully.\r
@@ -432,19 +426,19 @@ PS2MouseGetPacket (
       RelativeMovementX = Packet[1];\r
       RelativeMovementY = Packet[2];\r
       //\r
-      //               Bit 7   |    Bit 6   |    Bit 5   |   Bit 4    |   Bit 3  |   Bit 2    |   Bit 1   |   Bit 0 \r
-      //  Byte 0  | Y overflow | X overflow | Y sign bit | X sign bit | Always 1 | Middle Btn | Right Btn | Left Btn \r
-      //  Byte 1  |                                           8 bit X Movement \r
-      //  Byte 2  |                                           8 bit Y Movement \r
-      // \r
+      //               Bit 7   |    Bit 6   |    Bit 5   |   Bit 4    |   Bit 3  |   Bit 2    |   Bit 1   |   Bit 0\r
+      //  Byte 0  | Y overflow | X overflow | Y sign bit | X sign bit | Always 1 | Middle Btn | Right Btn | Left Btn\r
+      //  Byte 1  |                                           8 bit X Movement\r
+      //  Byte 2  |                                           8 bit Y Movement\r
+      //\r
       // 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.\r
       // Y sign bit + 8 bit Y Movement : Same as X sign bit + 8 bit X Movement.\r
       //\r
       //\r
       // First, Clear X and Y high 8 bits\r
       //\r
-      RelativeMovementX = (INT16) (RelativeMovementX & 0xFF); \r
-      RelativeMovementY = (INT16) (RelativeMovementY & 0xFF); \r
+      RelativeMovementX = (INT16) (RelativeMovementX & 0xFF);\r
+      RelativeMovementY = (INT16) (RelativeMovementY & 0xFF);\r
       //\r
       // Second, if the 9-bit signed twos complement integer is negative, set the high 8 bit 0xff\r
       //\r
@@ -455,7 +449,7 @@ PS2MouseGetPacket (
         RelativeMovementY = (INT16) (RelativeMovementY | 0xFF00);\r
       }\r
 \r
-      \r
+\r
       RButton           = (UINT8) (Packet[0] & 0x2);\r
       LButton           = (UINT8) (Packet[0] & 0x1);\r
 \r
@@ -475,12 +469,12 @@ PS2MouseGetPacket (
 \r
 /**\r
   Read data via IsaIo protocol with given number.\r
-  \r
+\r
   @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
   @param Buffer  Buffer receive data of mouse\r
   @param BufSize The size of buffer\r
   @param State   Check input or read data\r
-  \r
+\r
   @return status of reading mouse data.\r
 **/\r
 EFI_STATUS\r
@@ -535,11 +529,11 @@ PS2MouseRead (
 //\r
 /**\r
   I/O work flow of outing 8042 command.\r
-  \r
+\r
   @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
   @param Command I/O command.\r
-  \r
-  @retval EFI_SUCCESS Success to excute I/O work flow\r
+\r
+  @retval EFI_SUCCESS Success to execute I/O work flow\r
   @retval EFI_TIMEOUT Keyboard controller time out.\r
 **/\r
 EFI_STATUS\r
@@ -574,11 +568,11 @@ Out8042Command (
 \r
 /**\r
   I/O work flow of outing 8042 data.\r
-  \r
+\r
   @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
   @param Data    Data value\r
-  \r
-  @retval EFI_SUCCESS Success to excute I/O work flow\r
+\r
+  @retval EFI_SUCCESS Success to execute I/O work flow\r
   @retval EFI_TIMEOUT Keyboard controller time out.\r
 **/\r
 EFI_STATUS\r
@@ -588,7 +582,7 @@ Out8042Data (
   )\r
 {\r
   EFI_STATUS  Status;\r
-  UINT8       temp;\r
+  UINT8       Temp;\r
   //\r
   // Wait keyboard controller input buffer empty\r
   //\r
@@ -597,8 +591,8 @@ Out8042Data (
     return Status;\r
   }\r
 \r
-  temp = Data;\r
-  IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &temp);\r
+  Temp = Data;\r
+  IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Temp);\r
 \r
   Status = WaitInputEmpty (IsaIo, TIMEOUT);\r
   if (EFI_ERROR (Status)) {\r
@@ -610,11 +604,11 @@ Out8042Data (
 \r
 /**\r
   I/O work flow of in 8042 data.\r
-  \r
+\r
   @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
   @param Data    Data value\r
-  \r
-  @retval EFI_SUCCESS Success to excute I/O work flow\r
+\r
+  @retval EFI_SUCCESS Success to execute I/O work flow\r
   @retval EFI_TIMEOUT Keyboard controller time out.\r
 **/\r
 EFI_STATUS\r
@@ -624,23 +618,23 @@ In8042Data (
   )\r
 {\r
   UINTN Delay;\r
-  UINT8 temp;\r
+  UINT8 Temp;\r
 \r
   Delay = TIMEOUT / 50;\r
 \r
   do {\r
-    IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &temp);\r
+    IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Temp);\r
 \r
     //\r
     // Check keyboard controller status bit 0(output buffer status)\r
     //\r
-    if ((temp & KBC_OUTB) == KBC_OUTB) {\r
+    if ((Temp & KBC_OUTB) == KBC_OUTB) {\r
       break;\r
     }\r
 \r
     gBS->Stall (50);\r
     Delay--;\r
-  } while (Delay);\r
+  } while (Delay != 0);\r
 \r
   if (Delay == 0) {\r
     return EFI_TIMEOUT;\r
@@ -653,12 +647,12 @@ In8042Data (
 \r
 /**\r
   I/O work flow of outing 8042 Aux command.\r
-  \r
+\r
   @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
   @param Command Aux I/O command\r
   @param Resend  Whether need resend the Aux command.\r
-  \r
-  @retval EFI_SUCCESS Success to excute I/O work flow\r
+\r
+  @retval EFI_SUCCESS Success to execute I/O work flow\r
   @retval EFI_TIMEOUT Keyboard controller time out.\r
 **/\r
 EFI_STATUS\r
@@ -735,11 +729,11 @@ Out8042AuxCommand (
 \r
 /**\r
   I/O work flow of outing 8042 Aux data.\r
-  \r
+\r
   @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  @param Command Aux I/O command\r
-  \r
-  @retval EFI_SUCCESS Success to excute I/O work flow\r
+  @param Data    Buffer holding return value\r
+\r
+  @retval EFI_SUCCESS Success to execute I/O work flow\r
   @retval EFI_TIMEOUT Keyboard controller time out.\r
 **/\r
 EFI_STATUS\r
@@ -781,11 +775,11 @@ Out8042AuxData (
 \r
 /**\r
   I/O work flow of in 8042 Aux data.\r
-  \r
+\r
   @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
   @param Data    Buffer holding return value.\r
-  \r
-  @retval EFI_SUCCESS Success to excute I/O work flow\r
+\r
+  @retval EFI_SUCCESS Success to execute I/O work flow\r
   @retval EFI_TIMEOUT Keyboard controller time out.\r
 **/\r
 EFI_STATUS\r
@@ -811,10 +805,10 @@ In8042AuxData (
 \r
 \r
 /**\r
-  Check keyboard controller status, if it is output buffer full and for auxiliary device\r
-  \r
+  Check keyboard controller status, if it is output buffer full and for auxiliary device.\r
+\r
   @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-  \r
+\r
   @retval EFI_SUCCESS   Keyboard controller is ready\r
   @retval EFI_NOT_READY Keyboard controller is not ready\r
 **/\r
@@ -839,10 +833,10 @@ CheckForInput (
 \r
 /**\r
   I/O work flow to wait input buffer empty in given time.\r
-  \r
+\r
   @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
   @param Timeout Wating time.\r
-  \r
+\r
   @retval EFI_TIMEOUT if input is still not empty in given time.\r
   @retval EFI_SUCCESS input is empty.\r
 **/\r
@@ -869,7 +863,7 @@ WaitInputEmpty (
 \r
     gBS->Stall (50);\r
     Delay--;\r
-  } while (Delay);\r
+  } while (Delay != 0);\r
 \r
   if (Delay == 0) {\r
     return EFI_TIMEOUT;\r
@@ -880,10 +874,10 @@ WaitInputEmpty (
 \r
 /**\r
   I/O work flow to wait output buffer full in given time.\r
-  \r
+\r
   @param IsaIo   Pointer to instance of EFI_ISA_IO_PROTOCOL\r
   @param Timeout given time\r
-  \r
+\r
   @retval EFI_TIMEOUT  output is not full in given time\r
   @retval EFI_SUCCESS  output is full in given time.\r
 **/\r
@@ -892,23 +886,6 @@ WaitOutputFull (
   IN EFI_ISA_IO_PROTOCOL                  *IsaIo,\r
   IN UINTN                                Timeout\r
   )\r
-/**\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  IsaIo   - GC_TODO: add argument description\r
-  Timeout - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  EFI_TIMEOUT - GC_TODO: Add description for return value\r
-  EFI_SUCCESS - GC_TODO: Add description for return value\r
-\r
-**/\r
 {\r
   UINTN Delay;\r
   UINT8 Data;\r
@@ -928,7 +905,7 @@ Returns:
 \r
     gBS->Stall (50);\r
     Delay--;\r
-  } while (Delay);\r
+  } while (Delay != 0);\r
 \r
   if (Delay == 0) {\r
     return EFI_TIMEOUT;\r