2007-09-16 23:08:06 +02:00
|
|
|
/*
|
2007-05-23 21:58:11 +02:00
|
|
|
* Arnewsh 5206 ColdFire system emulation.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2007 CodeSourcery.
|
|
|
|
*
|
2011-06-26 04:21:35 +02:00
|
|
|
* This code is licensed under the GPL
|
2007-05-23 21:58:11 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-26 19:17:23 +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"
|
2013-02-05 17:06:20 +01:00
|
|
|
#include "hw/m68k/mcf.h"
|
2013-02-04 15:40:22 +01:00
|
|
|
#include "hw/boards.h"
|
|
|
|
#include "hw/loader.h"
|
2009-09-20 16:58:02 +02:00
|
|
|
#include "elf.h"
|
2012-12-17 18:19:49 +01:00
|
|
|
#include "exec/address-spaces.h"
|
2015-12-17 17:35:09 +01:00
|
|
|
#include "qemu/error-report.h"
|
2013-07-29 18:48:58 +02:00
|
|
|
#include "sysemu/qtest.h"
|
2007-05-23 21:58:11 +02:00
|
|
|
|
|
|
|
#define KERNEL_LOAD_ADDR 0x10000
|
|
|
|
#define AN5206_MBAR_ADDR 0x10000000
|
|
|
|
#define AN5206_RAMBAR_ADDR 0x20000000
|
|
|
|
|
|
|
|
/* Board init. */
|
|
|
|
|
2014-05-07 16:42:57 +02:00
|
|
|
static void an5206_init(MachineState *machine)
|
2007-05-23 21:58:11 +02:00
|
|
|
{
|
2014-05-07 16:42:57 +02:00
|
|
|
ram_addr_t ram_size = machine->ram_size;
|
|
|
|
const char *kernel_filename = machine->kernel_filename;
|
2013-01-18 14:10:34 +01:00
|
|
|
M68kCPU *cpu;
|
2012-03-14 01:38:23 +01:00
|
|
|
CPUM68KState *env;
|
2007-05-23 21:58:11 +02:00
|
|
|
int kernel_size;
|
|
|
|
uint64_t elf_entry;
|
2012-10-23 12:30:10 +02:00
|
|
|
hwaddr entry;
|
2011-07-25 13:14:31 +02:00
|
|
|
MemoryRegion *address_space_mem = get_system_memory();
|
|
|
|
MemoryRegion *ram = g_new(MemoryRegion, 1);
|
|
|
|
MemoryRegion *sram = g_new(MemoryRegion, 1);
|
2007-05-23 21:58:11 +02:00
|
|
|
|
2017-10-05 15:50:46 +02:00
|
|
|
cpu = M68K_CPU(cpu_create(machine->cpu_type));
|
2013-01-18 14:10:34 +01:00
|
|
|
env = &cpu->env;
|
2007-05-23 21:58:11 +02: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 */
|
2015-03-24 23:11:03 +01:00
|
|
|
memory_region_allocate_system_memory(ram, NULL, "an5206.ram", ram_size);
|
2011-07-25 13:14:31 +02:00
|
|
|
memory_region_add_subregion(address_space_mem, 0, ram);
|
2007-05-23 21:58:11 +02:00
|
|
|
|
|
|
|
/* Internal SRAM. */
|
2017-07-07 16:42:53 +02:00
|
|
|
memory_region_init_ram(sram, NULL, "an5206.sram", 512, &error_fatal);
|
2011-07-25 13:14:31 +02:00
|
|
|
memory_region_add_subregion(address_space_mem, AN5206_RAMBAR_ADDR, sram);
|
2007-05-23 21:58:11 +02:00
|
|
|
|
2013-01-18 14:10:34 +01:00
|
|
|
mcf5206_init(address_space_mem, AN5206_MBAR_ADDR, cpu);
|
2007-05-23 21:58:11 +02:00
|
|
|
|
|
|
|
/* Load kernel. */
|
|
|
|
if (!kernel_filename) {
|
2013-07-29 18:48:58 +02: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 02:16:06 +02:00
|
|
|
error_report("Kernel image must be specified");
|
2007-05-23 21:58:11 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2019-01-15 13:18:03 +01:00
|
|
|
kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, &elf_entry,
|
2016-03-04 12:30:21 +01:00
|
|
|
NULL, NULL, 1, EM_68K, 0, 0);
|
2007-05-23 21:58:11 +02:00
|
|
|
entry = elf_entry;
|
|
|
|
if (kernel_size < 0) {
|
2014-10-19 05:42:22 +02:00
|
|
|
kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL,
|
|
|
|
NULL, NULL);
|
2007-05-23 21:58:11 +02:00
|
|
|
}
|
|
|
|
if (kernel_size < 0) {
|
2009-04-09 22:05:49 +02:00
|
|
|
kernel_size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR,
|
|
|
|
ram_size - KERNEL_LOAD_ADDR);
|
2007-05-23 21:58:11 +02: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 02:16:06 +02:00
|
|
|
error_report("Could not load kernel '%s'", kernel_filename);
|
2007-05-23 21:58:11 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
env->pc = entry;
|
|
|
|
}
|
|
|
|
|
2015-09-04 20:37:08 +02:00
|
|
|
static void an5206_machine_init(MachineClass *mc)
|
2009-05-21 01:38:09 +02:00
|
|
|
{
|
2015-09-04 20:37:08 +02:00
|
|
|
mc->desc = "Arnewsh 5206";
|
|
|
|
mc->init = an5206_init;
|
2017-10-05 15:50:46 +02:00
|
|
|
mc->default_cpu_type = M68K_CPU_TYPE_NAME("m5206");
|
2009-05-21 01:38:09 +02:00
|
|
|
}
|
|
|
|
|
2015-09-04 20:37:08 +02:00
|
|
|
DEFINE_MACHINE("an5206", an5206_machine_init)
|