2012-07-04 12:43:34 +02:00
|
|
|
/*
|
|
|
|
* KZM Board System emulation.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2008 OKL and 2011 NICTA
|
|
|
|
* Written by Hans at OK-Labs
|
|
|
|
* Updated by Peter Chubb.
|
|
|
|
*
|
2012-08-10 22:03:26 +02:00
|
|
|
* This code is licensed under the GPL, version 2 or later.
|
2012-07-04 12:43:34 +02: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 17:23:45 +01: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 09:01:28 +01:00
|
|
|
#include "qapi/error.h"
|
2016-01-19 21:51:44 +01:00
|
|
|
#include "cpu.h"
|
2015-09-07 11:39:30 +02:00
|
|
|
#include "hw/arm/fsl-imx31.h"
|
|
|
|
#include "hw/boards.h"
|
|
|
|
#include "qemu/error-report.h"
|
2012-12-17 18:19:49 +01:00
|
|
|
#include "exec/address-spaces.h"
|
2012-10-24 08:43:34 +02:00
|
|
|
#include "net/net.h"
|
2019-04-12 18:54:13 +02:00
|
|
|
#include "hw/net/lan9118.h"
|
2013-02-05 17:06:20 +01:00
|
|
|
#include "hw/char/serial.h"
|
2015-09-07 11:39:30 +02:00
|
|
|
#include "sysemu/qtest.h"
|
2019-08-12 07:23:57 +02:00
|
|
|
#include "sysemu/sysemu.h"
|
2020-02-19 17:08:52 +01:00
|
|
|
#include "qemu/cutils.h"
|
2015-09-07 11:39:30 +02:00
|
|
|
|
|
|
|
/* 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_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 12:43:34 +02:00
|
|
|
|
|
|
|
static struct arm_boot_info kzm_binfo = {
|
2015-09-07 11:39:30 +02:00
|
|
|
.loader_start = KZM_RAM_ADDR,
|
2012-07-04 12:43:34 +02:00
|
|
|
.board_id = 1722,
|
|
|
|
};
|
|
|
|
|
2014-05-07 16:42:57 +02:00
|
|
|
static void kzm_init(MachineState *machine)
|
2012-07-04 12:43:34 +02:00
|
|
|
{
|
2015-09-07 11:39:30 +02:00
|
|
|
IMX31KZM *s = g_new0(IMX31KZM, 1);
|
|
|
|
unsigned int ram_size;
|
|
|
|
unsigned int alias_offset;
|
|
|
|
unsigned int i;
|
|
|
|
|
qom: Less verbose object_initialize_child()
All users of object_initialize_child() pass the obvious child size
argument. Almost all pass &error_abort and no properties. Tiresome.
Rename object_initialize_child() to
object_initialize_child_with_props() to free the name. New
convenience wrapper object_initialize_child() automates the size
argument, and passes &error_abort and no properties.
Rename object_initialize_childv() to
object_initialize_child_with_propsv() for consistency.
Convert callers with this Coccinelle script:
@@
expression parent, propname, type;
expression child, size;
symbol error_abort;
@@
- object_initialize_child(parent, propname, OBJECT(child), size, type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, size, type, &error_abort, NULL)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, child, sizeof(*child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, type)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, &child, sizeof(child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, &child, type)
@@
expression parent, propname, type;
expression child, size, err;
expression list props;
@@
- object_initialize_child(parent, propname, child, size, type, err, props)
+ object_initialize_child_with_props(parent, propname, child, size, type, err, props)
Note that Coccinelle chokes on ARMSSE typedef vs. macro in
hw/arm/armsse.c. Worked around by temporarily renaming the macro for
the spatch run.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
[Rebased: machine opentitan is new (commit fe0fe4735e7)]
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-37-armbru@redhat.com>
2020-06-10 07:32:25 +02:00
|
|
|
object_initialize_child(OBJECT(machine), "soc", &s->soc, TYPE_FSL_IMX31);
|
2015-09-07 11:39:30 +02:00
|
|
|
|
qdev: Convert bus-less devices to qdev_realize() with Coccinelle
All remaining conversions to qdev_realize() are for bus-less devices.
Coccinelle script:
// only correct for bus-less @dev!
@@
expression errp;
expression dev;
@@
- qdev_init_nofail(dev);
+ qdev_realize(dev, NULL, &error_fatal);
@ depends on !(file in "hw/core/qdev.c") && !(file in "hw/core/bus.c")@
expression errp;
expression dev;
symbol true;
@@
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize(DEVICE(dev), NULL, errp);
@ depends on !(file in "hw/core/qdev.c") && !(file in "hw/core/bus.c")@
expression errp;
expression dev;
symbol true;
@@
- object_property_set_bool(dev, true, "realized", errp);
+ qdev_realize(DEVICE(dev), NULL, errp);
Note that Coccinelle chokes on ARMSSE typedef vs. macro in
hw/arm/armsse.c. Worked around by temporarily renaming the macro for
the spatch run.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-57-armbru@redhat.com>
2020-06-10 07:32:45 +02:00
|
|
|
qdev_realize(DEVICE(&s->soc), NULL, &error_fatal);
|
2012-07-04 12:43:34 +02:00
|
|
|
|
2015-09-07 11:39:30 +02:00
|
|
|
/* Check the amount of memory is compatible with the SOC */
|
|
|
|
if (machine->ram_size > (FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE)) {
|
2020-02-19 17:08:52 +01:00
|
|
|
char *sz = size_to_str(FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE);
|
|
|
|
error_report("RAM size more than %s is not supported", sz);
|
|
|
|
g_free(sz);
|
|
|
|
exit(EXIT_FAILURE);
|
2015-09-07 11:39:30 +02:00
|
|
|
}
|
2012-07-04 12:43:34 +02:00
|
|
|
|
2015-09-07 11:39:30 +02:00
|
|
|
memory_region_add_subregion(get_system_memory(), FSL_IMX31_SDRAM0_ADDR,
|
2020-02-19 17:08:53 +01:00
|
|
|
machine->ram);
|
2015-09-07 11:39:30 +02:00
|
|
|
|
|
|
|
/* 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",
|
2020-02-19 17:08:53 +01:00
|
|
|
machine->ram,
|
|
|
|
alias_offset, ram[i].size - size);
|
2015-09-07 11:39:30 +02:00
|
|
|
memory_region_add_subregion(get_system_memory(),
|
|
|
|
ram[i].addr + size, &s->ram_alias);
|
|
|
|
}
|
|
|
|
|
|
|
|
alias_offset += ram[i].size;
|
|
|
|
}
|
2012-07-04 12:43:34 +02:00
|
|
|
|
2012-07-24 17:35:11 +02:00
|
|
|
if (nd_table[0].used) {
|
2015-09-07 11:39:30 +02:00
|
|
|
lan9118_init(&nd_table[0], KZM_LAN9118_ADDR,
|
|
|
|
qdev_get_gpio_in(DEVICE(&s->soc.avic), 52));
|
2012-07-04 12:43:34 +02:00
|
|
|
}
|
|
|
|
|
2018-04-20 16:52:43 +02:00
|
|
|
if (serial_hd(2)) { /* touchscreen */
|
2015-09-07 11:39:30 +02:00
|
|
|
serial_mm_init(get_system_memory(), KZM_FPGA_ADDR+0x10, 0,
|
|
|
|
qdev_get_gpio_in(DEVICE(&s->soc.avic), 52),
|
2018-04-20 16:52:43 +02:00
|
|
|
14745600, serial_hd(2), DEVICE_NATIVE_ENDIAN);
|
2012-07-04 12:43:34 +02:00
|
|
|
}
|
|
|
|
|
2015-09-07 11:39:30 +02:00
|
|
|
kzm_binfo.ram_size = machine->ram_size;
|
2012-07-04 12:43:34 +02:00
|
|
|
kzm_binfo.nb_cpus = 1;
|
2015-09-07 11:39:30 +02:00
|
|
|
|
|
|
|
if (!qtest_enabled()) {
|
2019-08-09 08:57:21 +02:00
|
|
|
arm_load_kernel(&s->soc.cpu, machine, &kzm_binfo);
|
2015-09-07 11:39:30 +02:00
|
|
|
}
|
2012-07-04 12:43:34 +02:00
|
|
|
}
|
|
|
|
|
2015-09-04 20:37:08 +02:00
|
|
|
static void kzm_machine_init(MachineClass *mc)
|
2012-07-04 12:43:34 +02:00
|
|
|
{
|
2015-09-04 20:37:08 +02:00
|
|
|
mc->desc = "ARM KZM Emulation Baseboard (ARM1136)";
|
|
|
|
mc->init = kzm_init;
|
2017-09-07 14:54:54 +02:00
|
|
|
mc->ignore_memory_transaction_failures = true;
|
2020-02-19 17:08:53 +01:00
|
|
|
mc->default_ram_id = "kzm.ram";
|
2012-07-04 12:43:34 +02:00
|
|
|
}
|
|
|
|
|
2015-09-04 20:37:08 +02:00
|
|
|
DEFINE_MACHINE("kzm", kzm_machine_init)
|