2013-12-17 23:42:36 +04:00
|
|
|
/*
|
|
|
|
* QEMU model of the Canon DIGIC boards (cameras indeed :).
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Antony Pavlov <antonynpavlov@gmail.com>
|
|
|
|
*
|
|
|
|
* This model is based on reverse engineering efforts
|
|
|
|
* made by CHDK (http://chdk.wikia.com) and
|
|
|
|
* Magic Lantern (http://www.magiclantern.fm) projects
|
|
|
|
* contributors.
|
|
|
|
*
|
|
|
|
* See docs here:
|
|
|
|
* http://magiclantern.wikia.com/wiki/Register_Map
|
|
|
|
*
|
|
|
|
* 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 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"
|
2020-10-28 14:36:57 +03:00
|
|
|
#include "qemu/datadir.h"
|
2016-01-19 23:51:44 +03:00
|
|
|
#include "cpu.h"
|
2013-12-17 23:42:36 +04:00
|
|
|
#include "hw/boards.h"
|
|
|
|
#include "exec/address-spaces.h"
|
|
|
|
#include "qemu/error-report.h"
|
|
|
|
#include "hw/arm/digic.h"
|
2013-12-17 23:42:37 +04:00
|
|
|
#include "hw/block/flash.h"
|
|
|
|
#include "hw/loader.h"
|
|
|
|
#include "sysemu/qtest.h"
|
2020-02-19 19:08:47 +03:00
|
|
|
#include "qemu/units.h"
|
|
|
|
#include "qemu/cutils.h"
|
2013-12-17 23:42:37 +04:00
|
|
|
|
|
|
|
#define DIGIC4_ROM0_BASE 0xf0000000
|
|
|
|
#define DIGIC4_ROM1_BASE 0xf8000000
|
|
|
|
#define DIGIC4_ROM_MAX_SIZE 0x08000000
|
2013-12-17 23:42:36 +04:00
|
|
|
|
|
|
|
typedef struct DigicBoard {
|
2020-02-19 19:08:47 +03:00
|
|
|
void (*add_rom0)(DigicState *, hwaddr, const char *);
|
2013-12-17 23:42:37 +04:00
|
|
|
const char *rom0_def_filename;
|
2020-02-19 19:08:47 +03:00
|
|
|
void (*add_rom1)(DigicState *, hwaddr, const char *);
|
2013-12-17 23:42:37 +04:00
|
|
|
const char *rom1_def_filename;
|
2013-12-17 23:42:36 +04:00
|
|
|
} DigicBoard;
|
|
|
|
|
2020-02-19 19:08:47 +03:00
|
|
|
static void digic4_board_init(MachineState *machine, DigicBoard *board)
|
2013-12-17 23:42:36 +04:00
|
|
|
{
|
|
|
|
Error *err = NULL;
|
2020-02-19 19:08:47 +03:00
|
|
|
DigicState *s = DIGIC(object_new(TYPE_DIGIC));
|
|
|
|
MachineClass *mc = MACHINE_GET_CLASS(machine);
|
|
|
|
|
|
|
|
if (machine->ram_size != mc->default_ram_size) {
|
|
|
|
char *sz = size_to_str(mc->default_ram_size);
|
|
|
|
error_report("Invalid RAM size, should be %s", sz);
|
|
|
|
g_free(sz);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2013-12-17 23:42:36 +04:00
|
|
|
|
qdev: Use returned bool to check for qdev_realize() etc. failure
Convert
foo(..., &err);
if (err) {
...
}
to
if (!foo(..., &err)) {
...
}
for qdev_realize(), qdev_realize_and_unref(), qbus_realize() and their
wrappers isa_realize_and_unref(), pci_realize_and_unref(),
sysbus_realize(), sysbus_realize_and_unref(), usb_realize_and_unref().
Coccinelle script:
@@
identifier fun = {
isa_realize_and_unref, pci_realize_and_unref, qbus_realize,
qdev_realize, qdev_realize_and_unref, sysbus_realize,
sysbus_realize_and_unref, usb_realize_and_unref
};
expression list args, args2;
typedef Error;
Error *err;
@@
- fun(args, &err, args2);
- if (err)
+ if (!fun(args, &err, args2))
{
...
}
Chokes on hw/arm/musicpal.c's lcd_refresh() with the unhelpful error
message "no position information". Nothing to convert there; skipped.
Fails to convert hw/arm/armsse.c, because Coccinelle gets confused by
ARMSSE being used both as typedef and function-like macro there.
Converted manually.
A few line breaks tidied up manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <20200707160613.848843-5-armbru@redhat.com>
2020-07-07 19:05:32 +03:00
|
|
|
if (!qdev_realize(DEVICE(s), NULL, &err)) {
|
2015-12-18 18:35:14 +03:00
|
|
|
error_reportf_err(err, "Couldn't realize DIGIC SoC: ");
|
2013-12-17 23:42:36 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2020-02-19 19:08:47 +03:00
|
|
|
memory_region_add_subregion(get_system_memory(), 0, machine->ram);
|
2013-12-17 23:42:37 +04:00
|
|
|
|
|
|
|
if (board->add_rom0) {
|
2020-10-22 17:50:02 +03:00
|
|
|
board->add_rom0(s, DIGIC4_ROM0_BASE,
|
|
|
|
machine->firmware ?: board->rom0_def_filename);
|
2013-12-17 23:42:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (board->add_rom1) {
|
2020-10-22 17:50:02 +03:00
|
|
|
board->add_rom1(s, DIGIC4_ROM1_BASE,
|
|
|
|
machine->firmware ?: board->rom1_def_filename);
|
2013-12-17 23:42:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-19 19:08:47 +03:00
|
|
|
static void digic_load_rom(DigicState *s, hwaddr addr,
|
2020-10-22 17:50:02 +03:00
|
|
|
hwaddr max_size, const char *filename)
|
2013-12-17 23:42:37 +04:00
|
|
|
{
|
|
|
|
target_long rom_size;
|
|
|
|
|
|
|
|
if (qtest_enabled()) {
|
|
|
|
/* qtest runs no code so don't attempt a ROM load which
|
|
|
|
* could fail and result in a spurious test failure.
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filename) {
|
|
|
|
char *fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, filename);
|
|
|
|
|
|
|
|
if (!fn) {
|
2015-02-25 07:22:36 +03:00
|
|
|
error_report("Couldn't find rom image '%s'.", filename);
|
2013-12-17 23:42:37 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
rom_size = load_image_targphys(fn, addr, max_size);
|
|
|
|
if (rom_size < 0 || rom_size > max_size) {
|
2015-02-25 07:22:36 +03:00
|
|
|
error_report("Couldn't load rom image '%s'.", filename);
|
2013-12-17 23:42:37 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
2015-03-05 05:58:32 +03:00
|
|
|
g_free(fn);
|
2013-12-17 23:42:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Samsung K8P3215UQB
|
|
|
|
* 64M Bit (4Mx16) Page Mode / Multi-Bank NOR Flash Memory
|
|
|
|
*/
|
2020-02-19 19:08:47 +03:00
|
|
|
static void digic4_add_k8p3215uqb_rom(DigicState *s, hwaddr addr,
|
2020-10-22 17:50:02 +03:00
|
|
|
const char *filename)
|
2013-12-17 23:42:37 +04:00
|
|
|
{
|
|
|
|
#define FLASH_K8P3215UQB_SIZE (4 * 1024 * 1024)
|
|
|
|
#define FLASH_K8P3215UQB_SECTOR_SIZE (64 * 1024)
|
|
|
|
|
2019-03-08 12:46:09 +03:00
|
|
|
pflash_cfi02_register(addr, "pflash", FLASH_K8P3215UQB_SIZE,
|
2013-12-17 23:42:37 +04:00
|
|
|
NULL, FLASH_K8P3215UQB_SECTOR_SIZE,
|
|
|
|
DIGIC4_ROM_MAX_SIZE / FLASH_K8P3215UQB_SIZE,
|
|
|
|
4,
|
|
|
|
0x00EC, 0x007E, 0x0003, 0x0001,
|
|
|
|
0x0555, 0x2aa, 0);
|
|
|
|
|
2020-10-22 17:50:02 +03:00
|
|
|
digic_load_rom(s, addr, FLASH_K8P3215UQB_SIZE, filename);
|
2013-12-17 23:42:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static DigicBoard digic4_board_canon_a1100 = {
|
2013-12-17 23:42:37 +04:00
|
|
|
.add_rom1 = digic4_add_k8p3215uqb_rom,
|
|
|
|
.rom1_def_filename = "canon-a1100-rom1.bin",
|
2013-12-17 23:42:36 +04:00
|
|
|
};
|
|
|
|
|
2014-05-07 18:42:57 +04:00
|
|
|
static void canon_a1100_init(MachineState *machine)
|
2013-12-17 23:42:36 +04:00
|
|
|
{
|
2020-02-19 19:08:47 +03:00
|
|
|
digic4_board_init(machine, &digic4_board_canon_a1100);
|
2013-12-17 23:42:36 +04:00
|
|
|
}
|
|
|
|
|
2015-09-04 21:37:08 +03:00
|
|
|
static void canon_a1100_machine_init(MachineClass *mc)
|
2013-12-17 23:42:36 +04:00
|
|
|
{
|
2021-01-31 21:44:49 +03:00
|
|
|
mc->desc = "Canon PowerShot A1100 IS (ARM946)";
|
2015-09-04 21:37:08 +03:00
|
|
|
mc->init = &canon_a1100_init;
|
2017-09-07 15:54:54 +03:00
|
|
|
mc->ignore_memory_transaction_failures = true;
|
2020-02-19 19:08:47 +03:00
|
|
|
mc->default_ram_size = 64 * MiB;
|
|
|
|
mc->default_ram_id = "ram";
|
2013-12-17 23:42:36 +04:00
|
|
|
}
|
|
|
|
|
2015-09-04 21:37:08 +03:00
|
|
|
DEFINE_MACHINE("canon-a1100", canon_a1100_machine_init)
|