]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c
UefiCpuPkg: Remove double \r
[mirror_edk2.git] / Nt32Pkg / WinNtBusDriverDxe / WinNtBusDriver.c
index 999fb0cc5d85094be8ddfd76d7b53c276d7a4b21..f4b7e1ba15f06b28e2463a26e68469f807e4a407 100644 (file)
@@ -1,13 +1,8 @@
-/*+++\r
+/**@file\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
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2018 Hewlett Packard Enterprise Development LP<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 Module Name:\r
 \r
@@ -26,7 +21,7 @@ EFI_WIN_NT_PHYSICAL_DISKS - maps to drives on your system
 EFI_WIN_NT_VIRTUAL_DISKS  - maps to a device emulated by a file\r
 EFI_WIN_NT_FILE_SYSTEM    - mouts a directory as a file system\r
 EFI_WIN_NT_CONSOLE        - make a logical comand line window (only one!)\r
-EFI_WIN_NT_UGA            - Builds UGA Windows of Width and Height\r
+EFI_WIN_NT_GOP            - Builds GOP Windows of Width and Height\r
 EFI_WIN_NT_SERIAL_PORT    - maps physical serial ports\r
 \r
  <F>ixed       - Fixed disk like a hard drive.\r
@@ -76,11 +71,11 @@ EFI_WIN_NT_SERIAL_PORT    - maps physical serial ports
    Declaring a text console window with the title "My EFI Console" woild look like:\r
    EFI_WIN_NT_CONSOLE=My EFI Console\r
 \r
- EFI_WIN_NT_UGA =\r
+ EFI_WIN_NT_GOP =\r
    <width> <height>[!...]\r
 \r
-   Declaring a two UGA windows with resolutions of 800x600 and 1024x768 would look like:\r
-   Example : EFI_WIN_NT_UGA=800 600!1024 768\r
+   Declaring a two GOP windows with resolutions of 800x600 and 1024x768 would look like:\r
+   Example : EFI_WIN_NT_GOP=800 600!1024 768\r
 \r
  EFI_WIN_NT_SERIAL_PORT =\r
    <port name>[!...]\r
@@ -144,24 +139,21 @@ EFI_DRIVER_BINDING_PROTOCOL           gWinNtBusDriverBinding = {
 // Table to map NT Environment variable to the GUID that should be in\r
 // device path.\r
 //\r
-static NT_PCD_ENTRY  mPcdEnvironment[] = {\r
+NT_PCD_ENTRY  mPcdEnvironment[] = {\r
   PcdToken(PcdWinNtConsole),       &gEfiWinNtConsoleGuid,\r
   PcdToken(PcdWinNtGop),           &gEfiWinNtGopGuid,\r
   PcdToken(PcdWinNtSerialPort),    &gEfiWinNtSerialPortGuid,\r
   PcdToken(PcdWinNtFileSystem),    &gEfiWinNtFileSystemGuid,\r
   PcdToken(PcdWinNtVirtualDisk),   &gEfiWinNtVirtualDisksGuid,\r
-  PcdToken(PcdWinNtPhysicalDisk),  &gEfiWinNtPhysicalDisksGuid,\r
-  PcdToken(PcdWinNtCpuModel),      &gEfiWinNtCPUModelGuid,\r
-  PcdToken(PcdWinNtCpuSpeed),      &gEfiWinNtCPUSpeedGuid,\r
-  PcdToken(PcdWinNtMemorySize),    &gEfiWinNtMemoryGuid\r
+  PcdToken(PcdWinNtPhysicalDisk),  &gEfiWinNtPhysicalDisksGuid\r
 };\r
 \r
 /**\r
   The user Entry Point for module WinNtBusDriver. The user code starts with this function.\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 other             Some error occurs when executing this entry point.\r
 \r
@@ -178,14 +170,13 @@ InitializeWinNtBusDriver(
   //\r
   // Install driver model protocol(s).\r
   //\r
-  Status = EfiLibInstallAllDriverProtocols (\r
+  Status = EfiLibInstallDriverBindingComponentName2 (\r
              ImageHandle,\r
              SystemTable,\r
              &gWinNtBusDriverBinding,\r
              ImageHandle,\r
              &gWinNtBusDriverComponentName,\r
-             NULL,\r
-             NULL\r
+             &gWinNtBusDriverComponentName2\r
              );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
@@ -224,7 +215,7 @@ Returns:
 \r
   None\r
 \r
---*/\r
+**/\r
 // TODO:    This - add argument and description to function comment\r
 // TODO:    ControllerHandle - add argument and description to function comment\r
 // TODO:    RemainingDevicePath - add argument and description to function comment\r
