mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20150213' into staging
target-arm queue: * PCIe support in virt board * Support 32-bit guests on 64-bit KVM hosts in virt board * Fixes to avoid C undefined behaviour # gpg: Signature made Fri 13 Feb 2015 05:53:07 GMT using RSA key ID 14360CDE # gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" * remotes/pmaydell/tags/pull-target-arm-20150213: target-arm: A64: Avoid signed shifts in disas_ldst_pair() target-arm: A64: Avoid left shifting negative integers in disas_pc_rel_addr target-arm: A64: Fix handling of rotate in logic_imm_decode_wmask target-arm: A64: Fix shifts into sign bit target-arm: Add AArch32 guest support to KVM64 target-arm: Add 32/64-bit register sync target-arm: Add feature parsing to virt target-arm: Add CPU property to disable AArch64 pci: Move PCI VGA to pci.mak arm: Add PCIe host bridge in virt machine pci: Add generic PCIe host bridge pci: Allocate PCIe host bridge PCI ID Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
@@ -5,8 +5,6 @@ include usb.mak
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_I8254=y
|
||||
CONFIG_PCKBD=y
|
||||
CONFIG_VGA=y
|
||||
CONFIG_VGA_PCI=y
|
||||
CONFIG_VGA_CIRRUS=y
|
||||
CONFIG_IDE_CORE=y
|
||||
CONFIG_IDE_QDEV=y
|
||||
|
||||
@@ -82,6 +82,8 @@ CONFIG_ZYNQ=y
|
||||
CONFIG_VERSATILE_PCI=y
|
||||
CONFIG_VERSATILE_I2C=y
|
||||
|
||||
CONFIG_PCI_GENERIC=y
|
||||
|
||||
CONFIG_SDHCI=y
|
||||
CONFIG_INTEGRATOR_DEBUG=y
|
||||
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
include pci.mak
|
||||
include sound.mak
|
||||
include usb.mak
|
||||
CONFIG_VGA=y
|
||||
CONFIG_QXL=$(CONFIG_SPICE)
|
||||
CONFIG_VGA_PCI=y
|
||||
CONFIG_VGA_ISA=y
|
||||
CONFIG_VGA_CIRRUS=y
|
||||
CONFIG_VMWARE_VGA=y
|
||||
|
||||
@@ -4,8 +4,6 @@ include pci.mak
|
||||
include sound.mak
|
||||
include usb.mak
|
||||
CONFIG_ESP=y
|
||||
CONFIG_VGA=y
|
||||
CONFIG_VGA_PCI=y
|
||||
CONFIG_VGA_ISA=y
|
||||
CONFIG_VGA_ISA_MM=y
|
||||
CONFIG_VGA_CIRRUS=y
|
||||
|
||||
@@ -4,8 +4,6 @@ include pci.mak
|
||||
include sound.mak
|
||||
include usb.mak
|
||||
CONFIG_ESP=y
|
||||
CONFIG_VGA=y
|
||||
CONFIG_VGA_PCI=y
|
||||
CONFIG_VGA_ISA=y
|
||||
CONFIG_VGA_ISA_MM=y
|
||||
CONFIG_VGA_CIRRUS=y
|
||||
|
||||
@@ -4,8 +4,6 @@ include pci.mak
|
||||
include sound.mak
|
||||
include usb.mak
|
||||
CONFIG_ESP=y
|
||||
CONFIG_VGA=y
|
||||
CONFIG_VGA_PCI=y
|
||||
CONFIG_VGA_ISA=y
|
||||
CONFIG_VGA_ISA_MM=y
|
||||
CONFIG_VGA_CIRRUS=y
|
||||
|
||||
@@ -4,8 +4,6 @@ include pci.mak
|
||||
include sound.mak
|
||||
include usb.mak
|
||||
CONFIG_ESP=y
|
||||
CONFIG_VGA=y
|
||||
CONFIG_VGA_PCI=y
|
||||
CONFIG_VGA_ISA=y
|
||||
CONFIG_VGA_ISA_MM=y
|
||||
CONFIG_VGA_CIRRUS=y
|
||||
|
||||
@@ -33,3 +33,5 @@ CONFIG_NVME_PCI=y
|
||||
CONFIG_SD=y
|
||||
CONFIG_SDHCI=y
|
||||
CONFIG_EDU=y
|
||||
CONFIG_VGA=y
|
||||
CONFIG_VGA_PCI=y
|
||||
|
||||
@@ -6,8 +6,6 @@ include usb.mak
|
||||
CONFIG_ISA_MMIO=y
|
||||
CONFIG_ESCC=y
|
||||
CONFIG_M48T59=y
|
||||
CONFIG_VGA=y
|
||||
CONFIG_VGA_PCI=y
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_PARALLEL=y
|
||||
CONFIG_I8254=y
|
||||
|
||||
@@ -6,8 +6,6 @@ include usb.mak
|
||||
CONFIG_ISA_MMIO=y
|
||||
CONFIG_ESCC=y
|
||||
CONFIG_M48T59=y
|
||||
CONFIG_VGA=y
|
||||
CONFIG_VGA_PCI=y
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_PARALLEL=y
|
||||
CONFIG_I8254=y
|
||||
|
||||
@@ -4,8 +4,6 @@ include pci.mak
|
||||
include sound.mak
|
||||
include usb.mak
|
||||
CONFIG_M48T59=y
|
||||
CONFIG_VGA=y
|
||||
CONFIG_VGA_PCI=y
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_I8257=y
|
||||
CONFIG_OPENPIC=y
|
||||
|
||||
@@ -5,8 +5,6 @@ include usb.mak
|
||||
CONFIG_ISA_MMIO=y
|
||||
CONFIG_M48T59=y
|
||||
CONFIG_PTIMER=y
|
||||
CONFIG_VGA=y
|
||||
CONFIG_VGA_PCI=y
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_PARALLEL=y
|
||||
CONFIG_PCKBD=y
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
include pci.mak
|
||||
include sound.mak
|
||||
include usb.mak
|
||||
CONFIG_VGA=y
|
||||
CONFIG_QXL=$(CONFIG_SPICE)
|
||||
CONFIG_VGA_PCI=y
|
||||
CONFIG_VGA_ISA=y
|
||||
CONFIG_VGA_CIRRUS=y
|
||||
CONFIG_VMWARE_VGA=y
|
||||
|
||||
+150
-8
@@ -42,6 +42,7 @@
|
||||
#include "exec/address-spaces.h"
|
||||
#include "qemu/bitops.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "hw/pci-host/gpex.h"
|
||||
|
||||
#define NUM_VIRTIO_TRANSPORTS 32
|
||||
|
||||
@@ -69,6 +70,7 @@ enum {
|
||||
VIRT_MMIO,
|
||||
VIRT_RTC,
|
||||
VIRT_FW_CFG,
|
||||
VIRT_PCIE,
|
||||
};
|
||||
|
||||
typedef struct MemMapEntry {
|
||||
@@ -129,13 +131,21 @@ static const MemMapEntry a15memmap[] = {
|
||||
[VIRT_FW_CFG] = { 0x09020000, 0x0000000a },
|
||||
[VIRT_MMIO] = { 0x0a000000, 0x00000200 },
|
||||
/* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */
|
||||
/* 0x10000000 .. 0x40000000 reserved for PCI */
|
||||
/*
|
||||
* PCIE verbose map:
|
||||
*
|
||||
* MMIO window { 0x10000000, 0x2eff0000 },
|
||||
* PIO window { 0x3eff0000, 0x00010000 },
|
||||
* ECAM { 0x3f000000, 0x01000000 },
|
||||
*/
|
||||
[VIRT_PCIE] = { 0x10000000, 0x30000000 },
|
||||
[VIRT_MEM] = { 0x40000000, 30ULL * 1024 * 1024 * 1024 },
|
||||
};
|
||||
|
||||
static const int a15irqmap[] = {
|
||||
[VIRT_UART] = 1,
|
||||
[VIRT_RTC] = 2,
|
||||
[VIRT_PCIE] = 3, /* ... to 6 */
|
||||
[VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */
|
||||
};
|
||||
|
||||
@@ -312,7 +322,7 @@ static void fdt_add_cpu_nodes(const VirtBoardInfo *vbi)
|
||||
}
|
||||
}
|
||||
|
||||
static void fdt_add_gic_node(const VirtBoardInfo *vbi)
|
||||
static uint32_t fdt_add_gic_node(const VirtBoardInfo *vbi)
|
||||
{
|
||||
uint32_t gic_phandle;
|
||||
|
||||
@@ -331,9 +341,11 @@ static void fdt_add_gic_node(const VirtBoardInfo *vbi)
|
||||
2, vbi->memmap[VIRT_GIC_CPU].base,
|
||||
2, vbi->memmap[VIRT_GIC_CPU].size);
|
||||
qemu_fdt_setprop_cell(vbi->fdt, "/intc", "phandle", gic_phandle);
|
||||
|
||||
return gic_phandle;
|
||||
}
|
||||
|
||||
static void create_gic(const VirtBoardInfo *vbi, qemu_irq *pic)
|
||||
static uint32_t create_gic(const VirtBoardInfo *vbi, qemu_irq *pic)
|
||||
{
|
||||
/* We create a standalone GIC v2 */
|
||||
DeviceState *gicdev;
|
||||
@@ -380,7 +392,7 @@ static void create_gic(const VirtBoardInfo *vbi, qemu_irq *pic)
|
||||
pic[i] = qdev_get_gpio_in(gicdev, i);
|
||||
}
|
||||
|
||||
fdt_add_gic_node(vbi);
|
||||
return fdt_add_gic_node(vbi);
|
||||
}
|
||||
|
||||
static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic)
|
||||
@@ -585,6 +597,119 @@ static void create_fw_cfg(const VirtBoardInfo *vbi)
|
||||
g_free(nodename);
|
||||
}
|
||||
|
||||
static void create_pcie_irq_map(const VirtBoardInfo *vbi, uint32_t gic_phandle,
|
||||
int first_irq, const char *nodename)
|
||||
{
|
||||
int devfn, pin;
|
||||
uint32_t full_irq_map[4 * 4 * 8] = { 0 };
|
||||
uint32_t *irq_map = full_irq_map;
|
||||
|
||||
for (devfn = 0; devfn <= 0x18; devfn += 0x8) {
|
||||
for (pin = 0; pin < 4; pin++) {
|
||||
int irq_type = GIC_FDT_IRQ_TYPE_SPI;
|
||||
int irq_nr = first_irq + ((pin + PCI_SLOT(devfn)) % PCI_NUM_PINS);
|
||||
int irq_level = GIC_FDT_IRQ_FLAGS_LEVEL_HI;
|
||||
int i;
|
||||
|
||||
uint32_t map[] = {
|
||||
devfn << 8, 0, 0, /* devfn */
|
||||
pin + 1, /* PCI pin */
|
||||
gic_phandle, irq_type, irq_nr, irq_level }; /* GIC irq */
|
||||
|
||||
/* Convert map to big endian */
|
||||
for (i = 0; i < 8; i++) {
|
||||
irq_map[i] = cpu_to_be32(map[i]);
|
||||
}
|
||||
irq_map += 8;
|
||||
}
|
||||
}
|
||||
|
||||
qemu_fdt_setprop(vbi->fdt, nodename, "interrupt-map",
|
||||
full_irq_map, sizeof(full_irq_map));
|
||||
|
||||
qemu_fdt_setprop_cells(vbi->fdt, nodename, "interrupt-map-mask",
|
||||
0x1800, 0, 0, /* devfn (PCI_SLOT(3)) */
|
||||
0x7 /* PCI irq */);
|
||||
}
|
||||
|
||||
static void create_pcie(const VirtBoardInfo *vbi, qemu_irq *pic,
|
||||
uint32_t gic_phandle)
|
||||
{
|
||||
hwaddr base = vbi->memmap[VIRT_PCIE].base;
|
||||
hwaddr size = vbi->memmap[VIRT_PCIE].size;
|
||||
hwaddr end = base + size;
|
||||
hwaddr size_mmio;
|
||||
hwaddr size_ioport = 64 * 1024;
|
||||
int nr_pcie_buses = 16;
|
||||
hwaddr size_ecam = PCIE_MMCFG_SIZE_MIN * nr_pcie_buses;
|
||||
hwaddr base_mmio = base;
|
||||
hwaddr base_ioport;
|
||||
hwaddr base_ecam;
|
||||
int irq = vbi->irqmap[VIRT_PCIE];
|
||||
MemoryRegion *mmio_alias;
|
||||
MemoryRegion *mmio_reg;
|
||||
MemoryRegion *ecam_alias;
|
||||
MemoryRegion *ecam_reg;
|
||||
DeviceState *dev;
|
||||
char *nodename;
|
||||
int i;
|
||||
|
||||
base_ecam = QEMU_ALIGN_DOWN(end - size_ecam, size_ecam);
|
||||
base_ioport = QEMU_ALIGN_DOWN(base_ecam - size_ioport, size_ioport);
|
||||
size_mmio = base_ioport - base;
|
||||
|
||||
dev = qdev_create(NULL, TYPE_GPEX_HOST);
|
||||
qdev_init_nofail(dev);
|
||||
|
||||
/* Map only the first size_ecam bytes of ECAM space */
|
||||
ecam_alias = g_new0(MemoryRegion, 1);
|
||||
ecam_reg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0);
|
||||
memory_region_init_alias(ecam_alias, OBJECT(dev), "pcie-ecam",
|
||||
ecam_reg, 0, size_ecam);
|
||||
memory_region_add_subregion(get_system_memory(), base_ecam, ecam_alias);
|
||||
|
||||
/* Map the MMIO window into system address space so as to expose
|
||||
* the section of PCI MMIO space which starts at the same base address
|
||||
* (ie 1:1 mapping for that part of PCI MMIO space visible through
|
||||
* the window).
|
||||
*/
|
||||
mmio_alias = g_new0(MemoryRegion, 1);
|
||||
mmio_reg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 1);
|
||||
memory_region_init_alias(mmio_alias, OBJECT(dev), "pcie-mmio",
|
||||
mmio_reg, base_mmio, size_mmio);
|
||||
memory_region_add_subregion(get_system_memory(), base_mmio, mmio_alias);
|
||||
|
||||
/* Map IO port space */
|
||||
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, base_ioport);
|
||||
|
||||
for (i = 0; i < GPEX_NUM_IRQS; i++) {
|
||||
sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]);
|
||||
}
|
||||
|
||||
nodename = g_strdup_printf("/pcie@%" PRIx64, base);
|
||||
qemu_fdt_add_subnode(vbi->fdt, nodename);
|
||||
qemu_fdt_setprop_string(vbi->fdt, nodename,
|
||||
"compatible", "pci-host-ecam-generic");
|
||||
qemu_fdt_setprop_string(vbi->fdt, nodename, "device_type", "pci");
|
||||
qemu_fdt_setprop_cell(vbi->fdt, nodename, "#address-cells", 3);
|
||||
qemu_fdt_setprop_cell(vbi->fdt, nodename, "#size-cells", 2);
|
||||
qemu_fdt_setprop_cells(vbi->fdt, nodename, "bus-range", 0,
|
||||
nr_pcie_buses - 1);
|
||||
|
||||
qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg",
|
||||
2, base_ecam, 2, size_ecam);
|
||||
qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "ranges",
|
||||
1, FDT_PCI_RANGE_IOPORT, 2, 0,
|
||||
2, base_ioport, 2, size_ioport,
|
||||
1, FDT_PCI_RANGE_MMIO, 2, base_mmio,
|
||||
2, base_mmio, 2, size_mmio);
|
||||
|
||||
qemu_fdt_setprop_cell(vbi->fdt, nodename, "#interrupt-cells", 1);
|
||||
create_pcie_irq_map(vbi, gic_phandle, irq, nodename);
|
||||
|
||||
g_free(nodename);
|
||||
}
|
||||
|
||||
static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size)
|
||||
{
|
||||
const VirtBoardInfo *board = (const VirtBoardInfo *)binfo;
|
||||
@@ -602,15 +727,20 @@ static void machvirt_init(MachineState *machine)
|
||||
MemoryRegion *ram = g_new(MemoryRegion, 1);
|
||||
const char *cpu_model = machine->cpu_model;
|
||||
VirtBoardInfo *vbi;
|
||||
uint32_t gic_phandle;
|
||||
char **cpustr;
|
||||
|
||||
if (!cpu_model) {
|
||||
cpu_model = "cortex-a15";
|
||||
}
|
||||
|
||||
vbi = find_machine_info(cpu_model);
|
||||
/* Separate the actual CPU model name from any appended features */
|
||||
cpustr = g_strsplit(cpu_model, ",", 2);
|
||||
|
||||
vbi = find_machine_info(cpustr[0]);
|
||||
|
||||
if (!vbi) {
|
||||
error_report("mach-virt: CPU %s not supported", cpu_model);
|
||||
error_report("mach-virt: CPU %s not supported", cpustr[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -624,8 +754,10 @@ static void machvirt_init(MachineState *machine)
|
||||
create_fdt(vbi);
|
||||
|
||||
for (n = 0; n < smp_cpus; n++) {
|
||||
ObjectClass *oc = cpu_class_by_name(TYPE_ARM_CPU, cpu_model);
|
||||
ObjectClass *oc = cpu_class_by_name(TYPE_ARM_CPU, cpustr[0]);
|
||||
CPUClass *cc = CPU_CLASS(oc);
|
||||
Object *cpuobj;
|
||||
Error *err = NULL;
|
||||
|
||||
if (!oc) {
|
||||
fprintf(stderr, "Unable to find CPU definition\n");
|
||||
@@ -633,6 +765,13 @@ static void machvirt_init(MachineState *machine)
|
||||
}
|
||||
cpuobj = object_new(object_class_get_name(oc));
|
||||
|
||||
/* Handle any CPU options specified by the user */
|
||||
cc->parse_features(CPU(cpuobj), cpustr[1], &err);
|
||||
if (err) {
|
||||
error_report("%s", error_get_pretty(err));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!vms->secure) {
|
||||
object_property_set_bool(cpuobj, false, "has_el3", NULL);
|
||||
}
|
||||
@@ -652,6 +791,7 @@ static void machvirt_init(MachineState *machine)
|
||||
|
||||
object_property_set_bool(cpuobj, true, "realized", NULL);
|
||||
}
|
||||
g_strfreev(cpustr);
|
||||
fdt_add_timer_nodes(vbi);
|
||||
fdt_add_cpu_nodes(vbi);
|
||||
fdt_add_psci_node(vbi);
|
||||
@@ -663,12 +803,14 @@ static void machvirt_init(MachineState *machine)
|
||||
|
||||
create_flash(vbi);
|
||||
|
||||
create_gic(vbi, pic);
|
||||
gic_phandle = create_gic(vbi, pic);
|
||||
|
||||
create_uart(vbi, pic);
|
||||
|
||||
create_rtc(vbi, pic);
|
||||
|
||||
create_pcie(vbi, pic, gic_phandle);
|
||||
|
||||
/* Create mmio transports, so the user can create virtio backends
|
||||
* (which will be automatically plugged in to the transports). If
|
||||
* no backend is created the transport will just sit harmlessly idle.
|
||||
|
||||
@@ -15,3 +15,4 @@ common-obj-$(CONFIG_PCI_APB) += apb.o
|
||||
common-obj-$(CONFIG_FULONG) += bonito.o
|
||||
common-obj-$(CONFIG_PCI_PIIX) += piix.o
|
||||
common-obj-$(CONFIG_PCI_Q35) += q35.o
|
||||
common-obj-$(CONFIG_PCI_GENERIC) += gpex.o
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* QEMU Generic PCI Express Bridge Emulation
|
||||
*
|
||||
* Copyright (C) 2015 Alexander Graf <agraf@suse.de>
|
||||
*
|
||||
* Code loosely based on q35.c.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* Check out these documents for more information on the device:
|
||||
*
|
||||
* http://www.kernel.org/doc/Documentation/devicetree/bindings/pci/host-generic-pci.txt
|
||||
* http://www.firmware.org/1275/practice/imap/imap0_9d.pdf
|
||||
*/
|
||||
#include "hw/hw.h"
|
||||
#include "hw/pci-host/gpex.h"
|
||||
|
||||
/****************************************************************************
|
||||
* GPEX host
|
||||
*/
|
||||
|
||||
static void gpex_set_irq(void *opaque, int irq_num, int level)
|
||||
{
|
||||
GPEXHost *s = opaque;
|
||||
|
||||
qemu_set_irq(s->irq[irq_num], level);
|
||||
}
|
||||
|
||||
static void gpex_host_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
PCIHostState *pci = PCI_HOST_BRIDGE(dev);
|
||||
GPEXHost *s = GPEX_HOST(dev);
|
||||
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
|
||||
PCIExpressHost *pex = PCIE_HOST_BRIDGE(dev);
|
||||
int i;
|
||||
|
||||
pcie_host_mmcfg_init(pex, PCIE_MMCFG_SIZE_MAX);
|
||||
memory_region_init(&s->io_mmio, OBJECT(s), "gpex_mmio", UINT64_MAX);
|
||||
memory_region_init(&s->io_ioport, OBJECT(s), "gpex_ioport", 64 * 1024);
|
||||
|
||||
sysbus_init_mmio(sbd, &pex->mmio);
|
||||
sysbus_init_mmio(sbd, &s->io_mmio);
|
||||
sysbus_init_mmio(sbd, &s->io_ioport);
|
||||
for (i = 0; i < GPEX_NUM_IRQS; i++) {
|
||||
sysbus_init_irq(sbd, &s->irq[i]);
|
||||
}
|
||||
|
||||
pci->bus = pci_register_bus(dev, "pcie.0", gpex_set_irq,
|
||||
pci_swizzle_map_irq_fn, s, &s->io_mmio,
|
||||
&s->io_ioport, 0, 4, TYPE_PCIE_BUS);
|
||||
|
||||
qdev_set_parent_bus(DEVICE(&s->gpex_root), BUS(pci->bus));
|
||||
qdev_init_nofail(DEVICE(&s->gpex_root));
|
||||
}
|
||||
|
||||
static const char *gpex_host_root_bus_path(PCIHostState *host_bridge,
|
||||
PCIBus *rootbus)
|
||||
{
|
||||
return "0000:00";
|
||||
}
|
||||
|
||||
static void gpex_host_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(klass);
|
||||
|
||||
hc->root_bus_path = gpex_host_root_bus_path;
|
||||
dc->realize = gpex_host_realize;
|
||||
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
|
||||
dc->fw_name = "pci";
|
||||
}
|
||||
|
||||
static void gpex_host_initfn(Object *obj)
|
||||
{
|
||||
GPEXHost *s = GPEX_HOST(obj);
|
||||
GPEXRootState *root = &s->gpex_root;
|
||||
|
||||
object_initialize(root, sizeof(*root), TYPE_GPEX_ROOT_DEVICE);
|
||||
object_property_add_child(obj, "gpex_root", OBJECT(root), NULL);
|
||||
qdev_prop_set_uint32(DEVICE(root), "addr", PCI_DEVFN(0, 0));
|
||||
qdev_prop_set_bit(DEVICE(root), "multifunction", false);
|
||||
}
|
||||
|
||||
static const TypeInfo gpex_host_info = {
|
||||
.name = TYPE_GPEX_HOST,
|
||||
.parent = TYPE_PCIE_HOST_BRIDGE,
|
||||
.instance_size = sizeof(GPEXHost),
|
||||
.instance_init = gpex_host_initfn,
|
||||
.class_init = gpex_host_class_init,
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* GPEX Root D0:F0
|
||||
*/
|
||||
|
||||
static const VMStateDescription vmstate_gpex_root = {
|
||||
.name = "gpex_root",
|
||||
.version_id = 1,
|
||||
.minimum_version_id = 1,
|
||||
.fields = (VMStateField[]) {
|
||||
VMSTATE_PCI_DEVICE(parent_obj, GPEXRootState),
|
||||
VMSTATE_END_OF_LIST()
|
||||
}
|
||||
};
|
||||
|
||||
static void gpex_root_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
|
||||
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
|
||||
dc->desc = "QEMU generic PCIe host bridge";
|
||||
dc->vmsd = &vmstate_gpex_root;
|
||||
k->vendor_id = PCI_VENDOR_ID_REDHAT;
|
||||
k->device_id = PCI_DEVICE_ID_REDHAT_PCIE_HOST;
|
||||
k->revision = 0;
|
||||
k->class_id = PCI_CLASS_BRIDGE_HOST;
|
||||
/*
|
||||
* PCI-facing part of the host bridge, not usable without the
|
||||
* host-facing part, which can't be device_add'ed, yet.
|
||||
*/
|
||||
dc->cannot_instantiate_with_device_add_yet = true;
|
||||
}
|
||||
|
||||
static const TypeInfo gpex_root_info = {
|
||||
.name = TYPE_GPEX_ROOT_DEVICE,
|
||||
.parent = TYPE_PCI_DEVICE,
|
||||
.instance_size = sizeof(GPEXRootState),
|
||||
.class_init = gpex_root_class_init,
|
||||
};
|
||||
|
||||
static void gpex_register(void)
|
||||
{
|
||||
type_register_static(&gpex_root_info);
|
||||
type_register_static(&gpex_host_info);
|
||||
}
|
||||
|
||||
type_init(gpex_register)
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* QEMU Generic PCI Express Bridge Emulation
|
||||
*
|
||||
* Copyright (C) 2015 Alexander Graf <agraf@suse.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#ifndef HW_GPEX_H
|
||||
#define HW_GPEX_H
|
||||
|
||||
#include "hw/hw.h"
|
||||
#include "hw/sysbus.h"
|
||||
#include "hw/pci/pci.h"
|
||||
#include "hw/pci/pcie_host.h"
|
||||
|
||||
#define TYPE_GPEX_HOST "gpex-pcihost"
|
||||
#define GPEX_HOST(obj) \
|
||||
OBJECT_CHECK(GPEXHost, (obj), TYPE_GPEX_HOST)
|
||||
|
||||
#define TYPE_GPEX_ROOT_DEVICE "gpex-root"
|
||||
#define MCH_PCI_DEVICE(obj) \
|
||||
OBJECT_CHECK(GPEXRootState, (obj), TYPE_GPEX_ROOT_DEVICE)
|
||||
|
||||
#define GPEX_NUM_IRQS 4
|
||||
|
||||
typedef struct GPEXRootState {
|
||||
/*< private >*/
|
||||
PCIDevice parent_obj;
|
||||
/*< public >*/
|
||||
} GPEXRootState;
|
||||
|
||||
typedef struct GPEXHost {
|
||||
/*< private >*/
|
||||
PCIExpressHost parent_obj;
|
||||
/*< public >*/
|
||||
|
||||
GPEXRootState gpex_root;
|
||||
|
||||
MemoryRegion io_ioport;
|
||||
MemoryRegion io_mmio;
|
||||
qemu_irq irq[GPEX_NUM_IRQS];
|
||||
} GPEXHost;
|
||||
|
||||
#endif /* HW_GPEX_H */
|
||||
@@ -89,6 +89,7 @@
|
||||
#define PCI_DEVICE_ID_REDHAT_SERIAL4 0x0004
|
||||
#define PCI_DEVICE_ID_REDHAT_TEST 0x0005
|
||||
#define PCI_DEVICE_ID_REDHAT_SDHCI 0x0007
|
||||
#define PCI_DEVICE_ID_REDHAT_PCIE_HOST 0x0008
|
||||
#define PCI_DEVICE_ID_REDHAT_QXL 0x0100
|
||||
|
||||
#define FMT_PCIBUS PRIx64
|
||||
|
||||
@@ -110,4 +110,13 @@ int qemu_fdt_setprop_sized_cells_from_array(void *fdt,
|
||||
qdt_tmp); \
|
||||
})
|
||||
|
||||
#define FDT_PCI_RANGE_RELOCATABLE 0x80000000
|
||||
#define FDT_PCI_RANGE_PREFETCHABLE 0x40000000
|
||||
#define FDT_PCI_RANGE_ALIASED 0x20000000
|
||||
#define FDT_PCI_RANGE_TYPE_MASK 0x03000000
|
||||
#define FDT_PCI_RANGE_MMIO_64BIT 0x03000000
|
||||
#define FDT_PCI_RANGE_MMIO 0x02000000
|
||||
#define FDT_PCI_RANGE_IOPORT 0x01000000
|
||||
#define FDT_PCI_RANGE_CONFIG 0x00000000
|
||||
|
||||
#endif /* __DEVICE_TREE_H__ */
|
||||
|
||||
+4
-1
@@ -544,13 +544,16 @@ static ObjectClass *arm_cpu_class_by_name(const char *cpu_model)
|
||||
{
|
||||
ObjectClass *oc;
|
||||
char *typename;
|
||||
char **cpuname;
|
||||
|
||||
if (!cpu_model) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
typename = g_strdup_printf("%s-" TYPE_ARM_CPU, cpu_model);
|
||||
cpuname = g_strsplit(cpu_model, ",", 1);
|
||||
typename = g_strdup_printf("%s-" TYPE_ARM_CPU, cpuname[0]);
|
||||
oc = object_class_by_name(typename);
|
||||
g_strfreev(cpuname);
|
||||
g_free(typename);
|
||||
if (!oc || !object_class_dynamic_cast(oc, TYPE_ARM_CPU) ||
|
||||
object_class_is_abstract(oc)) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user