2007-09-17 01:08:06 +04:00
|
|
|
/*
|
2007-05-23 23:58:11 +04:00
|
|
|
* Arnewsh 5206 ColdFire system emulation.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2007 CodeSourcery.
|
|
|
|
*
|
2011-06-26 06:21:35 +04:00
|
|
|
* This code is licensed under the GPL
|
2007-05-23 23:58:11 +04:00
|
|
|
*/
|
|
|
|
|
2016-01-26 21:17:23 +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 "cpu.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/m68k/mcf.h"
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/boards.h"
|
|
|
|
#include "hw/loader.h"
|
2009-09-20 18:58:02 +04:00
|
|
|
#include "elf.h"
|
2015-12-17 19:35:09 +03:00
|
|
|
#include "qemu/error-report.h"
|
2013-07-29 20:48:58 +04:00
|
|
|
#include "sysemu/qtest.h"
|
2007-05-23 23:58:11 +04:00
|
|
|
|
|
|
|
#define KERNEL_LOAD_ADDR 0x10000
|
|
|
|
#define AN5206_MBAR_ADDR 0x10000000
|
|
|
|
#define AN5206_RAMBAR_ADDR 0x20000000
|
|
|
|
|
2023-10-24 11:30:05 +03:00
|
|
|
static void mcf5206_init(M68kCPU *cpu, MemoryRegion *sysmem, uint32_t base)
|
2020-08-19 09:52:01 +03:00
|
|
|
{
|
|
|
|
DeviceState *dev;
|
|
|
|
SysBusDevice *s;
|
|
|
|
|
|
|
|
dev = qdev_new(TYPE_MCF5206_MBAR);
|
2023-10-24 11:30:05 +03:00
|
|
|
object_property_set_link(OBJECT(dev), "m68k-cpu",
|
|
|
|
OBJECT(cpu), &error_abort);
|
2020-08-19 09:52:01 +03:00
|
|
|
s = SYS_BUS_DEVICE(dev);
|
|
|
|
sysbus_realize_and_unref(s, &error_fatal);
|
|
|
|
|
|
|
|
memory_region_add_subregion(sysmem, base, sysbus_mmio_get_region(s, 0));
|
|
|
|
}
|
2007-05-23 23:58:11 +04:00
|
|
|
|
2014-05-07 18:42:57 +04:00
|
|
|
static void an5206_init(MachineState *machine)
|
2007-05-23 23:58:11 +04:00
|
|
|
{
|
2014-05-07 18:42:57 +04:00
|
|
|
ram_addr_t ram_size = machine->ram_size;
|
|
|
|
const char *kernel_filename = machine->kernel_filename;
|
2013-01-18 17:10:34 +04:00
|
|
|
M68kCPU *cpu;
|
2012-03-14 04:38:23 +04:00
|
|
|
CPUM68KState *env;
|
2007-05-23 23:58:11 +04:00
|
|
|
int kernel_size;
|
|
|
|
uint64_t elf_entry;
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr entry;
|
2011-07-25 15:14:31 +04:00
|
|
|
MemoryRegion *address_space_mem = get_system_memory();
|
|
|
|
MemoryRegion *sram = g_new(MemoryRegion, 1);
|
2007-05-23 23:58:11 +04:00
|
|
|
|
2017-10-05 16:50:46 +03:00
|
|
|
cpu = M68K_CPU(cpu_create(machine->cpu_type));
|
2013-01-18 17:10:34 +04:00
|
|
|
env = &cpu->env;
|
2007-05-23 23:58:11 +04:00
|
|
|
|
|
|
|
/* Initialize CPU registers. */
|
|
|
|
env->vbr = 0;
|
|
|
|
/* TODO: allow changing MBAR and RAMBAR. */
|
|
|
|
env->mbar = AN5206_MBAR_ADDR | 1;
|
|
|
|
env->rambar0 = AN5206_RAMBAR_ADDR | 1;
|
|
|
|
|
|
|
|
/* DRAM at address zero */
|
2020-02-19 19:09:20 +03:00
|
|
|
memory_region_add_subregion(address_space_mem, 0, machine->ram);
|
2007-05-23 23:58:11 +04:00
|
|
|
|
|
|
|
/* Internal SRAM. */
|
2017-07-07 17:42:53 +03:00
|
|
|
memory_region_init_ram(sram, NULL, "an5206.sram", 512, &error_fatal);
|
2011-07-25 15:14:31 +04:00
|
|
|
memory_region_add_subregion(address_space_mem, AN5206_RAMBAR_ADDR, sram);
|
2007-05-23 23:58:11 +04:00
|
|
|
|
2023-10-24 11:30:05 +03:00
|
|
|
mcf5206_init(cpu, address_space_mem, AN5206_MBAR_ADDR);
|
2007-05-23 23:58:11 +04:00
|
|
|
|
|
|
|
/* Load kernel. */
|
|
|
|
if (!kernel_filename) {
|
2013-07-29 20:48:58 +04:00
|
|
|
if (qtest_enabled()) {
|
|
|
|
return;
|
|
|
|
}
|
hw/m68k: Replace fprintf(stderr, "*\n" with error_report()
Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
Some lines where then manually tweaked to pass checkpatch.
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Reviewed-by: Thomas Huth <huth@tuxfamily.org>
[thuth: Remove "qemu:" prefix from strings]
Signed-off-by: Thomas Huth <thuth@redhat.com>
2017-09-30 03:16:06 +03:00
|
|
|
error_report("Kernel image must be specified");
|
2007-05-23 23:58:11 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2019-01-15 15:18:03 +03:00
|
|
|
kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, &elf_entry,
|
2020-01-27 01:55:04 +03:00
|
|
|
NULL, NULL, NULL, 1, EM_68K, 0, 0);
|
2007-05-23 23:58:11 +04:00
|
|
|
entry = elf_entry;
|
|
|
|
if (kernel_size < 0) {
|
2014-10-19 07:42:22 +04:00
|
|
|
kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL,
|
|
|
|
NULL, NULL);
|
2007-05-23 23:58:11 +04:00
|
|
|
}
|
|
|
|
if (kernel_size < 0) {
|
2009-04-10 00:05:49 +04:00
|
|
|
kernel_size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR,
|
|
|
|
ram_size - KERNEL_LOAD_ADDR);
|
2007-05-23 23:58:11 +04:00
|
|
|
entry = KERNEL_LOAD_ADDR;
|
|
|
|
}
|
|
|
|
if (kernel_size < 0) {
|
hw/m68k: Replace fprintf(stderr, "*\n" with error_report()
Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
Some lines where then manually tweaked to pass checkpatch.
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Reviewed-by: Thomas Huth <huth@tuxfamily.org>
[thuth: Remove "qemu:" prefix from strings]
Signed-off-by: Thomas Huth <thuth@redhat.com>
2017-09-30 03:16:06 +03:00
|
|
|
error_report("Could not load kernel '%s'", kernel_filename);
|
2007-05-23 23:58:11 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
env->pc = entry;
|
|
|
|
}
|
|
|
|
|
2015-09-04 21:37:08 +03:00
|
|
|
static void an5206_machine_init(MachineClass *mc)
|
2009-05-21 03:38:09 +04:00
|
|
|
{
|
2015-09-04 21:37:08 +03:00
|
|
|
mc->desc = "Arnewsh 5206";
|
|
|
|
mc->init = an5206_init;
|
2017-10-05 16:50:46 +03:00
|
|
|
mc->default_cpu_type = M68K_CPU_TYPE_NAME("m5206");
|
2020-02-19 19:09:20 +03:00
|
|
|
mc->default_ram_id = "an5206.ram";
|
2009-05-21 03:38:09 +04:00
|
|
|
}
|
|
|
|
|
2015-09-04 21:37:08 +03:00
|
|
|
DEFINE_MACHINE("an5206", an5206_machine_init)
|