]> git.proxmox.com Git - mirror_edk2.git/commitdiff
code scrub.
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 18 Jul 2008 08:20:08 +0000 (08:20 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 18 Jul 2008 08:20:08 +0000 (08:20 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5518 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c

index 21ae6ae8601c58e3c50e3acf8b7bb6079656929a..d02306fda8f2daa5d298718a315d0186c47547f1 100644 (file)
@@ -119,16 +119,16 @@ TERMINAL_DEV  gTerminalDevTemplate = {
 \r
 \r
 /**\r
-  Test to see if this driver supports ControllerHandle\r
+  Test to see if this driver supports Controller. \r
 \r
   @param  This                Protocol instance pointer.\r
-  @param  ControllerHandle    Handle of device to test\r
+  @param  Controller          Handle of device to test\r
   @param  RemainingDevicePath Optional parameter use to pick a specific child\r
                               device to start.\r
 \r
-  @retval EFI_SUCCESS         This driver supports this device\r
-  @retval EFI_ALREADY_STARTED This driver is already running on this device\r
-  @retval other               This driver does not support this device\r
+  @retval EFI_SUCCESS         This driver supports this device.\r
+  @retval EFI_ALREADY_STARTED This driver is already running on this device.\r
+  @retval other               This driver does not support this device.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -230,19 +230,19 @@ TerminalDriverBindingSupported (
 }\r
 \r
 /**\r
-  Start this driver on ControllerHandle by opening a Serial IO protocol,\r
+  Start this driver on Controller by opening a Serial IO protocol,\r
   reading Device Path, and creating a child handle with a Simple Text In,\r
   Simple Text In Ex and Simple Text Out protocol, and device path protocol.\r
   And store Console Device Environment Variables.\r
 \r
   @param  This                 Protocol instance pointer.\r
-  @param  ControllerHandle     Handle of device to bind driver to\r
+  @param  Controller           Handle of device to bind driver to\r
   @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
                                device to start.\r
 \r
-  @retval EFI_SUCCESS          This driver is added to ControllerHandle\r
-  @retval EFI_ALREADY_STARTED  This driver is already running on ControllerHandle\r
-  @retval other                This driver does not support this device\r
+  @retval EFI_SUCCESS          This driver is added to Controller.\r
+  @retval EFI_ALREADY_STARTED  This driver is already running on Controller.\r
+  @retval other                This driver does not support this device.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -383,7 +383,7 @@ TerminalDriverBindingStart (
     ASSERT (TerminalType <= VTUTF8TYPE);\r
 \r
     CopyMem (&DefaultNode->Guid, gTerminalType[TerminalType], sizeof (EFI_GUID));\r
-    RemainingDevicePath = (EFI_DEVICE_PATH_PROTOCOL*)DefaultNode;\r
+    RemainingDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) DefaultNode;\r
   } else {\r
     //\r
     // Use the RemainingDevicePath to determine the terminal type\r
@@ -753,17 +753,17 @@ Error:
 }\r
 \r
 /**\r
-  Stop this driver on ControllerHandle by closing Simple Text In, Simple Text\r
+  Stop this driver on Controller by closing Simple Text In, Simple Text\r
   In Ex, Simple Text Out protocol, and removing parent device path from\r
   Console Device Environment Variables.    \r
 \r
   @param  This              Protocol instance pointer.\r
-  @param  ControllerHandle  Handle of device to stop driver on\r
+  @param  Controller        Handle of device to stop driver on\r
   @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
                             children is zero stop the entire bus driver.\r
   @param  ChildHandleBuffer List of Child Handles to Stop.\r
 \r
-  @retval EFI_SUCCESS       This driver is removed ControllerHandle.\r
+  @retval EFI_SUCCESS       This driver is removed Controller.\r
   @retval other             This driver could not be removed from this device.\r
 \r
 **/\r
@@ -972,7 +972,7 @@ TerminalFreeNotifyList (
                    TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
                    );\r
     RemoveEntryList (ListHead->ForwardLink);\r
-    gBS->FreePool (NotifyNode);\r
+    FreePool (NotifyNode);\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -1172,8 +1172,8 @@ TerminalRemoveConsoleDevVariable (
   @param  VariableSize           Returns the size of the EFI variable that was read\r
 \r
   @return Dynamically allocated memory that contains a copy of the EFI variable.\r
-  @return Caller is repsoncible freeing the buffer.\r
-  @retval NULL                   Variable was not read\r
+          Caller is repsoncible freeing the buffer. If variable was not read, \r
+          NULL regturned.\r
 \r
 **/\r
 VOID *\r
@@ -1263,53 +1263,40 @@ SetTerminalDevicePath (
   Node.Header.SubType = MSG_VENDOR_DP;\r
 \r
   //\r
-  // generate terminal device path node according to terminal type.\r
+  // Generate terminal device path node according to terminal type.\r
   //\r
   switch (TerminalType) {\r
 \r
   case PCANSITYPE:\r
-    CopyMem (\r
-      &Node.Guid,\r
-      &gEfiPcAnsiGuid,\r
-      sizeof (EFI_GUID)\r
-      );\r
+    CopyGuid (&Node.Guid, &gEfiPcAnsiGuid);\r
     break;\r
 \r
   case VT100TYPE:\r
-    CopyMem (\r
-      &Node.Guid,\r
-      &gEfiVT100Guid,\r
-      sizeof (EFI_GUID)\r
-      );\r
+    CopyGuid (&Node.Guid, &gEfiVT100Guid);\r
     break;\r
 \r
   case VT100PLUSTYPE:\r
-    CopyMem (\r
-      &Node.Guid,\r
-      &gEfiVT100PlusGuid,\r
-      sizeof (EFI_GUID)\r
-      );\r
+    CopyGuid (&Node.Guid, &gEfiVT100PlusGuid);\r
     break;\r
 \r
   case VTUTF8TYPE:\r
-    CopyMem (\r
-      &Node.Guid,\r
-      &gEfiVTUTF8Guid,\r
-      sizeof (EFI_GUID)\r
-      );\r
+    CopyGuid (&Node.Guid, &gEfiVTUTF8Guid);\r
     break;\r
 \r
   default:\r
     return EFI_UNSUPPORTED;\r
-    break;\r
   }\r
 \r
+  //\r
+  // Get VENDOR_DEVCIE_PATH size and put into Node.Header\r
+  //\r
   SetDevicePathNodeLength (\r
     &Node.Header,\r
     sizeof (VENDOR_DEVICE_PATH)\r
     );\r
+\r
   //\r
-  // append the terminal node onto parent device path\r
+  // Append the terminal node onto parent device path\r
   // to generate a complete terminal device path.\r
   //\r
   *TerminalDevicePath = AppendDevicePathNode (\r
@@ -1384,8 +1371,8 @@ InitializeEfiKeyFiFo (
 /**\r
   The user Entry Point for module Terminal. The user code starts with this function.\r
 \r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.\r
-  @param[in] SystemTable    A pointer to the EFI System Table.\r
+  @param  ImageHandle    The firmware allocated handle for the EFI image.\r
+  @param  SystemTable    A pointer to the EFI System Table.\r
 \r
   @retval EFI_SUCCESS       The entry point is executed successfully.\r
   @retval other             Some error occurs when executing this entry point.\r
index 7410f33e366ebeb69173bf41096a78b6509b5396..abe432437ee4432515da27045b23d90586dea7fb 100644 (file)
@@ -603,40 +603,40 @@ TerminalConOutEnableCursor (
 ;\r
 \r
 /**\r
-  Test to see if this driver supports ControllerHandle\r
+  Test to see if this driver supports Controller. \r
 \r
   @param  This                Protocol instance pointer.\r
-  @param  ControllerHandle    Handle of device to test\r
+  @param  Controller          Handle of device to test\r
   @param  RemainingDevicePath Optional parameter use to pick a specific child\r
                               device to start.\r
 \r
-  @retval EFI_SUCCESS         This driver supports this device\r
-  @retval EFI_ALREADY_STARTED This driver is already running on this device\r
-  @retval other               This driver does not support this device\r
+  @retval EFI_SUCCESS         This driver supports this device.\r
+  @retval EFI_ALREADY_STARTED This driver is already running on this device.\r
+  @retval other               This driver does not support this device.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 TerminalDriverBindingSupported (\r
   IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
+  IN EFI_HANDLE                     ControllerHandle,\r
   IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
   );\r
 \r
 /**\r
-  Start this driver on ControllerHandle by opening a Serial IO protocol,\r
+  Start this driver on Controller by opening a Serial IO protocol,\r
   reading Device Path, and creating a child handle with a Simple Text In,\r
   Simple Text In Ex and Simple Text Out protocol, and device path protocol.\r
   And store Console Device Environment Variables.\r
 \r
   @param  This                 Protocol instance pointer.\r
-  @param  ControllerHandle     Handle of device to bind driver to\r
+  @param  Controller           Handle of device to bind driver to\r
   @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
                                device to start.\r
 \r
-  @retval EFI_SUCCESS          This driver is added to ControllerHandle\r
-  @retval EFI_ALREADY_STARTED  This driver is already running on ControllerHandle\r
-  @retval other                This driver does not support this device\r
+  @retval EFI_SUCCESS          This driver is added to Controller.\r
+  @retval EFI_ALREADY_STARTED  This driver is already running on Controller.\r
+  @retval other                This driver does not support this device.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -647,18 +647,19 @@ TerminalDriverBindingStart (
   IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
   );\r
 \r
+\r
 /**\r
-  Stop this driver on ControllerHandle by closing Simple Text In, Simple Text\r
+  Stop this driver on Controller by closing Simple Text In, Simple Text\r
   In Ex, Simple Text Out protocol, and removing parent device path from\r
   Console Device Environment Variables.    \r
 \r
   @param  This              Protocol instance pointer.\r
-  @param  ControllerHandle  Handle of device to stop driver on\r
+  @param  Controller        Handle of device to stop driver on\r
   @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
                             children is zero stop the entire bus driver.\r
   @param  ChildHandleBuffer List of Child Handles to Stop.\r
 \r
-  @retval EFI_SUCCESS       This driver is removed ControllerHandle.\r
+  @retval EFI_SUCCESS       This driver is removed Controller.\r
   @retval other             This driver could not be removed from this device.\r
 \r
 **/\r
@@ -859,8 +860,8 @@ TerminalRemoveConsoleDevVariable (
   @param  VariableSize           Returns the size of the EFI variable that was read\r
 \r
   @return Dynamically allocated memory that contains a copy of the EFI variable.\r
-  @return Caller is repsoncible freeing the buffer.\r
-  @retval NULL                   Variable was not read\r
+          Caller is repsoncible freeing the buffer. If variable was not read, \r
+          NULL regturned.\r
 \r
 **/\r
 VOID                                *\r
@@ -1262,7 +1263,7 @@ AnsiRawDataToUnicode (
 **/\r
 VOID\r
 UnicodeToEfiKey (\r
-  IN  TERMINAL_DEV    *PcAnsiDevice\r
+  IN  TERMINAL_DEV    *TerminalDevice\r
   )\r
 ;\r
 \r
index 6d0899d694f92c66747a69bbab3dc815eb3acb15..b82ff3d8afcf76e0563c71cb78975ac1330de3cd 100644 (file)
@@ -15,7 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "Terminal.h"\r
 \r
 \r
-\r
 /**\r
   Reads the next keystroke from the input device. The WaitForKey Event can\r
   be used to test for existance of a keystroke via WaitForEvent () call.\r
@@ -601,6 +600,9 @@ TerminalConInCheckForKey (
 \r
     SerialInTimeOut = 0;\r
     if (Mode->BaudRate != 0) {\r
+      //\r
+      // According to BAUD rate to calculate the timeout value.\r
+      //\r
       SerialInTimeOut = (1 + Mode->DataBits + Mode->StopBits) * 2 * 1000000 / (UINTN) Mode->BaudRate;\r
     }\r
 \r
@@ -621,11 +623,11 @@ TerminalConInCheckForKey (
     }\r
   }\r
   //\r
-  //  check whether serial buffer is empty\r
+  //  Check whether serial buffer is empty.\r
   //\r
   Status = SerialIo->GetControl (SerialIo, &Control);\r
 \r
-  if (0 != (Control & EFI_SERIAL_INPUT_BUFFER_EMPTY)) {\r
+  if ((Control & EFI_SERIAL_INPUT_BUFFER_EMPTY) != 0) {\r
     //\r
     // Translate all the raw data in RawFIFO into EFI Key,\r
     // according to different terminal type supported.\r
@@ -701,6 +703,9 @@ GetOneKeyFromSerial (
   Size    = 1;\r
   *Output = 0;\r
 \r
+  //\r
+  // Read one key from serial I/O device.\r
+  //\r
   Status  = SerialIo->Read (SerialIo, &Size, Output);\r
 \r
   if (EFI_ERROR (Status)) {\r
@@ -1119,36 +1124,39 @@ UnicodeToEfiKeyFlushState (
 {\r
   EFI_INPUT_KEY Key;\r
 \r
-  if (0 != (TerminalDevice->InputState & INPUT_STATE_ESC)) {\r
+  if ((TerminalDevice->InputState & INPUT_STATE_ESC) != 0) {\r
     Key.ScanCode    = SCAN_ESC;\r
     Key.UnicodeChar = 0;\r
     EfiKeyFiFoInsertOneKey (TerminalDevice, Key);\r
   }\r
 \r
-  if (0 != (TerminalDevice->InputState & INPUT_STATE_CSI)) {\r
+  if ((TerminalDevice->InputState & INPUT_STATE_CSI) != 0) {\r
     Key.ScanCode    = SCAN_NULL;\r
     Key.UnicodeChar = CSI;\r
     EfiKeyFiFoInsertOneKey (TerminalDevice, Key);\r
   }\r
 \r
-  if (0 != (TerminalDevice->InputState & INPUT_STATE_LEFTOPENBRACKET)) {\r
+  if ((TerminalDevice->InputState & INPUT_STATE_LEFTOPENBRACKET) != 0) {\r
     Key.ScanCode    = SCAN_NULL;\r
     Key.UnicodeChar = LEFTOPENBRACKET;\r
     EfiKeyFiFoInsertOneKey (TerminalDevice, Key);\r
   }\r
 \r
-  if (0 != (TerminalDevice->InputState & INPUT_STATE_O)) {\r
+  if ((TerminalDevice->InputState & INPUT_STATE_O) != 0) {\r
     Key.ScanCode    = SCAN_NULL;\r
     Key.UnicodeChar = 'O';\r
     EfiKeyFiFoInsertOneKey (TerminalDevice, Key);\r
   }\r
 \r
-  if (0 != (TerminalDevice->InputState & INPUT_STATE_2)) {\r
+  if ((TerminalDevice->InputState & INPUT_STATE_2) != 0) {\r
     Key.ScanCode    = SCAN_NULL;\r
     Key.UnicodeChar = '2';\r
     EfiKeyFiFoInsertOneKey (TerminalDevice, Key);\r
   }\r
 \r
+  //\r
+  // Cancel the timer.\r
+  //\r
   gBS->SetTimer (\r
         TerminalDevice->TwoSecondTimeOut,\r
         TimerCancel,\r
index c7c94fe0296b026749d125d397cd9e0383d1dd40..daa40d894a77ccf731731c1b8fc04d729d85d9e2 100644 (file)
@@ -70,18 +70,18 @@ STATIC UNICODE_TO_CHAR  UnicodeToPcAnsiOrAscii[] = {
   { GEOMETRICSHAPE_DOWN_TRIANGLE,       0x1f, L'v' },\r
   { GEOMETRICSHAPE_LEFT_TRIANGLE,       0x11, L'<' },\r
 \r
-  {  ARROW_LEFT,                         0x3c, L'<' },\r
-  {  ARROW_UP,                           0x18, L'^' },\r
-  {  ARROW_RIGHT,                        0x3e, L'>' },\r
-  {  ARROW_DOWN,                         0x19, L'v' },\r
+  { ARROW_LEFT,                         0x3c, L'<' },\r
+  { ARROW_UP,                           0x18, L'^' },\r
+  { ARROW_RIGHT,                        0x3e, L'>' },\r
+  { ARROW_DOWN,                         0x19, L'v' },\r
 \r
   { 0x0000,                             0x00, L'\0' }\r
 };\r
 \r
-CHAR16 mSetModeString[]            = { ESC, '[', '=', '3', 'h', 0 };\r
-CHAR16 mSetAttributeString[]       = { ESC, '[', '0', 'm', ESC, '[', '4', '0', 'm', ESC, '[', '4', '0', 'm', 0 };\r
-CHAR16 mClearScreenString[]        = { ESC, '[', '2', 'J', 0 };\r
-CHAR16 mSetCursorPositionString[]  = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0 };\r
+STATIC CHAR16 mSetModeString[]            = { ESC, '[', '=', '3', 'h', 0 };\r
+STATIC CHAR16 mSetAttributeString[]       = { ESC, '[', '0', 'm', ESC, '[', '4', '0', 'm', ESC, '[', '4', '0', 'm', 0 };\r
+STATIC CHAR16 mClearScreenString[]        = { ESC, '[', '2', 'J', 0 };\r
+STATIC CHAR16 mSetCursorPositionString[]  = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0 };\r
 \r
 //\r
 // Body of the ConOut functions\r
@@ -89,6 +89,7 @@ CHAR16 mSetCursorPositionString[]  = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0
 \r
 /**\r
   Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset().\r
+\r
   If ExtendeVerification is TRUE, then perform dependent serial device reset,\r
   and set display mode to mode 0.\r
   If ExtendedVerification is FALSE, only set display mode to mode 0.\r
@@ -152,6 +153,7 @@ TerminalConOutReset (
 \r
 /**\r
   Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().\r
+\r
   The Unicode string will be converted to terminal expressible data stream\r
   and send to terminal via serial port.\r
 \r
@@ -335,6 +337,7 @@ OutputError:
 \r
 /**\r
   Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString().\r
+\r
   If one of the characters in the *Wstring is\r
   neither valid Unicode drawing characters,\r
   not ASCII code, then this function will return\r
@@ -385,6 +388,7 @@ TerminalConOutTestString (
 \r
 /**\r
   Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().\r
+\r
   It returns information for an available text mode\r
   that the terminal supports.\r
   In this driver, we support text mode 80x25 (mode 0),\r
@@ -433,6 +437,7 @@ TerminalConOutQueryMode (
 \r
 /**\r
   Implements EFI_SIMPLE_TEXT_OUT.SetMode().\r
+\r
   Set the terminal to a specified display mode.\r
   In this driver, we only support mode 0.\r
 \r
@@ -782,6 +787,7 @@ TerminalConOutSetCursorPosition (
 \r
 /**\r
   Implements SIMPLE_TEXT_OUTPUT.EnableCursor().\r
+\r
   In this driver, the cursor cannot be hidden.\r
 \r
   @param This      Indicates the calling context.\r