]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Bus/Pci/PciBus/Dxe/PciDeviceSupport.c
1. Remove #ifdef _MSC_EXTENSION_ from all source files
[mirror_edk2.git] / EdkModulePkg / Bus / Pci / PciBus / Dxe / PciDeviceSupport.c
index 54a7fe745297fb65997001ec9cf8a9ed594b1bf8..cbbc00b18383998f5e322dd0b7682c737f04c4cd 100644 (file)
@@ -1,18 +1,18 @@
 /*++\r
 \r
-Copyright (c) 2006, 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, 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
 \r
 Module Name:\r
 \r
   PciDeviceSupport.c\r
-  \r
+\r
 Abstract:\r
 \r
   This file provides routine to support Pci device node manipulation\r
@@ -119,7 +119,7 @@ DestroyRootBridge (
 \r
 Routine Description:\r
 \r
-  \r
+\r
 Arguments:\r
 \r
   RootBridge   - A pointer to the PCI_IO_DEVICE.\r
@@ -147,7 +147,7 @@ FreePciDevice (
 Routine Description:\r
 \r
   Destroy a pci device node.\r
-  Also all direct or indirect allocated resource for this node will be freed.   \r
+  Also all direct or indirect allocated resource for this node will be freed.\r
 \r
 Arguments:\r
 \r
@@ -232,7 +232,7 @@ DestroyRootBridgeByHandle (
 Routine Description:\r
 \r
   Destroy all device nodes under the root bridge\r
-  specified by Controller. \r
+  specified by Controller.\r
   The root bridge itself is also included.\r
 \r
 Arguments:\r
@@ -283,28 +283,29 @@ RegisterPciDevice (
 \r
 Routine Description:\r
 \r
-  This function is used to register the PCI device to the EFI,\r
-  create a handle for this PCI device,then attach apporpriate protocols\r
-  onto the handle.\r
+  This function registers the PCI IO device. It creates a handle for this PCI IO device\r
+  (if the handle does not exist), attaches appropriate protocols onto the handle, does\r
+  necessary initialization, and sets up parent/child relationship with its bus controller.\r
 \r
 Arguments:\r
 \r
-  Controller    - An efi handle.\r
-  PciIoDevice   - A pointer to the PCI_IO_DEVICE.\r
-  Handle        - A pointer to a efi handle.\r
+  Controller    - An EFI handle for the PCI bus controller.\r
+  PciIoDevice   - A PCI_IO_DEVICE pointer to the PCI IO device to be registered.\r
+  Handle        - A pointer to hold the EFI handle for the PCI IO device.\r
 \r
 Returns:\r
 \r
-  None\r
+  EFI_SUCCESS   - The PCI device is successfully registered.\r
+  Others        - An error occurred when registering the PCI device.\r
 \r
 --*/\r
-// TODO:    EFI_SUCCESS - add return value to function comment\r
 {\r
   EFI_STATUS          Status;\r
   VOID                *PlatformOpRomBuffer;\r
   UINTN               PlatformOpRomSize;\r
   UINT8               PciExpressCapRegOffset;\r
   EFI_PCI_IO_PROTOCOL *PciIo;\r
+  UINT8               Data8;\r
 \r
   //\r
   // Install the pciio protocol, device path protocol\r
@@ -326,20 +327,23 @@ Returns:
   //\r
   PciExpressCapRegOffset = 0;\r
   Status = LocateCapabilityRegBlock (\r
-            PciIoDevice,\r
-            EFI_PCI_CAPABILITY_ID_PCIEXP,\r
-            &PciExpressCapRegOffset,\r
-            NULL\r
-            );\r
+             PciIoDevice,\r
+             EFI_PCI_CAPABILITY_ID_PCIEXP,\r
+             &PciExpressCapRegOffset,\r
+             NULL\r
+             );\r
   if (!EFI_ERROR (Status)) {\r
     PciIoDevice->IsPciExp = TRUE;\r
   }\r
-  \r
+\r
   //\r
-  // Force Interrupt line to zero for cards that come up randomly\r
+  // Force Interrupt line to "Unknown" or "No Connection"\r
   //\r
   PciIo = &(PciIoDevice->PciIo);\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint8, 0x3C, 1, &gAllZero);\r
+  Data8 = PCI_INT_LINE_UNKNOWN;\r
+\r
+  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint8, 0x3C, 1, &Data8);\r
+\r
   //\r
   // Process Platform OpRom\r
   //\r
