Revision ca77089d hw/pci.c

b/hw/pci.c
1682 1682
    pdev->rom_offset = 0;
1683 1683
}
1684 1684

  
1685
/* Reserve space and add capability to the linked list in pci config space */
1686
int pci_add_capability_at_offset(PCIDevice *pdev, uint8_t cap_id,
1687
                                 uint8_t offset, uint8_t size)
1685
/*
1686
 * if !offset
1687
 * Reserve space and add capability to the linked list in pci config space
1688
 *
1689
 * if offset = 0,
1690
 * Find and reserve space and add capability to the linked list
1691
 * in pci config space */
1692
int pci_add_capability(PCIDevice *pdev, uint8_t cap_id,
1693
                       uint8_t offset, uint8_t size)
1688 1694
{
1689
    uint8_t *config = pdev->config + offset;
1695
    uint8_t *config;
1696
    if (!offset) {
1697
        offset = pci_find_space(pdev, size);
1698
        if (!offset) {
1699
            return -ENOSPC;
1700
        }
1701
    }
1702

  
1703
    config = pdev->config + offset;
1690 1704
    config[PCI_CAP_LIST_ID] = cap_id;
1691 1705
    config[PCI_CAP_LIST_NEXT] = pdev->config[PCI_CAPABILITY_LIST];
1692 1706
    pdev->config[PCI_CAPABILITY_LIST] = offset;
......
1699 1713
    return offset;
1700 1714
}
1701 1715

  
1702
/* Find and reserve space and add capability to the linked list
1703
 * in pci config space */
1704
int pci_add_capability(PCIDevice *pdev, uint8_t cap_id, uint8_t size)
1705
{
1706
    uint8_t offset = pci_find_space(pdev, size);
1707
    if (!offset) {
1708
        return -ENOSPC;
1709
    }
1710
    return pci_add_capability_at_offset(pdev, cap_id, offset, size);
1711
}
1712

  
1713 1716
/* Unlink capability from the pci config space. */
1714 1717
void pci_del_capability(PCIDevice *pdev, uint8_t cap_id, uint8_t size)
1715 1718
{

Also available in: Unified diff