]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UnixPkg/UnixBusDriverDxe/UnixBusDriver.c
Fix issue with fixing tabs.
[mirror_edk2.git] / UnixPkg / UnixBusDriverDxe / UnixBusDriver.c
index 64f0245fc751249fac2e8b69270fb3f6d0f2356f..e1ec083822e689d10d0e82a3917607dfade561e4 100644 (file)
@@ -1,7 +1,7 @@
 /*+++\r
 \r
-Copyright (c) 2006, 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
@@ -15,7 +15,7 @@ Module Name:
 \r
 Abstract:\r
 \r
-This following section documents the envirnoment variables for the Win UNIX \r
+This following section documents the environment variables for the UNIX \r
 build.  These variables are used to define the (virtual) hardware \r
 configuration of the UNIX environment\r
 \r
@@ -118,15 +118,17 @@ EFI_DRIVER_BINDING_PROTOCOL           gUnixBusDriverBinding = {
 // device path.\r
 //\r
 UNIX_PCD_ENTRY  mPcdEnvironment[] = {\r
-  {PcdToken(PcdUnixConsole),       &gEfiUnixConsoleGuid},\r
-  {PcdToken(PcdUnixUga),           &gEfiUnixUgaGuid},\r
-  {PcdToken(PcdUnixFileSystem),    &gEfiUnixFileSystemGuid},\r
-  {PcdToken(PcdUnixSerialPort),    &gEfiUnixSerialPortGuid},\r
-  {PcdToken(PcdUnixVirtualDisk),   &gEfiUnixVirtualDisksGuid},\r
-  {PcdToken(PcdUnixPhysicalDisk),  &gEfiUnixPhysicalDisksGuid},\r
-  {PcdToken(PcdUnixCpuModel),      &gEfiUnixCPUModelGuid},\r
-  {PcdToken(PcdUnixCpuSpeed),      &gEfiUnixCPUSpeedGuid},\r
-  {PcdToken(PcdUnixMemorySize),    &gEfiUnixMemoryGuid}\r
+  {PcdToken(PcdUnixConsole),           &gEfiUnixConsoleGuid},\r
+  {PcdToken(PcdUnixUga),               &gEfiUnixUgaGuid},\r
+  {PcdToken(PcdUnixGop),               &gEfiUnixGopGuid},\r
+  {PcdToken(PcdUnixFileSystem),        &gEfiUnixFileSystemGuid},\r
+  {PcdToken(PcdUnixSerialPort),        &gEfiUnixSerialPortGuid},\r
+  {PcdToken(PcdUnixVirtualDisk),       &gEfiUnixVirtualDisksGuid},\r
+  {PcdToken(PcdUnixPhysicalDisk),      &gEfiUnixPhysicalDisksGuid},\r
+  {PcdToken(PcdUnixCpuModel),          &gEfiUnixCPUModelGuid},\r
+  {PcdToken(PcdUnixCpuSpeed),          &gEfiUnixCPUSpeedGuid},\r
+  {PcdToken(PcdUnixMemorySize),        &gEfiUnixMemoryGuid},\r
+  {PcdToken(PcdUnixNetworkInterface),  &gEfiUnixNetworkGuid}\r
 };\r
 \r
 VOID *\r
@@ -168,13 +170,6 @@ Returns:
   None\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
-// TODO:    EFI_UNSUPPORTED - add return value to function comment\r
-// TODO:    EFI_UNSUPPORTED - add return value to function comment\r
-// TODO:    EFI_SUCCESS - add return value to function comment\r
-// TODO:    EFI_SUCCESS - add return value to function comment\r
 {\r
   EFI_STATUS                Status;\r
   EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
@@ -186,20 +181,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 +213,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 +227,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 +265,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
@@ -284,12 +295,6 @@ Returns:
   None\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
-// TODO:    EFI_OUT_OF_RESOURCES - add return value to function comment\r
-// TODO:    EFI_OUT_OF_RESOURCES - add return value to function comment\r
-// TODO:    EFI_SUCCESS - add return value to function comment\r
 {\r
   EFI_STATUS                      Status;\r
   EFI_STATUS                      InstallStatus;\r
@@ -387,7 +392,7 @@ Returns:
     StartString = TempStr;\r
 \r
     //\r
-    // Parse the envirnment variable into sub strings using '!' as a delimator.\r
+    // Parse the environment variable into sub strings using '!' as a delimator.\r
     // Each substring needs it's own handle to be added to the system. This code\r
     // does not understand the sub string. Thats the device drivers job.\r
     //\r
@@ -414,15 +419,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
@@ -453,7 +468,7 @@ Returns:
 \r
         UnixDevice->ControllerNameTable = NULL;\r
 \r
-       //  FIXME: check size\r
+  //  FIXME: check size\r
         StrCpy(ComponentName, UnixDevice->UnixIo.EnvString);\r
 \r
         UnixDevice->DevicePath = UnixBusCreateDevicePath (\r
@@ -540,13 +555,6 @@ Returns:
     None\r
 \r
 --*/\r
-// TODO:    This - add argument and description to function comment\r
-// TODO:    ControllerHandle - add argument and description to function comment\r
-// TODO:    NumberOfChildren - add argument and description to function comment\r
-// TODO:    ChildHandleBuffer - add argument and description to function comment\r
-// TODO:    EFI_SUCCESS - add return value to function comment\r
-// TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
-// TODO:    EFI_SUCCESS - add return value to function comment\r
 {\r
   EFI_STATUS                Status;\r
   UINTN                     Index;\r