diff options
author | Avi Kivity <avi@redhat.com> | 2009-12-20 12:36:44 +0200 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-12-20 12:36:44 +0200 |
commit | 842d70aade6915b6ab403366bbdbcbe348809acf (patch) | |
tree | 5d566d08e88a93e90c32a24ed21d7fb7160bc9cb /hw/pci.c | |
parent | Merge commit '2b311b3cce0e30dc361a4f67948a8ccfe4db248d' into stable-0.12-merge (diff) | |
parent | Support PCI based option rom loading (diff) | |
download | qemu-kvm-842d70aade6915b6ab403366bbdbcbe348809acf.tar.gz qemu-kvm-842d70aade6915b6ab403366bbdbcbe348809acf.tar.bz2 qemu-kvm-842d70aade6915b6ab403366bbdbcbe348809acf.zip |
Merge commit '72bb3c7571226af13cfe9eec020a56add3d30a70' into stable-0.12-merge
* commit '72bb3c7571226af13cfe9eec020a56add3d30a70':
Support PCI based option rom loading
Fix backcompat for hotplug of SCSI controllers
fdc: fix migration from 0.11
Revert "fdc: fix vmstate variable passed"
monitor: Accept input only byte-wise
Revert "kvm: x86: Save/restore exception_index"
vmware: increase cursor buffer size.
Conflicts:
hw/pci.c
hw/pci.h
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'hw/pci.c')
-rw-r--r-- | hw/pci.c | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -26,6 +26,7 @@ #include "monitor.h" #include "net.h" #include "sysemu.h" +#include "loader.h" #include "qemu-kvm.h" #include "hw/pc.h" #include "device-assignment.h" @@ -1586,6 +1587,40 @@ 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); +} + +/* Add an option rom for the device */ +int pci_add_option_rom(PCIDevice *pdev, const char *name) +{ + int size; + char *path; + void *ptr; + + path = qemu_find_file(QEMU_FILE_TYPE_BIOS, name); + if (path == NULL) { + path = qemu_strdup(name); + } + + size = get_image_size(path); + if (size & (size - 1)) { + size = 1 << qemu_fls(size); + } + + pdev->rom_offset = qemu_ram_alloc(size); + + ptr = qemu_get_ram_ptr(pdev->rom_offset); + load_image(path, ptr); + qemu_free(path); + + pci_register_bar(pdev, PCI_ROM_SLOT, size, + 0, pci_map_option_rom); + + return 0; +} + /* Reserve space and add capability to the linked list in pci config space */ int pci_add_capability(PCIDevice *pdev, uint8_t cap_id, uint8_t size) { |