]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UnixPkg/UnixBusDriverDxe/UnixBusDriver.c
Fix build break. Was fixing Beagle names in Omap35xx package and missed a few.
[mirror_edk2.git] / UnixPkg / UnixBusDriverDxe / UnixBusDriver.c
index b6b2ac6b77559c54a0e080832c1d28f5cb1f097a..fa242eb1711b8ac7392f1f309692d41441dbaa56 100644 (file)
@@ -1,6 +1,6 @@
 /*+++\r
 \r
-Copyright (c) 2006, 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
@@ -95,7 +95,7 @@ EFI_UNIX_UGA            - Builds UGA Windows of Width and Height
 //\r
 // Define GUID for the Unix Bus Driver\r
 //\r
-static EFI_GUID gUnixBusDriverGuid = {\r
+EFI_GUID gUnixBusDriverGuid = {\r
   0x419f582, 0x625, 0x4531, {0x8a, 0x33, 0x85, 0xa9, 0x96, 0x5c, 0x95, 0xbc}\r
 };\r
 \r
@@ -117,7 +117,7 @@ EFI_DRIVER_BINDING_PROTOCOL           gUnixBusDriverBinding = {
 // Table to map UNIX Environment variable to the GUID that should be in\r
 // device path.\r
 //\r
-static UNIX_PCD_ENTRY  mPcdEnvironment[] = {\r
+UNIX_PCD_ENTRY  mPcdEnvironment[] = {\r
   {PcdToken(PcdUnixConsole),       &gEfiUnixConsoleGuid},\r
   {PcdToken(PcdUnixUga),           &gEfiUnixUgaGuid},\r
   {PcdToken(PcdUnixFileSystem),    &gEfiUnixFileSystemGuid},\r
@@ -186,20 +186,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(UNIX_VENDOR_DEVICE_PATH_NODE)) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-\r
-    for (Index = 0; Index < UNIX_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(UNIX_VENDOR_DEVICE_PATH_NODE)) {\r
+        return EFI_UNSUPPORTED;\r
+      }\r
+  \r
+      for (Index = 0; Index < UNIX_PCD_ARRAY_SIZE; Index++) {\r
+        if (CompareGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid, mPcdEnvironment[Index].DevicePathGuid)) {\r
+          break;\r
+        }\r
+      }\r
+  \r
+      if (Index >= UNIX_PCD_ARRAY_SIZE) {\r
+        return EFI_UNSUPPORTED;\r
       }\r
-    }\r
-\r
-    if (Index >= UNIX_PCD_ARRAY_SIZE) {\r
-      return EFI_UNSUPPORTED;\r
     }\r
   }\r
   \r
@@ -208,8 +218,8 @@ Returns:
   //\r
   Status = gBS->OpenProtocol (\r
                   ControllerHandle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **)&ParentDevicePath,\r
+                  &gEfiUnixThunkProtocolGuid,\r
+                  (VOID **)&UnixThunk,\r
                   This->DriverBindingHandle,\r
                   ControllerHandle,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -222,17 +232,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
+        &gEfiUnixThunkProtocolGuid,\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
-                  &gEfiUnixThunkProtocolGuid,\r
-                  (VOID **)&UnixThunk,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **)&ParentDevicePath,\r
                   This->DriverBindingHandle,\r
                   ControllerHandle,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -254,11 +270,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
-        &gEfiUnixThunkProtocolGuid,\r
+        &gEfiDevicePathProtocolGuid,\r
         This->DriverBindingHandle,\r
         ControllerHandle\r
         );\r
@@ -414,15 +430,25 @@ Returns:
       CreateDevice = TRUE;\r
       if (RemainingDevicePath != NULL) {\r
         CreateDevice  = FALSE;\r
-        Node          = (UNIX_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 (UNIX_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          = (UNIX_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 (UNIX_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