2013-12-17 20:42:38 +01:00
|
|
|
/*
|
|
|
|
* cubieboard emulation
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Li Guang
|
|
|
|
* Written by Li Guang <lig.fnst@cn.fujitsu.com>
|
|
|
|
*
|
|
|
|
* This program 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.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
2015-12-07 17:23:45 +01:00
|
|
|
#include "qemu/osdep.h"
|
2019-08-12 07:23:40 +02:00
|
|
|
#include "exec/address-spaces.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"
|
2020-03-05 17:09:19 +01:00
|
|
|
#include "sysemu/sysemu.h"
|
2013-12-17 20:42:38 +01:00
|
|
|
#include "hw/sysbus.h"
|
|
|
|
#include "hw/boards.h"
|
2020-03-11 23:18:44 +01:00
|
|
|
#include "hw/qdev-properties.h"
|
2013-12-17 20:42:38 +01:00
|
|
|
#include "hw/arm/allwinner-a10.h"
|
|
|
|
|
|
|
|
static struct arm_boot_info cubieboard_binfo = {
|
|
|
|
.loader_start = AW_A10_SDRAM_BASE,
|
|
|
|
.board_id = 0x1008,
|
|
|
|
};
|
|
|
|
|
2014-05-07 16:42:57 +02:00
|
|
|
static void cubieboard_init(MachineState *machine)
|
2013-12-17 20:42:38 +01:00
|
|
|
{
|
2020-03-05 17:09:19 +01:00
|
|
|
AwA10State *a10;
|
2013-12-17 20:42:38 +01:00
|
|
|
Error *err = NULL;
|
2020-03-11 23:18:44 +01:00
|
|
|
DriveInfo *di;
|
|
|
|
BlockBackend *blk;
|
|
|
|
BusState *bus;
|
|
|
|
DeviceState *carddev;
|
2013-12-17 20:42:38 +01:00
|
|
|
|
2020-03-05 17:09:19 +01:00
|
|
|
/* BIOS is not supported by this board */
|
|
|
|
if (bios_name) {
|
|
|
|
error_report("BIOS not supported for this machine");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2020-03-05 17:09:19 +01:00
|
|
|
/* This board has fixed size RAM (512MiB or 1GiB) */
|
|
|
|
if (machine->ram_size != 512 * MiB &&
|
|
|
|
machine->ram_size != 1 * GiB) {
|
|
|
|
error_report("This machine can only be used with 512MiB or 1GiB RAM");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2020-03-05 17:09:19 +01:00
|
|
|
/* Only allow Cortex-A8 for this board */
|
|
|
|
if (strcmp(machine->cpu_type, ARM_CPU_TYPE_NAME("cortex-a8")) != 0) {
|
|
|
|
error_report("This board can only be used with cortex-a8 CPU");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
a10 = AW_A10(object_new(TYPE_AW_A10));
|
qom: Drop parameter @errp of object_property_add() & friends
The only way object_property_add() can fail is when a property with
the same name already exists. Since our property names are all
hardcoded, failure is a programming error, and the appropriate way to
handle it is passing &error_abort.
Same for its variants, except for object_property_add_child(), which
additionally fails when the child already has a parent. Parentage is
also under program control, so this is a programming error, too.
We have a bit over 500 callers. Almost half of them pass
&error_abort, slightly fewer ignore errors, one test case handles
errors, and the remaining few callers pass them to their own callers.
The previous few commits demonstrated once again that ignoring
programming errors is a bad idea.
Of the few ones that pass on errors, several violate the Error API.
The Error ** argument must be NULL, &error_abort, &error_fatal, or a
pointer to a variable containing NULL. Passing an argument of the
latter kind twice without clearing it in between is wrong: if the
first call sets an error, it no longer points to NULL for the second
call. ich9_pm_add_properties(), sparc32_ledma_realize(),
sparc32_dma_realize(), xilinx_axidma_realize(), xilinx_enet_realize()
are wrong that way.
When the one appropriate choice of argument is &error_abort, letting
users pick the argument is a bad idea.
Drop parameter @errp and assert the preconditions instead.
There's one exception to "duplicate property name is a programming
error": the way object_property_add() implements the magic (and
undocumented) "automatic arrayification". Don't drop @errp there.
Instead, rename object_property_add() to object_property_try_add(),
and add the obvious wrapper object_property_add().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200505152926.18877-15-armbru@redhat.com>
[Two semantic rebase conflicts resolved]
2020-05-05 17:29:22 +02:00
|
|
|
object_property_add_child(OBJECT(machine), "soc", OBJECT(a10));
|
2020-03-03 10:12:54 +01:00
|
|
|
object_unref(OBJECT(a10));
|
2020-03-05 17:09:19 +01:00
|
|
|
|
2020-02-19 17:08:46 +01:00
|
|
|
object_property_set_int(OBJECT(&a10->emac), 1, "phy-addr", &err);
|
2014-01-30 23:02:07 +01:00
|
|
|
if (err != NULL) {
|
2015-12-18 16:35:14 +01:00
|
|
|
error_reportf_err(err, "Couldn't set phy address: ");
|
2014-01-30 23:02:07 +01:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2020-02-19 17:08:46 +01:00
|
|
|
object_property_set_int(OBJECT(&a10->timer), 32768, "clk0-freq", &err);
|
2014-03-25 19:22:08 +01:00
|
|
|
if (err != NULL) {
|
2015-12-18 16:35:14 +01:00
|
|
|
error_reportf_err(err, "Couldn't set clk0 frequency: ");
|
2014-03-25 19:22:08 +01:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2020-02-19 17:08:46 +01:00
|
|
|
object_property_set_int(OBJECT(&a10->timer), 24000000, "clk1-freq", &err);
|
2014-03-25 19:22:08 +01:00
|
|
|
if (err != NULL) {
|
2015-12-18 16:35:14 +01:00
|
|
|
error_reportf_err(err, "Couldn't set clk1 frequency: ");
|
2014-03-25 19:22:08 +01:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
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(a10), NULL, &err);
|
2013-12-17 20:42:38 +01:00
|
|
|
if (err != NULL) {
|
2015-12-18 16:35:14 +01:00
|
|
|
error_reportf_err(err, "Couldn't realize Allwinner A10: ");
|
2013-12-17 20:42:38 +01:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2020-03-11 23:18:44 +01:00
|
|
|
/* Retrieve SD bus */
|
|
|
|
di = drive_get_next(IF_SD);
|
|
|
|
blk = di ? blk_by_legacy_dinfo(di) : NULL;
|
|
|
|
bus = qdev_get_child_bus(DEVICE(a10), "sd-bus");
|
|
|
|
|
|
|
|
/* Plug in SD card */
|
qdev: Convert uses of qdev_create() with Coccinelle
This is the transformation explained in the commit before previous.
Takes care of just one pattern that needs conversion. More to come in
this series.
Coccinelle script:
@ depends on !(file in "hw/arm/highbank.c")@
expression bus, type_name, dev, expr;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr;
identifier DOWN;
@@
- dev = DOWN(qdev_create(bus, type_name));
+ dev = DOWN(qdev_new(type_name));
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal);
@@
expression bus, type_name, expr;
identifier dev;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr, errp;
symbol true;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
@@
expression bus, type_name, expr, errp;
identifier dev;
symbol true;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
The first rule exempts hw/arm/highbank.c, because it matches along two
control flow paths there, with different @type_name. Covered by the
next commit's manual conversions.
Missing #include "qapi/error.h" added manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-10-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 07:31:58 +02:00
|
|
|
carddev = qdev_new(TYPE_SD_CARD);
|
qdev: Make qdev_prop_set_drive() match the other helpers
qdev_prop_set_drive() can fail. None of the other qdev_prop_set_FOO()
can; they abort on error.
To clean up this inconsistency, rename qdev_prop_set_drive() to
qdev_prop_set_drive_err(), and create a qdev_prop_set_drive() that
aborts on error.
Coccinelle script to update callers:
@ depends on !(file in "hw/core/qdev-properties-system.c")@
expression dev, name, value;
symbol error_abort;
@@
- qdev_prop_set_drive(dev, name, value, &error_abort);
+ qdev_prop_set_drive(dev, name, value);
@@
expression dev, name, value, errp;
@@
- qdev_prop_set_drive(dev, name, value, errp);
+ qdev_prop_set_drive_err(dev, name, value, errp);
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200622094227.1271650-14-armbru@redhat.com>
2020-06-22 11:42:24 +02:00
|
|
|
qdev_prop_set_drive_err(carddev, "drive", blk, &error_fatal);
|
qdev: Convert uses of qdev_create() with Coccinelle
This is the transformation explained in the commit before previous.
Takes care of just one pattern that needs conversion. More to come in
this series.
Coccinelle script:
@ depends on !(file in "hw/arm/highbank.c")@
expression bus, type_name, dev, expr;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr;
identifier DOWN;
@@
- dev = DOWN(qdev_create(bus, type_name));
+ dev = DOWN(qdev_new(type_name));
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal);
@@
expression bus, type_name, expr;
identifier dev;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr, errp;
symbol true;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
@@
expression bus, type_name, expr, errp;
identifier dev;
symbol true;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
The first rule exempts hw/arm/highbank.c, because it matches along two
control flow paths there, with different @type_name. Covered by the
next commit's manual conversions.
Missing #include "qapi/error.h" added manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-10-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 07:31:58 +02:00
|
|
|
qdev_realize_and_unref(carddev, bus, &error_fatal);
|
2020-03-11 23:18:44 +01:00
|
|
|
|
2013-12-17 20:42:38 +01:00
|
|
|
memory_region_add_subregion(get_system_memory(), AW_A10_SDRAM_BASE,
|
2020-02-19 17:08:46 +01:00
|
|
|
machine->ram);
|
2013-12-17 20:42:38 +01:00
|
|
|
|
hw/arm/cubieboard hw/arm/xlnx-ep108: Fix units_per_default_bus
Machine types cubieboard, xlnx-ep108, xlnx-zcu102 have an onboard AHCI
controller, but neglect to set their MachineClass member
units_per_default_bus = 1. This permits -drive if=ide,unit=1, which
makes no sense for AHCI. It also screws up index=N for odd N, because
it gets desugared to unit=1,bus=N/2
Doesn't really matter, because these machine types fail to honor
-drive if=ide. Add the missing units_per_default_bus = 1 anyway,
along with a TODO comment on what needs to be done for -drive if=ide.
Also set block_default_type = IF_IDE explicitly. It's currently the
default, but the next commit will change it to something more
sensible, and we want to keep the IF_IDE default for these three
machines. See also the previous commit.
Cc: Beniamino Galvani <b.galvani@gmail.com>
Cc: Alistair Francis <alistair.francis@xilinx.com>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Alistair Francis <alistair.francis@xilinx.com>
Message-Id: <1487153147-11530-3-git-send-email-armbru@redhat.com>
2017-02-15 11:05:41 +01:00
|
|
|
/* TODO create and connect IDE devices for ide_drive_get() */
|
|
|
|
|
2014-05-07 16:42:57 +02:00
|
|
|
cubieboard_binfo.ram_size = machine->ram_size;
|
2020-02-19 17:08:46 +01:00
|
|
|
arm_load_kernel(&a10->cpu, machine, &cubieboard_binfo);
|
2013-12-17 20:42:38 +01:00
|
|
|
}
|
|
|
|
|
2015-09-04 20:37:08 +02:00
|
|
|
static void cubieboard_machine_init(MachineClass *mc)
|
2013-12-17 20:42:38 +01:00
|
|
|
{
|
2020-03-05 17:09:19 +01:00
|
|
|
mc->desc = "cubietech cubieboard (Cortex-A8)";
|
|
|
|
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a8");
|
2020-03-05 17:09:19 +01:00
|
|
|
mc->default_ram_size = 1 * GiB;
|
2015-09-04 20:37:08 +02:00
|
|
|
mc->init = cubieboard_init;
|
hw/arm/cubieboard hw/arm/xlnx-ep108: Fix units_per_default_bus
Machine types cubieboard, xlnx-ep108, xlnx-zcu102 have an onboard AHCI
controller, but neglect to set their MachineClass member
units_per_default_bus = 1. This permits -drive if=ide,unit=1, which
makes no sense for AHCI. It also screws up index=N for odd N, because
it gets desugared to unit=1,bus=N/2
Doesn't really matter, because these machine types fail to honor
-drive if=ide. Add the missing units_per_default_bus = 1 anyway,
along with a TODO comment on what needs to be done for -drive if=ide.
Also set block_default_type = IF_IDE explicitly. It's currently the
default, but the next commit will change it to something more
sensible, and we want to keep the IF_IDE default for these three
machines. See also the previous commit.
Cc: Beniamino Galvani <b.galvani@gmail.com>
Cc: Alistair Francis <alistair.francis@xilinx.com>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Alistair Francis <alistair.francis@xilinx.com>
Message-Id: <1487153147-11530-3-git-send-email-armbru@redhat.com>
2017-02-15 11:05:41 +01:00
|
|
|
mc->block_default_type = IF_IDE;
|
|
|
|
mc->units_per_default_bus = 1;
|
2017-09-07 14:54:54 +02:00
|
|
|
mc->ignore_memory_transaction_failures = true;
|
2020-02-19 17:08:46 +01:00
|
|
|
mc->default_ram_id = "cubieboard.ram";
|
2013-12-17 20:42:38 +01:00
|
|
|
}
|
|
|
|
|
2015-09-04 20:37:08 +02:00
|
|
|
DEFINE_MACHINE("cubieboard", cubieboard_machine_init)
|