hw/vexpress.c: Factor out daughterboard-specific initialization

Factor out daughterboard specifics into a data structure and
daughterboard initialization function, in preparation for adding
vexpress-a15 support.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2012-02-16 09:56:09 +00:00
parent aac1e02c1d
commit 4c3b29b8ad

View File

@ -103,32 +103,43 @@ static target_phys_addr_t motherboard_legacy_map[] = {
[VE_USB] = 0x4f000000, [VE_USB] = 0x4f000000,
}; };
static void vexpress_a9_init(ram_addr_t ram_size, /* Structure defining the peculiarities of a specific daughterboard */
const char *boot_device,
const char *kernel_filename, const char *kernel_cmdline, typedef struct VEDBoardInfo VEDBoardInfo;
const char *initrd_filename, const char *cpu_model)
typedef void DBoardInitFn(const VEDBoardInfo *daughterboard,
ram_addr_t ram_size,
const char *cpu_model,
qemu_irq *pic, uint32_t *proc_id);
struct VEDBoardInfo {
const target_phys_addr_t *motherboard_map;
target_phys_addr_t loader_start;
DBoardInitFn *init;
};
static void a9_daughterboard_init(const VEDBoardInfo *daughterboard,
ram_addr_t ram_size,
const char *cpu_model,
qemu_irq *pic, uint32_t *proc_id)
{ {
CPUState *env = NULL; CPUState *env = NULL;
MemoryRegion *sysmem = get_system_memory(); MemoryRegion *sysmem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *lowram = g_new(MemoryRegion, 1); MemoryRegion *lowram = g_new(MemoryRegion, 1);
MemoryRegion *vram = g_new(MemoryRegion, 1); DeviceState *dev;
MemoryRegion *sram = g_new(MemoryRegion, 1);
DeviceState *dev, *sysctl, *pl041;
SysBusDevice *busdev; SysBusDevice *busdev;
qemu_irq *irqp; qemu_irq *irqp;
qemu_irq pic[64];
int n; int n;
qemu_irq cpu_irq[4]; qemu_irq cpu_irq[4];
uint32_t proc_id; ram_addr_t low_ram_size;
uint32_t sys_id;
ram_addr_t low_ram_size, vram_size, sram_size;
target_phys_addr_t *map = motherboard_legacy_map;
if (!cpu_model) { if (!cpu_model) {
cpu_model = "cortex-a9"; cpu_model = "cortex-a9";
} }
*proc_id = 0x0c000191;
for (n = 0; n < smp_cpus; n++) { for (n = 0; n < smp_cpus; n++) {
env = cpu_init(cpu_model); env = cpu_init(cpu_model);
if (!env) { if (!env) {
@ -141,7 +152,7 @@ static void vexpress_a9_init(ram_addr_t ram_size,
if (ram_size > 0x40000000) { if (ram_size > 0x40000000) {
/* 1GB is the maximum the address space permits */ /* 1GB is the maximum the address space permits */
fprintf(stderr, "vexpress: cannot model more than 1GB RAM\n"); fprintf(stderr, "vexpress-a9: cannot model more than 1GB RAM\n");
exit(1); exit(1);
} }
@ -179,12 +190,58 @@ static void vexpress_a9_init(ram_addr_t ram_size,
pic[n] = qdev_get_gpio_in(dev, n); pic[n] = qdev_get_gpio_in(dev, n);
} }
/* Daughterboard peripherals : 0x10020000 .. 0x20000000 */
/* 0x10020000 PL111 CLCD (daughterboard) */
sysbus_create_simple("pl111", 0x10020000, pic[44]);
/* 0x10060000 AXI RAM */
/* 0x100e0000 PL341 Dynamic Memory Controller */
/* 0x100e1000 PL354 Static Memory Controller */
/* 0x100e2000 System Configuration Controller */
sysbus_create_simple("sp804", 0x100e4000, pic[48]);
/* 0x100e5000 SP805 Watchdog module */
/* 0x100e6000 BP147 TrustZone Protection Controller */
/* 0x100e9000 PL301 'Fast' AXI matrix */
/* 0x100ea000 PL301 'Slow' AXI matrix */
/* 0x100ec000 TrustZone Address Space Controller */
/* 0x10200000 CoreSight debug APB */
/* 0x1e00a000 PL310 L2 Cache Controller */
sysbus_create_varargs("l2x0", 0x1e00a000, NULL);
}
static const VEDBoardInfo a9_daughterboard = {
.motherboard_map = motherboard_legacy_map,
.loader_start = 0x60000000,
.init = a9_daughterboard_init,
};
static void vexpress_common_init(const VEDBoardInfo *daughterboard,
ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
const char *cpu_model)
{
DeviceState *dev, *sysctl, *pl041;
qemu_irq pic[64];
uint32_t proc_id;
uint32_t sys_id;
ram_addr_t vram_size, sram_size;
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *vram = g_new(MemoryRegion, 1);
MemoryRegion *sram = g_new(MemoryRegion, 1);
const target_phys_addr_t *map = daughterboard->motherboard_map;
daughterboard->init(daughterboard, ram_size, cpu_model, pic, &proc_id);
/* Motherboard peripherals: the wiring is the same but the /* Motherboard peripherals: the wiring is the same but the
* addresses vary between the legacy and A-Series memory maps. * addresses vary between the legacy and A-Series memory maps.
*/ */
sys_id = 0x1190f500; sys_id = 0x1190f500;
proc_id = 0x0c000191;
sysctl = qdev_create(NULL, "realview_sysctl"); sysctl = qdev_create(NULL, "realview_sysctl");
qdev_prop_set_uint32(sysctl, "sys_id", sys_id); qdev_prop_set_uint32(sysctl, "sys_id", sys_id);
@ -227,26 +284,6 @@ static void vexpress_a9_init(ram_addr_t ram_size,
/* VE_CLCD: not modelled (we use the daughterboard CLCD only) */ /* VE_CLCD: not modelled (we use the daughterboard CLCD only) */
/* Daughterboard peripherals : 0x10020000 .. 0x20000000 */
/* 0x10020000 PL111 CLCD (daughterboard) */
sysbus_create_simple("pl111", 0x10020000, pic[44]);
/* 0x10060000 AXI RAM */
/* 0x100e0000 PL341 Dynamic Memory Controller */
/* 0x100e1000 PL354 Static Memory Controller */
/* 0x100e2000 System Configuration Controller */
sysbus_create_simple("sp804", 0x100e4000, pic[48]);
/* 0x100e5000 SP805 Watchdog module */
/* 0x100e6000 BP147 TrustZone Protection Controller */
/* 0x100e9000 PL301 'Fast' AXI matrix */
/* 0x100ea000 PL301 'Slow' AXI matrix */
/* 0x100ec000 TrustZone Address Space Controller */
/* 0x10200000 CoreSight debug APB */
/* 0x1e00a000 PL310 L2 Cache Controller */
sysbus_create_varargs("l2x0", 0x1e00a000, NULL);
/* VE_NORFLASH0: not modelled */ /* VE_NORFLASH0: not modelled */
/* VE_NORFLASH0ALIAS: not modelled */ /* VE_NORFLASH0ALIAS: not modelled */
/* VE_NORFLASH1: not modelled */ /* VE_NORFLASH1: not modelled */
@ -276,12 +313,23 @@ static void vexpress_a9_init(ram_addr_t ram_size,
vexpress_binfo.initrd_filename = initrd_filename; vexpress_binfo.initrd_filename = initrd_filename;
vexpress_binfo.nb_cpus = smp_cpus; vexpress_binfo.nb_cpus = smp_cpus;
vexpress_binfo.board_id = VEXPRESS_BOARD_ID; vexpress_binfo.board_id = VEXPRESS_BOARD_ID;
vexpress_binfo.loader_start = 0x60000000; vexpress_binfo.loader_start = daughterboard->loader_start;
vexpress_binfo.smp_loader_start = map[VE_SRAM]; vexpress_binfo.smp_loader_start = map[VE_SRAM];
vexpress_binfo.smp_bootreg_addr = map[VE_SYSREGS] + 0x30; vexpress_binfo.smp_bootreg_addr = map[VE_SYSREGS] + 0x30;
arm_load_kernel(first_cpu, &vexpress_binfo); arm_load_kernel(first_cpu, &vexpress_binfo);
} }
static void vexpress_a9_init(ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
const char *cpu_model)
{
vexpress_common_init(&a9_daughterboard,
ram_size, boot_device, kernel_filename,
kernel_cmdline, initrd_filename, cpu_model);
}
static QEMUMachine vexpress_a9_machine = { static QEMUMachine vexpress_a9_machine = {
.name = "vexpress-a9", .name = "vexpress-a9",