]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverModelLib.c
Some adjustment in ECP to make it compatible with EDK1.01(EDK1117) foundation in...
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Dxe / EfiDriverLib / EfiDriverModelLib.c
index 5c2b47b66e8c2fd2d57770e5655f5c6e0ae6e803..eef61548b3092a0db6ae80296f1b17e8ffe405d1 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+Copyright (c) 2004 - 2008, 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
@@ -73,18 +73,17 @@ Returns:
 }\r
 \r
 EFI_STATUS\r
-EfiLibInstallAllDriverProtocols (\r
+InstallAllDriverProtocolsWorker (\r
   IN EFI_HANDLE                         ImageHandle,\r
   IN EFI_SYSTEM_TABLE                   * SystemTable,\r
   IN EFI_DRIVER_BINDING_PROTOCOL        * DriverBinding,\r
   IN EFI_HANDLE                         DriverBindingHandle,\r
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-  IN EFI_COMPONENT_NAME2_PROTOCOL       * ComponentName, OPTIONAL\r
-#else\r
   IN EFI_COMPONENT_NAME_PROTOCOL        * ComponentName, OPTIONAL\r
-#endif\r
+  IN EFI_COMPONENT_NAME2_PROTOCOL       * ComponentName2, OPTIONAL\r
   IN EFI_DRIVER_CONFIGURATION_PROTOCOL  * DriverConfiguration, OPTIONAL\r
-  IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL    * DriverDiagnostics OPTIONAL\r
+  IN EFI_DRIVER_CONFIGURATION2_PROTOCOL * DriverConfiguration2, OPTIONAL\r
+  IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL    * DriverDiagnostics, OPTIONAL\r
+  IN EFI_DRIVER_DIAGNOSTICS2_PROTOCOL   * DriverDiagnostics2 OPTIONAL\r
   )\r
 /*++\r
 \r
@@ -109,10 +108,16 @@ Arguments:
 \r
   ComponentName       - A Component Name Protocol instance that this driver is producing\r
 \r
+  ComponentName2      - A Component Name2 Protocol instance that this driver is producing\r
+\r
   DriverConfiguration - A Driver Configuration Protocol instance that this driver is producing\r
+\r
+  DriverConfiguration2- A Driver Configuration2 Protocol instance that this driver is producing\r
   \r
   DriverDiagnostics   - A Driver Diagnostics Protocol instance that this driver is producing\r
 \r
+  DriverDiagnostics2  - A Driver Diagnostics2 Protocol instance that this driver is producing\r
+\r
 Returns: \r
 \r
   EFI_SUCCESS if all the protocols were installed onto DriverBindingHandle\r
@@ -131,11 +136,7 @@ Returns:
   if (ComponentName != NULL) {\r
     Status = gBS->InstallProtocolInterface (\r
                     &DriverBinding->DriverBindingHandle,\r
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-                    &gEfiComponentName2ProtocolGuid,\r
-#else\r
                     &gEfiComponentNameProtocolGuid,\r
-#endif\r
                     EFI_NATIVE_INTERFACE,\r
                     ComponentName\r
                     );\r
@@ -144,6 +145,18 @@ Returns:
     }\r
   }\r
 \r
+  if (ComponentName2 != NULL) {\r
+    Status = gBS->InstallProtocolInterface (\r
+                    &DriverBinding->DriverBindingHandle,\r
+                    &gEfiComponentName2ProtocolGuid,\r
+                    EFI_NATIVE_INTERFACE,\r
+                    ComponentName2\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+\r
   if (DriverConfiguration != NULL) {\r
     Status = gBS->InstallProtocolInterface (\r
                     &DriverBinding->DriverBindingHandle,\r
@@ -156,6 +169,18 @@ Returns:
     }\r
   }\r
 \r
+  if (DriverConfiguration2 != NULL) {\r
+    Status = gBS->InstallProtocolInterface (\r
+                    &DriverBinding->DriverBindingHandle,\r
+                    &gEfiDriverConfiguration2ProtocolGuid,\r
+                    EFI_NATIVE_INTERFACE,\r
+                    DriverConfiguration2\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+\r
   if (DriverDiagnostics != NULL) {\r
     Status = gBS->InstallProtocolInterface (\r
                     &DriverBinding->DriverBindingHandle,\r
@@ -168,9 +193,139 @@ Returns:
     }\r
   }\r
 \r
+  if (DriverDiagnostics2 != NULL) {\r
+    Status = gBS->InstallProtocolInterface (\r
+                    &DriverBinding->DriverBindingHandle,\r
+                    &gEfiDriverDiagnostics2ProtocolGuid,\r
+                    EFI_NATIVE_INTERFACE,\r
+                    DriverDiagnostics2\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
+EFI_STATUS\r
+EfiLibInstallAllDriverProtocols (\r
+  IN EFI_HANDLE                         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE                   * SystemTable,\r
+  IN EFI_DRIVER_BINDING_PROTOCOL        * DriverBinding,\r
+  IN EFI_HANDLE                         DriverBindingHandle,\r
+  IN EFI_COMPONENT_NAME_PROTOCOL        * ComponentName, OPTIONAL\r
+  IN EFI_DRIVER_CONFIGURATION_PROTOCOL  * DriverConfiguration, OPTIONAL\r
+  IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL    * DriverDiagnostics OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize a driver by installing the Driver Binding Protocol onto the \r
+  driver's DriverBindingHandle.  This is typically the same as the driver's\r
+  ImageHandle, but it can be different if the driver produces multiple\r
+  DriverBinding Protocols.  This function also initializes the EFI Driver\r
+  Library that initializes the global variables gST, gBS, gRT.\r
+\r
+Arguments:\r
+\r
+  ImageHandle         - The image handle of the driver\r
+\r
+  SystemTable         - The EFI System Table that was passed to the driver's entry point\r
+\r
+  DriverBinding       - A Driver Binding Protocol instance that this driver is producing\r
+\r
+  DriverBindingHandle - The handle that DriverBinding is to be installe onto.  If this\r
+                        parameter is NULL, then a new handle is created.\r
+\r
+  ComponentName       - A Component Name Protocol instance that this driver is producing\r
+\r
+  DriverConfiguration - A Driver Configuration Protocol instance that this driver is producing\r
+  \r
+  DriverDiagnostics   - A Driver Diagnostics Protocol instance that this driver is producing\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS if all the protocols were installed onto DriverBindingHandle\r
+\r
+  Otherwise, then return status from gBS->InstallProtocolInterface()\r
+\r
+--*/\r
+{\r
+  return InstallAllDriverProtocolsWorker (\r
+           ImageHandle,\r
+           SystemTable,\r
+           DriverBinding,\r
+           DriverBindingHandle,\r
+           ComponentName,\r
+           NULL,\r
+           DriverConfiguration,\r
+           NULL,\r
+           DriverDiagnostics,\r
+           NULL\r
+           );\r
+}\r
+\r
+EFI_STATUS\r
+EfiLibInstallAllDriverProtocols2 (\r
+  IN EFI_HANDLE                         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE                   * SystemTable,\r
+  IN EFI_DRIVER_BINDING_PROTOCOL        * DriverBinding,\r
+  IN EFI_HANDLE                         DriverBindingHandle,\r
+  IN EFI_COMPONENT_NAME2_PROTOCOL       * ComponentName2, OPTIONAL\r
+  IN EFI_DRIVER_CONFIGURATION2_PROTOCOL * DriverConfiguration2, OPTIONAL\r
+  IN EFI_DRIVER_DIAGNOSTICS2_PROTOCOL   * DriverDiagnostics2 OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize a driver by installing the Driver Binding Protocol onto the \r
+  driver's DriverBindingHandle.  This is typically the same as the driver's\r
+  ImageHandle, but it can be different if the driver produces multiple\r
+  DriverBinding Protocols.  This function also initializes the EFI Driver\r
+  Library that initializes the global variables gST, gBS, gRT.\r
+\r
+Arguments:\r
+\r
+  ImageHandle         - The image handle of the driver\r
+\r
+  SystemTable         - The EFI System Table that was passed to the driver's entry point\r
+\r
+  DriverBinding       - A Driver Binding Protocol instance that this driver is producing\r
+\r
+  DriverBindingHandle - The handle that DriverBinding is to be installe onto.  If this\r
+                        parameter is NULL, then a new handle is created.\r
+\r
+  ComponentName2      - A Component Name2 Protocol instance that this driver is producing\r
+\r
+  DriverConfiguration2- A Driver Configuration2 Protocol instance that this driver is producing\r
+  \r
+  DriverDiagnostics2  - A Driver Diagnostics2 Protocol instance that this driver is producing\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS if all the protocols were installed onto DriverBindingHandle\r
+\r
+  Otherwise, then return status from gBS->InstallProtocolInterface()\r
+\r
+--*/\r
+{\r
+  return InstallAllDriverProtocolsWorker (\r
+           ImageHandle,\r
+           SystemTable,\r
+           DriverBinding,\r
+           DriverBindingHandle,\r
+           NULL,\r
+           ComponentName2,\r
+           NULL,\r
+           DriverConfiguration2,\r
+           NULL,\r
+           DriverDiagnostics2\r
+           );\r
+}\r
+\r
 EFI_STATUS\r
 EfiLibTestManagedDevice (\r
   IN EFI_HANDLE       ControllerHandle,\r