Revision 14caaf7f
b/hw/pci.c | ||
---|---|---|
1855 | 1855 |
return next; |
1856 | 1856 |
} |
1857 | 1857 |
|
1858 |
static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, pcibus_t size, int type) |
|
1859 |
{ |
|
1860 |
cpu_register_physical_memory(addr, size, pdev->rom_offset); |
|
1861 |
} |
|
1862 |
|
|
1863 | 1858 |
/* Patch the PCI vendor and device ids in a PCI rom image if necessary. |
1864 | 1859 |
This is needed for an option rom which is used for more than one device. */ |
1865 | 1860 |
static void pci_patch_ids(PCIDevice *pdev, uint8_t *ptr, int size) |
... | ... | |
1963 | 1958 |
snprintf(name, sizeof(name), "%s.rom", pdev->qdev.info->vmsd->name); |
1964 | 1959 |
else |
1965 | 1960 |
snprintf(name, sizeof(name), "%s.rom", pdev->qdev.info->name); |
1966 |
pdev->rom_offset = qemu_ram_alloc(&pdev->qdev, name, size);
|
|
1967 |
|
|
1968 |
ptr = qemu_get_ram_ptr(pdev->rom_offset);
|
|
1961 |
pdev->has_rom = true;
|
|
1962 |
memory_region_init_ram(&pdev->rom, &pdev->qdev, name, size); |
|
1963 |
ptr = memory_region_get_ram_ptr(&pdev->rom);
|
|
1969 | 1964 |
load_image(path, ptr); |
1970 | 1965 |
qemu_free(path); |
1971 | 1966 |
|
... | ... | |
1976 | 1971 |
|
1977 | 1972 |
qemu_put_ram_ptr(ptr); |
1978 | 1973 |
|
1979 |
pci_register_bar(pdev, PCI_ROM_SLOT, size, |
|
1980 |
0, pci_map_option_rom); |
|
1974 |
pci_register_bar_region(pdev, PCI_ROM_SLOT, 0, &pdev->rom); |
|
1981 | 1975 |
|
1982 | 1976 |
return 0; |
1983 | 1977 |
} |
1984 | 1978 |
|
1985 | 1979 |
static void pci_del_option_rom(PCIDevice *pdev) |
1986 | 1980 |
{ |
1987 |
if (!pdev->rom_offset)
|
|
1981 |
if (!pdev->has_rom)
|
|
1988 | 1982 |
return; |
1989 | 1983 |
|
1990 |
qemu_ram_free(pdev->rom_offset);
|
|
1991 |
pdev->rom_offset = 0;
|
|
1984 |
memory_region_destroy(&pdev->rom);
|
|
1985 |
pdev->has_rom = false;
|
|
1992 | 1986 |
} |
1993 | 1987 |
|
1994 | 1988 |
/* |
b/hw/pci.h | ||
---|---|---|
191 | 191 |
|
192 | 192 |
/* Location of option rom */ |
193 | 193 |
char *romfile; |
194 |
ram_addr_t rom_offset; |
|
194 |
bool has_rom; |
|
195 |
MemoryRegion rom; |
|
195 | 196 |
uint32_t rom_bar; |
196 | 197 |
}; |
197 | 198 |
|
Also available in: Unified diff