@@ -243,20 +234,30 @@ Returns:
   // it is a legal Device Path Node for this bus driver's children.\r
   //\r
   if (RemainingDevicePath != NULL) {\r
-    if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH ||\r
-        RemainingDevicePath->SubType != HW_VENDOR_DP ||\r
-        DevicePathNodeLength(RemainingDevicePath) != sizeof(WIN_NT_VENDOR_DEVICE_PATH_NODE)) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-\r
-    for (Index = 0; Index < NT_PCD_ARRAY_SIZE; Index++) {\r
-      if (CompareGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid, mPcdEnvironment[Index].DevicePathGuid)) {\r
-        break;\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
+      if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH ||\r
+          RemainingDevicePath->SubType != HW_VENDOR_DP ||\r
+          DevicePathNodeLength(RemainingDevicePath) != sizeof(WIN_NT_VENDOR_DEVICE_PATH_NODE)) {\r
+        return EFI_UNSUPPORTED;\r
+      }\r
+  \r
+      for (Index = 0; Index < NT_PCD_ARRAY_SIZE; Index++) {\r
+        if (CompareGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid, mPcdEnvironment[Index].DevicePathGuid)) {\r
+          break;\r
+        }\r
+      }\r
+  \r
+      if (Index >= NT_PCD_ARRAY_SIZE) {\r
+        return EFI_UNSUPPORTED;\r
       }\r
-    }\r
-\r
-    if (Index >= NT_PCD_ARRAY_SIZE) {\r
-      return EFI_UNSUPPORTED;\r
     }\r
   }\r
 \r
@@ -265,8 +266,8 @@ Returns:
   //\r
   Status = gBS->OpenProtocol (\r
                   ControllerHandle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  &ParentDevicePath,\r
+                  &gEfiWinNtThunkProtocolGuid,\r
+                  (VOID **) &WinNtThunk,\r
                   This->DriverBindingHandle,\r
                   ControllerHandle,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -279,17 +280,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
         ControllerHandle,\r
-        &gEfiDevicePathProtocolGuid,\r
+        &gEfiWinNtThunkProtocolGuid,\r
         This->DriverBindingHandle,\r
         ControllerHandle\r
         );\r
 \r
+  //\r
+  // Open the EFI Device Path protocol needed to perform the supported test\r
+  //\r
   Status = gBS->OpenProtocol (\r
                   ControllerHandle,\r
-                  &gEfiWinNtThunkProtocolGuid,\r
-                  &WinNtThunk,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &ParentDevicePath,\r
                   This->DriverBindingHandle,\r
                   ControllerHandle,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -311,11 +318,11 @@ Returns:
   }\r
 \r
   //\r
-  // Close the I/O Abstraction(s) used to perform the supported test\r
+  // Close protocol, don't use device path protocol in the Support() function\r
   //\r
   gBS->CloseProtocol (\r
         ControllerHandle,\r
-        &gEfiWinNtThunkProtocolGuid,\r
+        &gEfiDevicePathProtocolGuid,\r
         This->DriverBindingHandle,\r
         ControllerHandle\r
         );\r
