/*++\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
\r
Routine Description:\r
\r
- \r
+\r
Arguments:\r
\r
RootBridge - A pointer to the PCI_IO_DEVICE.\r
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
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
\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
//\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
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
);\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
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
if (Temp->Registered) {\r
DeRegisterPciDevice (RootBridgeHandle, Temp->Handle);\r
}\r
- \r
+\r
//\r
// Remove this node from the linked list\r
//\r
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
);\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
\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
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
ChildHandleBuffer[*NumberOfChildren] = Temp->Handle;\r
(*NumberOfChildren)++;\r
}\r
- \r
+\r
//\r
// Get the next device path\r
//\r
if (EfiIsDevicePathEnd (CurrentDevicePath)) {\r
return EFI_SUCCESS;\r
}\r
- \r
+\r
//\r
// If it is a PPB\r
//\r
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
/*++\r
\r
Routine Description:\r
- \r
+\r
Arguments:\r
\r
Bridge - A pointer to the PCI_IO_DEVICE.\r
Arguments:\r
\r
VgaDevice - A pointer to the PCI_IO_DEVICE.\r
- \r
+\r
Returns:\r
\r
None\r
\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
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