PCI: make pci_mem_base private
Make pci_mem_base private to PCIBus. Add a function to set it. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
2fe0ee97f9
commit
2e01c8cf4b
28
hw/pci.c
28
hw/pci.c
|
@ -45,6 +45,7 @@ struct PCIBus {
|
|||
void *irq_opaque;
|
||||
PCIDevice *devices[256];
|
||||
PCIDevice *parent_dev;
|
||||
target_phys_addr_t mem_base;
|
||||
|
||||
QLIST_HEAD(, PCIBus) child; /* this will be replaced by qdev later */
|
||||
QLIST_ENTRY(PCIBus) sibling;/* this will be replaced by qdev later */
|
||||
|
@ -72,7 +73,6 @@ static void pci_update_mappings(PCIDevice *d);
|
|||
static void pci_set_irq(void *opaque, int irq_num, int level);
|
||||
static int pci_add_option_rom(PCIDevice *pdev);
|
||||
|
||||
target_phys_addr_t pci_mem_base;
|
||||
static uint16_t pci_default_sub_vendor_id = PCI_SUBVENDOR_ID_REDHAT_QUMRANET;
|
||||
static uint16_t pci_default_sub_device_id = PCI_SUBDEVICE_ID_QEMU;
|
||||
|
||||
|
@ -238,6 +238,11 @@ void pci_bus_hotplug(PCIBus *bus, pci_hotplug_fn hotplug)
|
|||
bus->hotplug = hotplug;
|
||||
}
|
||||
|
||||
void pci_bus_set_mem_base(PCIBus *bus, target_phys_addr_t base)
|
||||
{
|
||||
bus->mem_base = base;
|
||||
}
|
||||
|
||||
PCIBus *pci_register_bus(DeviceState *parent, const char *name,
|
||||
pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
|
||||
void *irq_opaque, int devfn_min, int nirq)
|
||||
|
@ -634,9 +639,11 @@ PCIDevice *pci_register_device(PCIBus *bus, const char *name,
|
|||
}
|
||||
return pci_dev;
|
||||
}
|
||||
static target_phys_addr_t pci_to_cpu_addr(target_phys_addr_t addr)
|
||||
|
||||
static target_phys_addr_t pci_to_cpu_addr(PCIBus *bus,
|
||||
target_phys_addr_t addr)
|
||||
{
|
||||
return addr + pci_mem_base;
|
||||
return addr + bus->mem_base;
|
||||
}
|
||||
|
||||
static void pci_unregister_io_regions(PCIDevice *pci_dev)
|
||||
|
@ -651,9 +658,10 @@ static void pci_unregister_io_regions(PCIDevice *pci_dev)
|
|||
if (r->type == PCI_BASE_ADDRESS_SPACE_IO) {
|
||||
isa_unassign_ioport(r->addr, r->filtered_size);
|
||||
} else {
|
||||
cpu_register_physical_memory(pci_to_cpu_addr(r->addr),
|
||||
r->filtered_size,
|
||||
IO_MEM_UNASSIGNED);
|
||||
cpu_register_physical_memory(pci_to_cpu_addr(pci_dev->bus,
|
||||
r->addr),
|
||||
r->filtered_size,
|
||||
IO_MEM_UNASSIGNED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -891,7 +899,7 @@ static void pci_update_mappings(PCIDevice *d)
|
|||
{
|
||||
PCIIORegion *r;
|
||||
int i;
|
||||
pcibus_t new_addr, filtered_size;
|
||||
pcibus_t new_addr, filtered_size, bus_addr;
|
||||
|
||||
for(i = 0; i < PCI_NUM_REGIONS; i++) {
|
||||
r = &d->io_regions[i];
|
||||
|
@ -913,6 +921,7 @@ static void pci_update_mappings(PCIDevice *d)
|
|||
continue;
|
||||
|
||||
/* now do the real mapping */
|
||||
bus_addr = r->addr;
|
||||
if (r->addr != PCI_BAR_UNMAPPED) {
|
||||
if (r->type & PCI_BASE_ADDRESS_SPACE_IO) {
|
||||
int class;
|
||||
|
@ -925,7 +934,8 @@ static void pci_update_mappings(PCIDevice *d)
|
|||
isa_unassign_ioport(r->addr, r->filtered_size);
|
||||
}
|
||||
} else {
|
||||
cpu_register_physical_memory(pci_to_cpu_addr(r->addr),
|
||||
bus_addr = pci_to_cpu_addr(d->bus, r->addr);
|
||||
cpu_register_physical_memory(bus_addr,
|
||||
r->filtered_size,
|
||||
IO_MEM_UNASSIGNED);
|
||||
qemu_unregister_coalesced_mmio(r->addr, r->filtered_size);
|
||||
|
@ -941,7 +951,7 @@ static void pci_update_mappings(PCIDevice *d)
|
|||
* Teach them such cases, such that filtered_size < size and
|
||||
* addr & (size - 1) != 0.
|
||||
*/
|
||||
r->map_func(d, i, r->addr, r->filtered_size, r->type);
|
||||
r->map_func(d, i, bus_addr, r->filtered_size, r->type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
4
hw/pci.h
4
hw/pci.h
|
@ -10,8 +10,6 @@
|
|||
|
||||
/* PCI bus */
|
||||
|
||||
extern target_phys_addr_t pci_mem_base;
|
||||
|
||||
#define PCI_DEVFN(slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07))
|
||||
#define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f)
|
||||
#define PCI_FUNC(devfn) ((devfn) & 0x07)
|
||||
|
@ -286,6 +284,8 @@ PCIBus *pci_register_bus(DeviceState *parent, const char *name,
|
|||
pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
|
||||
void *irq_opaque, int devfn_min, int nirq);
|
||||
|
||||
void pci_bus_set_mem_base(PCIBus *bus, target_phys_addr_t base);
|
||||
|
||||
PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
|
||||
const char *default_devaddr);
|
||||
PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model,
|
||||
|
|
Loading…
Reference in a new issue