FreeBSD/sys/contrib/dev/acpica/components/hardware/hwpci.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiHwBuildPciList
 *
 * PARAMETERS:  RootPciDevice       - A handle to a PCI device object. This
 *                                    object is guaranteed to be a PCI Root
 *                                    Bridge having a _HID value of either
 *                                    PNP0A03 or PNP0A08
 *              PciRegion           - A handle to the PCI configuration space
 *                                    Operation Region
 *              ReturnListHead      - Where the PCI device list is returned
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Builds a list of devices from the input PCI region up to the
 *              Root PCI device for this namespace subtree.
 *
 ******************************************************************************/
AcpiHwBuildPciList
PARAMETERS:  RootPciDevice       - A handle to a PCI device object. This
object is guaranteed to be a PCI Root
Bridge having a _HID value of either
PNP0A03 or PNP0A08
PciRegion           - A handle to the PCI configuration space
Operation Region
ReturnListHead      - Where the PCI device list is returned

Status

Builds a list of devices from the input PCI region up to the
Root PCI device for this namespace subtree.
AcpiHwBuildPciList PARAMETERS : RootPciDevice - A handle to a PCI device object . This object is guaranteed to be a PCI Root Bridge having a _HID value of either PNP0A03 or PNP0A08 PciRegion - A handle to the PCI configuration space Operation Region ReturnListHead - Where the PCI device list is returned Status Builds a list of devices from the input PCI region up to the Root PCI device for this namespace subtree .
static ACPI_STATUS
AcpiHwBuildPciList (
    ACPI_HANDLE             RootPciDevice,
    ACPI_HANDLE             PciRegion,
    ACPI_PCI_DEVICE         **ReturnListHead)
{
    ACPI_HANDLE             CurrentDevice;
    ACPI_HANDLE             ParentDevice;
    ACPI_STATUS             Status;
    ACPI_PCI_DEVICE         *ListElement;
    *ReturnListHead = NULL;
    CurrentDevice = PciRegion;
    while (1)
    {
        Status = AcpiGetParent (CurrentDevice, &ParentDevice);
        if (ACPI_FAILURE (Status))
        {
            AcpiHwDeletePciList (*ReturnListHead);
            return (Status);
        }
        if (ParentDevice == RootPciDevice)
        {
            return (AE_OK);
        }
        ListElement = ACPI_ALLOCATE (sizeof (ACPI_PCI_DEVICE));
        if (!ListElement)
        {
            AcpiHwDeletePciList (*ReturnListHead);
            return (AE_NO_MEMORY);
        }
        ListElement->Next = *ReturnListHead;
        ListElement->Device = ParentDevice;
        *ReturnListHead = ListElement;
        CurrentDevice = ParentDevice;
    }
}
static ACPI_STATUS AcpiHwBuildPciList ( ACPI_HANDLE RootPciDevice , ACPI_HANDLE PciRegion , ACPI_PCI_DEVICE * * ReturnListHead ) { ACPI_HANDLE CurrentDevice ; ACPI_HANDLE ParentDevice ; ACPI_STATUS Status ; ACPI_PCI_DEVICE * ListElement ; * ReturnListHead = NULL ; CurrentDevice = PciRegion ; while ( 1 ) { Status = AcpiGetParent ( CurrentDevice , & ParentDevice ) ; if ( ACPI_FAILURE ( Status ) ) { AcpiHwDeletePciList ( * ReturnListHead ) ; return ( Status ) ; } if ( ParentDevice == RootPciDevice ) { return ( AE_OK ) ; } ListElement = ACPI_ALLOCATE ( sizeof ( ACPI_PCI_DEVICE ) ) ; if ( ! ListElement ) { AcpiHwDeletePciList ( * ReturnListHead ) ; return ( AE_NO_MEMORY ) ; } ListElement -> Next = * ReturnListHead ; ListElement -> Device = ParentDevice ; * ReturnListHead = ListElement ; CurrentDevice = ParentDevice ; } }
FUNCTION:    AcpiHwBuildPciList
 PARAMETERS:  RootPciDevice       - A handle to a PCI device object.
FUNCTION : AcpiHwBuildPciList PARAMETERS : RootPciDevice - A handle to a PCI device object .
/*
     * Ascend namespace branch until the RootPciDevice is reached, building
     * a list of device nodes. Loop will exit when either the PCI device is
     * found, or the root of the namespace is reached.
     */ /* Must delete the list before exit */ /* Finished when we reach the PCI root device (PNP0A03 or PNP0A08) */ /* Must delete the list before exit */ /* Put new element at the head of the list */