2009-03-03 00:42:42 +08:00
|
|
|
/*
|
2012-04-07 15:23:39 +08:00
|
|
|
* QEMU PowerPC MPC8544DS board emulation
|
2009-03-03 00:42:42 +08:00
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Freescale Semiconductor, Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* Author: Yu Liu, <yu.liu@freescale.com>
|
|
|
|
*
|
|
|
|
* This file is derived from hw/ppc440_bamboo.c,
|
|
|
|
* the copyright for that material belongs to the original owners.
|
|
|
|
*
|
|
|
|
* This 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "qemu-common.h"
|
|
|
|
#include "net.h"
|
|
|
|
#include "hw.h"
|
|
|
|
#include "pc.h"
|
|
|
|
#include "pci.h"
|
|
|
|
#include "boards.h"
|
|
|
|
#include "sysemu.h"
|
|
|
|
#include "kvm.h"
|
|
|
|
#include "kvm_ppc.h"
|
|
|
|
#include "device_tree.h"
|
|
|
|
#include "openpic.h"
|
2011-05-01 05:34:53 +08:00
|
|
|
#include "ppc.h"
|
2009-09-20 22:58:02 +08:00
|
|
|
#include "loader.h"
|
|
|
|
#include "elf.h"
|
2010-08-31 06:22:28 +08:00
|
|
|
#include "sysbus.h"
|
2011-08-12 07:07:16 +08:00
|
|
|
#include "exec-memory.h"
|
2012-05-19 06:48:50 +08:00
|
|
|
#include "host-utils.h"
|
2009-03-03 00:42:42 +08:00
|
|
|
|
|
|
|
#define BINARY_DEVICE_TREE_FILE "mpc8544ds.dtb"
|
|
|
|
#define UIMAGE_LOAD_BASE 0
|
2010-02-02 16:49:03 +08:00
|
|
|
#define DTC_LOAD_PAD 0x500000
|
|
|
|
#define DTC_PAD_MASK 0xFFFFF
|
|
|
|
#define INITRD_LOAD_PAD 0x2000000
|
|
|
|
#define INITRD_PAD_MASK 0xFFFFFF
|
2009-03-03 00:42:42 +08:00
|
|
|
|
|
|
|
#define RAM_SIZES_ALIGN (64UL << 20)
|
|
|
|
|
|
|
|
#define MPC8544_CCSRBAR_BASE 0xE0000000
|
2012-05-17 20:51:07 +08:00
|
|
|
#define MPC8544_CCSRBAR_REGSIZE 0x00001000
|
|
|
|
#define MPC8544_CCSRBAR_SIZE 0x00100000
|
2009-03-03 00:42:42 +08:00
|
|
|
#define MPC8544_MPIC_REGS_BASE (MPC8544_CCSRBAR_BASE + 0x40000)
|
|
|
|
#define MPC8544_SERIAL0_REGS_BASE (MPC8544_CCSRBAR_BASE + 0x4500)
|
|
|
|
#define MPC8544_SERIAL1_REGS_BASE (MPC8544_CCSRBAR_BASE + 0x4600)
|
|
|
|
#define MPC8544_PCI_REGS_BASE (MPC8544_CCSRBAR_BASE + 0x8000)
|
|
|
|
#define MPC8544_PCI_REGS_SIZE 0x1000
|
|
|
|
#define MPC8544_PCI_IO 0xE1000000
|
|
|
|
#define MPC8544_PCI_IOLEN 0x10000
|
2011-06-02 19:53:40 +08:00
|
|
|
#define MPC8544_UTIL_BASE (MPC8544_CCSRBAR_BASE + 0xe0000)
|
2011-07-22 19:32:29 +08:00
|
|
|
#define MPC8544_SPIN_BASE 0xEF000000
|
2009-03-03 00:42:42 +08:00
|
|
|
|
2011-05-01 05:34:53 +08:00
|
|
|
struct boot_info
|
|
|
|
{
|
|
|
|
uint32_t dt_base;
|
2012-05-19 06:48:50 +08:00
|
|
|
uint32_t dt_size;
|
2011-05-01 05:34:53 +08:00
|
|
|
uint32_t entry;
|
|
|
|
};
|
|
|
|
|
2012-03-14 08:38:23 +08:00
|
|
|
static int mpc8544_load_device_tree(CPUPPCState *env,
|
2011-06-16 05:34:04 +08:00
|
|
|
target_phys_addr_t addr,
|
|
|
|
uint32_t ramsize,
|
|
|
|
target_phys_addr_t initrd_base,
|
|
|
|
target_phys_addr_t initrd_size,
|
|
|
|
const char *kernel_cmdline)
|
2009-03-03 00:42:42 +08:00
|
|
|
{
|
2010-02-28 02:47:22 +08:00
|
|
|
int ret = -1;
|
2011-05-01 05:34:53 +08:00
|
|
|
uint32_t mem_reg_property[] = {0, cpu_to_be32(ramsize)};
|
2009-05-30 07:52:44 +08:00
|
|
|
char *filename;
|
2009-04-11 00:23:59 +08:00
|
|
|
int fdt_size;
|
2010-02-28 02:47:22 +08:00
|
|
|
void *fdt;
|
2011-06-16 05:34:04 +08:00
|
|
|
uint8_t hypercall[16];
|
2011-07-21 08:34:11 +08:00
|
|
|
uint32_t clock_freq = 400000000;
|
|
|
|
uint32_t tb_freq = 400000000;
|
2011-07-21 09:01:11 +08:00
|
|
|
int i;
|
2012-05-17 18:20:50 +08:00
|
|
|
char compatible[] = "MPC8544DS\0MPC85xxDS";
|
|
|
|
char model[] = "MPC8544DS";
|
2012-05-17 20:51:07 +08:00
|
|
|
char soc[128];
|
2009-03-03 00:42:42 +08:00
|
|
|
|
2009-05-30 07:52:44 +08:00
|
|
|
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
|
|
|
|
if (!filename) {
|
2009-03-03 00:42:42 +08:00
|
|
|
goto out;
|
2009-05-30 07:52:44 +08:00
|
|
|
}
|
|
|
|
fdt = load_device_tree(filename, &fdt_size);
|
2011-08-21 11:09:37 +08:00
|
|
|
g_free(filename);
|
2009-05-30 07:52:44 +08:00
|
|
|
if (fdt == NULL) {
|
|
|
|
goto out;
|
|
|
|
}
|
2009-03-03 00:42:42 +08:00
|
|
|
|
|
|
|
/* Manipulate device tree in memory. */
|
2012-05-17 18:20:50 +08:00
|
|
|
qemu_devtree_setprop_string(fdt, "/", "model", model);
|
|
|
|
qemu_devtree_setprop(fdt, "/", "compatible", compatible,
|
|
|
|
sizeof(compatible));
|
|
|
|
qemu_devtree_setprop_cell(fdt, "/", "#address-cells", 1);
|
|
|
|
qemu_devtree_setprop_cell(fdt, "/", "#size-cells", 1);
|
|
|
|
|
2012-05-17 17:34:50 +08:00
|
|
|
qemu_devtree_add_subnode(fdt, "/memory");
|
|
|
|
qemu_devtree_setprop_string(fdt, "/memory", "device_type", "memory");
|
|
|
|
qemu_devtree_setprop(fdt, "/memory", "reg", mem_reg_property,
|
|
|
|
sizeof(mem_reg_property));
|
2009-03-03 00:42:42 +08:00
|
|
|
|
2012-05-17 20:49:20 +08:00
|
|
|
qemu_devtree_add_subnode(fdt, "/chosen");
|
2011-05-01 05:34:53 +08:00
|
|
|
if (initrd_size) {
|
|
|
|
ret = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-start",
|
|
|
|
initrd_base);
|
|
|
|
if (ret < 0) {
|
|
|
|
fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n");
|
|
|
|
}
|
2009-03-03 00:42:42 +08:00
|
|
|
|
2011-05-01 05:34:53 +08:00
|
|
|
ret = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-end",
|
|
|
|
(initrd_base + initrd_size));
|
|
|
|
if (ret < 0) {
|
|
|
|
fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n");
|
|
|
|
}
|
|
|
|
}
|
2009-03-03 00:42:42 +08:00
|
|
|
|
|
|
|
ret = qemu_devtree_setprop_string(fdt, "/chosen", "bootargs",
|
|
|
|
kernel_cmdline);
|
|
|
|
if (ret < 0)
|
|
|
|
fprintf(stderr, "couldn't set /chosen/bootargs\n");
|
|
|
|
|
|
|
|
if (kvm_enabled()) {
|
2011-07-21 08:34:11 +08:00
|
|
|
/* Read out host's frequencies */
|
|
|
|
clock_freq = kvmppc_get_clockfreq();
|
|
|
|
tb_freq = kvmppc_get_tbfreq();
|
2011-06-16 05:34:04 +08:00
|
|
|
|
|
|
|
/* indicate KVM hypercall interface */
|
2012-05-17 17:50:05 +08:00
|
|
|
qemu_devtree_add_subnode(fdt, "/hypervisor");
|
2011-06-16 05:34:04 +08:00
|
|
|
qemu_devtree_setprop_string(fdt, "/hypervisor", "compatible",
|
|
|
|
"linux,kvm");
|
|
|
|
kvmppc_get_hypercall(env, hypercall, sizeof(hypercall));
|
|
|
|
qemu_devtree_setprop(fdt, "/hypervisor", "hcall-instructions",
|
|
|
|
hypercall, sizeof(hypercall));
|
2009-03-03 00:42:42 +08:00
|
|
|
}
|
2011-05-01 05:34:53 +08:00
|
|
|
|
2012-05-17 17:48:16 +08:00
|
|
|
/* Create CPU nodes */
|
|
|
|
qemu_devtree_add_subnode(fdt, "/cpus");
|
|
|
|
qemu_devtree_setprop_cell(fdt, "/cpus", "#address-cells", 1);
|
|
|
|
qemu_devtree_setprop_cell(fdt, "/cpus", "#size-cells", 0);
|
|
|
|
|
2011-07-23 16:56:40 +08:00
|
|
|
/* We need to generate the cpu nodes in reverse order, so Linux can pick
|
|
|
|
the first node as boot node and be happy */
|
|
|
|
for (i = smp_cpus - 1; i >= 0; i--) {
|
2011-07-21 09:01:11 +08:00
|
|
|
char cpu_name[128];
|
2011-07-23 16:56:40 +08:00
|
|
|
uint64_t cpu_release_addr = cpu_to_be64(MPC8544_SPIN_BASE + (i * 0x20));
|
2011-07-21 09:06:12 +08:00
|
|
|
|
2011-07-23 16:56:40 +08:00
|
|
|
for (env = first_cpu; env != NULL; env = env->next_cpu) {
|
|
|
|
if (env->cpu_index == i) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!env) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(cpu_name, sizeof(cpu_name), "/cpus/PowerPC,8544@%x", env->cpu_index);
|
|
|
|
qemu_devtree_add_subnode(fdt, cpu_name);
|
2011-07-21 09:01:11 +08:00
|
|
|
qemu_devtree_setprop_cell(fdt, cpu_name, "clock-frequency", clock_freq);
|
|
|
|
qemu_devtree_setprop_cell(fdt, cpu_name, "timebase-frequency", tb_freq);
|
2011-07-23 16:56:40 +08:00
|
|
|
qemu_devtree_setprop_string(fdt, cpu_name, "device_type", "cpu");
|
|
|
|
qemu_devtree_setprop_cell(fdt, cpu_name, "reg", env->cpu_index);
|
|
|
|
qemu_devtree_setprop_cell(fdt, cpu_name, "d-cache-line-size",
|
|
|
|
env->dcache_line_size);
|
|
|
|
qemu_devtree_setprop_cell(fdt, cpu_name, "i-cache-line-size",
|
|
|
|
env->icache_line_size);
|
|
|
|
qemu_devtree_setprop_cell(fdt, cpu_name, "d-cache-size", 0x8000);
|
|
|
|
qemu_devtree_setprop_cell(fdt, cpu_name, "i-cache-size", 0x8000);
|
|
|
|
qemu_devtree_setprop_cell(fdt, cpu_name, "bus-frequency", 0);
|
|
|
|
if (env->cpu_index) {
|
|
|
|
qemu_devtree_setprop_string(fdt, cpu_name, "status", "disabled");
|
|
|
|
qemu_devtree_setprop_string(fdt, cpu_name, "enable-method", "spin-table");
|
|
|
|
qemu_devtree_setprop(fdt, cpu_name, "cpu-release-addr",
|
|
|
|
&cpu_release_addr, sizeof(cpu_release_addr));
|
|
|
|
} else {
|
|
|
|
qemu_devtree_setprop_string(fdt, cpu_name, "status", "okay");
|
|
|
|
}
|
2009-03-03 00:42:42 +08:00
|
|
|
}
|
|
|
|
|
2012-05-17 20:51:07 +08:00
|
|
|
/* XXX These should go into their respective devices' code */
|
|
|
|
snprintf(soc, sizeof(soc), "/soc8544@%x", MPC8544_CCSRBAR_BASE);
|
|
|
|
qemu_devtree_add_subnode(fdt, soc);
|
|
|
|
qemu_devtree_setprop_string(fdt, soc, "device_type", "soc");
|
|
|
|
qemu_devtree_setprop_string(fdt, soc, "compatible", "simple-bus");
|
|
|
|
qemu_devtree_setprop_cell(fdt, soc, "#address-cells", 1);
|
|
|
|
qemu_devtree_setprop_cell(fdt, soc, "#size-cells", 1);
|
|
|
|
qemu_devtree_setprop_cells(fdt, soc, "ranges", 0x0, MPC8544_CCSRBAR_BASE,
|
|
|
|
MPC8544_CCSRBAR_SIZE);
|
|
|
|
qemu_devtree_setprop_cells(fdt, soc, "reg", MPC8544_CCSRBAR_BASE,
|
|
|
|
MPC8544_CCSRBAR_REGSIZE);
|
|
|
|
/* XXX should contain a reasonable value */
|
|
|
|
qemu_devtree_setprop_cell(fdt, soc, "bus-frequency", 0);
|
|
|
|
|
2010-02-02 16:49:02 +08:00
|
|
|
ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
|
2012-05-19 06:48:50 +08:00
|
|
|
if (ret < 0) {
|
|
|
|
goto out;
|
|
|
|
}
|
2011-08-21 11:09:37 +08:00
|
|
|
g_free(fdt);
|
2012-05-19 06:48:50 +08:00
|
|
|
ret = fdt_size;
|
2009-04-11 00:23:59 +08:00
|
|
|
|
2009-03-03 00:42:42 +08:00
|
|
|
out:
|
|
|
|
|
2010-02-02 16:49:02 +08:00
|
|
|
return ret;
|
2009-03-03 00:42:42 +08:00
|
|
|
}
|
|
|
|
|
2012-05-19 06:48:50 +08:00
|
|
|
/* Create -kernel TLB entries for BookE. */
|
2011-06-17 00:45:43 +08:00
|
|
|
static inline target_phys_addr_t booke206_page_size_to_tlb(uint64_t size)
|
|
|
|
{
|
2012-05-19 06:48:50 +08:00
|
|
|
return 63 - clz64(size >> 10);
|
2011-06-17 00:45:43 +08:00
|
|
|
}
|
|
|
|
|
2012-05-19 06:48:50 +08:00
|
|
|
static void mmubooke_create_initial_mapping(CPUPPCState *env)
|
2011-05-01 05:34:53 +08:00
|
|
|
{
|
2012-05-19 06:48:50 +08:00
|
|
|
struct boot_info *bi = env->load_info;
|
2011-06-17 00:45:43 +08:00
|
|
|
ppcmas_tlb_t *tlb = booke206_get_tlbm(env, 1, 0, 0);
|
2012-05-19 06:48:50 +08:00
|
|
|
target_phys_addr_t size, dt_end;
|
|
|
|
int ps;
|
|
|
|
|
|
|
|
/* Our initial TLB entry needs to cover everything from 0 to
|
|
|
|
the device tree top */
|
|
|
|
dt_end = bi->dt_base + bi->dt_size;
|
|
|
|
ps = booke206_page_size_to_tlb(dt_end) + 1;
|
|
|
|
size = (ps << MAS1_TSIZE_SHIFT);
|
2011-06-17 00:45:43 +08:00
|
|
|
tlb->mas1 = MAS1_VALID | size;
|
2012-05-19 06:48:50 +08:00
|
|
|
tlb->mas2 = 0;
|
|
|
|
tlb->mas7_3 = 0;
|
2011-06-17 00:45:43 +08:00
|
|
|
tlb->mas7_3 |= MAS3_UR | MAS3_UW | MAS3_UX | MAS3_SR | MAS3_SW | MAS3_SX;
|
2011-08-31 19:26:56 +08:00
|
|
|
|
|
|
|
env->tlb_dirty = true;
|
2011-05-01 05:34:53 +08:00
|
|
|
}
|
|
|
|
|
2011-07-22 19:32:29 +08:00
|
|
|
static void mpc8544ds_cpu_reset_sec(void *opaque)
|
|
|
|
{
|
2012-05-04 08:09:06 +08:00
|
|
|
PowerPCCPU *cpu = opaque;
|
|
|
|
CPUPPCState *env = &cpu->env;
|
2011-07-22 19:32:29 +08:00
|
|
|
|
2012-05-04 08:09:06 +08:00
|
|
|
cpu_reset(CPU(cpu));
|
2011-07-22 19:32:29 +08:00
|
|
|
|
|
|
|
/* Secondary CPU starts in halted state for now. Needs to change when
|
|
|
|
implementing non-kernel boot. */
|
|
|
|
env->halted = 1;
|
|
|
|
env->exception_index = EXCP_HLT;
|
2011-05-01 05:34:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mpc8544ds_cpu_reset(void *opaque)
|
|
|
|
{
|
2012-05-04 08:09:06 +08:00
|
|
|
PowerPCCPU *cpu = opaque;
|
|
|
|
CPUPPCState *env = &cpu->env;
|
2011-05-01 05:34:53 +08:00
|
|
|
struct boot_info *bi = env->load_info;
|
|
|
|
|
2012-05-04 08:09:06 +08:00
|
|
|
cpu_reset(CPU(cpu));
|
2011-05-01 05:34:53 +08:00
|
|
|
|
|
|
|
/* Set initial guest state. */
|
2011-07-22 19:32:29 +08:00
|
|
|
env->halted = 0;
|
2011-05-01 05:34:53 +08:00
|
|
|
env->gpr[1] = (16<<20) - 8;
|
|
|
|
env->gpr[3] = bi->dt_base;
|
|
|
|
env->nip = bi->entry;
|
2012-05-19 06:48:50 +08:00
|
|
|
mmubooke_create_initial_mapping(env);
|
2011-05-01 05:34:53 +08:00
|
|
|
}
|
|
|
|
|
2009-10-02 05:12:16 +08:00
|
|
|
static void mpc8544ds_init(ram_addr_t ram_size,
|
2009-03-03 00:42:42 +08:00
|
|
|
const char *boot_device,
|
|
|
|
const char *kernel_filename,
|
|
|
|
const char *kernel_cmdline,
|
|
|
|
const char *initrd_filename,
|
|
|
|
const char *cpu_model)
|
|
|
|
{
|
2011-08-12 07:07:16 +08:00
|
|
|
MemoryRegion *address_space_mem = get_system_memory();
|
2011-10-02 22:43:01 +08:00
|
|
|
MemoryRegion *ram = g_new(MemoryRegion, 1);
|
2009-03-03 00:42:42 +08:00
|
|
|
PCIBus *pci_bus;
|
2012-03-14 08:38:23 +08:00
|
|
|
CPUPPCState *env = NULL;
|
2009-03-03 00:42:42 +08:00
|
|
|
uint64_t elf_entry;
|
|
|
|
uint64_t elf_lowaddr;
|
2009-10-02 05:12:16 +08:00
|
|
|
target_phys_addr_t entry=0;
|
|
|
|
target_phys_addr_t loadaddr=UIMAGE_LOAD_BASE;
|
2009-03-03 00:42:42 +08:00
|
|
|
target_long kernel_size=0;
|
2010-02-02 16:49:03 +08:00
|
|
|
target_ulong dt_base = 0;
|
|
|
|
target_ulong initrd_base = 0;
|
2009-03-03 00:42:42 +08:00
|
|
|
target_long initrd_size=0;
|
|
|
|
int i=0;
|
|
|
|
unsigned int pci_irq_nrs[4] = {1, 2, 3, 4};
|
2011-07-21 07:42:58 +08:00
|
|
|
qemu_irq **irqs, *mpic;
|
2010-08-31 06:22:28 +08:00
|
|
|
DeviceState *dev;
|
2012-03-14 08:38:23 +08:00
|
|
|
CPUPPCState *firstenv = NULL;
|
2009-03-03 00:42:42 +08:00
|
|
|
|
2011-07-21 07:41:16 +08:00
|
|
|
/* Setup CPUs */
|
2011-05-01 05:05:03 +08:00
|
|
|
if (cpu_model == NULL) {
|
|
|
|
cpu_model = "e500v2_v30";
|
|
|
|
}
|
|
|
|
|
2011-07-21 07:42:58 +08:00
|
|
|
irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *));
|
|
|
|
irqs[0] = g_malloc0(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
|
2011-07-21 07:41:16 +08:00
|
|
|
for (i = 0; i < smp_cpus; i++) {
|
2012-05-03 11:43:05 +08:00
|
|
|
PowerPCCPU *cpu;
|
2011-07-21 07:41:16 +08:00
|
|
|
qemu_irq *input;
|
2012-05-03 11:43:05 +08:00
|
|
|
|
|
|
|
cpu = cpu_ppc_init(cpu_model);
|
|
|
|
if (cpu == NULL) {
|
2011-07-21 07:41:16 +08:00
|
|
|
fprintf(stderr, "Unable to initialize CPU!\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
2012-05-03 11:43:05 +08:00
|
|
|
env = &cpu->env;
|
2009-03-03 00:42:42 +08:00
|
|
|
|
2011-07-21 07:41:16 +08:00
|
|
|
if (!firstenv) {
|
|
|
|
firstenv = env;
|
|
|
|
}
|
2009-03-03 00:42:42 +08:00
|
|
|
|
2011-07-21 07:42:58 +08:00
|
|
|
irqs[i] = irqs[0] + (i * OPENPIC_OUTPUT_NB);
|
|
|
|
input = (qemu_irq *)env->irq_inputs;
|
|
|
|
irqs[i][OPENPIC_OUTPUT_INT] = input[PPCE500_INPUT_INT];
|
|
|
|
irqs[i][OPENPIC_OUTPUT_CINT] = input[PPCE500_INPUT_CINT];
|
2011-07-21 07:41:16 +08:00
|
|
|
env->spr[SPR_BOOKE_PIR] = env->cpu_index = i;
|
2011-05-01 05:34:53 +08:00
|
|
|
|
2011-09-13 12:00:32 +08:00
|
|
|
ppc_booke_timers_init(env, 400000000, PPC_TIMER_E500);
|
2011-07-21 07:41:16 +08:00
|
|
|
|
|
|
|
/* Register reset handler */
|
2011-07-22 19:32:29 +08:00
|
|
|
if (!i) {
|
|
|
|
/* Primary CPU */
|
|
|
|
struct boot_info *boot_info;
|
|
|
|
boot_info = g_malloc0(sizeof(struct boot_info));
|
2012-05-04 08:09:06 +08:00
|
|
|
qemu_register_reset(mpc8544ds_cpu_reset, cpu);
|
2011-07-22 19:32:29 +08:00
|
|
|
env->load_info = boot_info;
|
|
|
|
} else {
|
|
|
|
/* Secondary CPUs */
|
2012-05-04 08:09:06 +08:00
|
|
|
qemu_register_reset(mpc8544ds_cpu_reset_sec, cpu);
|
2011-07-22 19:32:29 +08:00
|
|
|
}
|
2011-07-21 07:41:16 +08:00
|
|
|
}
|
2011-05-01 05:34:53 +08:00
|
|
|
|
2011-07-21 07:41:16 +08:00
|
|
|
env = firstenv;
|
2011-05-01 05:34:53 +08:00
|
|
|
|
2009-03-03 00:42:42 +08:00
|
|
|
/* Fixup Memory size on a alignment boundary */
|
|
|
|
ram_size &= ~(RAM_SIZES_ALIGN - 1);
|
|
|
|
|
|
|
|
/* Register Memory */
|
2011-12-20 21:59:12 +08:00
|
|
|
memory_region_init_ram(ram, "mpc8544ds.ram", ram_size);
|
|
|
|
vmstate_register_ram_global(ram);
|
2011-10-02 22:43:01 +08:00
|
|
|
memory_region_add_subregion(address_space_mem, 0, ram);
|
2009-03-03 00:42:42 +08:00
|
|
|
|
|
|
|
/* MPIC */
|
2011-10-09 19:11:50 +08:00
|
|
|
mpic = mpic_init(address_space_mem, MPC8544_MPIC_REGS_BASE,
|
|
|
|
smp_cpus, irqs, NULL);
|
2011-07-21 07:42:58 +08:00
|
|
|
|
|
|
|
if (!mpic) {
|
|
|
|
cpu_abort(env, "MPIC failed to initialize\n");
|
|
|
|
}
|
2009-03-03 00:42:42 +08:00
|
|
|
|
|
|
|
/* Serial */
|
2010-03-22 03:47:11 +08:00
|
|
|
if (serial_hds[0]) {
|
2011-08-12 07:07:16 +08:00
|
|
|
serial_mm_init(address_space_mem, MPC8544_SERIAL0_REGS_BASE,
|
2010-10-14 02:41:29 +08:00
|
|
|
0, mpic[12+26], 399193,
|
2011-08-12 07:07:15 +08:00
|
|
|
serial_hds[0], DEVICE_BIG_ENDIAN);
|
2010-03-22 03:47:11 +08:00
|
|
|
}
|
2009-03-03 00:42:42 +08:00
|
|
|
|
2010-03-22 03:47:11 +08:00
|
|
|
if (serial_hds[1]) {
|
2011-08-12 07:07:16 +08:00
|
|
|
serial_mm_init(address_space_mem, MPC8544_SERIAL1_REGS_BASE,
|
2010-10-14 02:41:29 +08:00
|
|
|
0, mpic[12+26], 399193,
|
2011-08-12 07:07:15 +08:00
|
|
|
serial_hds[0], DEVICE_BIG_ENDIAN);
|
2010-03-22 03:47:11 +08:00
|
|
|
}
|
2009-03-03 00:42:42 +08:00
|
|
|
|
2011-06-02 19:53:40 +08:00
|
|
|
/* General Utility device */
|
|
|
|
sysbus_create_simple("mpc8544-guts", MPC8544_UTIL_BASE, NULL);
|
|
|
|
|
2009-03-03 00:42:42 +08:00
|
|
|
/* PCI */
|
2010-08-31 06:22:28 +08:00
|
|
|
dev = sysbus_create_varargs("e500-pcihost", MPC8544_PCI_REGS_BASE,
|
|
|
|
mpic[pci_irq_nrs[0]], mpic[pci_irq_nrs[1]],
|
|
|
|
mpic[pci_irq_nrs[2]], mpic[pci_irq_nrs[3]],
|
|
|
|
NULL);
|
2011-05-27 09:23:26 +08:00
|
|
|
pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0");
|
2009-03-03 00:42:42 +08:00
|
|
|
if (!pci_bus)
|
|
|
|
printf("couldn't create PCI controller!\n");
|
|
|
|
|
2010-12-08 19:05:49 +08:00
|
|
|
isa_mmio_init(MPC8544_PCI_IO, MPC8544_PCI_IOLEN);
|
2009-03-03 00:42:42 +08:00
|
|
|
|
|
|
|
if (pci_bus) {
|
|
|
|
/* Register network interfaces. */
|
|
|
|
for (i = 0; i < nb_nics; i++) {
|
2009-09-25 09:53:51 +08:00
|
|
|
pci_nic_init_nofail(&nd_table[i], "virtio", NULL);
|
2009-03-03 00:42:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-22 19:32:29 +08:00
|
|
|
/* Register spinning region */
|
|
|
|
sysbus_create_simple("e500-spin", MPC8544_SPIN_BASE, NULL);
|
|
|
|
|
2009-03-03 00:42:42 +08:00
|
|
|
/* Load kernel. */
|
|
|
|
if (kernel_filename) {
|
|
|
|
kernel_size = load_uimage(kernel_filename, &entry, &loadaddr, NULL);
|
|
|
|
if (kernel_size < 0) {
|
2010-03-15 04:20:59 +08:00
|
|
|
kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,
|
|
|
|
&elf_lowaddr, NULL, 1, ELF_MACHINE, 0);
|
2009-03-03 00:42:42 +08:00
|
|
|
entry = elf_entry;
|
|
|
|
loadaddr = elf_lowaddr;
|
|
|
|
}
|
|
|
|
/* XXX try again as binary */
|
|
|
|
if (kernel_size < 0) {
|
|
|
|
fprintf(stderr, "qemu: could not load kernel '%s'\n",
|
|
|
|
kernel_filename);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Load initrd. */
|
|
|
|
if (initrd_filename) {
|
2010-02-02 16:49:03 +08:00
|
|
|
initrd_base = (kernel_size + INITRD_LOAD_PAD) & ~INITRD_PAD_MASK;
|
2009-04-10 11:36:49 +08:00
|
|
|
initrd_size = load_image_targphys(initrd_filename, initrd_base,
|
|
|
|
ram_size - initrd_base);
|
2009-03-03 00:42:42 +08:00
|
|
|
|
|
|
|
if (initrd_size < 0) {
|
|
|
|
fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
|
|
|
|
initrd_filename);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we're loading a kernel directly, we must load the device tree too. */
|
|
|
|
if (kernel_filename) {
|
2011-07-22 19:32:29 +08:00
|
|
|
struct boot_info *boot_info;
|
2012-05-19 06:48:50 +08:00
|
|
|
int dt_size;
|
2011-07-22 19:32:29 +08:00
|
|
|
|
2012-05-19 06:48:50 +08:00
|
|
|
dt_base = (loadaddr + kernel_size + DTC_LOAD_PAD) & ~DTC_PAD_MASK;
|
|
|
|
dt_size = mpc8544_load_device_tree(env, dt_base, ram_size, initrd_base,
|
|
|
|
initrd_size, kernel_cmdline);
|
|
|
|
if (dt_size < 0) {
|
2009-03-03 00:42:42 +08:00
|
|
|
fprintf(stderr, "couldn't load device tree\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2011-07-21 07:41:16 +08:00
|
|
|
boot_info = env->load_info;
|
2011-05-01 05:34:53 +08:00
|
|
|
boot_info->entry = entry;
|
|
|
|
boot_info->dt_base = dt_base;
|
2012-05-19 06:48:50 +08:00
|
|
|
boot_info->dt_size = dt_size;
|
2009-03-03 00:42:42 +08:00
|
|
|
}
|
|
|
|
|
2011-05-01 05:34:53 +08:00
|
|
|
if (kvm_enabled()) {
|
2009-03-03 00:42:42 +08:00
|
|
|
kvmppc_init();
|
2011-05-01 05:34:53 +08:00
|
|
|
}
|
2009-03-03 00:42:42 +08:00
|
|
|
}
|
|
|
|
|
2009-05-21 07:38:09 +08:00
|
|
|
static QEMUMachine mpc8544ds_machine = {
|
2009-03-03 00:42:42 +08:00
|
|
|
.name = "mpc8544ds",
|
|
|
|
.desc = "mpc8544ds",
|
|
|
|
.init = mpc8544ds_init,
|
2011-07-21 07:45:37 +08:00
|
|
|
.max_cpus = 15,
|
2009-03-03 00:42:42 +08:00
|
|
|
};
|
2009-05-21 07:38:09 +08:00
|
|
|
|
|
|
|
static void mpc8544ds_machine_init(void)
|
|
|
|
{
|
|
|
|
qemu_register_machine(&mpc8544ds_machine);
|
|
|
|
}
|
|
|
|
|
|
|
|
machine_init(mpc8544ds_machine_init);
|