@@ -347,11 +351,11 @@ Returns:
     PciIoDevice->AllOpRomProcessed = TRUE;\r
 \r
     Status = gPciPlatformProtocol->GetPciRom (\r
-                                    gPciPlatformProtocol,\r
-                                    PciIoDevice->Handle,\r
-                                    &PlatformOpRomBuffer,\r
-                                    &PlatformOpRomSize\r
-                                    );\r
+                                     gPciPlatformProtocol,\r
+                                     PciIoDevice->Handle,\r
+                                     &PlatformOpRomBuffer,\r
+                                     &PlatformOpRomSize\r
+                                     );\r
 \r
     if (!EFI_ERROR (Status)) {\r
 \r
@@ -381,13 +385,13 @@ Returns:
                     );\r
     if (EFI_ERROR (Status)) {\r
       gBS->UninstallMultipleProtocolInterfaces (\r
-            &PciIoDevice->Handle,\r
-            &gEfiDevicePathProtocolGuid,\r
-            PciIoDevice->DevicePath,\r
-            &gEfiPciIoProtocolGuid,\r
-            &PciIoDevice->PciIo,\r
-            NULL\r
-            );\r
+             &PciIoDevice->Handle,\r
+             &gEfiDevicePathProtocolGuid,\r
+             PciIoDevice->DevicePath,\r
+             &gEfiPciIoProtocolGuid,\r
+             &PciIoDevice->PciIo,\r
+             NULL\r
+             );\r
 \r
       return Status;\r
     }\r
@@ -433,7 +437,7 @@ RemoveAllPciDeviceOnBridge (
 Routine Description:\r
 \r
   This function is used to remove the whole PCI devices from the bridge.\r
-  \r
+\r
 Arguments:\r
 \r
   RootBridgeHandle   - An efi handle.\r
@@ -462,7 +466,7 @@ Returns:
     if (Temp->Registered) {\r
       DeRegisterPciDevice (RootBridgeHandle, Temp->Handle);\r
     }\r
-    \r
+\r
     //\r
     // Remove this node from the linked list\r
     //\r
@@ -488,7 +492,7 @@ DeRegisterPciDevice (
 Routine Description:\r
 \r
   This function is used to de-register the PCI device from the EFI,\r
-  That includes un-installing PciIo protocol from the specified PCI \r
+  That includes un-installing PciIo protocol from the specified PCI\r
   device handle.\r
 \r
 Arguments:\r
@@ -600,7 +604,7 @@ Returns:
             );\r
       return Status;\r
     }\r
-    \r
+\r
     //\r
     // The Device Driver should disable this device after disconnect\r
     // so the Pci Bus driver will not touch this device any more.\r
@@ -668,7 +672,7 @@ Returns:
 \r
       Node.DevPath = RemainingDevicePath;\r
 \r
-      if (Node.Pci->Device != Temp->DeviceNumber || \r
+      if (Node.Pci->Device != Temp->DeviceNumber ||\r
           Node.Pci->Function != Temp->FunctionNumber) {\r
         CurrentLink = CurrentLink->ForwardLink;\r
         continue;\r
@@ -680,7 +684,7 @@ Returns:
       if (!Temp->Allocated) {\r
         return EFI_NOT_READY;\r
       }\r
-      \r
+\r
       //\r
       // Check if the current node has been registered before\r
       // If it is not, register it\r
@@ -700,7 +704,7 @@ Returns:
         ChildHandleBuffer[*NumberOfChildren] = Temp->Handle;\r
         (*NumberOfChildren)++;\r
       }\r
-      \r
+\r
       //\r
       // Get the next device path\r
       //\r
@@ -708,7 +712,7 @@ Returns:
       if (EfiIsDevicePathEnd (CurrentDevicePath)) {\r
         return EFI_SUCCESS;\r
       }\r
-  \r
+\r
       //\r
       // If it is a PPB\r
       //\r
@@ -811,7 +815,7 @@ StartPciDevices (
 Routine Description:\r
 \r
   Start to manage the PCI device according to RemainingDevicePath\r
-  If RemainingDevicePath == NULL, the PCI bus driver will start \r
+  If RemainingDevicePath == NULL, the PCI bus driver will start\r
   to manage all the PCI devices it found previously\r
 \r
 Arguments:\r
@@ -1041,7 +1045,7 @@ PciDeviceExisted (
 /*++\r
 \r
 Routine Description:\r
-  \r
+\r
 Arguments:\r
 \r
   Bridge       - A pointer to the PCI_IO_DEVICE.\r
@@ -1090,7 +1094,7 @@ Routine Description:
 Arguments:\r
 \r
   VgaDevice    - A pointer to the PCI_IO_DEVICE.\r
-  \r
+\r
 Returns:\r
 \r
   None\r
@@ -1148,8 +1152,11 @@ Returns:
 \r
     Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);\r
 \r
-    if (IS_PCI_VGA(&Temp->Pci) && \r
-        (Temp->Attributes & (EFI_PCI_IO_ATTRIBUTE_MEMORY | EFI_PCI_IO_ATTRIBUTE_IO))) {\r
+    if (IS_PCI_VGA(&Temp->Pci) &&\r
+        (Temp->Attributes &\r
+         (EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY |\r
+          EFI_PCI_IO_ATTRIBUTE_VGA_IO     |\r
+          EFI_PCI_IO_ATTRIBUTE_VGA_IO_16))) {\r
       return Temp;\r
     }\r
 \r
@@ -1183,7 +1190,7 @@ Arguments:
   PciRootBridgeIo       - A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r
   HpcDevicePath         - A pointer to the EFI_DEVICE_PATH_PROTOCL.\r
   PciAddress            - A pointer to the pci address.\r
-  \r
+\r
 Returns:\r
 \r
   None\r