]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c
Remove unused definitions
[mirror_edk2.git] / Nt32Pkg / WinNtSerialIoDxe / WinNtSerialIo.c
index ed8ee3c4538e6cfa59a754a1fc0e4907f5c1bc65..17e4fdacf63f2b53fd78c6f848c4cf6fa112a42d 100644 (file)
@@ -1,6 +1,6 @@
 /**@file\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+Copyright (c) 2006 - 2009, 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
@@ -97,7 +97,6 @@ InitializeWinNtSerialIo(
   return Status;\r
 }\r
 \r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 WinNtSerialIoDriverBindingSupported (\r
@@ -127,13 +126,55 @@ Returns:
   EFI_WIN_NT_IO_PROTOCOL    *WinNtIo;\r
   UART_DEVICE_PATH          *UartNode;\r
 \r
+  //\r
+  // Check RemainingDevicePath validation\r
+  //\r
+  if (RemainingDevicePath != NULL) {\r
+    //\r
+    // Check if RemainingDevicePath is the End of Device Path Node, \r
+    // if yes, go on checking other conditions\r
+    //\r
+    if (!IsDevicePathEnd (RemainingDevicePath)) {\r
+      //\r
+      // If RemainingDevicePath isn't the End of Device Path Node,\r
+      // check its validation\r
+      //\r
+      Status = EFI_UNSUPPORTED;\r
+\r
+      UartNode  = (UART_DEVICE_PATH *) RemainingDevicePath;\r
+      if (UartNode->Header.Type != MESSAGING_DEVICE_PATH ||\r
+          UartNode->Header.SubType != MSG_UART_DP ||\r
+          DevicePathNodeLength((EFI_DEVICE_PATH_PROTOCOL *)UartNode) != sizeof(UART_DEVICE_PATH)) {\r
+        goto Error;\r
+      }\r
+      if ( UartNode->BaudRate > SERIAL_PORT_MAX_BAUD_RATE) {\r
+        goto Error;\r
+      }\r
+      if (UartNode->Parity < NoParity || UartNode->Parity > SpaceParity) {\r
+        goto Error;\r
+      }\r
+      if (UartNode->DataBits < 5 || UartNode->DataBits > 8) {\r
+        goto Error;\r
+      }\r
+      if (UartNode->StopBits < OneStopBit || UartNode->StopBits > TwoStopBits) {\r
+        goto Error;\r
+      }\r
+      if ((UartNode->DataBits == 5) && (UartNode->StopBits == TwoStopBits)) {\r
+        goto Error;\r
+      }\r
+      if ((UartNode->DataBits >= 6) && (UartNode->DataBits <= 8) && (UartNode->StopBits == OneFiveStopBits)) {\r
+        goto Error;\r
+      }\r
+    }\r
+  }\r
+\r
   //\r
   // Open the IO Abstraction(s) needed to perform the supported test\r
   //\r
   Status = gBS->OpenProtocol (\r
                   Handle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  &ParentDevicePath,\r
+                  &gEfiWinNtIoProtocolGuid,\r
+                  (VOID **) &WinNtIo,\r
                   This->DriverBindingHandle,\r
                   Handle,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -146,17 +187,23 @@ Returns:
     return Status;\r
   }\r
 \r
+  //\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
+  //\r
   gBS->CloseProtocol (\r
         Handle,\r
-        &gEfiDevicePathProtocolGuid,\r
+        &gEfiWinNtIoProtocolGuid,\r
         This->DriverBindingHandle,\r
         Handle\r
         );\r
 \r
+  //\r
+  // Open the EFI Device Path protocol needed to perform the supported test\r
+  //\r
   Status = gBS->OpenProtocol (\r
                   Handle,\r
-                  &gEfiWinNtIoProtocolGuid,\r
-                  &WinNtIo,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &ParentDevicePath,\r
                   This->DriverBindingHandle,\r
                   Handle,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -169,6 +216,16 @@ Returns:
     return Status;\r
   }\r
 \r
+  //\r
+  // Close protocol, don't use device path protocol in the Support() function\r
+  //\r
+  gBS->CloseProtocol (\r
+        Handle,\r
+        &gEfiDevicePathProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        Handle\r
+        );\r
+\r
   //\r
   // Make sure that the WinNt Thunk Protocol is valid\r
   //\r
@@ -185,50 +242,12 @@ Returns:
     goto Error;\r
   }\r
 \r
-  if (RemainingDevicePath != NULL) {\r
-    Status    = EFI_UNSUPPORTED;\r
-    UartNode  = (UART_DEVICE_PATH *) RemainingDevicePath;\r
-    if (UartNode->Header.Type != MESSAGING_DEVICE_PATH ||\r
-        UartNode->Header.SubType != MSG_UART_DP ||\r
-        DevicePathNodeLength((EFI_DEVICE_PATH_PROTOCOL *)UartNode) != sizeof(UART_DEVICE_PATH)) {\r
-      goto Error;\r
-    }\r
-    if (UartNode->BaudRate < 0 || UartNode->BaudRate > SERIAL_PORT_MAX_BAUD_RATE) {\r
-      goto Error;\r
-    }\r
-    if (UartNode->Parity < NoParity || UartNode->Parity > SpaceParity) {\r
-      goto Error;\r
-    }\r
-    if (UartNode->DataBits < 5 || UartNode->DataBits > 8) {\r
-      goto Error;\r
-    }\r
-    if (UartNode->StopBits < OneStopBit || UartNode->StopBits > TwoStopBits) {\r
-      goto Error;\r
-    }\r
-    if ((UartNode->DataBits == 5) && (UartNode->StopBits == TwoStopBits)) {\r
-      goto Error;\r
-    }\r
-    if ((UartNode->DataBits >= 6) && (UartNode->DataBits <= 8) && (UartNode->StopBits == OneFiveStopBits)) {\r
-      goto Error;\r
-    }\r
-    Status = EFI_SUCCESS;\r
-  }\r
+  return EFI_SUCCESS;\r
 \r
 Error:\r
-  //\r
-  // Close the I/O Abstraction(s) used to perform the supported test\r
-  //\r
-  gBS->CloseProtocol (\r
-        Handle,\r
-        &gEfiWinNtIoProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Handle\r
-        );\r
-\r
   return Status;\r
 }\r
 \r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 WinNtSerialIoDriverBindingStart (\r
@@ -263,6 +282,7 @@ Returns:
   UINTN                               EntryCount;\r
   UINTN                               Index;\r
   EFI_SERIAL_IO_PROTOCOL              *SerialIo;\r
+  UART_DEVICE_PATH                    *UartNode;\r
 \r
   Private   = NULL;\r
   NtHandle  = INVALID_HANDLE_VALUE;\r
@@ -273,7 +293,7 @@ Returns:
   Status = gBS->OpenProtocol (\r
                   Handle,\r
                   &gEfiDevicePathProtocolGuid,\r
-                  &ParentDevicePath,\r
+                  (VOID **) &ParentDevicePath,\r
                   This->DriverBindingHandle,\r
                   Handle,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -288,7 +308,7 @@ Returns:
   Status = gBS->OpenProtocol (\r
                   Handle,\r
                   &gEfiWinNtIoProtocolGuid,\r
-                  &WinNtIo,\r
+                  (VOID **) &WinNtIo,\r
                   This->DriverBindingHandle,\r
                   Handle,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -305,7 +325,10 @@ Returns:
 \r
   if (Status == EFI_ALREADY_STARTED) {\r
 \r
-    if (RemainingDevicePath == NULL) {\r
+    if (RemainingDevicePath == NULL || IsDevicePathEnd (RemainingDevicePath)) {\r
+      //\r
+      // If RemainingDevicePath is NULL or is the End of Device Path Node\r
+      //\r
       return EFI_SUCCESS;\r
     }\r
 \r
@@ -329,21 +352,21 @@ Returns:
         Status = gBS->OpenProtocol (\r
                         OpenInfoBuffer[Index].ControllerHandle,\r
                         &gEfiSerialIoProtocolGuid,\r
-                        &SerialIo,\r
+                        (VOID **) &SerialIo,\r
                         This->DriverBindingHandle,\r
                         Handle,\r
                         EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
                         );\r
         if (!EFI_ERROR (Status)) {\r
-          CopyMem (&Node, RemainingDevicePath, sizeof (UART_DEVICE_PATH));\r
+          UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;\r
           Status = SerialIo->SetAttributes (\r
                               SerialIo,\r
-                              Node.BaudRate,\r
+                              UartNode->BaudRate,\r
                               SerialIo->Mode->ReceiveFifoDepth,\r
                               SerialIo->Mode->Timeout,\r
-                              Node.Parity,\r
-                              Node.DataBits,\r
-                              Node.StopBits\r
+                              (EFI_PARITY_TYPE)UartNode->Parity,\r
+                              UartNode->DataBits,\r
+                              (EFI_STOP_BITS_TYPE)UartNode->StopBits\r
                               );\r
         }\r
         break;\r
@@ -354,6 +377,37 @@ Returns:
     return Status;\r
   }\r
 \r
+  if (RemainingDevicePath == NULL) {\r
+    //\r
+    // Build the device path by appending the UART node to the ParentDevicePath\r
+    // from the WinNtIo handle. The Uart setings are zero here, since\r
+    // SetAttribute() will update them to match the default setings.\r
+    //\r
+    ZeroMem (&Node, sizeof (UART_DEVICE_PATH));\r
+    Node.Header.Type     = MESSAGING_DEVICE_PATH;\r
+    Node.Header.SubType  = MSG_UART_DP;\r
+    SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) &Node, sizeof (UART_DEVICE_PATH));\r
+\r
+  } else if (!IsDevicePathEnd (RemainingDevicePath)) {\r
+    //\r
+    // If RemainingDevicePath isn't the End of Device Path Node, \r
+    // only scan the specified device by RemainingDevicePath\r
+    //\r
+    //\r
+    // Match the configuration of the RemainingDevicePath. IsHandleSupported()\r
+    // already checked to make sure the RemainingDevicePath contains settings\r
+    // that we can support.\r
+    //\r
+    CopyMem (&Node, RemainingDevicePath, sizeof (UART_DEVICE_PATH));\r
+\r
+  } else {\r
+    //\r
+    // If RemainingDevicePath is the End of Device Path Node,\r
+    // skip enumerate any device and return EFI_SUCESSS\r
+    // \r
+    return EFI_SUCCESS;\r
+  }\r
+\r
   //\r
   // Check to see if we can access the hardware device. If it's Open in NT we\r
   // will not get access.\r
@@ -398,6 +452,8 @@ Returns:
   Private->Fifo.Last              = 0;\r
   Private->Fifo.Surplus           = SERIAL_MAX_BUFFER_SIZE;\r
 \r
+  CopyMem (&Private->UartDevicePath, &Node, sizeof (UART_DEVICE_PATH));\r
+\r
   AddUnicodeString2 (\r
     "eng",\r
     gWinNtSerialIoComponentName.SupportedLanguages,\r
@@ -423,25 +479,6 @@ Returns:
   Private->SerialIo.Read          = WinNtSerialIoRead;\r
   Private->SerialIo.Mode          = &Private->SerialIoMode;\r
 \r
-  if (RemainingDevicePath != NULL) {\r
-    //\r
-    // Match the configuration of the RemainingDevicePath. IsHandleSupported()\r
-    // already checked to make sure the RemainingDevicePath contains settings\r
-    // that we can support.\r
-    //\r
-    CopyMem (&Private->UartDevicePath, RemainingDevicePath, sizeof (UART_DEVICE_PATH));\r
-  } else {\r
-    //\r
-    // Build the device path by appending the UART node to the ParentDevicePath\r
-    // from the WinNtIo handle. The Uart setings are zero here, since\r
-    // SetAttribute() will update them to match the default setings.\r
-    //\r
-    ZeroMem (&Private->UartDevicePath, sizeof (UART_DEVICE_PATH));\r
-    Private->UartDevicePath.Header.Type     = MESSAGING_DEVICE_PATH;\r
-    Private->UartDevicePath.Header.SubType  = MSG_UART_DP;\r
-    SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) &Private->UartDevicePath, sizeof (UART_DEVICE_PATH));\r
-  }\r
-\r
   //\r
   // Build the device path by appending the UART node to the ParentDevicePath\r
   // from the WinNtIo handle. The Uart setings are zero here, since\r
@@ -496,7 +533,7 @@ Returns:
   Status = gBS->OpenProtocol (\r
                   Handle,\r
                   &gEfiWinNtIoProtocolGuid,\r
-                  &WinNtIo,\r
+                  (VOID **) &WinNtIo,\r
                   This->DriverBindingHandle,\r
                   Private->Handle,\r
                   EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
@@ -534,7 +571,6 @@ Error:
   return Status;\r
 }\r
 \r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 WinNtSerialIoDriverBindingStop (\r
@@ -600,7 +636,7 @@ Returns:
     Status = gBS->OpenProtocol (\r
                     ChildHandleBuffer[Index],\r
                     &gEfiSerialIoProtocolGuid,\r
-                    &SerialIo,\r
+                    (VOID **) &SerialIo,\r
                     This->DriverBindingHandle,\r
                     Handle,\r
                     EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
@@ -662,7 +698,6 @@ Returns:
 // Serial IO Protocol member functions\r
 //\r
 \r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 WinNtSerialIoReset (\r
@@ -703,13 +738,12 @@ Returns:
                 This->Mode->BaudRate,\r
                 This->Mode->ReceiveFifoDepth,\r
                 This->Mode->Timeout,\r
-                This->Mode->Parity,\r
+                (EFI_PARITY_TYPE)This->Mode->Parity,\r
                 (UINT8) This->Mode->DataBits,\r
-                This->Mode->StopBits\r
+                (EFI_STOP_BITS_TYPE)This->Mode->StopBits\r
                 );\r
 }\r
 \r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 WinNtSerialIoSetAttributes (\r
@@ -779,7 +813,7 @@ Returns:
   }\r
 \r
   if (Parity == DefaultParity) {\r
-    Parity = FixedPcdGet8 (PcdUartDefaultParity);\r
+    Parity = (EFI_PARITY_TYPE) (FixedPcdGet8 (PcdUartDefaultParity));\r
   }\r
 \r
   if (DataBits == 0) {\r
@@ -975,7 +1009,6 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 WinNtSerialIoSetControl (\r
@@ -1071,7 +1104,6 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 WinNtSerialIoGetControl (\r
@@ -1186,7 +1218,6 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 WinNtSerialIoWrite (\r
@@ -1290,7 +1321,6 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 WinNtSerialIoRead (\r