]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c
CorebootPayloadPkg: Add "Down" key to Boot Manager Menu
[mirror_edk2.git] / Nt32Pkg / WinNtBusDriverDxe / WinNtBusDriver.c
index a0baa751e6e453363a98309f15bd76bed9174cc0..1516ab8d1c12ec6b2a06d96d9f65a74bee9bc3cb 100644 (file)
@@ -1,7 +1,7 @@
-/*+++\r
+/**@file\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+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
@@ -26,7 +26,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 +76,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
@@ -138,52 +138,27 @@ EFI_DRIVER_BINDING_PROTOCOL           gWinNtBusDriverBinding = {
   NULL\r
 };\r
 \r
-#define NT_PCD_ARRAY_SIZE (sizeof(mPcdEnvironment)/sizeof(NT_ENVIRONMENT_VARIABLE_ENTRY))\r
-\r
-//\r
-// BUGBUG: Because currently the new build tools does not support dynamic PCD \r
-//         following dynamic PCd will be hard code. After tools ready, we should\r
-//         use dynmanic PCD AQAP.\r
-//\r
+#define NT_PCD_ARRAY_SIZE (sizeof(mPcdEnvironment)/sizeof(NT_PCD_ENTRY))\r
 \r
 //\r
 // Table to map NT Environment variable to the GUID that should be in\r
 // device path.\r
 //\r
-//static 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
-//};\r
-typedef struct {\r
-  CHAR16    *Variable;\r
-  EFI_GUID  *DevicePathGuid;\r
-} NT_ENVIRONMENT_VARIABLE_ENTRY;\r
-\r
-static NT_ENVIRONMENT_VARIABLE_ENTRY  mPcdEnvironment[] = {\r
-  L"Bus Driver Console Window",         &gEfiWinNtConsoleGuid,\r
-  L"UGA Window 1!UGA Window 2",         &gEfiWinNtGopGuid,\r
-  L"COM1!COM2",                        &gEfiWinNtSerialPortGuid,\r
-  L".!..\\..\\..\\..\\EdkShellBinPkg\\bin\\ia32\\Apps",      &gEfiWinNtFileSystemGuid,\r
-  L"FW;40960;512",                     &gEfiWinNtVirtualDisksGuid,\r
-  L"E:RW;245760;512",                  &gEfiWinNtPhysicalDisksGuid,\r
-  L"Intel(R) Processor Model",         &gEfiWinNtCPUModelGuid,\r
-  L"3000",                             &gEfiWinNtCPUSpeedGuid,\r
-  L"64!64",                             &gEfiWinNtMemoryGuid\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
 };\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
@@ -200,14 +175,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
@@ -246,7 +220,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
@@ -265,20 +239,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
@@ -287,8 +271,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
@@ -301,17 +285,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
@@ -333,11 +323,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
@@ -371,7 +361,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
@@ -396,7 +385,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
@@ -408,7 +397,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
@@ -426,12 +415,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
@@ -450,10 +448,8 @@ 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
-    PcdTempStr = mPcdEnvironment[Index].Variable;\r
+    PcdTempStr = (VOID *)LibPcdGetPtr (mPcdEnvironment[Index].Token);\r
     ASSERT (PcdTempStr != NULL);\r
 \r
     TempStrSize = StrLen (PcdTempStr);\r
@@ -490,15 +486,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
@@ -542,13 +548,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
@@ -572,14 +587,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
@@ -644,7 +656,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
@@ -687,7 +699,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