2007-09-29 23:24:41 +04:00
|
|
|
/*
|
|
|
|
* Renesas SH7751R R2D-PLUS emulation
|
|
|
|
*
|
|
|
|
* Copyright (c) 2007 Magnus Damm
|
2008-09-02 20:18:38 +04:00
|
|
|
* Copyright (c) 2008 Paul Mundt
|
2007-09-29 23:24:41 +04:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2016-01-26 21:17:20 +03:00
|
|
|
#include "qemu/osdep.h"
|
2018-06-25 15:42:20 +03:00
|
|
|
#include "qemu/units.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"
|
2021-10-30 00:02:09 +03:00
|
|
|
#include "qemu/error-report.h"
|
2016-01-19 23:51:44 +03:00
|
|
|
#include "cpu.h"
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/sysbus.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/sh4/sh.h"
|
2019-08-12 08:23:38 +03:00
|
|
|
#include "sysemu/reset.h"
|
2019-08-12 08:23:59 +03:00
|
|
|
#include "sysemu/runstate.h"
|
2012-12-17 21:20:04 +04:00
|
|
|
#include "sysemu/sysemu.h"
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/boards.h"
|
|
|
|
#include "hw/pci/pci.h"
|
2019-08-12 08:23:51 +03:00
|
|
|
#include "hw/qdev-properties.h"
|
2012-10-24 10:43:34 +04:00
|
|
|
#include "net/net.h"
|
2013-03-18 20:36:02 +04:00
|
|
|
#include "sh7750_regs.h"
|
2023-02-10 01:24:42 +03:00
|
|
|
#include "hw/ide/mmio.h"
|
2019-08-12 08:23:42 +03:00
|
|
|
#include "hw/irq.h"
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/loader.h"
|
|
|
|
#include "hw/usb.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/block/flash.h"
|
2010-04-11 05:58:19 +04:00
|
|
|
|
|
|
|
#define FLASH_BASE 0x00000000
|
r2d: Fix flash memory size, sector size, width, device ID
pflash_cfi02_register() takes a size in bytes, a block size in bytes
and a number of blocks. r2d_init() passes FLASH_SIZE, 16 * KiB,
FLASH_SIZE >> 16. Does not compute: size doesn't match block size *
number of blocks. The latter happens to win: FLASH_SIZE / 4,
i.e. 8MiB.
The best information we have on the physical hardware lists a Cypress
S29PL127J60TFI130 128MiBit NOR flash addressable in words of 16 bits,
in sectors of 4 and 32 Kibiwords. We don't model multiple sector
sizes.
Fix the flash size from 8 to 16MiB, and adjust the sector size from 16
to 64KiB. Fix the width from 4 to 2. While there, supply the real
device IDs 0x0001, 0x227e, 0x2220, 0x2200 instead of zeros.
Cc: Magnus Damm <magnus.damm@gmail.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190308094610.21210-10-armbru@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
2019-03-08 12:46:04 +03:00
|
|
|
#define FLASH_SIZE (16 * MiB)
|
2007-09-29 23:24:41 +04:00
|
|
|
|
|
|
|
#define SDRAM_BASE 0x0c000000 /* Physical location of SDRAM: Area 3 */
|
|
|
|
#define SDRAM_SIZE 0x04000000
|
|
|
|
|
2008-11-05 23:24:35 +03:00
|
|
|
#define SM501_VRAM_SIZE 0x800000
|
|
|
|
|
2010-04-11 21:20:32 +04:00
|
|
|
#define BOOT_PARAMS_OFFSET 0x0010000
|
2009-03-29 03:14:32 +04:00
|
|
|
/* CONFIG_BOOT_LINK_OFFSET of Linux kernel */
|
2010-04-11 21:20:32 +04:00
|
|
|
#define LINUX_LOAD_OFFSET 0x0800000
|
|
|
|
#define INITRD_LOAD_OFFSET 0x1800000
|
2009-03-29 03:14:32 +04:00
|
|
|
|
2021-10-30 00:02:09 +03:00
|
|
|
#define PA_IRLMSK 0x00
|
|
|
|
#define PA_POWOFF 0x30
|
|
|
|
#define PA_VERREG 0x32
|
|
|
|
#define PA_OUTPORT 0x36
|
2008-09-02 20:18:38 +04:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint16_t bcr;
|
2008-12-07 21:59:57 +03:00
|
|
|
uint16_t irlmsk;
|
2008-09-02 20:18:38 +04:00
|
|
|
uint16_t irlmon;
|
|
|
|
uint16_t cfctl;
|
|
|
|
uint16_t cfpow;
|
|
|
|
uint16_t dispctl;
|
|
|
|
uint16_t sdmpow;
|
|
|
|
uint16_t rtcce;
|
|
|
|
uint16_t pcicd;
|
|
|
|
uint16_t voyagerrts;
|
|
|
|
uint16_t cfrst;
|
|
|
|
uint16_t admrts;
|
|
|
|
uint16_t extrst;
|
|
|
|
uint16_t cfcdintclr;
|
|
|
|
uint16_t keyctlclr;
|
|
|
|
uint16_t pad0;
|
|
|
|
uint16_t pad1;
|
|
|
|
uint16_t verreg;
|
|
|
|
uint16_t inport;
|
|
|
|
uint16_t outport;
|
|
|
|
uint16_t bverreg;
|
2008-12-07 21:59:57 +03:00
|
|
|
|
|
|
|
/* output pin */
|
|
|
|
qemu_irq irl;
|
2011-10-02 18:48:42 +04:00
|
|
|
MemoryRegion iomem;
|
2009-10-02 01:12:16 +04:00
|
|
|
} r2d_fpga_t;
|
2008-09-02 20:18:38 +04:00
|
|
|
|
2008-12-07 21:59:57 +03:00
|
|
|
enum r2d_fpga_irq {
|
|
|
|
PCI_INTD, CF_IDE, CF_CD, PCI_INTC, SM501, KEY, RTC_A, RTC_T,
|
|
|
|
SDCARD, PCI_INTA, PCI_INTB, EXT, TP,
|
|
|
|
NR_IRQS
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct { short irl; uint16_t msk; } irqtab[NR_IRQS] = {
|
2021-10-30 00:02:09 +03:00
|
|
|
[CF_IDE] = { 1, 1 << 9 },
|
|
|
|
[CF_CD] = { 2, 1 << 8 },
|
|
|
|
[PCI_INTA] = { 9, 1 << 14 },
|
|
|
|
[PCI_INTB] = { 10, 1 << 13 },
|
|
|
|
[PCI_INTC] = { 3, 1 << 12 },
|
|
|
|
[PCI_INTD] = { 0, 1 << 11 },
|
|
|
|
[SM501] = { 4, 1 << 10 },
|
|
|
|
[KEY] = { 5, 1 << 6 },
|
|
|
|
[RTC_A] = { 6, 1 << 5 },
|
|
|
|
[RTC_T] = { 7, 1 << 4 },
|
|
|
|
[SDCARD] = { 8, 1 << 7 },
|
|
|
|
[EXT] = { 11, 1 << 0 },
|
|
|
|
[TP] = { 12, 1 << 15 },
|
2008-12-07 21:59:57 +03:00
|
|
|
};
|
|
|
|
|
2009-10-02 01:12:16 +04:00
|
|
|
static void update_irl(r2d_fpga_t *fpga)
|
2008-12-07 21:59:57 +03:00
|
|
|
{
|
|
|
|
int i, irl = 15;
|
2021-10-30 00:02:09 +03:00
|
|
|
for (i = 0; i < NR_IRQS; i++) {
|
|
|
|
if ((fpga->irlmon & fpga->irlmsk & irqtab[i].msk) &&
|
|
|
|
irqtab[i].irl < irl) {
|
|
|
|
irl = irqtab[i].irl;
|
|
|
|
}
|
|
|
|
}
|
2008-12-07 21:59:57 +03:00
|
|
|
qemu_set_irq(fpga->irl, irl ^ 15);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void r2d_fpga_irq_set(void *opaque, int n, int level)
|
|
|
|
{
|
2009-10-02 01:12:16 +04:00
|
|
|
r2d_fpga_t *fpga = opaque;
|
2021-10-30 00:02:09 +03:00
|
|
|
if (level) {
|
2008-12-07 21:59:57 +03:00
|
|
|
fpga->irlmon |= irqtab[n].msk;
|
2021-10-30 00:02:09 +03:00
|
|
|
} else {
|
2008-12-07 21:59:57 +03:00
|
|
|
fpga->irlmon &= ~irqtab[n].msk;
|
2021-10-30 00:02:09 +03:00
|
|
|
}
|
2008-12-07 21:59:57 +03:00
|
|
|
update_irl(fpga);
|
|
|
|
}
|
|
|
|
|
2015-06-04 00:16:43 +03:00
|
|
|
static uint64_t r2d_fpga_read(void *opaque, hwaddr addr, unsigned int size)
|
2008-09-02 20:18:38 +04:00
|
|
|
{
|
2009-10-02 01:12:16 +04:00
|
|
|
r2d_fpga_t *s = opaque;
|
2008-09-02 20:18:38 +04:00
|
|
|
|
|
|
|
switch (addr) {
|
2008-12-07 21:59:57 +03:00
|
|
|
case PA_IRLMSK:
|
|
|
|
return s->irlmsk;
|
2008-09-02 20:18:38 +04:00
|
|
|
case PA_OUTPORT:
|
2018-12-14 01:37:37 +03:00
|
|
|
return s->outport;
|
2008-09-02 20:18:38 +04:00
|
|
|
case PA_POWOFF:
|
2018-12-14 01:37:37 +03:00
|
|
|
return 0x00;
|
2008-09-02 20:18:38 +04:00
|
|
|
case PA_VERREG:
|
2018-12-14 01:37:37 +03:00
|
|
|
return 0x10;
|
2008-09-02 20:18:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-06-04 00:16:43 +03:00
|
|
|
r2d_fpga_write(void *opaque, hwaddr addr, uint64_t value, unsigned int size)
|
2008-09-02 20:18:38 +04:00
|
|
|
{
|
2009-10-02 01:12:16 +04:00
|
|
|
r2d_fpga_t *s = opaque;
|
2008-09-02 20:18:38 +04:00
|
|
|
|
|
|
|
switch (addr) {
|
2008-12-07 21:59:57 +03:00
|
|
|
case PA_IRLMSK:
|
|
|
|
s->irlmsk = value;
|
|
|
|
update_irl(s);
|
2018-12-14 01:37:37 +03:00
|
|
|
break;
|
2008-09-02 20:18:38 +04:00
|
|
|
case PA_OUTPORT:
|
2018-12-14 01:37:37 +03:00
|
|
|
s->outport = value;
|
|
|
|
break;
|
2008-09-02 20:18:38 +04:00
|
|
|
case PA_POWOFF:
|
2010-01-30 22:41:33 +03:00
|
|
|
if (value & 1) {
|
2017-05-16 00:41:13 +03:00
|
|
|
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
|
2010-01-30 22:41:33 +03:00
|
|
|
}
|
|
|
|
break;
|
2008-09-02 20:18:38 +04:00
|
|
|
case PA_VERREG:
|
2018-12-14 01:37:37 +03:00
|
|
|
/* Discard writes */
|
|
|
|
break;
|
2008-09-02 20:18:38 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-02 18:48:42 +04:00
|
|
|
static const MemoryRegionOps r2d_fpga_ops = {
|
2015-06-04 00:16:43 +03:00
|
|
|
.read = r2d_fpga_read,
|
|
|
|
.write = r2d_fpga_write,
|
|
|
|
.impl.min_access_size = 2,
|
|
|
|
.impl.max_access_size = 2,
|
2011-10-02 18:48:42 +04:00
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
2008-09-02 20:18:38 +04:00
|
|
|
};
|
|
|
|
|
2011-10-02 18:48:42 +04:00
|
|
|
static qemu_irq *r2d_fpga_init(MemoryRegion *sysmem,
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr base, qemu_irq irl)
|
2008-09-02 20:18:38 +04:00
|
|
|
{
|
2009-10-02 01:12:16 +04:00
|
|
|
r2d_fpga_t *s;
|
2008-09-02 20:18:38 +04:00
|
|
|
|
2022-03-15 17:41:56 +03:00
|
|
|
s = g_new0(r2d_fpga_t, 1);
|
2008-12-07 21:59:57 +03:00
|
|
|
|
|
|
|
s->irl = irl;
|
2008-09-02 20:18:38 +04:00
|
|
|
|
2013-06-06 13:41:28 +04:00
|
|
|
memory_region_init_io(&s->iomem, NULL, &r2d_fpga_ops, s, "r2d-fpga", 0x40);
|
2011-10-02 18:48:42 +04:00
|
|
|
memory_region_add_subregion(sysmem, base, &s->iomem);
|
2008-12-07 21:59:57 +03:00
|
|
|
return qemu_allocate_irqs(r2d_fpga_irq_set, s, NR_IRQS);
|
2008-09-02 20:18:38 +04:00
|
|
|
}
|
|
|
|
|
2011-01-14 22:39:18 +03:00
|
|
|
typedef struct ResetData {
|
2012-05-04 20:40:14 +04:00
|
|
|
SuperHCPU *cpu;
|
2011-01-14 22:39:18 +03:00
|
|
|
uint32_t vector;
|
|
|
|
} ResetData;
|
|
|
|
|
|
|
|
static void main_cpu_reset(void *opaque)
|
|
|
|
{
|
|
|
|
ResetData *s = (ResetData *)opaque;
|
2012-05-04 20:40:14 +04:00
|
|
|
CPUSH4State *env = &s->cpu->env;
|
2011-01-14 22:39:18 +03:00
|
|
|
|
2012-05-04 20:40:14 +04:00
|
|
|
cpu_reset(CPU(s->cpu));
|
2011-01-14 22:39:18 +03:00
|
|
|
env->pc = s->vector;
|
|
|
|
}
|
|
|
|
|
2011-08-31 14:38:01 +04:00
|
|
|
static struct QEMU_PACKED
|
2010-04-11 21:20:32 +04:00
|
|
|
{
|
|
|
|
int mount_root_rdonly;
|
|
|
|
int ramdisk_flags;
|
|
|
|
int orig_root_dev;
|
|
|
|
int loader_type;
|
|
|
|
int initrd_start;
|
|
|
|
int initrd_size;
|
|
|
|
|
|
|
|
char pad[232];
|
|
|
|
|
2019-02-02 01:57:42 +03:00
|
|
|
char kernel_cmdline[256] QEMU_NONSTRING;
|
2010-04-11 21:20:32 +04:00
|
|
|
} boot_params;
|
|
|
|
|
2014-05-07 18:42:57 +04:00
|
|
|
static void r2d_init(MachineState *machine)
|
2007-09-29 23:24:41 +04:00
|
|
|
{
|
2014-05-07 18:42:57 +04:00
|
|
|
const char *kernel_filename = machine->kernel_filename;
|
|
|
|
const char *kernel_cmdline = machine->kernel_cmdline;
|
|
|
|
const char *initrd_filename = machine->initrd_filename;
|
2023-05-11 19:30:21 +03:00
|
|
|
MachineClass *mc = MACHINE_GET_CLASS(machine);
|
2012-05-04 20:38:01 +04:00
|
|
|
SuperHCPU *cpu;
|
2012-03-14 04:38:23 +04:00
|
|
|
CPUSH4State *env;
|
2011-01-14 22:39:18 +03:00
|
|
|
ResetData *reset_info;
|
2007-09-29 23:24:41 +04:00
|
|
|
struct SH7750State *s;
|
2011-10-02 18:48:42 +04:00
|
|
|
MemoryRegion *sdram = g_new(MemoryRegion, 1);
|
2008-12-07 21:59:57 +03:00
|
|
|
qemu_irq *irq;
|
2009-07-22 18:42:57 +04:00
|
|
|
DriveInfo *dinfo;
|
2011-12-17 02:37:46 +04:00
|
|
|
DeviceState *dev;
|
|
|
|
SysBusDevice *busdev;
|
2011-08-12 03:07:20 +04:00
|
|
|
MemoryRegion *address_space_mem = get_system_memory();
|
2013-06-06 12:48:51 +04:00
|
|
|
PCIBus *pci_bus;
|
2007-09-29 23:24:41 +04:00
|
|
|
|
2017-10-05 16:50:53 +03:00
|
|
|
cpu = SUPERH_CPU(cpu_create(machine->cpu_type));
|
2012-05-04 20:38:01 +04:00
|
|
|
env = &cpu->env;
|
|
|
|
|
2022-03-15 17:41:56 +03:00
|
|
|
reset_info = g_new0(ResetData, 1);
|
2012-05-04 20:40:14 +04:00
|
|
|
reset_info->cpu = cpu;
|
2011-01-14 22:39:18 +03:00
|
|
|
reset_info->vector = env->pc;
|
|
|
|
qemu_register_reset(main_cpu_reset, reset_info);
|
2007-09-29 23:24:41 +04:00
|
|
|
|
|
|
|
/* Allocate memory space */
|
2017-07-07 17:42:53 +03:00
|
|
|
memory_region_init_ram(sdram, NULL, "r2d.sdram", SDRAM_SIZE, &error_fatal);
|
2011-10-02 18:48:42 +04:00
|
|
|
memory_region_add_subregion(address_space_mem, SDRAM_BASE, sdram);
|
2007-09-29 23:24:41 +04:00
|
|
|
/* Register peripherals */
|
2013-04-09 18:51:24 +04:00
|
|
|
s = sh7750_init(cpu, address_space_mem);
|
2011-10-02 18:48:42 +04:00
|
|
|
irq = r2d_fpga_init(address_space_mem, 0x04000000, sh7750_irl(s));
|
2011-12-17 02:37:46 +04:00
|
|
|
|
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 08:31:58 +03:00
|
|
|
dev = qdev_new("sh_pci");
|
2013-01-20 05:47:33 +04:00
|
|
|
busdev = SYS_BUS_DEVICE(dev);
|
sysbus: Convert to sysbus_realize() etc. with Coccinelle
Convert from qdev_realize(), qdev_realize_and_unref() with null @bus
argument to sysbus_realize(), sysbus_realize_and_unref().
Coccinelle script:
@@
expression dev, errp;
@@
- qdev_realize(DEVICE(dev), NULL, errp);
+ sysbus_realize(SYS_BUS_DEVICE(dev), errp);
@@
expression sysbus_dev, dev, errp;
@@
+ sysbus_dev = SYS_BUS_DEVICE(dev);
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
- sysbus_dev = SYS_BUS_DEVICE(dev);
@@
expression sysbus_dev, dev, errp;
expression expr;
@@
sysbus_dev = SYS_BUS_DEVICE(dev);
... when != dev = expr;
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(DEVICE(dev), NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
Whitespace changes minimized manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-46-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 08:32:34 +03:00
|
|
|
sysbus_realize_and_unref(busdev, &error_fatal);
|
2013-06-06 12:48:51 +04:00
|
|
|
pci_bus = PCI_BUS(qdev_get_child_bus(dev, "pci"));
|
2011-12-17 02:37:46 +04:00
|
|
|
sysbus_mmio_map(busdev, 0, P4ADDR(0x1e200000));
|
|
|
|
sysbus_mmio_map(busdev, 1, A7ADDR(0x1e200000));
|
|
|
|
sysbus_connect_irq(busdev, 0, irq[PCI_INTA]);
|
|
|
|
sysbus_connect_irq(busdev, 1, irq[PCI_INTB]);
|
|
|
|
sysbus_connect_irq(busdev, 2, irq[PCI_INTC]);
|
|
|
|
sysbus_connect_irq(busdev, 3, irq[PCI_INTD]);
|
2008-12-07 21:59:57 +03:00
|
|
|
|
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 08:31:58 +03:00
|
|
|
dev = qdev_new("sysbus-sm501");
|
2017-04-21 18:18:09 +03:00
|
|
|
busdev = SYS_BUS_DEVICE(dev);
|
|
|
|
qdev_prop_set_uint32(dev, "vram-size", SM501_VRAM_SIZE);
|
2023-02-03 17:31:52 +03:00
|
|
|
qdev_prop_set_uint64(dev, "dma-offset", 0x10000000);
|
2019-10-23 17:06:23 +03:00
|
|
|
qdev_prop_set_chr(dev, "chardev", serial_hd(2));
|
sysbus: Convert to sysbus_realize() etc. with Coccinelle
Convert from qdev_realize(), qdev_realize_and_unref() with null @bus
argument to sysbus_realize(), sysbus_realize_and_unref().
Coccinelle script:
@@
expression dev, errp;
@@
- qdev_realize(DEVICE(dev), NULL, errp);
+ sysbus_realize(SYS_BUS_DEVICE(dev), errp);
@@
expression sysbus_dev, dev, errp;
@@
+ sysbus_dev = SYS_BUS_DEVICE(dev);
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
- sysbus_dev = SYS_BUS_DEVICE(dev);
@@
expression sysbus_dev, dev, errp;
expression expr;
@@
sysbus_dev = SYS_BUS_DEVICE(dev);
... when != dev = expr;
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(DEVICE(dev), NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
Whitespace changes minimized manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-46-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 08:32:34 +03:00
|
|
|
sysbus_realize_and_unref(busdev, &error_fatal);
|
2017-04-21 18:18:09 +03:00
|
|
|
sysbus_mmio_map(busdev, 0, 0x10000000);
|
|
|
|
sysbus_mmio_map(busdev, 1, 0x13e00000);
|
|
|
|
sysbus_connect_irq(busdev, 0, irq[SM501]);
|
2008-12-07 21:41:42 +03:00
|
|
|
|
|
|
|
/* onboard CF (True IDE mode, Master only). */
|
2010-04-12 00:27:23 +04:00
|
|
|
dinfo = drive_get(IF_IDE, 0, 0);
|
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 08:31:58 +03:00
|
|
|
dev = qdev_new("mmio-ide");
|
2013-02-01 03:13:41 +04:00
|
|
|
busdev = SYS_BUS_DEVICE(dev);
|
|
|
|
sysbus_connect_irq(busdev, 0, irq[CF_IDE]);
|
|
|
|
qdev_prop_set_uint32(dev, "shift", 1);
|
sysbus: Convert to sysbus_realize() etc. with Coccinelle
Convert from qdev_realize(), qdev_realize_and_unref() with null @bus
argument to sysbus_realize(), sysbus_realize_and_unref().
Coccinelle script:
@@
expression dev, errp;
@@
- qdev_realize(DEVICE(dev), NULL, errp);
+ sysbus_realize(SYS_BUS_DEVICE(dev), errp);
@@
expression sysbus_dev, dev, errp;
@@
+ sysbus_dev = SYS_BUS_DEVICE(dev);
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
- sysbus_dev = SYS_BUS_DEVICE(dev);
@@
expression sysbus_dev, dev, errp;
expression expr;
@@
sysbus_dev = SYS_BUS_DEVICE(dev);
... when != dev = expr;
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(DEVICE(dev), NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
Whitespace changes minimized manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-46-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 08:32:34 +03:00
|
|
|
sysbus_realize_and_unref(busdev, &error_fatal);
|
2013-02-01 03:13:41 +04:00
|
|
|
sysbus_mmio_map(busdev, 0, 0x14001000);
|
|
|
|
sysbus_mmio_map(busdev, 1, 0x1400080c);
|
|
|
|
mmio_ide_init_drives(dev, dinfo, NULL);
|
2008-12-07 21:41:42 +03:00
|
|
|
|
r2d: Fix flash memory size, sector size, width, device ID
pflash_cfi02_register() takes a size in bytes, a block size in bytes
and a number of blocks. r2d_init() passes FLASH_SIZE, 16 * KiB,
FLASH_SIZE >> 16. Does not compute: size doesn't match block size *
number of blocks. The latter happens to win: FLASH_SIZE / 4,
i.e. 8MiB.
The best information we have on the physical hardware lists a Cypress
S29PL127J60TFI130 128MiBit NOR flash addressable in words of 16 bits,
in sectors of 4 and 32 Kibiwords. We don't model multiple sector
sizes.
Fix the flash size from 8 to 16MiB, and adjust the sector size from 16
to 64KiB. Fix the width from 4 to 2. While there, supply the real
device IDs 0x0001, 0x227e, 0x2220, 0x2200 instead of zeros.
Cc: Magnus Damm <magnus.damm@gmail.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190308094610.21210-10-armbru@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
2019-03-08 12:46:04 +03:00
|
|
|
/*
|
|
|
|
* Onboard flash memory
|
|
|
|
* According to the old board user document in Japanese (under
|
|
|
|
* NDA) what is referred to as FROM (Area0) is connected via a
|
|
|
|
* 32-bit bus and CS0 to CN8. The docs mention a Cypress
|
|
|
|
* S29PL127J60TFI130 chipsset. Per the 'S29PL-J 002-00615
|
|
|
|
* Rev. *E' datasheet, it is a 128Mbit NOR parallel flash
|
|
|
|
* addressable in words of 16bit.
|
|
|
|
*/
|
2010-06-18 00:19:53 +04:00
|
|
|
dinfo = drive_get(IF_PFLASH, 0, 0);
|
2019-03-08 12:46:09 +03:00
|
|
|
pflash_cfi02_register(0x0, "r2d.flash", FLASH_SIZE,
|
2014-10-07 15:59:18 +04:00
|
|
|
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
|
2019-03-08 12:46:10 +03:00
|
|
|
64 * KiB, 1, 2, 0x0001, 0x227e, 0x2220, 0x2200,
|
2011-08-25 23:39:18 +04:00
|
|
|
0x555, 0x2aa, 0);
|
2010-04-11 05:58:19 +04:00
|
|
|
|
2008-12-07 22:20:43 +03:00
|
|
|
/* NIC: rtl8139 on-board, and 2 slots. */
|
2023-10-23 11:37:23 +03:00
|
|
|
pci_init_nic_in_slot(pci_bus, mc->default_nic, NULL, "2");
|
|
|
|
pci_init_nic_devices(pci_bus, mc->default_nic);
|
2008-12-07 22:20:43 +03:00
|
|
|
|
2010-04-02 14:16:04 +04:00
|
|
|
/* USB keyboard */
|
2015-02-04 15:28:13 +03:00
|
|
|
usb_create_simple(usb_bus_find(-1), "usb-kbd");
|
2010-04-02 14:16:04 +04:00
|
|
|
|
2007-09-29 23:24:41 +04:00
|
|
|
/* Todo: register on board registers */
|
2010-04-11 21:20:32 +04:00
|
|
|
memset(&boot_params, 0, sizeof(boot_params));
|
|
|
|
|
2009-03-29 03:14:32 +04:00
|
|
|
if (kernel_filename) {
|
2010-04-11 21:20:32 +04:00
|
|
|
int kernel_size;
|
|
|
|
|
|
|
|
kernel_size = load_image_targphys(kernel_filename,
|
|
|
|
SDRAM_BASE + LINUX_LOAD_OFFSET,
|
|
|
|
INITRD_LOAD_OFFSET - LINUX_LOAD_OFFSET);
|
|
|
|
if (kernel_size < 0) {
|
2021-10-30 00:02:09 +03:00
|
|
|
error_report("qemu: could not load kernel '%s'", kernel_filename);
|
2021-10-30 00:02:09 +03:00
|
|
|
exit(1);
|
2010-04-11 21:20:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* initialization which should be done by firmware */
|
Switch non-CPU callers from ld/st*_phys to address_space_ld/st*
Switch all the uses of ld/st*_phys to address_space_ld/st*,
except for those cases where the address space is the CPU's
(ie cs->as). This was done with the following script which
generates a Coccinelle patch.
A few over-80-columns lines in the result were rewrapped by
hand where Coccinelle failed to do the wrapping automatically,
as well as one location where it didn't put a line-continuation
'\' when wrapping lines on a change made to a match inside
a macro definition.
===begin===
#!/bin/sh -e
# Usage:
# ./ldst-phys.spatch.sh > ldst-phys.spatch
# spatch -sp_file ldst-phys.spatch -dir . | sed -e '/^+/s/\t/ /g' > out.patch
# patch -p1 < out.patch
for FN in ub uw_le uw_be l_le l_be q_le q_be uw l q; do
cat <<EOF
@ cpu_matches_ld_${FN} @
expression E1,E2;
identifier as;
@@
ld${FN}_phys(E1->as,E2)
@ other_matches_ld_${FN} depends on !cpu_matches_ld_${FN} @
expression E1,E2;
@@
-ld${FN}_phys(E1,E2)
+address_space_ld${FN}(E1,E2, MEMTXATTRS_UNSPECIFIED, NULL)
EOF
done
for FN in b w_le w_be l_le l_be q_le q_be w l q; do
cat <<EOF
@ cpu_matches_st_${FN} @
expression E1,E2,E3;
identifier as;
@@
st${FN}_phys(E1->as,E2,E3)
@ other_matches_st_${FN} depends on !cpu_matches_st_${FN} @
expression E1,E2,E3;
@@
-st${FN}_phys(E1,E2,E3)
+address_space_st${FN}(E1,E2,E3, MEMTXATTRS_UNSPECIFIED, NULL)
EOF
done
===endit===
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
2015-04-26 18:49:24 +03:00
|
|
|
address_space_stl(&address_space_memory, SH7750_BCR1, 1 << 3,
|
|
|
|
MEMTXATTRS_UNSPECIFIED, NULL); /* cs3 SDRAM */
|
|
|
|
address_space_stw(&address_space_memory, SH7750_BCR2, 3 << (3 * 2),
|
|
|
|
MEMTXATTRS_UNSPECIFIED, NULL); /* cs3 32bit */
|
2021-10-30 00:02:09 +03:00
|
|
|
/* Start from P2 area */
|
|
|
|
reset_info->vector = (SDRAM_BASE + LINUX_LOAD_OFFSET) | 0xa0000000;
|
2007-09-29 23:24:41 +04:00
|
|
|
}
|
2010-04-11 21:20:32 +04:00
|
|
|
|
|
|
|
if (initrd_filename) {
|
|
|
|
int initrd_size;
|
|
|
|
|
|
|
|
initrd_size = load_image_targphys(initrd_filename,
|
|
|
|
SDRAM_BASE + INITRD_LOAD_OFFSET,
|
|
|
|
SDRAM_SIZE - INITRD_LOAD_OFFSET);
|
|
|
|
|
|
|
|
if (initrd_size < 0) {
|
2021-10-30 00:02:09 +03:00
|
|
|
error_report("qemu: could not load initrd '%s'", initrd_filename);
|
2021-10-30 00:02:09 +03:00
|
|
|
exit(1);
|
2010-04-11 21:20:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* initialization which should be done by firmware */
|
2015-08-12 17:20:36 +03:00
|
|
|
boot_params.loader_type = tswap32(1);
|
|
|
|
boot_params.initrd_start = tswap32(INITRD_LOAD_OFFSET);
|
|
|
|
boot_params.initrd_size = tswap32(initrd_size);
|
2010-04-11 21:20:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (kernel_cmdline) {
|
2021-10-30 00:02:09 +03:00
|
|
|
/*
|
|
|
|
* I see no evidence that this .kernel_cmdline buffer requires
|
|
|
|
* NUL-termination, so using strncpy should be ok.
|
|
|
|
*/
|
2010-04-11 21:20:32 +04:00
|
|
|
strncpy(boot_params.kernel_cmdline, kernel_cmdline,
|
|
|
|
sizeof(boot_params.kernel_cmdline));
|
|
|
|
}
|
|
|
|
|
|
|
|
rom_add_blob_fixed("boot_params", &boot_params, sizeof(boot_params),
|
|
|
|
SDRAM_BASE + BOOT_PARAMS_OFFSET);
|
2007-09-29 23:24:41 +04:00
|
|
|
}
|
|
|
|
|
2015-09-04 21:37:08 +03:00
|
|
|
static void r2d_machine_init(MachineClass *mc)
|
2009-05-21 03:38:09 +04:00
|
|
|
{
|
2015-09-04 21:37:08 +03:00
|
|
|
mc->desc = "r2d-plus board";
|
|
|
|
mc->init = r2d_init;
|
2017-02-15 13:05:40 +03:00
|
|
|
mc->block_default_type = IF_IDE;
|
2017-10-05 16:50:53 +03:00
|
|
|
mc->default_cpu_type = TYPE_SH7751R_CPU;
|
2023-05-11 19:30:21 +03:00
|
|
|
mc->default_nic = "rtl8139";
|
2009-05-21 03:38:09 +04:00
|
|
|
}
|
|
|
|
|
2015-09-04 21:37:08 +03:00
|
|
|
DEFINE_MACHINE("r2d", r2d_machine_init)
|