From: Blue Swirl Date: Fri, 25 Dec 2009 16:50:36 +0000 (+0000) Subject: PCI: make pci_mem_base private X-Git-Tag: TizenStudio_2.0_p2.3.2~208^2~9175 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2e01c8cf4b076b05013c87723e3fc710b50a0a7a;p=sdk%2Femulator%2Fqemu.git PCI: make pci_mem_base private Make pci_mem_base private to PCIBus. Add a function to set it. Signed-off-by: Blue Swirl --- diff --git a/hw/pci.c b/hw/pci.c index 9cc5a6a..b0c32c6 100644 --- a/hw/pci.c +++ b/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); } } } diff --git a/hw/pci.h b/hw/pci.h index e52e632..fd16460 100644 --- a/hw/pci.h +++ b/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,