X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=EdkModulePkg%2FBus%2FPci%2FPciBus%2FDxe%2FPciDeviceSupport.c;h=cbbc00b18383998f5e322dd0b7682c737f04c4cd;hp=b1cee26c0a3e6c1b01da8517fb5bef1e3b1054d1;hb=e5f461a8507ffcc89cd99ca43a09b76dca136ab5;hpb=c5986ece6722efa7bf596966ec2d0586d8c2d660 diff --git a/EdkModulePkg/Bus/Pci/PciBus/Dxe/PciDeviceSupport.c b/EdkModulePkg/Bus/Pci/PciBus/Dxe/PciDeviceSupport.c index b1cee26c0a..cbbc00b183 100644 --- a/EdkModulePkg/Bus/Pci/PciBus/Dxe/PciDeviceSupport.c +++ b/EdkModulePkg/Bus/Pci/PciBus/Dxe/PciDeviceSupport.c @@ -1,18 +1,18 @@ /*++ -Copyright (c) 2006, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Module Name: PciDeviceSupport.c - + Abstract: This file provides routine to support Pci device node manipulation @@ -119,7 +119,7 @@ DestroyRootBridge ( Routine Description: - + Arguments: RootBridge - A pointer to the PCI_IO_DEVICE. @@ -147,7 +147,7 @@ FreePciDevice ( Routine Description: Destroy a pci device node. - Also all direct or indirect allocated resource for this node will be freed. + Also all direct or indirect allocated resource for this node will be freed. Arguments: @@ -232,7 +232,7 @@ DestroyRootBridgeByHandle ( Routine Description: Destroy all device nodes under the root bridge - specified by Controller. + specified by Controller. The root bridge itself is also included. Arguments: @@ -283,28 +283,29 @@ RegisterPciDevice ( Routine Description: - This function is used to register the PCI device to the EFI, - create a handle for this PCI device,then attach apporpriate protocols - onto the handle. + This function registers the PCI IO device. It creates a handle for this PCI IO device + (if the handle does not exist), attaches appropriate protocols onto the handle, does + necessary initialization, and sets up parent/child relationship with its bus controller. Arguments: - Controller - An efi handle. - PciIoDevice - A pointer to the PCI_IO_DEVICE. - Handle - A pointer to a efi handle. + Controller - An EFI handle for the PCI bus controller. + PciIoDevice - A PCI_IO_DEVICE pointer to the PCI IO device to be registered. + Handle - A pointer to hold the EFI handle for the PCI IO device. Returns: - None + EFI_SUCCESS - The PCI device is successfully registered. + Others - An error occurred when registering the PCI device. --*/ -// TODO: EFI_SUCCESS - add return value to function comment { EFI_STATUS Status; VOID *PlatformOpRomBuffer; UINTN PlatformOpRomSize; UINT8 PciExpressCapRegOffset; EFI_PCI_IO_PROTOCOL *PciIo; + UINT8 Data8; // // Install the pciio protocol, device path protocol @@ -326,21 +327,23 @@ Returns: // PciExpressCapRegOffset = 0; Status = LocateCapabilityRegBlock ( - PciIoDevice, - EFI_PCI_CAPABILITY_ID_PCIEXP, - &PciExpressCapRegOffset, - NULL - ); + PciIoDevice, + EFI_PCI_CAPABILITY_ID_PCIEXP, + &PciExpressCapRegOffset, + NULL + ); if (!EFI_ERROR (Status)) { PciIoDevice->IsPciExp = TRUE; } - + // - // Force Interrupt line to zero for cards that come up randomly + // Force Interrupt line to "Unknown" or "No Connection" // PciIo = &(PciIoDevice->PciIo); - PciIo->Pci.Write (PciIo, EfiPciIoWidthUint8, 0x3C, 1, &gAllZero); - + Data8 = PCI_INT_LINE_UNKNOWN; + + PciIo->Pci.Write (PciIo, EfiPciIoWidthUint8, 0x3C, 1, &Data8); + // // Process Platform OpRom // @@ -348,11 +351,11 @@ Returns: PciIoDevice->AllOpRomProcessed = TRUE; Status = gPciPlatformProtocol->GetPciRom ( - gPciPlatformProtocol, - PciIoDevice->Handle, - &PlatformOpRomBuffer, - &PlatformOpRomSize - ); + gPciPlatformProtocol, + PciIoDevice->Handle, + &PlatformOpRomBuffer, + &PlatformOpRomSize + ); if (!EFI_ERROR (Status)) { @@ -382,13 +385,13 @@ Returns: ); if (EFI_ERROR (Status)) { gBS->UninstallMultipleProtocolInterfaces ( - &PciIoDevice->Handle, - &gEfiDevicePathProtocolGuid, - PciIoDevice->DevicePath, - &gEfiPciIoProtocolGuid, - &PciIoDevice->PciIo, - NULL - ); + &PciIoDevice->Handle, + &gEfiDevicePathProtocolGuid, + PciIoDevice->DevicePath, + &gEfiPciIoProtocolGuid, + &PciIoDevice->PciIo, + NULL + ); return Status; } @@ -434,7 +437,7 @@ RemoveAllPciDeviceOnBridge ( Routine Description: This function is used to remove the whole PCI devices from the bridge. - + Arguments: RootBridgeHandle - An efi handle. @@ -463,7 +466,7 @@ Returns: if (Temp->Registered) { DeRegisterPciDevice (RootBridgeHandle, Temp->Handle); } - + // // Remove this node from the linked list // @@ -489,7 +492,7 @@ DeRegisterPciDevice ( Routine Description: This function is used to de-register the PCI device from the EFI, - That includes un-installing PciIo protocol from the specified PCI + That includes un-installing PciIo protocol from the specified PCI device handle. Arguments: @@ -601,7 +604,7 @@ Returns: ); return Status; } - + // // The Device Driver should disable this device after disconnect // so the Pci Bus driver will not touch this device any more. @@ -669,7 +672,7 @@ Returns: Node.DevPath = RemainingDevicePath; - if (Node.Pci->Device != Temp->DeviceNumber || + if (Node.Pci->Device != Temp->DeviceNumber || Node.Pci->Function != Temp->FunctionNumber) { CurrentLink = CurrentLink->ForwardLink; continue; @@ -681,7 +684,7 @@ Returns: if (!Temp->Allocated) { return EFI_NOT_READY; } - + // // Check if the current node has been registered before // If it is not, register it @@ -701,7 +704,7 @@ Returns: ChildHandleBuffer[*NumberOfChildren] = Temp->Handle; (*NumberOfChildren)++; } - + // // Get the next device path // @@ -709,7 +712,7 @@ Returns: if (EfiIsDevicePathEnd (CurrentDevicePath)) { return EFI_SUCCESS; } - + // // If it is a PPB // @@ -812,7 +815,7 @@ StartPciDevices ( Routine Description: Start to manage the PCI device according to RemainingDevicePath - If RemainingDevicePath == NULL, the PCI bus driver will start + If RemainingDevicePath == NULL, the PCI bus driver will start to manage all the PCI devices it found previously Arguments: @@ -1042,7 +1045,7 @@ PciDeviceExisted ( /*++ Routine Description: - + Arguments: Bridge - A pointer to the PCI_IO_DEVICE. @@ -1091,7 +1094,7 @@ Routine Description: Arguments: VgaDevice - A pointer to the PCI_IO_DEVICE. - + Returns: None @@ -1149,7 +1152,7 @@ Returns: Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink); - if (IS_PCI_VGA(&Temp->Pci) && + if (IS_PCI_VGA(&Temp->Pci) && (Temp->Attributes & (EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO | @@ -1187,7 +1190,7 @@ Arguments: PciRootBridgeIo - A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL. HpcDevicePath - A pointer to the EFI_DEVICE_PATH_PROTOCL. PciAddress - A pointer to the pci address. - + Returns: None