]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DebugPortDxe/DebugPort.c
Code clean up in NetLib:
[mirror_edk2.git] / MdeModulePkg / Universal / DebugPortDxe / DebugPort.c
index ffe3fb72ecf0fc8fa567d6ecc61b224a4f7b18f0..a66e3566316fb78c2988069d85a33126033243e5 100644 (file)
@@ -4,7 +4,7 @@
   ALL CODE IN THE SERIALIO STACK MUST BE RE-ENTRANT AND CALLABLE FROM\r
   INTERRUPT CONTEXT\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
+Copyright (c) 2006 - 2009, Intel Corporation. <BR>\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
@@ -37,9 +37,9 @@ DEBUGPORT_DEVICE mDebugPortDevice = {
   (EFI_DEVICE_PATH_PROTOCOL *) NULL,\r
   {\r
     DebugPortReset,\r
-    DebugPortRead, \r
-    DebugPortWrite, \r
-    DebugPortPoll \r
+    DebugPortRead,\r
+    DebugPortWrite,\r
+    DebugPortPoll\r
   },\r
   (EFI_HANDLE) 0,\r
   (EFI_SERIAL_IO_PROTOCOL *) NULL,\r
@@ -127,15 +127,15 @@ GetDebugPortVariable (
 }\r
 \r
 /**\r
-  Debug Port Driver entry point. \r
+  Debug Port Driver entry point.\r
 \r
   Reads DebugPort variable to determine what device and settings to use as the\r
   debug port.  Binds exclusively to SerialIo. Reverts to defaults if no variable\r
   is found.\r
 \r
-  @param[in] ImageHandle       The firmware allocated handle for the EFI image.  \r
+  @param[in] ImageHandle       The firmware allocated handle for the EFI image.\r
   @param[in] SystemTable       A pointer to the EFI System Table.\r
-  \r
+\r
   @retval EFI_SUCCESS          The entry point is executed successfully.\r
   @retval EFI_OUT_OF_RESOURCES Fails to allocate memory for device.\r
   @retval other                Some error occurs when executing this entry point.\r
@@ -167,7 +167,7 @@ InitializeDebugPortDriver (
 }\r
 \r
 /**\r
-  Checks to see if there's not already a DebugPort interface somewhere. \r
+  Checks to see if there's not already a DebugPort interface somewhere.\r
 \r
   If there's a DEBUGPORT variable, the device path must match exactly.  If there's\r
   no DEBUGPORT variable, then device path is not checked and does not matter.\r
@@ -203,8 +203,8 @@ DebugPortSupported (
   EFI_HANDLE                TempHandle;\r
 \r
   //\r
-  // Check to see that there's not a debugport protocol already published\r
-  // Question: Why do we prevent debugport protocol published on more one device?\r
+  // Check to see that there's not a debugport protocol already published,\r
+  // since only one standard UART serial port could be supported by this driver.\r
   //\r
   if (gBS->LocateProtocol (&gEfiDebugPortProtocolGuid, NULL, (VOID **) &DebugPortInterface) != EFI_NOT_FOUND) {\r
     return EFI_UNSUPPORTED;\r
@@ -238,15 +238,15 @@ DebugPortSupported (
       Status = EFI_UNSUPPORTED;\r
     }\r
 \r
-    if (Status == EFI_SUCCESS && \r
+    if (Status == EFI_SUCCESS &&\r
         (Dp2->Type != MESSAGING_DEVICE_PATH ||\r
-         Dp2->SubType != MSG_VENDOR_DP || \r
+         Dp2->SubType != MSG_VENDOR_DP ||\r
          *((UINT16 *) Dp2->Length) != sizeof (DEBUGPORT_DEVICE_PATH))) {\r
 \r
       Status = EFI_UNSUPPORTED;\r
     }\r
 \r
-    if (Status == EFI_SUCCESS && CompareMem (&gEfiDebugPortDevicePathGuid, Dp2 + 1, sizeof (EFI_GUID))) {\r
+    if (Status == EFI_SUCCESS && !CompareGuid (&gEfiDebugPortDevicePathGuid, (GUID *) (Dp2 + 1))) {\r
       Status = EFI_UNSUPPORTED;\r
     }\r
 \r
@@ -289,7 +289,7 @@ DebugPortSupported (
 \r
   @retval EFI_SUCCESS          This driver is added to ControllerHandle.\r
   @retval EFI_OUT_OF_RESOURCES Fails to allocate memory for device.\r
-  @retval others               Some error occurs.                \r
+  @retval others               Some error occurs.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -365,7 +365,7 @@ DebugPortStart (
   DebugPortDP.Header.Type     = MESSAGING_DEVICE_PATH;\r
   DebugPortDP.Header.SubType  = MSG_VENDOR_DP;\r
   SetDevicePathNodeLength (&(DebugPortDP.Header), sizeof (DebugPortDP));\r
-  CopyMem (&DebugPortDP.Guid, &gEfiDebugPortDevicePathGuid, sizeof (EFI_GUID));\r
+  CopyGuid (&DebugPortDP.Guid, &gEfiDebugPortDevicePathGuid);\r
 \r
   Dp1 = DevicePathFromHandle (ControllerHandle);\r
   if (Dp1 == NULL) {\r
@@ -411,18 +411,6 @@ DebugPortStart (
                   );\r
 \r
   if (EFI_ERROR (Status)) {\r
-    DEBUG_CODE_BEGIN ();\r
-      UINTN  BufferSize;\r
-\r
-      BufferSize = 48;\r
-      DebugPortWrite (\r
-        &mDebugPortDevice.DebugPortInterface,\r
-        0,\r
-        &BufferSize,\r
-        "DebugPort driver failed to open child controller\n\n"\r
-        );\r
-    DEBUG_CODE_END ();\r
-\r
     gBS->CloseProtocol (\r
           ControllerHandle,\r
           &gEfiSerialIoProtocolGuid,\r
@@ -432,19 +420,6 @@ DebugPortStart (
     return Status;\r
   }\r
 \r
-  DEBUG_CODE_BEGIN ();\r
-    UINTN                     BufferSize;\r
-\r
-    BufferSize = 38;\r
-    DebugPortWrite (\r
-      &mDebugPortDevice.DebugPortInterface,\r
-      0,\r
-      &BufferSize,\r
-      "Hello World from the DebugPort driver\n\n"\r
-      );\r
-\r
-  DEBUG_CODE_END ();\r
-\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -547,11 +522,11 @@ DebugPortStop (
 \r
   The port itself should be fine since it was set up during initialization.\r
 \r
-  @param  This              Protocol instance pointer.   \r
+  @param  This              Protocol instance pointer.\r
 \r
   @return EFI_SUCCESS       Always.\r
 \r
-**/  \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 DebugPortReset (\r
@@ -579,8 +554,8 @@ DebugPortReset (
                               On output, the amount of data actually written.\r
   @param  Buffer              Pointer to buffer to read.\r
 \r
-  @retval EFI_SUCCESS         \r
-  @retval others              \r
+  @retval EFI_SUCCESS\r
+  @retval others\r
 \r
 **/\r
 EFI_STATUS\r
@@ -692,7 +667,7 @@ DebugPortWrite (
                               DebugPort interface\r
   @retval EFI_DEVICE_ERROR    A hardware failure occured... (from SerialIo)\r
 \r
-**/   \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 DebugPortPoll (\r