2012-07-04 14:43:34 +04:00
|
|
|
/*
|
|
|
|
* KZM Board System emulation.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2008 OKL and 2011 NICTA
|
|
|
|
* Written by Hans at OK-Labs
|
|
|
|
* Updated by Peter Chubb.
|
|
|
|
*
|
2012-08-11 00:03:26 +04:00
|
|
|
* This code is licensed under the GPL, version 2 or later.
|
2012-07-04 14:43:34 +04:00
|
|
|
* See the file `COPYING' in the top level directory.
|
|
|
|
*
|
|
|
|
* It (partially) emulates a Kyoto Microcomputer
|
|
|
|
* KZM-ARM11-01 evaluation board, with a Freescale
|
|
|
|
* i.MX31 SoC
|
|
|
|
*/
|
|
|
|
|
2015-12-07 19:23:45 +03:00
|
|
|
#include "qemu/osdep.h"
|
include/qemu/osdep.h: Don't include qapi/error.h
Commit 57cb38b included qapi/error.h into qemu/osdep.h to get the
Error typedef. Since then, we've moved to include qemu/osdep.h
everywhere. Its file comment explains: "To avoid getting into
possible circular include dependencies, this file should not include
any other QEMU headers, with the exceptions of config-host.h,
compiler.h, os-posix.h and os-win32.h, all of which are doing a
similar job to this file and are under similar constraints."
qapi/error.h doesn't do a similar job, and it doesn't adhere to
similar constraints: it includes qapi-types.h. That's in excess of
100KiB of crap most .c files don't actually need.
Add the typedef to qemu/typedefs.h, and include that instead of
qapi/error.h. Include qapi/error.h in .c files that need it and don't
get it now. Include qapi-types.h in qom/object.h for uint16List.
Update scripts/clean-includes accordingly. Update it further to match
reality: replace config.h by config-target.h, add sysemu/os-posix.h,
sysemu/os-win32.h. Update the list of includes in the qemu/osdep.h
comment quoted above similarly.
This reduces the number of objects depending on qapi/error.h from "all
of them" to less than a third. Unfortunately, the number depending on
qapi-types.h shrinks only a little. More work is needed for that one.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
[Fix compilation without the spice devel packages. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-14 11:01:28 +03:00
|
|
|
#include "qapi/error.h"
|
2016-01-19 23:51:44 +03:00
|
|
|
#include "qemu-common.h"
|
|
|
|
#include "cpu.h"
|
2015-09-07 12:39:30 +03:00
|
|
|
#include "hw/arm/fsl-imx31.h"
|
|
|
|
#include "hw/boards.h"
|
|
|
|
#include "qemu/error-report.h"
|
2012-12-17 21:19:49 +04:00
|
|
|
#include "exec/address-spaces.h"
|
2012-10-24 10:43:34 +04:00
|
|
|
#include "net/net.h"
|
2015-09-07 12:39:30 +03:00
|
|
|
#include "hw/devices.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/char/serial.h"
|
2015-09-07 12:39:30 +03:00
|
|
|
#include "sysemu/qtest.h"
|
|
|
|
|
|
|
|
/* Memory map for Kzm Emulation Baseboard:
|
|
|
|
* 0x00000000-0x7fffffff See i.MX31 SOC for support
|
|
|
|
* 0x80000000-0x8fffffff RAM EMULATED
|
|
|
|
* 0x90000000-0x9fffffff RAM EMULATED
|
|
|
|
* 0xa0000000-0xafffffff Flash IGNORED
|
|
|
|
* 0xb0000000-0xb3ffffff Unavailable IGNORED
|
|
|
|
* 0xb4000000-0xb4000fff 8-bit free space IGNORED
|
|
|
|
* 0xb4001000-0xb400100f Board control IGNORED
|
|
|
|
* 0xb4001003 DIP switch
|
|
|
|
* 0xb4001010-0xb400101f 7-segment LED IGNORED
|
|
|
|
* 0xb4001020-0xb400102f LED IGNORED
|
|
|
|
* 0xb4001030-0xb400103f LED IGNORED
|
|
|
|
* 0xb4001040-0xb400104f FPGA, UART EMULATED
|
|
|
|
* 0xb4001050-0xb400105f FPGA, UART EMULATED
|
|
|
|
* 0xb4001060-0xb40fffff FPGA IGNORED
|
|
|
|
* 0xb6000000-0xb61fffff LAN controller EMULATED
|
|
|
|
* 0xb6200000-0xb62fffff FPGA NAND Controller IGNORED
|
|
|
|
* 0xb6300000-0xb7ffffff Free IGNORED
|
|
|
|
* 0xb8000000-0xb8004fff Memory control registers IGNORED
|
|
|
|
* 0xc0000000-0xc3ffffff PCMCIA/CF IGNORED
|
|
|
|
* 0xc4000000-0xffffffff Reserved IGNORED
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct IMX31KZM {
|
|
|
|
FslIMX31State soc;
|
|
|
|
MemoryRegion ram;
|
|
|
|
MemoryRegion ram_alias;
|
|
|
|
} IMX31KZM;
|
|
|
|
|
|
|
|
#define KZM_RAM_ADDR (FSL_IMX31_SDRAM0_ADDR)
|
|
|
|
#define KZM_FPGA_ADDR (FSL_IMX31_CS4_ADDR + 0x1040)
|
|
|
|
#define KZM_LAN9118_ADDR (FSL_IMX31_CS5_ADDR)
|
2012-07-04 14:43:34 +04:00
|
|
|
|
|
|
|
static struct arm_boot_info kzm_binfo = {
|
2015-09-07 12:39:30 +03:00
|
|
|
.loader_start = KZM_RAM_ADDR,
|
2012-07-04 14:43:34 +04:00
|
|
|
.board_id = 1722,
|
|
|
|
};
|
|
|
|
|
2014-05-07 18:42:57 +04:00
|
|
|
static void kzm_init(MachineState *machine)
|
2012-07-04 14:43:34 +04:00
|
|
|
{
|
2015-09-07 12:39:30 +03:00
|
|
|
IMX31KZM *s = g_new0(IMX31KZM, 1);
|
|
|
|
unsigned int ram_size;
|
|
|
|
unsigned int alias_offset;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
object_initialize(&s->soc, sizeof(s->soc), TYPE_FSL_IMX31);
|
|
|
|
object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc),
|
|
|
|
&error_abort);
|
|
|
|
|
2016-01-14 18:02:12 +03:00
|
|
|
object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_fatal);
|
2012-07-04 14:43:34 +04:00
|
|
|
|
2015-09-07 12:39:30 +03:00
|
|
|
/* Check the amount of memory is compatible with the SOC */
|
|
|
|
if (machine->ram_size > (FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE)) {
|
2017-07-12 16:57:41 +03:00
|
|
|
warn_report("RAM size " RAM_ADDR_FMT " above max supported, "
|
|
|
|
"reduced to %x", machine->ram_size,
|
|
|
|
FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE);
|
2015-09-07 12:39:30 +03:00
|
|
|
machine->ram_size = FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE;
|
|
|
|
}
|
2012-07-04 14:43:34 +04:00
|
|
|
|
2015-09-07 12:39:30 +03:00
|
|
|
memory_region_allocate_system_memory(&s->ram, NULL, "kzm.ram",
|
|
|
|
machine->ram_size);
|
|
|
|
memory_region_add_subregion(get_system_memory(), FSL_IMX31_SDRAM0_ADDR,
|
|
|
|
&s->ram);
|
|
|
|
|
|
|
|
/* initialize the alias memory if any */
|
|
|
|
for (i = 0, ram_size = machine->ram_size, alias_offset = 0;
|
|
|
|
(i < 2) && ram_size; i++) {
|
|
|
|
unsigned int size;
|
|
|
|
static const struct {
|
|
|
|
hwaddr addr;
|
|
|
|
unsigned int size;
|
|
|
|
} ram[2] = {
|
|
|
|
{ FSL_IMX31_SDRAM0_ADDR, FSL_IMX31_SDRAM0_SIZE },
|
|
|
|
{ FSL_IMX31_SDRAM1_ADDR, FSL_IMX31_SDRAM1_SIZE },
|
|
|
|
};
|
|
|
|
|
|
|
|
size = MIN(ram_size, ram[i].size);
|
|
|
|
|
|
|
|
ram_size -= size;
|
|
|
|
|
|
|
|
if (size < ram[i].size) {
|
|
|
|
memory_region_init_alias(&s->ram_alias, NULL, "ram.alias",
|
|
|
|
&s->ram, alias_offset, ram[i].size - size);
|
|
|
|
memory_region_add_subregion(get_system_memory(),
|
|
|
|
ram[i].addr + size, &s->ram_alias);
|
|
|
|
}
|
|
|
|
|
|
|
|
alias_offset += ram[i].size;
|
|
|
|
}
|
2012-07-04 14:43:34 +04:00
|
|
|
|
2012-07-24 19:35:11 +04:00
|
|
|
if (nd_table[0].used) {
|
2015-09-07 12:39:30 +03:00
|
|
|
lan9118_init(&nd_table[0], KZM_LAN9118_ADDR,
|
|
|
|
qdev_get_gpio_in(DEVICE(&s->soc.avic), 52));
|
2012-07-04 14:43:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (serial_hds[2]) { /* touchscreen */
|
2015-09-07 12:39:30 +03:00
|
|
|
serial_mm_init(get_system_memory(), KZM_FPGA_ADDR+0x10, 0,
|
|
|
|
qdev_get_gpio_in(DEVICE(&s->soc.avic), 52),
|
|
|
|
14745600, serial_hds[2], DEVICE_NATIVE_ENDIAN);
|
2012-07-04 14:43:34 +04:00
|
|
|
}
|
|
|
|
|
2015-09-07 12:39:30 +03:00
|
|
|
kzm_binfo.ram_size = machine->ram_size;
|
|
|
|
kzm_binfo.kernel_filename = machine->kernel_filename;
|
|
|
|
kzm_binfo.kernel_cmdline = machine->kernel_cmdline;
|
|
|
|
kzm_binfo.initrd_filename = machine->initrd_filename;
|
2012-07-04 14:43:34 +04:00
|
|
|
kzm_binfo.nb_cpus = 1;
|
2015-09-07 12:39:30 +03:00
|
|
|
|
|
|
|
if (!qtest_enabled()) {
|
|
|
|
arm_load_kernel(&s->soc.cpu, &kzm_binfo);
|
|
|
|
}
|
2012-07-04 14:43:34 +04:00
|
|
|
}
|
|
|
|
|
2015-09-04 21:37:08 +03:00
|
|
|
static void kzm_machine_init(MachineClass *mc)
|
2012-07-04 14:43:34 +04:00
|
|
|
{
|
2015-09-04 21:37:08 +03:00
|
|
|
mc->desc = "ARM KZM Emulation Baseboard (ARM1136)";
|
|
|
|
mc->init = kzm_init;
|
2017-09-07 15:54:54 +03:00
|
|
|
mc->ignore_memory_transaction_failures = true;
|
2012-07-04 14:43:34 +04:00
|
|
|
}
|
|
|
|
|
2015-09-04 21:37:08 +03:00
|
|
|
DEFINE_MACHINE("kzm", kzm_machine_init)
|