[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 35/39] pci: convert pci rom to memory API
From: |
Avi Kivity |
Subject: |
[Qemu-devel] [PATCH 35/39] pci: convert pci rom to memory API |
Date: |
Sun, 31 Jul 2011 20:57:58 +0300 |
Signed-off-by: Avi Kivity <address@hidden>
---
hw/pci.c | 20 +++++++-------------
hw/pci.h | 3 ++-
2 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index 6aca1af..481eb7e 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1857,11 +1857,6 @@ static uint8_t pci_find_capability_list(PCIDevice *pdev,
uint8_t cap_id,
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.
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)
@@ -1965,9 +1960,9 @@ static int pci_add_option_rom(PCIDevice *pdev, bool
is_default_rom)
snprintf(name, sizeof(name), "%s.rom", pdev->qdev.info->vmsd->name);
else
snprintf(name, sizeof(name), "%s.rom", pdev->qdev.info->name);
- pdev->rom_offset = qemu_ram_alloc(&pdev->qdev, name, size);
-
- ptr = qemu_get_ram_ptr(pdev->rom_offset);
+ pdev->has_rom = true;
+ memory_region_init_ram(&pdev->rom, &pdev->qdev, name, size);
+ ptr = memory_region_get_ram_ptr(&pdev->rom);
load_image(path, ptr);
qemu_free(path);
@@ -1978,19 +1973,18 @@ static int pci_add_option_rom(PCIDevice *pdev, bool
is_default_rom)
qemu_put_ram_ptr(ptr);
- pci_register_bar(pdev, PCI_ROM_SLOT, size,
- 0, pci_map_option_rom);
+ pci_register_bar_region(pdev, PCI_ROM_SLOT, 0, &pdev->rom);
return 0;
}
static void pci_del_option_rom(PCIDevice *pdev)
{
- if (!pdev->rom_offset)
+ if (!pdev->has_rom)
return;
- qemu_ram_free(pdev->rom_offset);
- pdev->rom_offset = 0;
+ memory_region_destroy(&pdev->rom);
+ pdev->has_rom = false;
}
/*
diff --git a/hw/pci.h b/hw/pci.h
index 25e28b1..6e2bcea 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -191,7 +191,8 @@ struct PCIDevice {
/* Location of option rom */
char *romfile;
- ram_addr_t rom_offset;
+ bool has_rom;
+ MemoryRegion rom;
uint32_t rom_bar;
};
--
1.7.5.3
- [Qemu-devel] [PATCH 11/39] pci: pass I/O address space to new PCI bus, (continued)
- [Qemu-devel] [PATCH 11/39] pci: pass I/O address space to new PCI bus, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 29/39] sun4u: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 14/39] ac97: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 32/39] xen-platform: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 34/39] pci: remove pci_register_bar_simple(), Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 07/39] vga: simplify vga window mmio access functions, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 33/39] msix: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 23/39] lsi53c895a: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 17/39] es1370: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 26/39] pcnet: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 35/39] pci: convert pci rom to memory API,
Avi Kivity <=
- [Qemu-devel] [PATCH 24/39] ppc: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 38/39] pci: rename pci_register_bar_region() to pci_register_bar(), Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 28/39] isa-mmio: concert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 03/39] vga: convert vga and its derivatives to the memory API, Avi Kivity, 2011/07/31
Re: [Qemu-devel] [PATCH 00/39] Memory API, batch 2: PCI devices, Avi Kivity, 2011/07/31