@@ -349,7 +356,6 @@ Returns:
 // TODO:    EFI_SUCCESS - add return value to function comment\r
 {\r
   EFI_STATUS                      Status;\r
-  EFI_STATUS                      InstallStatus;\r
   EFI_WIN_NT_THUNK_PROTOCOL       *WinNtThunk;\r
   EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath;\r
   WIN_NT_BUS_DEVICE               *WinNtBusDevice;\r
@@ -374,7 +380,7 @@ Returns:
   Status = gBS->OpenProtocol (\r
                   ControllerHandle,\r
                   &gEfiDevicePathProtocolGuid,\r
-                  &ParentDevicePath,\r
+                  (VOID **) &ParentDevicePath,\r
                   This->DriverBindingHandle,\r
                   ControllerHandle,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -386,7 +392,7 @@ Returns:
   Status = gBS->OpenProtocol (\r
                   ControllerHandle,\r
                   &gEfiWinNtThunkProtocolGuid,\r
-                  &WinNtThunk,\r
+                  (VOID **) &WinNtThunk,\r
                   This->DriverBindingHandle,\r
                   ControllerHandle,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -404,12 +410,21 @@ Returns:
     WinNtBusDevice->Signature           = WIN_NT_BUS_DEVICE_SIGNATURE;\r
     WinNtBusDevice->ControllerNameTable = NULL;\r
 \r
-    AddUnicodeString (\r
+    AddUnicodeString2 (\r
       "eng",\r
       gWinNtBusDriverComponentName.SupportedLanguages,\r
       &WinNtBusDevice->ControllerNameTable,\r
-      L"Windows Bus Controller"\r
+      L"Windows Bus Controller",\r
+      TRUE\r
       );\r
+    AddUnicodeString2 (\r
+      "en",\r
+      gWinNtBusDriverComponentName2.SupportedLanguages,\r
+      &WinNtBusDevice->ControllerNameTable,\r
+      L"Windows Bus Controller",\r
+      FALSE\r
+      );\r
+\r
 \r
     Status = gBS->InstallMultipleProtocolInterfaces (\r
                     &ControllerHandle,\r
@@ -428,13 +443,12 @@ Returns:
   // Loop on the Variable list. Parse each variable to produce a set of handles that\r
   // represent virtual hardware devices.\r
   //\r
-  InstallStatus   = EFI_NOT_FOUND;\r
   for (Index = 0; Index < NT_PCD_ARRAY_SIZE; Index++) {\r
     PcdTempStr = (VOID *)LibPcdGetPtr (mPcdEnvironment[Index].Token);\r
     ASSERT (PcdTempStr != NULL);\r
 \r
     TempStrSize = StrLen (PcdTempStr);\r
-    TempStr = AllocateMemory ((TempStrSize * sizeof (CHAR16)) + 1);\r
+    TempStr = AllocateMemory (((TempStrSize + 1) * sizeof (CHAR16)));\r
     StrCpy (TempStr, PcdTempStr);\r
 \r
     StartString = TempStr;\r
@@ -467,15 +481,25 @@ Returns:
       CreateDevice = TRUE;\r
       if (RemainingDevicePath != NULL) {\r
         CreateDevice  = FALSE;\r
-        Node          = (WIN_NT_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath;\r
-        if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH &&\r
-            Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP &&\r
-            DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE)\r
-            ) {\r
-          if (CompareGuid (&Node->VendorDevicePath.Guid, mPcdEnvironment[Index].DevicePathGuid) &&\r
-              Node->Instance == Count\r
+        //\r
+        // Check if RemainingDevicePath is the End of Device Path Node, \r
+        // if yes, don't create any child device \r
+        //\r
+        if (!IsDevicePathEnd (RemainingDevicePath)) {\r
+          //\r
+          // If RemainingDevicePath isn't the End of Device Path Node,\r
+          // check its validation\r
+          //\r
+          Node          = (WIN_NT_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath;\r
+          if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH &&\r
+              Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP &&\r
+              DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE)\r
               ) {\r
-            CreateDevice = TRUE;\r
+            if (CompareGuid (&Node->VendorDevicePath.Guid, mPcdEnvironment[Index].DevicePathGuid) &&\r
+                Node->Instance == Count\r
+                ) {\r
+              CreateDevice = TRUE;\r
+            }\r
           }\r
         }\r
       }\r
@@ -519,13 +543,22 @@ Returns:
           return EFI_OUT_OF_RESOURCES;\r
         }\r
 \r
-        AddUnicodeString (\r
+        AddUnicodeString2 (\r
           "eng",\r
           gWinNtBusDriverComponentName.SupportedLanguages,\r
           &WinNtDevice->ControllerNameTable,\r
-          ComponentName\r
+          ComponentName,\r
+          TRUE\r
+          );\r
+        AddUnicodeString2 (\r
+          "en",\r
+          gWinNtBusDriverComponentName2.SupportedLanguages,\r
+          &WinNtDevice->ControllerNameTable,\r
+          ComponentName,\r
+          FALSE\r
           );\r
 \r
+\r
         WinNtDevice->WinNtIo.TypeGuid       = mPcdEnvironment[Index].DevicePathGuid;\r
         WinNtDevice->WinNtIo.InstanceNumber = Count;\r
 \r
@@ -549,14 +582,11 @@ Returns:
           Status = gBS->OpenProtocol (\r
                           ControllerHandle,\r
                           &gEfiWinNtThunkProtocolGuid,\r
-                          &WinNtThunk,\r
+                          (VOID **) &WinNtThunk,\r
                           This->DriverBindingHandle,\r
                           WinNtDevice->Handle,\r
                           EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
                           );\r
-          if (!EFI_ERROR (Status)) {\r
-            InstallStatus = EFI_SUCCESS;\r
-          }\r
         }\r
       }\r
 \r
@@ -621,7 +651,7 @@ Returns:
     Status = gBS->OpenProtocol (\r
                     ControllerHandle,\r
                     &gWinNtBusDriverGuid,\r
-                    &WinNtBusDevice,\r
+                    (VOID **) &WinNtBusDevice,\r
                     This->DriverBindingHandle,\r
                     ControllerHandle,\r
                     EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
@@ -664,7 +694,7 @@ Returns:
     Status = gBS->OpenProtocol (\r
                     ChildHandleBuffer[Index],\r
                     &gEfiWinNtIoProtocolGuid,\r
-                    &WinNtIo,\r
+                    (VOID **) &WinNtIo,\r
                     This->DriverBindingHandle,\r
                     ControllerHandle,\r
                     EFI_OPEN_PROTOCOL_GET_PROTOCOL\r