mirror of https://github.com/xemu-project/xemu.git
pci: add pci_register_bar_simple() API
This is similar to pci_register_bar(), but automatically registers a single memory region spanning the entire BAR. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
af94482bce
commit
17cbcb0bf7
17
hw/pci.c
17
hw/pci.c
|
@ -866,6 +866,7 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num,
|
|||
r->filtered_size = size;
|
||||
r->type = type;
|
||||
r->map_func = map_func;
|
||||
r->ram_addr = IO_MEM_UNASSIGNED;
|
||||
|
||||
wmask = ~(size - 1);
|
||||
addr = pci_bar(pci_dev, region_num);
|
||||
|
@ -884,6 +885,22 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num,
|
|||
}
|
||||
}
|
||||
|
||||
static void pci_simple_bar_mapfunc(PCIDevice *pci_dev, int region_num,
|
||||
pcibus_t addr, pcibus_t size, int type)
|
||||
{
|
||||
cpu_register_physical_memory(addr, size,
|
||||
pci_dev->io_regions[region_num].ram_addr);
|
||||
}
|
||||
|
||||
void pci_register_bar_simple(PCIDevice *pci_dev, int region_num,
|
||||
pcibus_t size, uint8_t attr, ram_addr_t ram_addr)
|
||||
{
|
||||
pci_register_bar(pci_dev, region_num, size,
|
||||
PCI_BASE_ADDRESS_SPACE_MEMORY | attr,
|
||||
pci_simple_bar_mapfunc);
|
||||
pci_dev->io_regions[region_num].ram_addr = ram_addr;
|
||||
}
|
||||
|
||||
static void pci_bridge_filter(PCIDevice *d, pcibus_t *addr, pcibus_t *size,
|
||||
uint8_t type)
|
||||
{
|
||||
|
|
3
hw/pci.h
3
hw/pci.h
|
@ -92,6 +92,7 @@ typedef struct PCIIORegion {
|
|||
pcibus_t filtered_size;
|
||||
uint8_t type;
|
||||
PCIMapIORegionFunc *map_func;
|
||||
ram_addr_t ram_addr;
|
||||
} PCIIORegion;
|
||||
|
||||
#define PCI_ROM_SLOT 6
|
||||
|
@ -200,6 +201,8 @@ PCIDevice *pci_register_device(PCIBus *bus, const char *name,
|
|||
void pci_register_bar(PCIDevice *pci_dev, int region_num,
|
||||
pcibus_t size, uint8_t type,
|
||||
PCIMapIORegionFunc *map_func);
|
||||
void pci_register_bar_simple(PCIDevice *pci_dev, int region_num,
|
||||
pcibus_t size, uint8_t attr, ram_addr_t ram_addr);
|
||||
|
||||
int pci_add_capability(PCIDevice *pdev, uint8_t cap_id,
|
||||
uint8_t offset, uint8_t size);
|
||||
|
|
Loading…
Reference in New Issue