mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 17:53:56 -06:00
pci: convert pci rom to memory API
Reviewed-by: Richard Henderson <rth@twiddle.net> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
fa6c606589
commit
14caaf7f42
2 changed files with 9 additions and 14 deletions
20
hw/pci.c
20
hw/pci.c
|
@ -1855,11 +1855,6 @@ static uint8_t pci_find_capability_list(PCIDevice *pdev, uint8_t cap_id,
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, pcibus_t size, int type)
|
|
||||||
{
|
|
||||||
cpu_register_physical_memory(addr, size, pdev->rom_offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Patch the PCI vendor and device ids in a PCI rom image if necessary.
|
/* Patch the PCI vendor and device ids in a PCI rom image if necessary.
|
||||||
This is needed for an option rom which is used for more than one device. */
|
This is needed for an option rom which is used for more than one device. */
|
||||||
static void pci_patch_ids(PCIDevice *pdev, uint8_t *ptr, int size)
|
static void pci_patch_ids(PCIDevice *pdev, uint8_t *ptr, int size)
|
||||||
|
@ -1963,9 +1958,9 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom)
|
||||||
snprintf(name, sizeof(name), "%s.rom", pdev->qdev.info->vmsd->name);
|
snprintf(name, sizeof(name), "%s.rom", pdev->qdev.info->vmsd->name);
|
||||||
else
|
else
|
||||||
snprintf(name, sizeof(name), "%s.rom", pdev->qdev.info->name);
|
snprintf(name, sizeof(name), "%s.rom", pdev->qdev.info->name);
|
||||||
pdev->rom_offset = qemu_ram_alloc(&pdev->qdev, name, size);
|
pdev->has_rom = true;
|
||||||
|
memory_region_init_ram(&pdev->rom, &pdev->qdev, name, size);
|
||||||
ptr = qemu_get_ram_ptr(pdev->rom_offset);
|
ptr = memory_region_get_ram_ptr(&pdev->rom);
|
||||||
load_image(path, ptr);
|
load_image(path, ptr);
|
||||||
qemu_free(path);
|
qemu_free(path);
|
||||||
|
|
||||||
|
@ -1976,19 +1971,18 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom)
|
||||||
|
|
||||||
qemu_put_ram_ptr(ptr);
|
qemu_put_ram_ptr(ptr);
|
||||||
|
|
||||||
pci_register_bar(pdev, PCI_ROM_SLOT, size,
|
pci_register_bar_region(pdev, PCI_ROM_SLOT, 0, &pdev->rom);
|
||||||
0, pci_map_option_rom);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pci_del_option_rom(PCIDevice *pdev)
|
static void pci_del_option_rom(PCIDevice *pdev)
|
||||||
{
|
{
|
||||||
if (!pdev->rom_offset)
|
if (!pdev->has_rom)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qemu_ram_free(pdev->rom_offset);
|
memory_region_destroy(&pdev->rom);
|
||||||
pdev->rom_offset = 0;
|
pdev->has_rom = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
3
hw/pci.h
3
hw/pci.h
|
@ -191,7 +191,8 @@ struct PCIDevice {
|
||||||
|
|
||||||
/* Location of option rom */
|
/* Location of option rom */
|
||||||
char *romfile;
|
char *romfile;
|
||||||
ram_addr_t rom_offset;
|
bool has_rom;
|
||||||
|
MemoryRegion rom;
|
||||||
uint32_t rom_bar;
|
uint32_t rom_bar;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue