2018-03-02 11:45:40 +01:00
|
|
|
/*
|
2019-02-01 15:55:41 +01:00
|
|
|
* Arm SSE (Subsystems for Embedded): IoTKit
|
2018-03-02 11:45:40 +01:00
|
|
|
*
|
|
|
|
* Copyright (c) 2018 Linaro Limited
|
|
|
|
* Written by Peter Maydell
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "qemu/osdep.h"
|
|
|
|
#include "qemu/log.h"
|
2019-05-23 16:35:07 +02:00
|
|
|
#include "qemu/module.h"
|
2019-02-28 11:55:16 +01:00
|
|
|
#include "qemu/bitops.h"
|
2021-05-10 21:08:44 +02:00
|
|
|
#include "qemu/units.h"
|
2018-03-02 11:45:40 +01:00
|
|
|
#include "qapi/error.h"
|
|
|
|
#include "trace.h"
|
|
|
|
#include "hw/sysbus.h"
|
2019-08-12 07:23:45 +02:00
|
|
|
#include "migration/vmstate.h"
|
2018-03-02 11:45:40 +01:00
|
|
|
#include "hw/registerfields.h"
|
2019-02-01 15:55:42 +01:00
|
|
|
#include "hw/arm/armsse.h"
|
2021-02-19 15:45:38 +01:00
|
|
|
#include "hw/arm/armsse-version.h"
|
2019-05-23 15:47:43 +02:00
|
|
|
#include "hw/arm/boot.h"
|
2019-08-12 07:23:42 +02:00
|
|
|
#include "hw/irq.h"
|
2021-01-28 12:41:31 +01:00
|
|
|
#include "hw/qdev-clock.h"
|
2018-03-02 11:45:40 +01:00
|
|
|
|
2021-02-19 15:45:56 +01:00
|
|
|
/*
|
|
|
|
* The SSE-300 puts some devices in different places to the
|
|
|
|
* SSE-200 (and original IoTKit). We use an array of these structs
|
|
|
|
* to define how each variant lays out these devices. (Parts of the
|
|
|
|
* SoC that are the same for all variants aren't handled via these
|
|
|
|
* data structures.)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define NO_IRQ -1
|
|
|
|
#define NO_PPC -1
|
2021-02-19 15:45:58 +01:00
|
|
|
/*
|
|
|
|
* Special values for ARMSSEDeviceInfo::irq to indicate that this
|
|
|
|
* device uses one of the inputs to the OR gate that feeds into the
|
|
|
|
* CPU NMI input.
|
|
|
|
*/
|
|
|
|
#define NMI_0 10000
|
|
|
|
#define NMI_1 10001
|
2021-02-19 15:45:56 +01:00
|
|
|
|
|
|
|
typedef struct ARMSSEDeviceInfo {
|
|
|
|
const char *name; /* name to use for the QOM object; NULL terminates list */
|
|
|
|
const char *type; /* QOM type name */
|
|
|
|
unsigned int index; /* Which of the N devices of this type is this ? */
|
|
|
|
hwaddr addr;
|
2021-02-19 15:46:02 +01:00
|
|
|
hwaddr size; /* only needed for TYPE_UNIMPLEMENTED_DEVICE */
|
2021-02-19 15:45:56 +01:00
|
|
|
int ppc; /* Index of APB PPC this device is wired up to, or NO_PPC */
|
|
|
|
int ppc_port; /* Port number of this device on the PPC */
|
2021-02-19 15:45:58 +01:00
|
|
|
int irq; /* NO_IRQ, or 0..NUM_SSE_IRQS-1, or NMI_0 or NMI_1 */
|
|
|
|
bool slowclk; /* true if device uses the slow 32KHz clock */
|
2021-02-19 15:45:56 +01:00
|
|
|
} ARMSSEDeviceInfo;
|
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
struct ARMSSEInfo {
|
|
|
|
const char *name;
|
2021-04-16 12:40:10 +02:00
|
|
|
const char *cpu_type;
|
2021-02-19 15:45:38 +01:00
|
|
|
uint32_t sse_version;
|
2019-02-01 15:55:42 +01:00
|
|
|
int sram_banks;
|
2021-05-10 21:08:41 +02:00
|
|
|
uint32_t sram_bank_base;
|
2019-02-01 15:55:42 +01:00
|
|
|
int num_cpus;
|
2019-02-01 15:55:42 +01:00
|
|
|
uint32_t sys_version;
|
2021-02-19 15:45:43 +01:00
|
|
|
uint32_t iidr;
|
2019-02-28 11:55:16 +01:00
|
|
|
uint32_t cpuwait_rst;
|
2019-02-01 15:55:43 +01:00
|
|
|
bool has_mhus;
|
2019-02-01 15:55:43 +01:00
|
|
|
bool has_cachectrl;
|
2019-02-01 15:55:43 +01:00
|
|
|
bool has_cpusecctrl;
|
2019-02-01 15:55:43 +01:00
|
|
|
bool has_cpuid;
|
2021-02-19 15:46:07 +01:00
|
|
|
bool has_cpu_pwrctrl;
|
2021-02-19 15:46:05 +01:00
|
|
|
bool has_sse_counter;
|
2021-05-10 21:08:44 +02:00
|
|
|
bool has_tcms;
|
2019-05-17 19:40:46 +02:00
|
|
|
Property *props;
|
2021-02-19 15:45:56 +01:00
|
|
|
const ARMSSEDeviceInfo *devinfo;
|
2021-02-19 15:46:04 +01:00
|
|
|
const bool *irq_is_common;
|
2019-05-17 19:40:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static Property iotkit_properties[] = {
|
|
|
|
DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION,
|
|
|
|
MemoryRegion *),
|
|
|
|
DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64),
|
|
|
|
DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15),
|
|
|
|
DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000),
|
|
|
|
DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true),
|
|
|
|
DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], true),
|
|
|
|
DEFINE_PROP_END_OF_LIST()
|
|
|
|
};
|
|
|
|
|
2021-04-15 20:23:53 +02:00
|
|
|
static Property sse200_properties[] = {
|
2019-05-17 19:40:46 +02:00
|
|
|
DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION,
|
|
|
|
MemoryRegion *),
|
|
|
|
DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64),
|
|
|
|
DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15),
|
|
|
|
DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000),
|
|
|
|
DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], false),
|
|
|
|
DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], false),
|
|
|
|
DEFINE_PROP_BOOL("CPU1_FPU", ARMSSE, cpu_fpu[1], true),
|
|
|
|
DEFINE_PROP_BOOL("CPU1_DSP", ARMSSE, cpu_dsp[1], true),
|
|
|
|
DEFINE_PROP_END_OF_LIST()
|
2019-02-01 15:55:41 +01:00
|
|
|
};
|
|
|
|
|
2021-04-15 20:23:53 +02:00
|
|
|
static Property sse300_properties[] = {
|
|
|
|
DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION,
|
|
|
|
MemoryRegion *),
|
|
|
|
DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64),
|
2021-05-10 21:08:41 +02:00
|
|
|
DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 18),
|
2021-04-15 20:23:53 +02:00
|
|
|
DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000),
|
|
|
|
DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true),
|
|
|
|
DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], true),
|
|
|
|
DEFINE_PROP_END_OF_LIST()
|
|
|
|
};
|
|
|
|
|
2021-02-19 15:46:02 +01:00
|
|
|
static const ARMSSEDeviceInfo iotkit_devices[] = {
|
|
|
|
{
|
|
|
|
.name = "timer0",
|
|
|
|
.type = TYPE_CMSDK_APB_TIMER,
|
|
|
|
.index = 0,
|
|
|
|
.addr = 0x40000000,
|
|
|
|
.ppc = 0,
|
|
|
|
.ppc_port = 0,
|
|
|
|
.irq = 3,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "timer1",
|
|
|
|
.type = TYPE_CMSDK_APB_TIMER,
|
|
|
|
.index = 1,
|
|
|
|
.addr = 0x40001000,
|
|
|
|
.ppc = 0,
|
|
|
|
.ppc_port = 1,
|
|
|
|
.irq = 4,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "s32ktimer",
|
|
|
|
.type = TYPE_CMSDK_APB_TIMER,
|
|
|
|
.index = 2,
|
|
|
|
.addr = 0x4002f000,
|
|
|
|
.ppc = 1,
|
|
|
|
.ppc_port = 0,
|
|
|
|
.irq = 2,
|
|
|
|
.slowclk = true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "dualtimer",
|
|
|
|
.type = TYPE_CMSDK_APB_DUALTIMER,
|
|
|
|
.index = 0,
|
|
|
|
.addr = 0x40002000,
|
|
|
|
.ppc = 0,
|
|
|
|
.ppc_port = 2,
|
|
|
|
.irq = 5,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "s32kwatchdog",
|
|
|
|
.type = TYPE_CMSDK_APB_WATCHDOG,
|
|
|
|
.index = 0,
|
|
|
|
.addr = 0x5002e000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NMI_0,
|
|
|
|
.slowclk = true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "nswatchdog",
|
|
|
|
.type = TYPE_CMSDK_APB_WATCHDOG,
|
|
|
|
.index = 1,
|
|
|
|
.addr = 0x40081000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "swatchdog",
|
|
|
|
.type = TYPE_CMSDK_APB_WATCHDOG,
|
|
|
|
.index = 2,
|
|
|
|
.addr = 0x50081000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NMI_1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "armsse-sysinfo",
|
|
|
|
.type = TYPE_IOTKIT_SYSINFO,
|
|
|
|
.index = 0,
|
|
|
|
.addr = 0x40020000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NO_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "armsse-sysctl",
|
|
|
|
.type = TYPE_IOTKIT_SYSCTL,
|
|
|
|
.index = 0,
|
|
|
|
.addr = 0x50021000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NO_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = NULL,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-02-19 15:45:56 +01:00
|
|
|
static const ARMSSEDeviceInfo sse200_devices[] = {
|
|
|
|
{
|
|
|
|
.name = "timer0",
|
|
|
|
.type = TYPE_CMSDK_APB_TIMER,
|
|
|
|
.index = 0,
|
|
|
|
.addr = 0x40000000,
|
|
|
|
.ppc = 0,
|
|
|
|
.ppc_port = 0,
|
|
|
|
.irq = 3,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "timer1",
|
|
|
|
.type = TYPE_CMSDK_APB_TIMER,
|
|
|
|
.index = 1,
|
|
|
|
.addr = 0x40001000,
|
|
|
|
.ppc = 0,
|
|
|
|
.ppc_port = 1,
|
|
|
|
.irq = 4,
|
|
|
|
},
|
2021-02-19 15:45:59 +01:00
|
|
|
{
|
|
|
|
.name = "s32ktimer",
|
|
|
|
.type = TYPE_CMSDK_APB_TIMER,
|
|
|
|
.index = 2,
|
|
|
|
.addr = 0x4002f000,
|
|
|
|
.ppc = 1,
|
|
|
|
.ppc_port = 0,
|
|
|
|
.irq = 2,
|
|
|
|
.slowclk = true,
|
|
|
|
},
|
2021-02-19 15:45:57 +01:00
|
|
|
{
|
|
|
|
.name = "dualtimer",
|
|
|
|
.type = TYPE_CMSDK_APB_DUALTIMER,
|
|
|
|
.index = 0,
|
|
|
|
.addr = 0x40002000,
|
|
|
|
.ppc = 0,
|
|
|
|
.ppc_port = 2,
|
|
|
|
.irq = 5,
|
|
|
|
},
|
2021-02-19 15:45:58 +01:00
|
|
|
{
|
|
|
|
.name = "s32kwatchdog",
|
|
|
|
.type = TYPE_CMSDK_APB_WATCHDOG,
|
|
|
|
.index = 0,
|
|
|
|
.addr = 0x5002e000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NMI_0,
|
|
|
|
.slowclk = true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "nswatchdog",
|
|
|
|
.type = TYPE_CMSDK_APB_WATCHDOG,
|
|
|
|
.index = 1,
|
|
|
|
.addr = 0x40081000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "swatchdog",
|
|
|
|
.type = TYPE_CMSDK_APB_WATCHDOG,
|
|
|
|
.index = 2,
|
|
|
|
.addr = 0x50081000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NMI_1,
|
|
|
|
},
|
2021-02-19 15:46:00 +01:00
|
|
|
{
|
|
|
|
.name = "armsse-sysinfo",
|
|
|
|
.type = TYPE_IOTKIT_SYSINFO,
|
|
|
|
.index = 0,
|
|
|
|
.addr = 0x40020000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NO_IRQ,
|
|
|
|
},
|
2021-02-19 15:46:01 +01:00
|
|
|
{
|
|
|
|
.name = "armsse-sysctl",
|
|
|
|
.type = TYPE_IOTKIT_SYSCTL,
|
|
|
|
.index = 0,
|
|
|
|
.addr = 0x50021000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NO_IRQ,
|
|
|
|
},
|
2021-02-19 15:46:02 +01:00
|
|
|
{
|
|
|
|
.name = "CPU0CORE_PPU",
|
|
|
|
.type = TYPE_UNIMPLEMENTED_DEVICE,
|
|
|
|
.index = 0,
|
|
|
|
.addr = 0x50023000,
|
|
|
|
.size = 0x1000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NO_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "CPU1CORE_PPU",
|
|
|
|
.type = TYPE_UNIMPLEMENTED_DEVICE,
|
|
|
|
.index = 1,
|
|
|
|
.addr = 0x50025000,
|
|
|
|
.size = 0x1000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NO_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "DBG_PPU",
|
|
|
|
.type = TYPE_UNIMPLEMENTED_DEVICE,
|
|
|
|
.index = 2,
|
|
|
|
.addr = 0x50029000,
|
|
|
|
.size = 0x1000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NO_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "RAM0_PPU",
|
|
|
|
.type = TYPE_UNIMPLEMENTED_DEVICE,
|
|
|
|
.index = 3,
|
|
|
|
.addr = 0x5002a000,
|
|
|
|
.size = 0x1000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NO_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "RAM1_PPU",
|
|
|
|
.type = TYPE_UNIMPLEMENTED_DEVICE,
|
|
|
|
.index = 4,
|
|
|
|
.addr = 0x5002b000,
|
|
|
|
.size = 0x1000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NO_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "RAM2_PPU",
|
|
|
|
.type = TYPE_UNIMPLEMENTED_DEVICE,
|
|
|
|
.index = 5,
|
|
|
|
.addr = 0x5002c000,
|
|
|
|
.size = 0x1000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NO_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "RAM3_PPU",
|
|
|
|
.type = TYPE_UNIMPLEMENTED_DEVICE,
|
|
|
|
.index = 6,
|
|
|
|
.addr = 0x5002d000,
|
|
|
|
.size = 0x1000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NO_IRQ,
|
|
|
|
},
|
2021-02-19 15:46:03 +01:00
|
|
|
{
|
|
|
|
.name = "SYS_PPU",
|
|
|
|
.type = TYPE_UNIMPLEMENTED_DEVICE,
|
|
|
|
.index = 7,
|
|
|
|
.addr = 0x50022000,
|
|
|
|
.size = 0x1000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NO_IRQ,
|
|
|
|
},
|
2021-02-19 15:45:56 +01:00
|
|
|
{
|
|
|
|
.name = NULL,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-02-19 15:46:08 +01:00
|
|
|
static const ARMSSEDeviceInfo sse300_devices[] = {
|
|
|
|
{
|
|
|
|
.name = "timer0",
|
|
|
|
.type = TYPE_SSE_TIMER,
|
|
|
|
.index = 0,
|
|
|
|
.addr = 0x48000000,
|
|
|
|
.ppc = 0,
|
|
|
|
.ppc_port = 0,
|
|
|
|
.irq = 3,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "timer1",
|
|
|
|
.type = TYPE_SSE_TIMER,
|
|
|
|
.index = 1,
|
|
|
|
.addr = 0x48001000,
|
|
|
|
.ppc = 0,
|
|
|
|
.ppc_port = 1,
|
|
|
|
.irq = 4,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "timer2",
|
|
|
|
.type = TYPE_SSE_TIMER,
|
|
|
|
.index = 2,
|
|
|
|
.addr = 0x48002000,
|
|
|
|
.ppc = 0,
|
|
|
|
.ppc_port = 2,
|
|
|
|
.irq = 5,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "timer3",
|
|
|
|
.type = TYPE_SSE_TIMER,
|
|
|
|
.index = 3,
|
|
|
|
.addr = 0x48003000,
|
|
|
|
.ppc = 0,
|
|
|
|
.ppc_port = 5,
|
|
|
|
.irq = 27,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "s32ktimer",
|
|
|
|
.type = TYPE_CMSDK_APB_TIMER,
|
|
|
|
.index = 0,
|
|
|
|
.addr = 0x4802f000,
|
|
|
|
.ppc = 1,
|
|
|
|
.ppc_port = 0,
|
|
|
|
.irq = 2,
|
|
|
|
.slowclk = true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "s32kwatchdog",
|
|
|
|
.type = TYPE_CMSDK_APB_WATCHDOG,
|
|
|
|
.index = 0,
|
|
|
|
.addr = 0x4802e000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NMI_0,
|
|
|
|
.slowclk = true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "watchdog",
|
|
|
|
.type = TYPE_UNIMPLEMENTED_DEVICE,
|
|
|
|
.index = 0,
|
|
|
|
.addr = 0x48040000,
|
|
|
|
.size = 0x2000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NO_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "armsse-sysinfo",
|
|
|
|
.type = TYPE_IOTKIT_SYSINFO,
|
|
|
|
.index = 0,
|
|
|
|
.addr = 0x48020000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NO_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "armsse-sysctl",
|
|
|
|
.type = TYPE_IOTKIT_SYSCTL,
|
|
|
|
.index = 0,
|
|
|
|
.addr = 0x58021000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NO_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "SYS_PPU",
|
|
|
|
.type = TYPE_UNIMPLEMENTED_DEVICE,
|
|
|
|
.index = 1,
|
|
|
|
.addr = 0x58022000,
|
|
|
|
.size = 0x1000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NO_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "CPU0CORE_PPU",
|
|
|
|
.type = TYPE_UNIMPLEMENTED_DEVICE,
|
|
|
|
.index = 2,
|
|
|
|
.addr = 0x50023000,
|
|
|
|
.size = 0x1000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NO_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "MGMT_PPU",
|
|
|
|
.type = TYPE_UNIMPLEMENTED_DEVICE,
|
|
|
|
.index = 3,
|
|
|
|
.addr = 0x50028000,
|
|
|
|
.size = 0x1000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NO_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "DEBUG_PPU",
|
|
|
|
.type = TYPE_UNIMPLEMENTED_DEVICE,
|
|
|
|
.index = 4,
|
|
|
|
.addr = 0x50029000,
|
|
|
|
.size = 0x1000,
|
|
|
|
.ppc = NO_PPC,
|
|
|
|
.irq = NO_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = NULL,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-02-19 15:46:04 +01:00
|
|
|
/* Is internal IRQ n shared between CPUs in a multi-core SSE ? */
|
|
|
|
static const bool sse200_irq_is_common[32] = {
|
|
|
|
[0 ... 5] = true,
|
|
|
|
/* 6, 7: per-CPU MHU interrupts */
|
|
|
|
[8 ... 12] = true,
|
|
|
|
/* 13: per-CPU icache interrupt */
|
|
|
|
/* 14: reserved */
|
|
|
|
[15 ... 20] = true,
|
|
|
|
/* 21: reserved */
|
|
|
|
[22 ... 26] = true,
|
|
|
|
/* 27: reserved */
|
|
|
|
/* 28, 29: per-CPU CTI interrupts */
|
|
|
|
/* 30, 31: reserved */
|
|
|
|
};
|
|
|
|
|
2021-02-19 15:46:08 +01:00
|
|
|
static const bool sse300_irq_is_common[32] = {
|
|
|
|
[0 ... 5] = true,
|
|
|
|
/* 6, 7: per-CPU MHU interrupts */
|
|
|
|
[8 ... 12] = true,
|
|
|
|
/* 13: reserved */
|
|
|
|
[14 ... 16] = true,
|
|
|
|
/* 17-25: reserved */
|
|
|
|
[26 ... 27] = true,
|
|
|
|
/* 28, 29: per-CPU CTI interrupts */
|
|
|
|
/* 30, 31: reserved */
|
|
|
|
};
|
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
static const ARMSSEInfo armsse_variants[] = {
|
|
|
|
{
|
|
|
|
.name = TYPE_IOTKIT,
|
2021-02-19 15:45:38 +01:00
|
|
|
.sse_version = ARMSSE_IOTKIT,
|
2021-04-16 12:40:10 +02:00
|
|
|
.cpu_type = ARM_CPU_TYPE_NAME("cortex-m33"),
|
2019-02-01 15:55:42 +01:00
|
|
|
.sram_banks = 1,
|
2021-05-10 21:08:41 +02:00
|
|
|
.sram_bank_base = 0x20000000,
|
2019-02-01 15:55:42 +01:00
|
|
|
.num_cpus = 1,
|
2019-02-01 15:55:42 +01:00
|
|
|
.sys_version = 0x41743,
|
2021-02-19 15:45:43 +01:00
|
|
|
.iidr = 0,
|
2019-02-28 11:55:16 +01:00
|
|
|
.cpuwait_rst = 0,
|
2019-02-01 15:55:43 +01:00
|
|
|
.has_mhus = false,
|
2019-02-01 15:55:43 +01:00
|
|
|
.has_cachectrl = false,
|
2019-02-01 15:55:43 +01:00
|
|
|
.has_cpusecctrl = false,
|
2019-02-01 15:55:43 +01:00
|
|
|
.has_cpuid = false,
|
2021-02-19 15:46:07 +01:00
|
|
|
.has_cpu_pwrctrl = false,
|
2021-02-19 15:46:05 +01:00
|
|
|
.has_sse_counter = false,
|
2021-05-10 21:08:44 +02:00
|
|
|
.has_tcms = false,
|
2019-05-17 19:40:46 +02:00
|
|
|
.props = iotkit_properties,
|
2021-02-19 15:46:02 +01:00
|
|
|
.devinfo = iotkit_devices,
|
2021-02-19 15:46:04 +01:00
|
|
|
.irq_is_common = sse200_irq_is_common,
|
2019-02-01 15:55:41 +01:00
|
|
|
},
|
2019-02-01 15:55:43 +01:00
|
|
|
{
|
|
|
|
.name = TYPE_SSE200,
|
2021-02-19 15:45:38 +01:00
|
|
|
.sse_version = ARMSSE_SSE200,
|
2021-04-16 12:40:10 +02:00
|
|
|
.cpu_type = ARM_CPU_TYPE_NAME("cortex-m33"),
|
2019-02-01 15:55:43 +01:00
|
|
|
.sram_banks = 4,
|
2021-05-10 21:08:41 +02:00
|
|
|
.sram_bank_base = 0x20000000,
|
2019-02-01 15:55:43 +01:00
|
|
|
.num_cpus = 2,
|
|
|
|
.sys_version = 0x22041743,
|
2021-02-19 15:45:43 +01:00
|
|
|
.iidr = 0,
|
2019-02-28 11:55:16 +01:00
|
|
|
.cpuwait_rst = 2,
|
2019-02-01 15:55:43 +01:00
|
|
|
.has_mhus = true,
|
|
|
|
.has_cachectrl = true,
|
|
|
|
.has_cpusecctrl = true,
|
|
|
|
.has_cpuid = true,
|
2021-02-19 15:46:07 +01:00
|
|
|
.has_cpu_pwrctrl = false,
|
2021-02-19 15:46:05 +01:00
|
|
|
.has_sse_counter = false,
|
2021-05-10 21:08:44 +02:00
|
|
|
.has_tcms = false,
|
2021-04-15 20:23:53 +02:00
|
|
|
.props = sse200_properties,
|
2021-02-19 15:45:56 +01:00
|
|
|
.devinfo = sse200_devices,
|
2021-02-19 15:46:04 +01:00
|
|
|
.irq_is_common = sse200_irq_is_common,
|
2019-02-01 15:55:43 +01:00
|
|
|
},
|
2021-02-19 15:46:08 +01:00
|
|
|
{
|
|
|
|
.name = TYPE_SSE300,
|
|
|
|
.sse_version = ARMSSE_SSE300,
|
2021-04-16 12:40:10 +02:00
|
|
|
.cpu_type = ARM_CPU_TYPE_NAME("cortex-m55"),
|
2021-02-19 15:46:08 +01:00
|
|
|
.sram_banks = 2,
|
2021-05-10 21:08:41 +02:00
|
|
|
.sram_bank_base = 0x21000000,
|
2021-02-19 15:46:08 +01:00
|
|
|
.num_cpus = 1,
|
|
|
|
.sys_version = 0x7e00043b,
|
|
|
|
.iidr = 0x74a0043b,
|
|
|
|
.cpuwait_rst = 0,
|
|
|
|
.has_mhus = false,
|
|
|
|
.has_cachectrl = false,
|
|
|
|
.has_cpusecctrl = true,
|
|
|
|
.has_cpuid = true,
|
|
|
|
.has_cpu_pwrctrl = true,
|
|
|
|
.has_sse_counter = true,
|
2021-05-10 21:08:44 +02:00
|
|
|
.has_tcms = true,
|
2021-04-15 20:23:53 +02:00
|
|
|
.props = sse300_properties,
|
2021-02-19 15:46:08 +01:00
|
|
|
.devinfo = sse300_devices,
|
|
|
|
.irq_is_common = sse300_irq_is_common,
|
|
|
|
},
|
2019-02-01 15:55:41 +01:00
|
|
|
};
|
|
|
|
|
2019-02-01 15:55:42 +01:00
|
|
|
static uint32_t armsse_sys_config_value(ARMSSE *s, const ARMSSEInfo *info)
|
|
|
|
{
|
|
|
|
/* Return the SYS_CONFIG value for this SSE */
|
|
|
|
uint32_t sys_config;
|
|
|
|
|
2021-02-19 15:45:42 +01:00
|
|
|
switch (info->sse_version) {
|
|
|
|
case ARMSSE_IOTKIT:
|
2019-02-01 15:55:42 +01:00
|
|
|
sys_config = 0;
|
|
|
|
sys_config = deposit32(sys_config, 0, 4, info->sram_banks);
|
|
|
|
sys_config = deposit32(sys_config, 4, 4, s->sram_addr_width - 12);
|
|
|
|
break;
|
2021-02-19 15:45:42 +01:00
|
|
|
case ARMSSE_SSE200:
|
2019-02-01 15:55:42 +01:00
|
|
|
sys_config = 0;
|
|
|
|
sys_config = deposit32(sys_config, 0, 4, info->sram_banks);
|
|
|
|
sys_config = deposit32(sys_config, 4, 5, s->sram_addr_width);
|
|
|
|
sys_config = deposit32(sys_config, 24, 4, 2);
|
|
|
|
if (info->num_cpus > 1) {
|
|
|
|
sys_config = deposit32(sys_config, 10, 1, 1);
|
|
|
|
sys_config = deposit32(sys_config, 20, 4, info->sram_banks - 1);
|
|
|
|
sys_config = deposit32(sys_config, 28, 4, 2);
|
|
|
|
}
|
|
|
|
break;
|
2021-02-19 15:45:42 +01:00
|
|
|
case ARMSSE_SSE300:
|
|
|
|
sys_config = 0;
|
|
|
|
sys_config = deposit32(sys_config, 0, 4, info->sram_banks);
|
|
|
|
sys_config = deposit32(sys_config, 4, 5, s->sram_addr_width);
|
|
|
|
sys_config = deposit32(sys_config, 16, 3, 3); /* CPU0 = Cortex-M55 */
|
|
|
|
break;
|
2019-02-01 15:55:42 +01:00
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
return sys_config;
|
|
|
|
}
|
|
|
|
|
2018-08-24 14:17:42 +02:00
|
|
|
/* Clock frequency in HZ of the 32KHz "slow clock" */
|
|
|
|
#define S32KCLK (32 * 1000)
|
|
|
|
|
2019-02-21 19:17:48 +01:00
|
|
|
/*
|
|
|
|
* Create an alias region in @container of @size bytes starting at @base
|
2018-03-02 11:45:40 +01:00
|
|
|
* which mirrors the memory starting at @orig.
|
|
|
|
*/
|
2019-02-21 19:17:48 +01:00
|
|
|
static void make_alias(ARMSSE *s, MemoryRegion *mr, MemoryRegion *container,
|
|
|
|
const char *name, hwaddr base, hwaddr size, hwaddr orig)
|
2018-03-02 11:45:40 +01:00
|
|
|
{
|
2019-02-21 19:17:48 +01:00
|
|
|
memory_region_init_alias(mr, NULL, name, container, orig, size);
|
2018-03-02 11:45:40 +01:00
|
|
|
/* The alias is even lower priority than unimplemented_device regions */
|
2019-02-21 19:17:48 +01:00
|
|
|
memory_region_add_subregion_overlap(container, base, mr, -1500);
|
2018-03-02 11:45:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void irq_status_forwarder(void *opaque, int n, int level)
|
|
|
|
{
|
|
|
|
qemu_irq destirq = opaque;
|
|
|
|
|
|
|
|
qemu_set_irq(destirq, level);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nsccfg_handler(void *opaque, int n, int level)
|
|
|
|
{
|
2020-08-25 21:20:21 +02:00
|
|
|
ARMSSE *s = ARM_SSE(opaque);
|
2018-03-02 11:45:40 +01:00
|
|
|
|
|
|
|
s->nsccfg = level;
|
|
|
|
}
|
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
static void armsse_forward_ppc(ARMSSE *s, const char *ppcname, int ppcnum)
|
2018-03-02 11:45:40 +01:00
|
|
|
{
|
|
|
|
/* Each of the 4 AHB and 4 APB PPCs that might be present in a
|
2019-02-01 15:55:41 +01:00
|
|
|
* system using the ARMSSE has a collection of control lines which
|
2018-03-02 11:45:40 +01:00
|
|
|
* are provided by the security controller and which we want to
|
2019-02-01 15:55:41 +01:00
|
|
|
* expose as control lines on the ARMSSE device itself, so the
|
|
|
|
* code using the ARMSSE can wire them up to the PPCs.
|
2018-03-02 11:45:40 +01:00
|
|
|
*/
|
|
|
|
SplitIRQ *splitter = &s->ppc_irq_splitter[ppcnum];
|
2019-02-01 15:55:41 +01:00
|
|
|
DeviceState *armssedev = DEVICE(s);
|
2018-03-02 11:45:40 +01:00
|
|
|
DeviceState *dev_secctl = DEVICE(&s->secctl);
|
|
|
|
DeviceState *dev_splitter = DEVICE(splitter);
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
name = g_strdup_printf("%s_nonsec", ppcname);
|
2019-02-01 15:55:41 +01:00
|
|
|
qdev_pass_gpios(dev_secctl, armssedev, name);
|
2018-03-02 11:45:40 +01:00
|
|
|
g_free(name);
|
|
|
|
name = g_strdup_printf("%s_ap", ppcname);
|
2019-02-01 15:55:41 +01:00
|
|
|
qdev_pass_gpios(dev_secctl, armssedev, name);
|
2018-03-02 11:45:40 +01:00
|
|
|
g_free(name);
|
|
|
|
name = g_strdup_printf("%s_irq_enable", ppcname);
|
2019-02-01 15:55:41 +01:00
|
|
|
qdev_pass_gpios(dev_secctl, armssedev, name);
|
2018-03-02 11:45:40 +01:00
|
|
|
g_free(name);
|
|
|
|
name = g_strdup_printf("%s_irq_clear", ppcname);
|
2019-02-01 15:55:41 +01:00
|
|
|
qdev_pass_gpios(dev_secctl, armssedev, name);
|
2018-03-02 11:45:40 +01:00
|
|
|
g_free(name);
|
|
|
|
|
|
|
|
/* irq_status is a little more tricky, because we need to
|
|
|
|
* split it so we can send it both to the security controller
|
|
|
|
* and to our OR gate for the NVIC interrupt line.
|
|
|
|
* Connect up the splitter's outputs, and create a GPIO input
|
|
|
|
* which will pass the line state to the input splitter.
|
|
|
|
*/
|
|
|
|
name = g_strdup_printf("%s_irq_status", ppcname);
|
|
|
|
qdev_connect_gpio_out(dev_splitter, 0,
|
|
|
|
qdev_get_gpio_in_named(dev_secctl,
|
|
|
|
name, 0));
|
|
|
|
qdev_connect_gpio_out(dev_splitter, 1,
|
|
|
|
qdev_get_gpio_in(DEVICE(&s->ppc_irq_orgate), ppcnum));
|
|
|
|
s->irq_status_in[ppcnum] = qdev_get_gpio_in(dev_splitter, 0);
|
2019-02-01 15:55:41 +01:00
|
|
|
qdev_init_gpio_in_named_with_opaque(armssedev, irq_status_forwarder,
|
2018-03-02 11:45:40 +01:00
|
|
|
s->irq_status_in[ppcnum], name, 1);
|
|
|
|
g_free(name);
|
|
|
|
}
|
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
static void armsse_forward_sec_resp_cfg(ARMSSE *s)
|
2018-03-02 11:45:40 +01:00
|
|
|
{
|
|
|
|
/* Forward the 3rd output from the splitter device as a
|
2019-02-01 15:55:41 +01:00
|
|
|
* named GPIO output of the armsse object.
|
2018-03-02 11:45:40 +01:00
|
|
|
*/
|
|
|
|
DeviceState *dev = DEVICE(s);
|
|
|
|
DeviceState *dev_splitter = DEVICE(&s->sec_resp_splitter);
|
|
|
|
|
|
|
|
qdev_init_gpio_out_named(dev, &s->sec_resp_cfg, "sec_resp_cfg", 1);
|
|
|
|
s->sec_resp_cfg_in = qemu_allocate_irq(irq_status_forwarder,
|
|
|
|
s->sec_resp_cfg, 1);
|
|
|
|
qdev_connect_gpio_out(dev_splitter, 2, s->sec_resp_cfg_in);
|
|
|
|
}
|
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
static void armsse_init(Object *obj)
|
2018-03-02 11:45:40 +01:00
|
|
|
{
|
2020-08-25 21:20:21 +02:00
|
|
|
ARMSSE *s = ARM_SSE(obj);
|
|
|
|
ARMSSEClass *asc = ARM_SSE_GET_CLASS(obj);
|
2019-02-01 15:55:42 +01:00
|
|
|
const ARMSSEInfo *info = asc->info;
|
2021-02-19 15:45:56 +01:00
|
|
|
const ARMSSEDeviceInfo *devinfo;
|
2018-03-02 11:45:40 +01:00
|
|
|
int i;
|
|
|
|
|
2019-02-01 15:55:42 +01:00
|
|
|
assert(info->sram_banks <= MAX_SRAM_BANKS);
|
2019-02-01 15:55:42 +01:00
|
|
|
assert(info->num_cpus <= SSE_MAX_CPUS);
|
2019-02-01 15:55:42 +01:00
|
|
|
|
2021-08-12 11:33:56 +02:00
|
|
|
s->mainclk = qdev_init_clock_in(DEVICE(s), "MAINCLK", NULL, NULL, 0);
|
2021-02-19 15:45:34 +01:00
|
|
|
s->s32kclk = qdev_init_clock_in(DEVICE(s), "S32KCLK", NULL, NULL, 0);
|
2021-01-28 12:41:31 +01:00
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
memory_region_init(&s->container, obj, "armsse-container", UINT64_MAX);
|
2018-03-02 11:45:40 +01:00
|
|
|
|
2019-02-01 15:55:42 +01:00
|
|
|
for (i = 0; i < info->num_cpus; i++) {
|
2019-02-01 15:55:42 +01:00
|
|
|
/*
|
|
|
|
* We put each CPU in its own cluster as they are logically
|
|
|
|
* distinct and may be configured differently.
|
|
|
|
*/
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
name = g_strdup_printf("cluster%d", i);
|
qom: Less verbose object_initialize_child()
All users of object_initialize_child() pass the obvious child size
argument. Almost all pass &error_abort and no properties. Tiresome.
Rename object_initialize_child() to
object_initialize_child_with_props() to free the name. New
convenience wrapper object_initialize_child() automates the size
argument, and passes &error_abort and no properties.
Rename object_initialize_childv() to
object_initialize_child_with_propsv() for consistency.
Convert callers with this Coccinelle script:
@@
expression parent, propname, type;
expression child, size;
symbol error_abort;
@@
- object_initialize_child(parent, propname, OBJECT(child), size, type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, size, type, &error_abort, NULL)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, child, sizeof(*child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, type)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, &child, sizeof(child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, &child, type)
@@
expression parent, propname, type;
expression child, size, err;
expression list props;
@@
- object_initialize_child(parent, propname, child, size, type, err, props)
+ object_initialize_child_with_props(parent, propname, child, size, type, err, props)
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>
[Rebased: machine opentitan is new (commit fe0fe4735e7)]
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-37-armbru@redhat.com>
2020-06-10 07:32:25 +02:00
|
|
|
object_initialize_child(obj, name, &s->cluster[i], TYPE_CPU_CLUSTER);
|
2019-02-01 15:55:42 +01:00
|
|
|
qdev_prop_set_uint32(DEVICE(&s->cluster[i]), "cluster-id", i);
|
|
|
|
g_free(name);
|
|
|
|
|
|
|
|
name = g_strdup_printf("armv7m%d", i);
|
2020-06-10 07:32:38 +02:00
|
|
|
object_initialize_child(OBJECT(&s->cluster[i]), name, &s->armv7m[i],
|
|
|
|
TYPE_ARMV7M);
|
2021-04-16 12:40:10 +02:00
|
|
|
qdev_prop_set_string(DEVICE(&s->armv7m[i]), "cpu-type", info->cpu_type);
|
2019-02-01 15:55:42 +01:00
|
|
|
g_free(name);
|
2019-02-01 15:55:42 +01:00
|
|
|
name = g_strdup_printf("arm-sse-cpu-container%d", i);
|
|
|
|
memory_region_init(&s->cpu_container[i], obj, name, UINT64_MAX);
|
|
|
|
g_free(name);
|
|
|
|
if (i > 0) {
|
|
|
|
name = g_strdup_printf("arm-sse-container-alias%d", i);
|
|
|
|
memory_region_init_alias(&s->container_alias[i - 1], obj,
|
|
|
|
name, &s->container, 0, UINT64_MAX);
|
|
|
|
g_free(name);
|
|
|
|
}
|
2019-02-01 15:55:42 +01:00
|
|
|
}
|
2018-03-02 11:45:40 +01:00
|
|
|
|
2021-02-19 15:45:56 +01:00
|
|
|
for (devinfo = info->devinfo; devinfo->name; devinfo++) {
|
|
|
|
assert(devinfo->ppc == NO_PPC || devinfo->ppc < ARRAY_SIZE(s->apb_ppc));
|
|
|
|
if (!strcmp(devinfo->type, TYPE_CMSDK_APB_TIMER)) {
|
|
|
|
assert(devinfo->index < ARRAY_SIZE(s->timer));
|
|
|
|
object_initialize_child(obj, devinfo->name,
|
|
|
|
&s->timer[devinfo->index],
|
|
|
|
TYPE_CMSDK_APB_TIMER);
|
2021-02-19 15:45:57 +01:00
|
|
|
} else if (!strcmp(devinfo->type, TYPE_CMSDK_APB_DUALTIMER)) {
|
|
|
|
assert(devinfo->index == 0);
|
|
|
|
object_initialize_child(obj, devinfo->name, &s->dualtimer,
|
|
|
|
TYPE_CMSDK_APB_DUALTIMER);
|
2021-02-19 15:46:06 +01:00
|
|
|
} else if (!strcmp(devinfo->type, TYPE_SSE_TIMER)) {
|
|
|
|
assert(devinfo->index < ARRAY_SIZE(s->sse_timer));
|
|
|
|
object_initialize_child(obj, devinfo->name,
|
|
|
|
&s->sse_timer[devinfo->index],
|
|
|
|
TYPE_SSE_TIMER);
|
2021-02-19 15:45:58 +01:00
|
|
|
} else if (!strcmp(devinfo->type, TYPE_CMSDK_APB_WATCHDOG)) {
|
|
|
|
assert(devinfo->index < ARRAY_SIZE(s->cmsdk_watchdog));
|
|
|
|
object_initialize_child(obj, devinfo->name,
|
|
|
|
&s->cmsdk_watchdog[devinfo->index],
|
|
|
|
TYPE_CMSDK_APB_WATCHDOG);
|
2021-02-19 15:46:00 +01:00
|
|
|
} else if (!strcmp(devinfo->type, TYPE_IOTKIT_SYSINFO)) {
|
|
|
|
assert(devinfo->index == 0);
|
|
|
|
object_initialize_child(obj, devinfo->name, &s->sysinfo,
|
|
|
|
TYPE_IOTKIT_SYSINFO);
|
2021-02-19 15:46:01 +01:00
|
|
|
} else if (!strcmp(devinfo->type, TYPE_IOTKIT_SYSCTL)) {
|
|
|
|
assert(devinfo->index == 0);
|
|
|
|
object_initialize_child(obj, devinfo->name, &s->sysctl,
|
|
|
|
TYPE_IOTKIT_SYSCTL);
|
2021-02-19 15:46:02 +01:00
|
|
|
} else if (!strcmp(devinfo->type, TYPE_UNIMPLEMENTED_DEVICE)) {
|
|
|
|
assert(devinfo->index < ARRAY_SIZE(s->unimp));
|
|
|
|
object_initialize_child(obj, devinfo->name,
|
|
|
|
&s->unimp[devinfo->index],
|
|
|
|
TYPE_UNIMPLEMENTED_DEVICE);
|
2021-02-19 15:45:56 +01:00
|
|
|
} else {
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
sysbus: Convert qdev_set_parent_bus() use with Coccinelle, part 2
This is the same transformation as in the previous commit, except
sysbus_init_child_obj() and realize are too separated for the commit's
Coccinelle script to handle, typically because sysbus_init_child_obj()
is in a device's instance_init() method, and the matching realize is
in its realize() method.
Perhaps a Coccinelle wizard could make it transform that pattern, but
I'm just a bungler, and the best I can do is transforming the two
separate parts separately:
@@
expression errp;
expression child;
symbol true;
@@
- object_property_set_bool(OBJECT(child), true, "realized", errp);
+ sysbus_realize(SYS_BUS_DEVICE(child), errp);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression errp;
expression child;
symbol true;
@@
- object_property_set_bool(child, true, "realized", errp);
+ sysbus_realize(SYS_BUS_DEVICE(child), errp);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression child;
@@
- qdev_init_nofail(DEVICE(child));
+ sysbus_realize(SYS_BUS_DEVICE(child), &error_fatal);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression child;
expression dev;
@@
dev = DEVICE(child);
...
- qdev_init_nofail(dev);
+ sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression child;
identifier dev;
@@
DeviceState *dev = DEVICE(child);
...
- qdev_init_nofail(dev);
+ sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression parent, name, size, type;
expression child;
symbol true;
@@
- sysbus_init_child_obj(parent, name, child, size, type);
+ sysbus_init_child_XXX(parent, name, child, size, type);
@@
expression parent, propname, type;
expression child;
@@
- sysbus_init_child_XXX(parent, propname, child, sizeof(*child), type)
+ object_initialize_child(parent, propname, child, type)
@@
expression parent, propname, type;
expression child;
@@
- sysbus_init_child_XXX(parent, propname, &child, sizeof(child), type)
+ object_initialize_child(parent, propname, &child, type)
This script is *unsound*: we need to manually verify init and realize
conversions are properly paired.
This commit has only the pairs where object_initialize_child()'s
@child and sysbus_realize()'s @dev argument text match exactly within
the same source file.
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-49-armbru@redhat.com>
2020-06-10 07:32:37 +02:00
|
|
|
object_initialize_child(obj, "secctl", &s->secctl, TYPE_IOTKIT_SECCTL);
|
2021-02-19 15:45:54 +01:00
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(s->apb_ppc); i++) {
|
|
|
|
g_autofree char *name = g_strdup_printf("apb-ppc%d", i);
|
|
|
|
object_initialize_child(obj, name, &s->apb_ppc[i], TYPE_TZ_PPC);
|
|
|
|
}
|
|
|
|
|
2019-02-01 15:55:42 +01:00
|
|
|
for (i = 0; i < info->sram_banks; i++) {
|
|
|
|
char *name = g_strdup_printf("mpc%d", i);
|
sysbus: Convert qdev_set_parent_bus() use with Coccinelle, part 2
This is the same transformation as in the previous commit, except
sysbus_init_child_obj() and realize are too separated for the commit's
Coccinelle script to handle, typically because sysbus_init_child_obj()
is in a device's instance_init() method, and the matching realize is
in its realize() method.
Perhaps a Coccinelle wizard could make it transform that pattern, but
I'm just a bungler, and the best I can do is transforming the two
separate parts separately:
@@
expression errp;
expression child;
symbol true;
@@
- object_property_set_bool(OBJECT(child), true, "realized", errp);
+ sysbus_realize(SYS_BUS_DEVICE(child), errp);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression errp;
expression child;
symbol true;
@@
- object_property_set_bool(child, true, "realized", errp);
+ sysbus_realize(SYS_BUS_DEVICE(child), errp);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression child;
@@
- qdev_init_nofail(DEVICE(child));
+ sysbus_realize(SYS_BUS_DEVICE(child), &error_fatal);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression child;
expression dev;
@@
dev = DEVICE(child);
...
- qdev_init_nofail(dev);
+ sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression child;
identifier dev;
@@
DeviceState *dev = DEVICE(child);
...
- qdev_init_nofail(dev);
+ sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression parent, name, size, type;
expression child;
symbol true;
@@
- sysbus_init_child_obj(parent, name, child, size, type);
+ sysbus_init_child_XXX(parent, name, child, size, type);
@@
expression parent, propname, type;
expression child;
@@
- sysbus_init_child_XXX(parent, propname, child, sizeof(*child), type)
+ object_initialize_child(parent, propname, child, type)
@@
expression parent, propname, type;
expression child;
@@
- sysbus_init_child_XXX(parent, propname, &child, sizeof(child), type)
+ object_initialize_child(parent, propname, &child, type)
This script is *unsound*: we need to manually verify init and realize
conversions are properly paired.
This commit has only the pairs where object_initialize_child()'s
@child and sysbus_realize()'s @dev argument text match exactly within
the same source file.
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-49-armbru@redhat.com>
2020-06-10 07:32:37 +02:00
|
|
|
object_initialize_child(obj, name, &s->mpc[i], TYPE_TZ_MPC);
|
2019-02-01 15:55:42 +01:00
|
|
|
g_free(name);
|
|
|
|
}
|
2018-07-16 14:59:21 +02:00
|
|
|
object_initialize_child(obj, "mpc-irq-orgate", &s->mpc_irq_orgate,
|
qom: Less verbose object_initialize_child()
All users of object_initialize_child() pass the obvious child size
argument. Almost all pass &error_abort and no properties. Tiresome.
Rename object_initialize_child() to
object_initialize_child_with_props() to free the name. New
convenience wrapper object_initialize_child() automates the size
argument, and passes &error_abort and no properties.
Rename object_initialize_childv() to
object_initialize_child_with_propsv() for consistency.
Convert callers with this Coccinelle script:
@@
expression parent, propname, type;
expression child, size;
symbol error_abort;
@@
- object_initialize_child(parent, propname, OBJECT(child), size, type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, size, type, &error_abort, NULL)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, child, sizeof(*child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, type)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, &child, sizeof(child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, &child, type)
@@
expression parent, propname, type;
expression child, size, err;
expression list props;
@@
- object_initialize_child(parent, propname, child, size, type, err, props)
+ object_initialize_child_with_props(parent, propname, child, size, type, err, props)
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>
[Rebased: machine opentitan is new (commit fe0fe4735e7)]
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-37-armbru@redhat.com>
2020-06-10 07:32:25 +02:00
|
|
|
TYPE_OR_IRQ);
|
2018-07-16 14:59:21 +02:00
|
|
|
|
2019-02-01 15:55:42 +01:00
|
|
|
for (i = 0; i < IOTS_NUM_EXP_MPC + info->sram_banks; i++) {
|
2018-06-22 14:28:40 +02:00
|
|
|
char *name = g_strdup_printf("mpc-irq-splitter-%d", i);
|
|
|
|
SplitIRQ *splitter = &s->mpc_irq_splitter[i];
|
|
|
|
|
qom: Less verbose object_initialize_child()
All users of object_initialize_child() pass the obvious child size
argument. Almost all pass &error_abort and no properties. Tiresome.
Rename object_initialize_child() to
object_initialize_child_with_props() to free the name. New
convenience wrapper object_initialize_child() automates the size
argument, and passes &error_abort and no properties.
Rename object_initialize_childv() to
object_initialize_child_with_propsv() for consistency.
Convert callers with this Coccinelle script:
@@
expression parent, propname, type;
expression child, size;
symbol error_abort;
@@
- object_initialize_child(parent, propname, OBJECT(child), size, type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, size, type, &error_abort, NULL)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, child, sizeof(*child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, type)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, &child, sizeof(child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, &child, type)
@@
expression parent, propname, type;
expression child, size, err;
expression list props;
@@
- object_initialize_child(parent, propname, child, size, type, err, props)
+ object_initialize_child_with_props(parent, propname, child, size, type, err, props)
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>
[Rebased: machine opentitan is new (commit fe0fe4735e7)]
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-37-armbru@redhat.com>
2020-06-10 07:32:25 +02:00
|
|
|
object_initialize_child(obj, name, splitter, TYPE_SPLIT_IRQ);
|
2018-06-22 14:28:40 +02:00
|
|
|
g_free(name);
|
|
|
|
}
|
2021-02-19 15:45:58 +01:00
|
|
|
|
2019-02-01 15:55:43 +01:00
|
|
|
if (info->has_mhus) {
|
2020-06-10 07:32:38 +02:00
|
|
|
object_initialize_child(obj, "mhu0", &s->mhu[0], TYPE_ARMSSE_MHU);
|
|
|
|
object_initialize_child(obj, "mhu1", &s->mhu[1], TYPE_ARMSSE_MHU);
|
2019-02-01 15:55:43 +01:00
|
|
|
}
|
2019-02-01 15:55:43 +01:00
|
|
|
if (info->has_cachectrl) {
|
|
|
|
for (i = 0; i < info->num_cpus; i++) {
|
|
|
|
char *name = g_strdup_printf("cachectrl%d", i);
|
|
|
|
|
sysbus: Convert qdev_set_parent_bus() use with Coccinelle, part 2
This is the same transformation as in the previous commit, except
sysbus_init_child_obj() and realize are too separated for the commit's
Coccinelle script to handle, typically because sysbus_init_child_obj()
is in a device's instance_init() method, and the matching realize is
in its realize() method.
Perhaps a Coccinelle wizard could make it transform that pattern, but
I'm just a bungler, and the best I can do is transforming the two
separate parts separately:
@@
expression errp;
expression child;
symbol true;
@@
- object_property_set_bool(OBJECT(child), true, "realized", errp);
+ sysbus_realize(SYS_BUS_DEVICE(child), errp);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression errp;
expression child;
symbol true;
@@
- object_property_set_bool(child, true, "realized", errp);
+ sysbus_realize(SYS_BUS_DEVICE(child), errp);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression child;
@@
- qdev_init_nofail(DEVICE(child));
+ sysbus_realize(SYS_BUS_DEVICE(child), &error_fatal);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression child;
expression dev;
@@
dev = DEVICE(child);
...
- qdev_init_nofail(dev);
+ sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression child;
identifier dev;
@@
DeviceState *dev = DEVICE(child);
...
- qdev_init_nofail(dev);
+ sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression parent, name, size, type;
expression child;
symbol true;
@@
- sysbus_init_child_obj(parent, name, child, size, type);
+ sysbus_init_child_XXX(parent, name, child, size, type);
@@
expression parent, propname, type;
expression child;
@@
- sysbus_init_child_XXX(parent, propname, child, sizeof(*child), type)
+ object_initialize_child(parent, propname, child, type)
@@
expression parent, propname, type;
expression child;
@@
- sysbus_init_child_XXX(parent, propname, &child, sizeof(child), type)
+ object_initialize_child(parent, propname, &child, type)
This script is *unsound*: we need to manually verify init and realize
conversions are properly paired.
This commit has only the pairs where object_initialize_child()'s
@child and sysbus_realize()'s @dev argument text match exactly within
the same source file.
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-49-armbru@redhat.com>
2020-06-10 07:32:37 +02:00
|
|
|
object_initialize_child(obj, name, &s->cachectrl[i],
|
|
|
|
TYPE_UNIMPLEMENTED_DEVICE);
|
2019-02-01 15:55:43 +01:00
|
|
|
g_free(name);
|
|
|
|
}
|
|
|
|
}
|
2019-02-01 15:55:43 +01:00
|
|
|
if (info->has_cpusecctrl) {
|
|
|
|
for (i = 0; i < info->num_cpus; i++) {
|
|
|
|
char *name = g_strdup_printf("cpusecctrl%d", i);
|
|
|
|
|
sysbus: Convert qdev_set_parent_bus() use with Coccinelle, part 2
This is the same transformation as in the previous commit, except
sysbus_init_child_obj() and realize are too separated for the commit's
Coccinelle script to handle, typically because sysbus_init_child_obj()
is in a device's instance_init() method, and the matching realize is
in its realize() method.
Perhaps a Coccinelle wizard could make it transform that pattern, but
I'm just a bungler, and the best I can do is transforming the two
separate parts separately:
@@
expression errp;
expression child;
symbol true;
@@
- object_property_set_bool(OBJECT(child), true, "realized", errp);
+ sysbus_realize(SYS_BUS_DEVICE(child), errp);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression errp;
expression child;
symbol true;
@@
- object_property_set_bool(child, true, "realized", errp);
+ sysbus_realize(SYS_BUS_DEVICE(child), errp);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression child;
@@
- qdev_init_nofail(DEVICE(child));
+ sysbus_realize(SYS_BUS_DEVICE(child), &error_fatal);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression child;
expression dev;
@@
dev = DEVICE(child);
...
- qdev_init_nofail(dev);
+ sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression child;
identifier dev;
@@
DeviceState *dev = DEVICE(child);
...
- qdev_init_nofail(dev);
+ sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression parent, name, size, type;
expression child;
symbol true;
@@
- sysbus_init_child_obj(parent, name, child, size, type);
+ sysbus_init_child_XXX(parent, name, child, size, type);
@@
expression parent, propname, type;
expression child;
@@
- sysbus_init_child_XXX(parent, propname, child, sizeof(*child), type)
+ object_initialize_child(parent, propname, child, type)
@@
expression parent, propname, type;
expression child;
@@
- sysbus_init_child_XXX(parent, propname, &child, sizeof(child), type)
+ object_initialize_child(parent, propname, &child, type)
This script is *unsound*: we need to manually verify init and realize
conversions are properly paired.
This commit has only the pairs where object_initialize_child()'s
@child and sysbus_realize()'s @dev argument text match exactly within
the same source file.
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-49-armbru@redhat.com>
2020-06-10 07:32:37 +02:00
|
|
|
object_initialize_child(obj, name, &s->cpusecctrl[i],
|
|
|
|
TYPE_UNIMPLEMENTED_DEVICE);
|
2019-02-01 15:55:43 +01:00
|
|
|
g_free(name);
|
|
|
|
}
|
|
|
|
}
|
2019-02-01 15:55:43 +01:00
|
|
|
if (info->has_cpuid) {
|
|
|
|
for (i = 0; i < info->num_cpus; i++) {
|
|
|
|
char *name = g_strdup_printf("cpuid%d", i);
|
|
|
|
|
sysbus: Convert qdev_set_parent_bus() use with Coccinelle, part 2
This is the same transformation as in the previous commit, except
sysbus_init_child_obj() and realize are too separated for the commit's
Coccinelle script to handle, typically because sysbus_init_child_obj()
is in a device's instance_init() method, and the matching realize is
in its realize() method.
Perhaps a Coccinelle wizard could make it transform that pattern, but
I'm just a bungler, and the best I can do is transforming the two
separate parts separately:
@@
expression errp;
expression child;
symbol true;
@@
- object_property_set_bool(OBJECT(child), true, "realized", errp);
+ sysbus_realize(SYS_BUS_DEVICE(child), errp);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression errp;
expression child;
symbol true;
@@
- object_property_set_bool(child, true, "realized", errp);
+ sysbus_realize(SYS_BUS_DEVICE(child), errp);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression child;
@@
- qdev_init_nofail(DEVICE(child));
+ sysbus_realize(SYS_BUS_DEVICE(child), &error_fatal);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression child;
expression dev;
@@
dev = DEVICE(child);
...
- qdev_init_nofail(dev);
+ sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression child;
identifier dev;
@@
DeviceState *dev = DEVICE(child);
...
- qdev_init_nofail(dev);
+ sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
// only correct with a matching sysbus_init_child_obj() transformation!
@@
expression parent, name, size, type;
expression child;
symbol true;
@@
- sysbus_init_child_obj(parent, name, child, size, type);
+ sysbus_init_child_XXX(parent, name, child, size, type);
@@
expression parent, propname, type;
expression child;
@@
- sysbus_init_child_XXX(parent, propname, child, sizeof(*child), type)
+ object_initialize_child(parent, propname, child, type)
@@
expression parent, propname, type;
expression child;
@@
- sysbus_init_child_XXX(parent, propname, &child, sizeof(child), type)
+ object_initialize_child(parent, propname, &child, type)
This script is *unsound*: we need to manually verify init and realize
conversions are properly paired.
This commit has only the pairs where object_initialize_child()'s
@child and sysbus_realize()'s @dev argument text match exactly within
the same source file.
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-49-armbru@redhat.com>
2020-06-10 07:32:37 +02:00
|
|
|
object_initialize_child(obj, name, &s->cpuid[i],
|
|
|
|
TYPE_ARMSSE_CPUID);
|
2019-02-01 15:55:43 +01:00
|
|
|
g_free(name);
|
|
|
|
}
|
|
|
|
}
|
2021-02-19 15:46:07 +01:00
|
|
|
if (info->has_cpu_pwrctrl) {
|
|
|
|
for (i = 0; i < info->num_cpus; i++) {
|
|
|
|
char *name = g_strdup_printf("cpu_pwrctrl%d", i);
|
|
|
|
|
|
|
|
object_initialize_child(obj, name, &s->cpu_pwrctrl[i],
|
|
|
|
TYPE_ARMSSE_CPU_PWRCTRL);
|
|
|
|
g_free(name);
|
|
|
|
}
|
|
|
|
}
|
2021-02-19 15:46:05 +01:00
|
|
|
if (info->has_sse_counter) {
|
|
|
|
object_initialize_child(obj, "sse-counter", &s->sse_counter,
|
|
|
|
TYPE_SSE_COUNTER);
|
|
|
|
}
|
|
|
|
|
qom: Less verbose object_initialize_child()
All users of object_initialize_child() pass the obvious child size
argument. Almost all pass &error_abort and no properties. Tiresome.
Rename object_initialize_child() to
object_initialize_child_with_props() to free the name. New
convenience wrapper object_initialize_child() automates the size
argument, and passes &error_abort and no properties.
Rename object_initialize_childv() to
object_initialize_child_with_propsv() for consistency.
Convert callers with this Coccinelle script:
@@
expression parent, propname, type;
expression child, size;
symbol error_abort;
@@
- object_initialize_child(parent, propname, OBJECT(child), size, type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, size, type, &error_abort, NULL)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, child, sizeof(*child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, type)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, &child, sizeof(child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, &child, type)
@@
expression parent, propname, type;
expression child, size, err;
expression list props;
@@
- object_initialize_child(parent, propname, child, size, type, err, props)
+ object_initialize_child_with_props(parent, propname, child, size, type, err, props)
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>
[Rebased: machine opentitan is new (commit fe0fe4735e7)]
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-37-armbru@redhat.com>
2020-06-10 07:32:25 +02:00
|
|
|
object_initialize_child(obj, "nmi-orgate", &s->nmi_orgate, TYPE_OR_IRQ);
|
2018-07-16 14:59:21 +02:00
|
|
|
object_initialize_child(obj, "ppc-irq-orgate", &s->ppc_irq_orgate,
|
qom: Less verbose object_initialize_child()
All users of object_initialize_child() pass the obvious child size
argument. Almost all pass &error_abort and no properties. Tiresome.
Rename object_initialize_child() to
object_initialize_child_with_props() to free the name. New
convenience wrapper object_initialize_child() automates the size
argument, and passes &error_abort and no properties.
Rename object_initialize_childv() to
object_initialize_child_with_propsv() for consistency.
Convert callers with this Coccinelle script:
@@
expression parent, propname, type;
expression child, size;
symbol error_abort;
@@
- object_initialize_child(parent, propname, OBJECT(child), size, type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, size, type, &error_abort, NULL)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, child, sizeof(*child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, type)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, &child, sizeof(child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, &child, type)
@@
expression parent, propname, type;
expression child, size, err;
expression list props;
@@
- object_initialize_child(parent, propname, child, size, type, err, props)
+ object_initialize_child_with_props(parent, propname, child, size, type, err, props)
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>
[Rebased: machine opentitan is new (commit fe0fe4735e7)]
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-37-armbru@redhat.com>
2020-06-10 07:32:25 +02:00
|
|
|
TYPE_OR_IRQ);
|
2018-07-16 14:59:21 +02:00
|
|
|
object_initialize_child(obj, "sec-resp-splitter", &s->sec_resp_splitter,
|
qom: Less verbose object_initialize_child()
All users of object_initialize_child() pass the obvious child size
argument. Almost all pass &error_abort and no properties. Tiresome.
Rename object_initialize_child() to
object_initialize_child_with_props() to free the name. New
convenience wrapper object_initialize_child() automates the size
argument, and passes &error_abort and no properties.
Rename object_initialize_childv() to
object_initialize_child_with_propsv() for consistency.
Convert callers with this Coccinelle script:
@@
expression parent, propname, type;
expression child, size;
symbol error_abort;
@@
- object_initialize_child(parent, propname, OBJECT(child), size, type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, size, type, &error_abort, NULL)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, child, sizeof(*child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, type)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, &child, sizeof(child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, &child, type)
@@
expression parent, propname, type;
expression child, size, err;
expression list props;
@@
- object_initialize_child(parent, propname, child, size, type, err, props)
+ object_initialize_child_with_props(parent, propname, child, size, type, err, props)
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>
[Rebased: machine opentitan is new (commit fe0fe4735e7)]
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-37-armbru@redhat.com>
2020-06-10 07:32:25 +02:00
|
|
|
TYPE_SPLIT_IRQ);
|
2018-03-02 11:45:40 +01:00
|
|
|
for (i = 0; i < ARRAY_SIZE(s->ppc_irq_splitter); i++) {
|
|
|
|
char *name = g_strdup_printf("ppc-irq-splitter-%d", i);
|
|
|
|
SplitIRQ *splitter = &s->ppc_irq_splitter[i];
|
|
|
|
|
qom: Less verbose object_initialize_child()
All users of object_initialize_child() pass the obvious child size
argument. Almost all pass &error_abort and no properties. Tiresome.
Rename object_initialize_child() to
object_initialize_child_with_props() to free the name. New
convenience wrapper object_initialize_child() automates the size
argument, and passes &error_abort and no properties.
Rename object_initialize_childv() to
object_initialize_child_with_propsv() for consistency.
Convert callers with this Coccinelle script:
@@
expression parent, propname, type;
expression child, size;
symbol error_abort;
@@
- object_initialize_child(parent, propname, OBJECT(child), size, type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, size, type, &error_abort, NULL)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, child, sizeof(*child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, type)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, &child, sizeof(child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, &child, type)
@@
expression parent, propname, type;
expression child, size, err;
expression list props;
@@
- object_initialize_child(parent, propname, child, size, type, err, props)
+ object_initialize_child_with_props(parent, propname, child, size, type, err, props)
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>
[Rebased: machine opentitan is new (commit fe0fe4735e7)]
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-37-armbru@redhat.com>
2020-06-10 07:32:25 +02:00
|
|
|
object_initialize_child(obj, name, splitter, TYPE_SPLIT_IRQ);
|
2018-07-16 14:59:21 +02:00
|
|
|
g_free(name);
|
2018-03-02 11:45:40 +01:00
|
|
|
}
|
2019-02-01 15:55:42 +01:00
|
|
|
if (info->num_cpus > 1) {
|
|
|
|
for (i = 0; i < ARRAY_SIZE(s->cpu_irq_splitter); i++) {
|
2021-02-19 15:46:04 +01:00
|
|
|
if (info->irq_is_common[i]) {
|
2019-02-01 15:55:42 +01:00
|
|
|
char *name = g_strdup_printf("cpu-irq-splitter%d", i);
|
|
|
|
SplitIRQ *splitter = &s->cpu_irq_splitter[i];
|
|
|
|
|
qom: Less verbose object_initialize_child()
All users of object_initialize_child() pass the obvious child size
argument. Almost all pass &error_abort and no properties. Tiresome.
Rename object_initialize_child() to
object_initialize_child_with_props() to free the name. New
convenience wrapper object_initialize_child() automates the size
argument, and passes &error_abort and no properties.
Rename object_initialize_childv() to
object_initialize_child_with_propsv() for consistency.
Convert callers with this Coccinelle script:
@@
expression parent, propname, type;
expression child, size;
symbol error_abort;
@@
- object_initialize_child(parent, propname, OBJECT(child), size, type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, size, type, &error_abort, NULL)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, child, sizeof(*child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, child, type)
@@
expression parent, propname, type;
expression child;
symbol error_abort;
@@
- object_initialize_child(parent, propname, &child, sizeof(child), type, &error_abort, NULL)
+ object_initialize_child(parent, propname, &child, type)
@@
expression parent, propname, type;
expression child, size, err;
expression list props;
@@
- object_initialize_child(parent, propname, child, size, type, err, props)
+ object_initialize_child_with_props(parent, propname, child, size, type, err, props)
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>
[Rebased: machine opentitan is new (commit fe0fe4735e7)]
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-37-armbru@redhat.com>
2020-06-10 07:32:25 +02:00
|
|
|
object_initialize_child(obj, name, splitter, TYPE_SPLIT_IRQ);
|
2019-02-01 15:55:42 +01:00
|
|
|
g_free(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-02 11:45:40 +01:00
|
|
|
}
|
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
static void armsse_exp_irq(void *opaque, int n, int level)
|
2018-03-02 11:45:40 +01:00
|
|
|
{
|
2019-02-01 15:55:42 +01:00
|
|
|
qemu_irq *irqarray = opaque;
|
2018-03-02 11:45:40 +01:00
|
|
|
|
2019-02-01 15:55:42 +01:00
|
|
|
qemu_set_irq(irqarray[n], level);
|
2018-03-02 11:45:40 +01:00
|
|
|
}
|
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
static void armsse_mpcexp_status(void *opaque, int n, int level)
|
2018-06-22 14:28:40 +02:00
|
|
|
{
|
2020-08-25 21:20:21 +02:00
|
|
|
ARMSSE *s = ARM_SSE(opaque);
|
2018-06-22 14:28:40 +02:00
|
|
|
qemu_set_irq(s->mpcexp_status_in[n], level);
|
|
|
|
}
|
|
|
|
|
2019-02-01 15:55:42 +01:00
|
|
|
static qemu_irq armsse_get_common_irq_in(ARMSSE *s, int irqno)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Return a qemu_irq which can be used to signal IRQ n to
|
|
|
|
* all CPUs in the SSE.
|
|
|
|
*/
|
2020-08-25 21:20:21 +02:00
|
|
|
ARMSSEClass *asc = ARM_SSE_GET_CLASS(s);
|
2019-02-01 15:55:42 +01:00
|
|
|
const ARMSSEInfo *info = asc->info;
|
|
|
|
|
2021-02-19 15:46:04 +01:00
|
|
|
assert(info->irq_is_common[irqno]);
|
2019-02-01 15:55:42 +01:00
|
|
|
|
|
|
|
if (info->num_cpus == 1) {
|
|
|
|
/* Only one CPU -- just connect directly to it */
|
|
|
|
return qdev_get_gpio_in(DEVICE(&s->armv7m[0]), irqno);
|
|
|
|
} else {
|
|
|
|
/* Connect to the splitter which feeds all CPUs */
|
|
|
|
return qdev_get_gpio_in(DEVICE(&s->cpu_irq_splitter[irqno]), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
static void armsse_realize(DeviceState *dev, Error **errp)
|
2018-03-02 11:45:40 +01:00
|
|
|
{
|
2022-11-21 09:50:47 +01:00
|
|
|
ERRP_GUARD();
|
2020-08-25 21:20:21 +02:00
|
|
|
ARMSSE *s = ARM_SSE(dev);
|
|
|
|
ARMSSEClass *asc = ARM_SSE_GET_CLASS(dev);
|
2019-02-01 15:55:42 +01:00
|
|
|
const ARMSSEInfo *info = asc->info;
|
2021-02-19 15:45:56 +01:00
|
|
|
const ARMSSEDeviceInfo *devinfo;
|
2018-03-02 11:45:40 +01:00
|
|
|
int i;
|
|
|
|
MemoryRegion *mr;
|
|
|
|
SysBusDevice *sbd_apb_ppc0;
|
|
|
|
SysBusDevice *sbd_secctl;
|
|
|
|
DeviceState *dev_apb_ppc0;
|
|
|
|
DeviceState *dev_apb_ppc1;
|
|
|
|
DeviceState *dev_secctl;
|
|
|
|
DeviceState *dev_splitter;
|
2019-02-01 15:55:42 +01:00
|
|
|
uint32_t addr_width_max;
|
2018-03-02 11:45:40 +01:00
|
|
|
|
|
|
|
if (!s->board_memory) {
|
|
|
|
error_setg(errp, "memory property was not set");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-01-28 12:41:42 +01:00
|
|
|
if (!clock_has_source(s->mainclk)) {
|
|
|
|
error_setg(errp, "MAINCLK clock was not connected");
|
|
|
|
}
|
|
|
|
if (!clock_has_source(s->s32kclk)) {
|
|
|
|
error_setg(errp, "S32KCLK clock was not connected");
|
2018-03-02 11:45:40 +01:00
|
|
|
}
|
|
|
|
|
2020-07-13 16:37:16 +02:00
|
|
|
assert(info->num_cpus <= SSE_MAX_CPUS);
|
|
|
|
|
2019-02-01 15:55:42 +01:00
|
|
|
/* max SRAM_ADDR_WIDTH: 24 - log2(SRAM_NUM_BANK) */
|
|
|
|
assert(is_power_of_2(info->sram_banks));
|
|
|
|
addr_width_max = 24 - ctz32(info->sram_banks);
|
|
|
|
if (s->sram_addr_width < 1 || s->sram_addr_width > addr_width_max) {
|
|
|
|
error_setg(errp, "SRAM_ADDR_WIDTH must be between 1 and %d",
|
|
|
|
addr_width_max);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-02 11:45:40 +01:00
|
|
|
/* Handling of which devices should be available only to secure
|
|
|
|
* code is usually done differently for M profile than for A profile.
|
|
|
|
* Instead of putting some devices only into the secure address space,
|
|
|
|
* devices exist in both address spaces but with hard-wired security
|
|
|
|
* permissions that will cause the CPU to fault for non-secure accesses.
|
|
|
|
*
|
2019-02-01 15:55:41 +01:00
|
|
|
* The ARMSSE has an IDAU (Implementation Defined Access Unit),
|
2018-03-02 11:45:40 +01:00
|
|
|
* which specifies hard-wired security permissions for different
|
2019-02-01 15:55:41 +01:00
|
|
|
* areas of the physical address space. For the ARMSSE IDAU, the
|
2018-03-02 11:45:40 +01:00
|
|
|
* top 4 bits of the physical address are the IDAU region ID, and
|
|
|
|
* if bit 28 (ie the lowest bit of the ID) is 0 then this is an NS
|
|
|
|
* region, otherwise it is an S region.
|
|
|
|
*
|
|
|
|
* The various devices and RAMs are generally all mapped twice,
|
|
|
|
* once into a region that the IDAU defines as secure and once
|
|
|
|
* into a non-secure region. They sit behind either a Memory
|
|
|
|
* Protection Controller (for RAM) or a Peripheral Protection
|
|
|
|
* Controller (for devices), which allow a more fine grained
|
|
|
|
* configuration of whether non-secure accesses are permitted.
|
|
|
|
*
|
|
|
|
* (The other place that guest software can configure security
|
|
|
|
* permissions is in the architected SAU (Security Attribution
|
|
|
|
* Unit), which is entirely inside the CPU. The IDAU can upgrade
|
|
|
|
* the security attributes for a region to more restrictive than
|
|
|
|
* the SAU specifies, but cannot downgrade them.)
|
|
|
|
*
|
|
|
|
* 0x10000000..0x1fffffff alias of 0x00000000..0x0fffffff
|
|
|
|
* 0x20000000..0x2007ffff 32KB FPGA block RAM
|
|
|
|
* 0x30000000..0x3fffffff alias of 0x20000000..0x2fffffff
|
|
|
|
* 0x40000000..0x4000ffff base peripheral region 1
|
2019-02-01 15:55:41 +01:00
|
|
|
* 0x40010000..0x4001ffff CPU peripherals (none for ARMSSE)
|
2018-03-02 11:45:40 +01:00
|
|
|
* 0x40020000..0x4002ffff system control element peripherals
|
|
|
|
* 0x40080000..0x400fffff base peripheral region 2
|
|
|
|
* 0x50000000..0x5fffffff alias of 0x40000000..0x4fffffff
|
|
|
|
*/
|
|
|
|
|
2019-02-01 15:55:42 +01:00
|
|
|
memory_region_add_subregion_overlap(&s->container, 0, s->board_memory, -2);
|
2018-03-02 11:45:40 +01:00
|
|
|
|
2019-02-01 15:55:42 +01:00
|
|
|
for (i = 0; i < info->num_cpus; i++) {
|
|
|
|
DeviceState *cpudev = DEVICE(&s->armv7m[i]);
|
|
|
|
Object *cpuobj = OBJECT(&s->armv7m[i]);
|
|
|
|
int j;
|
|
|
|
char *gpioname;
|
|
|
|
|
2021-08-12 11:33:38 +02:00
|
|
|
qdev_connect_clock_in(cpudev, "cpuclk", s->mainclk);
|
|
|
|
/* The SSE subsystems do not wire up a systick refclk */
|
|
|
|
|
2021-02-19 15:45:55 +01:00
|
|
|
qdev_prop_set_uint32(cpudev, "num-irq", s->exp_numirq + NUM_SSE_IRQS);
|
2019-02-01 15:55:42 +01:00
|
|
|
/*
|
2019-02-28 11:55:16 +01:00
|
|
|
* In real hardware the initial Secure VTOR is set from the INITSVTOR*
|
|
|
|
* registers in the IoT Kit System Control Register block. In QEMU
|
|
|
|
* we set the initial value here, and also the reset value of the
|
|
|
|
* sysctl register, from this object's QOM init-svtor property.
|
|
|
|
* If the guest changes the INITSVTOR* registers at runtime then the
|
|
|
|
* code in iotkit-sysctl.c will update the CPU init-svtor property
|
|
|
|
* (which will then take effect on the next CPU warm-reset).
|
|
|
|
*
|
|
|
|
* Note that typically a board using the SSE-200 will have a system
|
|
|
|
* control processor whose boot firmware initializes the INITSVTOR*
|
|
|
|
* registers before powering up the CPUs. QEMU doesn't emulate
|
2019-02-01 15:55:42 +01:00
|
|
|
* the control processor, so instead we behave in the way that the
|
2019-02-28 11:55:16 +01:00
|
|
|
* firmware does: the initial value should be set by the board code
|
|
|
|
* (using the init-svtor property on the ARMSSE object) to match
|
|
|
|
* whatever its firmware does.
|
2019-02-01 15:55:42 +01:00
|
|
|
*/
|
2019-02-21 19:17:47 +01:00
|
|
|
qdev_prop_set_uint32(cpudev, "init-svtor", s->init_svtor);
|
2019-02-01 15:55:42 +01:00
|
|
|
/*
|
2019-02-28 11:55:16 +01:00
|
|
|
* CPUs start powered down if the corresponding bit in the CPUWAIT
|
|
|
|
* register is 1. In real hardware the CPUWAIT register reset value is
|
|
|
|
* a configurable property of the SSE-200 (via the CPUWAIT0_RST and
|
|
|
|
* CPUWAIT1_RST parameters), but since all the boards we care about
|
|
|
|
* start CPU0 and leave CPU1 powered off, we hard-code that in
|
|
|
|
* info->cpuwait_rst for now. We can add QOM properties for this
|
2019-02-01 15:55:42 +01:00
|
|
|
* later if necessary.
|
|
|
|
*/
|
2019-02-28 11:55:16 +01:00
|
|
|
if (extract32(info->cpuwait_rst, i, 1)) {
|
qom: Use returned bool to check for failure, Coccinelle part
The previous commit enables conversion of
foo(..., &err);
if (err) {
...
}
to
if (!foo(..., errp)) {
...
}
for QOM functions that now return true / false on success / error.
Coccinelle script:
@@
identifier fun = {
object_apply_global_props, object_initialize_child_with_props,
object_initialize_child_with_propsv, object_property_get,
object_property_get_bool, object_property_parse, object_property_set,
object_property_set_bool, object_property_set_int,
object_property_set_link, object_property_set_qobject,
object_property_set_str, object_property_set_uint, object_set_props,
object_set_propv, user_creatable_add_dict,
user_creatable_complete, user_creatable_del
};
expression list args, args2;
typedef Error;
Error *err;
@@
- fun(args, &err, args2);
- if (err)
+ if (!fun(args, &err, args2))
{
...
}
Fails to convert hw/arm/armsse.c, because Coccinelle gets confused by
ARMSSE being used both as typedef and function-like macro there.
Convert manually.
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>
Message-Id: <20200707160613.848843-29-armbru@redhat.com>
2020-07-07 18:05:56 +02:00
|
|
|
if (!object_property_set_bool(cpuobj, "start-powered-off", true,
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
errp)) {
|
2019-02-01 15:55:42 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-05-17 19:40:46 +02:00
|
|
|
if (!s->cpu_fpu[i]) {
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
if (!object_property_set_bool(cpuobj, "vfp", false, errp)) {
|
2019-05-17 19:40:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!s->cpu_dsp[i]) {
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
if (!object_property_set_bool(cpuobj, "dsp", false, errp)) {
|
2019-05-17 19:40:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-02-01 15:55:42 +01:00
|
|
|
|
|
|
|
if (i > 0) {
|
|
|
|
memory_region_add_subregion_overlap(&s->cpu_container[i], 0,
|
|
|
|
&s->container_alias[i - 1], -1);
|
|
|
|
} else {
|
|
|
|
memory_region_add_subregion_overlap(&s->cpu_container[i], 0,
|
|
|
|
&s->container, -1);
|
|
|
|
}
|
qom: Put name parameter before value / visitor parameter
The object_property_set_FOO() setters take property name and value in
an unusual order:
void object_property_set_FOO(Object *obj, FOO_TYPE value,
const char *name, Error **errp)
Having to pass value before name feels grating. Swap them.
Same for object_property_set(), object_property_get(), and
object_property_parse().
Convert callers with this Coccinelle script:
@@
identifier fun = {
object_property_get, object_property_parse, object_property_set_str,
object_property_set_link, object_property_set_bool,
object_property_set_int, object_property_set_uint, object_property_set,
object_property_set_qobject
};
expression obj, v, name, errp;
@@
- fun(obj, v, name, errp)
+ fun(obj, name, v, errp)
Chokes on hw/arm/musicpal.c's lcd_refresh() with the unhelpful error
message "no position information". Convert that one manually.
Fails to convert hw/arm/armsse.c, because Coccinelle gets confused by
ARMSSE being used both as typedef and function-like macro there.
Convert manually.
Fails to convert hw/rx/rx-gdbsim.c, because Coccinelle gets confused
by RXCPU being used both as typedef and function-like macro there.
Convert manually. The other files using RXCPU that way don't need
conversion.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20200707160613.848843-27-armbru@redhat.com>
[Straightforwad conflict with commit 2336172d9b "audio: set default
value for pcspk.iobase property" resolved]
2020-07-07 18:05:54 +02:00
|
|
|
object_property_set_link(cpuobj, "memory",
|
|
|
|
OBJECT(&s->cpu_container[i]), &error_abort);
|
|
|
|
object_property_set_link(cpuobj, "idau", OBJECT(s), &error_abort);
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
if (!sysbus_realize(SYS_BUS_DEVICE(cpuobj), errp)) {
|
2019-02-01 15:55:42 +01:00
|
|
|
return;
|
|
|
|
}
|
2019-02-01 15:55:42 +01:00
|
|
|
/*
|
|
|
|
* The cluster must be realized after the armv7m container, as
|
|
|
|
* the container's CPU object is only created on realize, and the
|
|
|
|
* CPU must exist and have been parented into the cluster before
|
|
|
|
* the cluster is realized.
|
|
|
|
*/
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
if (!qdev_realize(DEVICE(&s->cluster[i]), NULL, errp)) {
|
2019-02-01 15:55:42 +01:00
|
|
|
return;
|
|
|
|
}
|
2019-02-01 15:55:42 +01:00
|
|
|
|
|
|
|
/* Connect EXP_IRQ/EXP_CPUn_IRQ GPIOs to the NVIC's lines 32 and up */
|
|
|
|
s->exp_irqs[i] = g_new(qemu_irq, s->exp_numirq);
|
|
|
|
for (j = 0; j < s->exp_numirq; j++) {
|
2021-02-19 15:45:55 +01:00
|
|
|
s->exp_irqs[i][j] = qdev_get_gpio_in(cpudev, j + NUM_SSE_IRQS);
|
2019-02-01 15:55:42 +01:00
|
|
|
}
|
|
|
|
if (i == 0) {
|
|
|
|
gpioname = g_strdup("EXP_IRQ");
|
|
|
|
} else {
|
|
|
|
gpioname = g_strdup_printf("EXP_CPU%d_IRQ", i);
|
|
|
|
}
|
|
|
|
qdev_init_gpio_in_named_with_opaque(dev, armsse_exp_irq,
|
|
|
|
s->exp_irqs[i],
|
|
|
|
gpioname, s->exp_numirq);
|
|
|
|
g_free(gpioname);
|
2018-03-02 11:45:40 +01:00
|
|
|
}
|
|
|
|
|
2019-02-01 15:55:42 +01:00
|
|
|
/* Wire up the splitters that connect common IRQs to all CPUs */
|
|
|
|
if (info->num_cpus > 1) {
|
|
|
|
for (i = 0; i < ARRAY_SIZE(s->cpu_irq_splitter); i++) {
|
2021-02-19 15:46:04 +01:00
|
|
|
if (info->irq_is_common[i]) {
|
2019-02-01 15:55:42 +01:00
|
|
|
Object *splitter = OBJECT(&s->cpu_irq_splitter[i]);
|
|
|
|
DeviceState *devs = DEVICE(splitter);
|
|
|
|
int cpunum;
|
|
|
|
|
qom: Use returned bool to check for failure, Coccinelle part
The previous commit enables conversion of
foo(..., &err);
if (err) {
...
}
to
if (!foo(..., errp)) {
...
}
for QOM functions that now return true / false on success / error.
Coccinelle script:
@@
identifier fun = {
object_apply_global_props, object_initialize_child_with_props,
object_initialize_child_with_propsv, object_property_get,
object_property_get_bool, object_property_parse, object_property_set,
object_property_set_bool, object_property_set_int,
object_property_set_link, object_property_set_qobject,
object_property_set_str, object_property_set_uint, object_set_props,
object_set_propv, user_creatable_add_dict,
user_creatable_complete, user_creatable_del
};
expression list args, args2;
typedef Error;
Error *err;
@@
- fun(args, &err, args2);
- if (err)
+ if (!fun(args, &err, args2))
{
...
}
Fails to convert hw/arm/armsse.c, because Coccinelle gets confused by
ARMSSE being used both as typedef and function-like macro there.
Convert manually.
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>
Message-Id: <20200707160613.848843-29-armbru@redhat.com>
2020-07-07 18:05:56 +02:00
|
|
|
if (!object_property_set_int(splitter, "num-lines",
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
info->num_cpus, errp)) {
|
2019-02-01 15:55:42 +01:00
|
|
|
return;
|
|
|
|
}
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
if (!qdev_realize(DEVICE(splitter), NULL, errp)) {
|
2019-02-01 15:55:42 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (cpunum = 0; cpunum < info->num_cpus; cpunum++) {
|
|
|
|
DeviceState *cpudev = DEVICE(&s->armv7m[cpunum]);
|
|
|
|
|
|
|
|
qdev_connect_gpio_out(devs, cpunum,
|
|
|
|
qdev_get_gpio_in(cpudev, i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-02 11:45:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set up the big aliases first */
|
2019-02-21 19:17:48 +01:00
|
|
|
make_alias(s, &s->alias1, &s->container, "alias 1",
|
|
|
|
0x10000000, 0x10000000, 0x00000000);
|
|
|
|
make_alias(s, &s->alias2, &s->container,
|
|
|
|
"alias 2", 0x30000000, 0x10000000, 0x20000000);
|
2018-03-02 11:45:40 +01:00
|
|
|
/* The 0x50000000..0x5fffffff region is not a pure alias: it has
|
|
|
|
* a few extra devices that only appear there (generally the
|
|
|
|
* control interfaces for the protection controllers).
|
|
|
|
* We implement this by mapping those devices over the top of this
|
2019-02-21 19:17:48 +01:00
|
|
|
* alias MR at a higher priority. Some of the devices in this range
|
|
|
|
* are per-CPU, so we must put this alias in the per-cpu containers.
|
2018-03-02 11:45:40 +01:00
|
|
|
*/
|
2019-02-21 19:17:48 +01:00
|
|
|
for (i = 0; i < info->num_cpus; i++) {
|
|
|
|
make_alias(s, &s->alias3[i], &s->cpu_container[i],
|
|
|
|
"alias 3", 0x50000000, 0x10000000, 0x40000000);
|
|
|
|
}
|
2018-03-02 11:45:40 +01:00
|
|
|
|
|
|
|
/* Security controller */
|
2021-02-19 15:45:40 +01:00
|
|
|
object_property_set_int(OBJECT(&s->secctl), "sse-version",
|
|
|
|
info->sse_version, &error_abort);
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
if (!sysbus_realize(SYS_BUS_DEVICE(&s->secctl), errp)) {
|
2018-03-02 11:45:40 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
sbd_secctl = SYS_BUS_DEVICE(&s->secctl);
|
|
|
|
dev_secctl = DEVICE(&s->secctl);
|
|
|
|
sysbus_mmio_map(sbd_secctl, 0, 0x50080000);
|
|
|
|
sysbus_mmio_map(sbd_secctl, 1, 0x40080000);
|
|
|
|
|
|
|
|
s->nsc_cfg_in = qemu_allocate_irq(nsccfg_handler, s, 1);
|
|
|
|
qdev_connect_gpio_out_named(dev_secctl, "nsc_cfg", 0, s->nsc_cfg_in);
|
|
|
|
|
|
|
|
/* The sec_resp_cfg output from the security controller must be split into
|
2019-02-01 15:55:41 +01:00
|
|
|
* multiple lines, one for each of the PPCs within the ARMSSE and one
|
|
|
|
* that will be an output from the ARMSSE to the system.
|
2018-03-02 11:45:40 +01:00
|
|
|
*/
|
qom: Use returned bool to check for failure, Coccinelle part
The previous commit enables conversion of
foo(..., &err);
if (err) {
...
}
to
if (!foo(..., errp)) {
...
}
for QOM functions that now return true / false on success / error.
Coccinelle script:
@@
identifier fun = {
object_apply_global_props, object_initialize_child_with_props,
object_initialize_child_with_propsv, object_property_get,
object_property_get_bool, object_property_parse, object_property_set,
object_property_set_bool, object_property_set_int,
object_property_set_link, object_property_set_qobject,
object_property_set_str, object_property_set_uint, object_set_props,
object_set_propv, user_creatable_add_dict,
user_creatable_complete, user_creatable_del
};
expression list args, args2;
typedef Error;
Error *err;
@@
- fun(args, &err, args2);
- if (err)
+ if (!fun(args, &err, args2))
{
...
}
Fails to convert hw/arm/armsse.c, because Coccinelle gets confused by
ARMSSE being used both as typedef and function-like macro there.
Convert manually.
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>
Message-Id: <20200707160613.848843-29-armbru@redhat.com>
2020-07-07 18:05:56 +02:00
|
|
|
if (!object_property_set_int(OBJECT(&s->sec_resp_splitter),
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
"num-lines", 3, errp)) {
|
2018-03-02 11:45:40 +01:00
|
|
|
return;
|
|
|
|
}
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
if (!qdev_realize(DEVICE(&s->sec_resp_splitter), NULL, errp)) {
|
2018-03-02 11:45:40 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
dev_splitter = DEVICE(&s->sec_resp_splitter);
|
|
|
|
qdev_connect_gpio_out_named(dev_secctl, "sec_resp_cfg", 0,
|
|
|
|
qdev_get_gpio_in(dev_splitter, 0));
|
|
|
|
|
2019-02-01 15:55:42 +01:00
|
|
|
/* Each SRAM bank lives behind its own Memory Protection Controller */
|
|
|
|
for (i = 0; i < info->sram_banks; i++) {
|
|
|
|
char *ramname = g_strdup_printf("armsse.sram%d", i);
|
|
|
|
SysBusDevice *sbd_mpc;
|
2019-02-01 15:55:42 +01:00
|
|
|
uint32_t sram_bank_size = 1 << s->sram_addr_width;
|
2019-02-01 15:55:42 +01:00
|
|
|
|
2019-02-01 15:55:42 +01:00
|
|
|
memory_region_init_ram(&s->sram[i], NULL, ramname,
|
2021-05-10 21:08:42 +02:00
|
|
|
sram_bank_size, errp);
|
2019-02-01 15:55:42 +01:00
|
|
|
g_free(ramname);
|
2021-05-10 21:08:42 +02:00
|
|
|
if (*errp) {
|
2019-02-01 15:55:42 +01:00
|
|
|
return;
|
|
|
|
}
|
qom: Put name parameter before value / visitor parameter
The object_property_set_FOO() setters take property name and value in
an unusual order:
void object_property_set_FOO(Object *obj, FOO_TYPE value,
const char *name, Error **errp)
Having to pass value before name feels grating. Swap them.
Same for object_property_set(), object_property_get(), and
object_property_parse().
Convert callers with this Coccinelle script:
@@
identifier fun = {
object_property_get, object_property_parse, object_property_set_str,
object_property_set_link, object_property_set_bool,
object_property_set_int, object_property_set_uint, object_property_set,
object_property_set_qobject
};
expression obj, v, name, errp;
@@
- fun(obj, v, name, errp)
+ fun(obj, name, v, errp)
Chokes on hw/arm/musicpal.c's lcd_refresh() with the unhelpful error
message "no position information". Convert that one manually.
Fails to convert hw/arm/armsse.c, because Coccinelle gets confused by
ARMSSE being used both as typedef and function-like macro there.
Convert manually.
Fails to convert hw/rx/rx-gdbsim.c, because Coccinelle gets confused
by RXCPU being used both as typedef and function-like macro there.
Convert manually. The other files using RXCPU that way don't need
conversion.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20200707160613.848843-27-armbru@redhat.com>
[Straightforwad conflict with commit 2336172d9b "audio: set default
value for pcspk.iobase property" resolved]
2020-07-07 18:05:54 +02:00
|
|
|
object_property_set_link(OBJECT(&s->mpc[i]), "downstream",
|
|
|
|
OBJECT(&s->sram[i]), &error_abort);
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
if (!sysbus_realize(SYS_BUS_DEVICE(&s->mpc[i]), errp)) {
|
2019-02-01 15:55:42 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Map the upstream end of the MPC into the right place... */
|
|
|
|
sbd_mpc = SYS_BUS_DEVICE(&s->mpc[i]);
|
2019-02-01 15:55:42 +01:00
|
|
|
memory_region_add_subregion(&s->container,
|
2021-05-10 21:08:41 +02:00
|
|
|
info->sram_bank_base + i * sram_bank_size,
|
2019-02-01 15:55:42 +01:00
|
|
|
sysbus_mmio_get_region(sbd_mpc, 1));
|
|
|
|
/* ...and its register interface */
|
|
|
|
memory_region_add_subregion(&s->container, 0x50083000 + i * 0x1000,
|
|
|
|
sysbus_mmio_get_region(sbd_mpc, 0));
|
2018-06-22 14:28:40 +02:00
|
|
|
}
|
|
|
|
|
2018-06-22 14:28:40 +02:00
|
|
|
/* We must OR together lines from the MPC splitters to go to the NVIC */
|
qom: Use returned bool to check for failure, Coccinelle part
The previous commit enables conversion of
foo(..., &err);
if (err) {
...
}
to
if (!foo(..., errp)) {
...
}
for QOM functions that now return true / false on success / error.
Coccinelle script:
@@
identifier fun = {
object_apply_global_props, object_initialize_child_with_props,
object_initialize_child_with_propsv, object_property_get,
object_property_get_bool, object_property_parse, object_property_set,
object_property_set_bool, object_property_set_int,
object_property_set_link, object_property_set_qobject,
object_property_set_str, object_property_set_uint, object_set_props,
object_set_propv, user_creatable_add_dict,
user_creatable_complete, user_creatable_del
};
expression list args, args2;
typedef Error;
Error *err;
@@
- fun(args, &err, args2);
- if (err)
+ if (!fun(args, &err, args2))
{
...
}
Fails to convert hw/arm/armsse.c, because Coccinelle gets confused by
ARMSSE being used both as typedef and function-like macro there.
Convert manually.
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>
Message-Id: <20200707160613.848843-29-armbru@redhat.com>
2020-07-07 18:05:56 +02:00
|
|
|
if (!object_property_set_int(OBJECT(&s->mpc_irq_orgate), "num-lines",
|
|
|
|
IOTS_NUM_EXP_MPC + info->sram_banks,
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
errp)) {
|
2018-06-22 14:28:40 +02:00
|
|
|
return;
|
|
|
|
}
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
if (!qdev_realize(DEVICE(&s->mpc_irq_orgate), NULL, errp)) {
|
2018-06-22 14:28:40 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
qdev_connect_gpio_out(DEVICE(&s->mpc_irq_orgate), 0,
|
2019-02-01 15:55:42 +01:00
|
|
|
armsse_get_common_irq_in(s, 9));
|
2018-06-22 14:28:40 +02:00
|
|
|
|
2021-02-19 15:45:58 +01:00
|
|
|
/* This OR gate wires together outputs from the secure watchdogs to NMI */
|
|
|
|
if (!object_property_set_int(OBJECT(&s->nmi_orgate), "num-lines", 2,
|
|
|
|
errp)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!qdev_realize(DEVICE(&s->nmi_orgate), NULL, errp)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
qdev_connect_gpio_out(DEVICE(&s->nmi_orgate), 0,
|
|
|
|
qdev_get_gpio_in_named(DEVICE(&s->armv7m), "NMI", 0));
|
|
|
|
|
2021-02-19 15:46:05 +01:00
|
|
|
/* The SSE-300 has a System Counter / System Timestamp Generator */
|
|
|
|
if (info->has_sse_counter) {
|
|
|
|
SysBusDevice *sbd = SYS_BUS_DEVICE(&s->sse_counter);
|
|
|
|
|
|
|
|
qdev_connect_clock_in(DEVICE(sbd), "CLK", s->mainclk);
|
|
|
|
if (!sysbus_realize(sbd, errp)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* The control frame is only in the Secure region;
|
|
|
|
* the status frame is in the NS region (and visible in the
|
|
|
|
* S region via the alias mapping).
|
|
|
|
*/
|
|
|
|
memory_region_add_subregion(&s->container, 0x58100000,
|
|
|
|
sysbus_mmio_get_region(sbd, 0));
|
|
|
|
memory_region_add_subregion(&s->container, 0x48101000,
|
|
|
|
sysbus_mmio_get_region(sbd, 1));
|
|
|
|
}
|
|
|
|
|
2021-05-10 21:08:44 +02:00
|
|
|
if (info->has_tcms) {
|
|
|
|
/* The SSE-300 has an ITCM at 0x0000_0000 and a DTCM at 0x2000_0000 */
|
|
|
|
memory_region_init_ram(&s->itcm, NULL, "sse300-itcm", 512 * KiB, errp);
|
|
|
|
if (*errp) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
memory_region_init_ram(&s->dtcm, NULL, "sse300-dtcm", 512 * KiB, errp);
|
|
|
|
if (*errp) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
memory_region_add_subregion(&s->container, 0x00000000, &s->itcm);
|
|
|
|
memory_region_add_subregion(&s->container, 0x20000000, &s->dtcm);
|
|
|
|
}
|
|
|
|
|
2018-03-02 11:45:40 +01:00
|
|
|
/* Devices behind APB PPC0:
|
|
|
|
* 0x40000000: timer0
|
|
|
|
* 0x40001000: timer1
|
|
|
|
* 0x40002000: dual timer
|
2019-02-01 15:55:43 +01:00
|
|
|
* 0x40003000: MHU0 (SSE-200 only)
|
|
|
|
* 0x40004000: MHU1 (SSE-200 only)
|
2018-03-02 11:45:40 +01:00
|
|
|
* We must configure and realize each downstream device and connect
|
|
|
|
* it to the appropriate PPC port; then we can realize the PPC and
|
|
|
|
* map its upstream ends to the right place in the container.
|
|
|
|
*/
|
2021-02-19 15:45:56 +01:00
|
|
|
for (devinfo = info->devinfo; devinfo->name; devinfo++) {
|
|
|
|
SysBusDevice *sbd;
|
|
|
|
qemu_irq irq;
|
2018-03-02 11:45:40 +01:00
|
|
|
|
2021-02-19 15:45:56 +01:00
|
|
|
if (!strcmp(devinfo->type, TYPE_CMSDK_APB_TIMER)) {
|
|
|
|
sbd = SYS_BUS_DEVICE(&s->timer[devinfo->index]);
|
|
|
|
|
2021-02-19 15:45:59 +01:00
|
|
|
qdev_connect_clock_in(DEVICE(sbd), "pclk",
|
|
|
|
devinfo->slowclk ? s->s32kclk : s->mainclk);
|
2021-02-19 15:45:56 +01:00
|
|
|
if (!sysbus_realize(sbd, errp)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mr = sysbus_mmio_get_region(sbd, 0);
|
2021-02-19 15:45:57 +01:00
|
|
|
} else if (!strcmp(devinfo->type, TYPE_CMSDK_APB_DUALTIMER)) {
|
|
|
|
sbd = SYS_BUS_DEVICE(&s->dualtimer);
|
|
|
|
|
|
|
|
qdev_connect_clock_in(DEVICE(sbd), "TIMCLK", s->mainclk);
|
|
|
|
if (!sysbus_realize(sbd, errp)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mr = sysbus_mmio_get_region(sbd, 0);
|
2021-02-19 15:46:06 +01:00
|
|
|
} else if (!strcmp(devinfo->type, TYPE_SSE_TIMER)) {
|
|
|
|
sbd = SYS_BUS_DEVICE(&s->sse_timer[devinfo->index]);
|
|
|
|
|
|
|
|
assert(info->has_sse_counter);
|
|
|
|
object_property_set_link(OBJECT(sbd), "counter",
|
|
|
|
OBJECT(&s->sse_counter), &error_abort);
|
|
|
|
if (!sysbus_realize(sbd, errp)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mr = sysbus_mmio_get_region(sbd, 0);
|
2021-02-19 15:45:58 +01:00
|
|
|
} else if (!strcmp(devinfo->type, TYPE_CMSDK_APB_WATCHDOG)) {
|
|
|
|
sbd = SYS_BUS_DEVICE(&s->cmsdk_watchdog[devinfo->index]);
|
|
|
|
|
|
|
|
qdev_connect_clock_in(DEVICE(sbd), "WDOGCLK",
|
|
|
|
devinfo->slowclk ? s->s32kclk : s->mainclk);
|
|
|
|
if (!sysbus_realize(sbd, errp)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mr = sysbus_mmio_get_region(sbd, 0);
|
2021-02-19 15:46:00 +01:00
|
|
|
} else if (!strcmp(devinfo->type, TYPE_IOTKIT_SYSINFO)) {
|
|
|
|
sbd = SYS_BUS_DEVICE(&s->sysinfo);
|
|
|
|
|
|
|
|
object_property_set_int(OBJECT(&s->sysinfo), "SYS_VERSION",
|
|
|
|
info->sys_version, &error_abort);
|
|
|
|
object_property_set_int(OBJECT(&s->sysinfo), "SYS_CONFIG",
|
|
|
|
armsse_sys_config_value(s, info),
|
|
|
|
&error_abort);
|
|
|
|
object_property_set_int(OBJECT(&s->sysinfo), "sse-version",
|
|
|
|
info->sse_version, &error_abort);
|
|
|
|
object_property_set_int(OBJECT(&s->sysinfo), "IIDR",
|
|
|
|
info->iidr, &error_abort);
|
|
|
|
if (!sysbus_realize(sbd, errp)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mr = sysbus_mmio_get_region(sbd, 0);
|
2021-02-19 15:46:01 +01:00
|
|
|
} else if (!strcmp(devinfo->type, TYPE_IOTKIT_SYSCTL)) {
|
|
|
|
/* System control registers */
|
|
|
|
sbd = SYS_BUS_DEVICE(&s->sysctl);
|
|
|
|
|
|
|
|
object_property_set_int(OBJECT(&s->sysctl), "sse-version",
|
|
|
|
info->sse_version, &error_abort);
|
|
|
|
object_property_set_int(OBJECT(&s->sysctl), "CPUWAIT_RST",
|
|
|
|
info->cpuwait_rst, &error_abort);
|
|
|
|
object_property_set_int(OBJECT(&s->sysctl), "INITSVTOR0_RST",
|
|
|
|
s->init_svtor, &error_abort);
|
|
|
|
object_property_set_int(OBJECT(&s->sysctl), "INITSVTOR1_RST",
|
|
|
|
s->init_svtor, &error_abort);
|
|
|
|
if (!sysbus_realize(sbd, errp)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mr = sysbus_mmio_get_region(sbd, 0);
|
2021-02-19 15:46:02 +01:00
|
|
|
} else if (!strcmp(devinfo->type, TYPE_UNIMPLEMENTED_DEVICE)) {
|
|
|
|
sbd = SYS_BUS_DEVICE(&s->unimp[devinfo->index]);
|
|
|
|
|
|
|
|
qdev_prop_set_string(DEVICE(sbd), "name", devinfo->name);
|
|
|
|
qdev_prop_set_uint64(DEVICE(sbd), "size", devinfo->size);
|
|
|
|
if (!sysbus_realize(sbd, errp)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mr = sysbus_mmio_get_region(sbd, 0);
|
2021-02-19 15:45:56 +01:00
|
|
|
} else {
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (devinfo->irq) {
|
|
|
|
case NO_IRQ:
|
|
|
|
irq = NULL;
|
|
|
|
break;
|
|
|
|
case 0 ... NUM_SSE_IRQS - 1:
|
|
|
|
irq = armsse_get_common_irq_in(s, devinfo->irq);
|
|
|
|
break;
|
2021-02-19 15:45:58 +01:00
|
|
|
case NMI_0:
|
|
|
|
case NMI_1:
|
|
|
|
irq = qdev_get_gpio_in(DEVICE(&s->nmi_orgate),
|
|
|
|
devinfo->irq - NMI_0);
|
|
|
|
break;
|
2021-02-19 15:45:56 +01:00
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (irq) {
|
|
|
|
sysbus_connect_irq(sbd, 0, irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Devices connected to a PPC are connected to the port here;
|
|
|
|
* we will map the upstream end of that port to the right address
|
|
|
|
* in the container later after the PPC has been realized.
|
|
|
|
* Devices not connected to a PPC can be mapped immediately.
|
|
|
|
*/
|
|
|
|
if (devinfo->ppc != NO_PPC) {
|
|
|
|
TZPPC *ppc = &s->apb_ppc[devinfo->ppc];
|
|
|
|
g_autofree char *portname = g_strdup_printf("port[%d]",
|
|
|
|
devinfo->ppc_port);
|
|
|
|
object_property_set_link(OBJECT(ppc), portname, OBJECT(mr),
|
|
|
|
&error_abort);
|
|
|
|
} else {
|
|
|
|
memory_region_add_subregion(&s->container, devinfo->addr, mr);
|
|
|
|
}
|
2018-03-02 11:45:40 +01:00
|
|
|
}
|
2018-08-24 14:17:41 +02:00
|
|
|
|
2019-02-01 15:55:43 +01:00
|
|
|
if (info->has_mhus) {
|
2019-02-28 11:55:15 +01:00
|
|
|
/*
|
|
|
|
* An SSE-200 with only one CPU should have only one MHU created,
|
|
|
|
* with the region where the second MHU usually is being RAZ/WI.
|
|
|
|
* We don't implement that SSE-200 config; if we want to support
|
|
|
|
* it then this code needs to be enhanced to handle creating the
|
|
|
|
* RAZ/WI region instead of the second MHU.
|
|
|
|
*/
|
|
|
|
assert(info->num_cpus == ARRAY_SIZE(s->mhu));
|
|
|
|
|
2019-02-01 15:55:43 +01:00
|
|
|
for (i = 0; i < ARRAY_SIZE(s->mhu); i++) {
|
2019-02-21 19:17:45 +01:00
|
|
|
char *port;
|
2019-02-28 11:55:15 +01:00
|
|
|
int cpunum;
|
|
|
|
SysBusDevice *mhu_sbd = SYS_BUS_DEVICE(&s->mhu[i]);
|
2019-02-01 15:55:43 +01:00
|
|
|
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
if (!sysbus_realize(SYS_BUS_DEVICE(&s->mhu[i]), errp)) {
|
2019-02-01 15:55:43 +01:00
|
|
|
return;
|
|
|
|
}
|
2019-02-21 19:17:45 +01:00
|
|
|
port = g_strdup_printf("port[%d]", i + 3);
|
2019-02-28 11:55:15 +01:00
|
|
|
mr = sysbus_mmio_get_region(mhu_sbd, 0);
|
2021-02-19 15:45:54 +01:00
|
|
|
object_property_set_link(OBJECT(&s->apb_ppc[0]), port, OBJECT(mr),
|
qom: Put name parameter before value / visitor parameter
The object_property_set_FOO() setters take property name and value in
an unusual order:
void object_property_set_FOO(Object *obj, FOO_TYPE value,
const char *name, Error **errp)
Having to pass value before name feels grating. Swap them.
Same for object_property_set(), object_property_get(), and
object_property_parse().
Convert callers with this Coccinelle script:
@@
identifier fun = {
object_property_get, object_property_parse, object_property_set_str,
object_property_set_link, object_property_set_bool,
object_property_set_int, object_property_set_uint, object_property_set,
object_property_set_qobject
};
expression obj, v, name, errp;
@@
- fun(obj, v, name, errp)
+ fun(obj, name, v, errp)
Chokes on hw/arm/musicpal.c's lcd_refresh() with the unhelpful error
message "no position information". Convert that one manually.
Fails to convert hw/arm/armsse.c, because Coccinelle gets confused by
ARMSSE being used both as typedef and function-like macro there.
Convert manually.
Fails to convert hw/rx/rx-gdbsim.c, because Coccinelle gets confused
by RXCPU being used both as typedef and function-like macro there.
Convert manually. The other files using RXCPU that way don't need
conversion.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20200707160613.848843-27-armbru@redhat.com>
[Straightforwad conflict with commit 2336172d9b "audio: set default
value for pcspk.iobase property" resolved]
2020-07-07 18:05:54 +02:00
|
|
|
&error_abort);
|
2019-02-21 19:17:45 +01:00
|
|
|
g_free(port);
|
2019-02-28 11:55:15 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Each MHU has an irq line for each CPU:
|
|
|
|
* MHU 0 irq line 0 -> CPU 0 IRQ 6
|
|
|
|
* MHU 0 irq line 1 -> CPU 1 IRQ 6
|
|
|
|
* MHU 1 irq line 0 -> CPU 0 IRQ 7
|
|
|
|
* MHU 1 irq line 1 -> CPU 1 IRQ 7
|
|
|
|
*/
|
|
|
|
for (cpunum = 0; cpunum < info->num_cpus; cpunum++) {
|
|
|
|
DeviceState *cpudev = DEVICE(&s->armv7m[cpunum]);
|
|
|
|
|
|
|
|
sysbus_connect_irq(mhu_sbd, cpunum,
|
|
|
|
qdev_get_gpio_in(cpudev, 6 + i));
|
|
|
|
}
|
2019-02-01 15:55:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-19 15:45:54 +01:00
|
|
|
if (!sysbus_realize(SYS_BUS_DEVICE(&s->apb_ppc[0]), errp)) {
|
2018-03-02 11:45:40 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-02-19 15:45:54 +01:00
|
|
|
sbd_apb_ppc0 = SYS_BUS_DEVICE(&s->apb_ppc[0]);
|
|
|
|
dev_apb_ppc0 = DEVICE(&s->apb_ppc[0]);
|
2018-03-02 11:45:40 +01:00
|
|
|
|
2019-02-01 15:55:43 +01:00
|
|
|
if (info->has_mhus) {
|
|
|
|
mr = sysbus_mmio_get_region(sbd_apb_ppc0, 3);
|
|
|
|
memory_region_add_subregion(&s->container, 0x40003000, mr);
|
|
|
|
mr = sysbus_mmio_get_region(sbd_apb_ppc0, 4);
|
|
|
|
memory_region_add_subregion(&s->container, 0x40004000, mr);
|
|
|
|
}
|
2018-03-02 11:45:40 +01:00
|
|
|
for (i = 0; i < IOTS_APB_PPC0_NUM_PORTS; i++) {
|
|
|
|
qdev_connect_gpio_out_named(dev_secctl, "apb_ppc0_nonsec", i,
|
|
|
|
qdev_get_gpio_in_named(dev_apb_ppc0,
|
|
|
|
"cfg_nonsec", i));
|
|
|
|
qdev_connect_gpio_out_named(dev_secctl, "apb_ppc0_ap", i,
|
|
|
|
qdev_get_gpio_in_named(dev_apb_ppc0,
|
|
|
|
"cfg_ap", i));
|
|
|
|
}
|
|
|
|
qdev_connect_gpio_out_named(dev_secctl, "apb_ppc0_irq_enable", 0,
|
|
|
|
qdev_get_gpio_in_named(dev_apb_ppc0,
|
|
|
|
"irq_enable", 0));
|
|
|
|
qdev_connect_gpio_out_named(dev_secctl, "apb_ppc0_irq_clear", 0,
|
|
|
|
qdev_get_gpio_in_named(dev_apb_ppc0,
|
|
|
|
"irq_clear", 0));
|
|
|
|
qdev_connect_gpio_out(dev_splitter, 0,
|
|
|
|
qdev_get_gpio_in_named(dev_apb_ppc0,
|
|
|
|
"cfg_sec_resp", 0));
|
|
|
|
|
|
|
|
/* All the PPC irq lines (from the 2 internal PPCs and the 8 external
|
|
|
|
* ones) are sent individually to the security controller, and also
|
|
|
|
* ORed together to give a single combined PPC interrupt to the NVIC.
|
|
|
|
*/
|
qom: Use returned bool to check for failure, Coccinelle part
The previous commit enables conversion of
foo(..., &err);
if (err) {
...
}
to
if (!foo(..., errp)) {
...
}
for QOM functions that now return true / false on success / error.
Coccinelle script:
@@
identifier fun = {
object_apply_global_props, object_initialize_child_with_props,
object_initialize_child_with_propsv, object_property_get,
object_property_get_bool, object_property_parse, object_property_set,
object_property_set_bool, object_property_set_int,
object_property_set_link, object_property_set_qobject,
object_property_set_str, object_property_set_uint, object_set_props,
object_set_propv, user_creatable_add_dict,
user_creatable_complete, user_creatable_del
};
expression list args, args2;
typedef Error;
Error *err;
@@
- fun(args, &err, args2);
- if (err)
+ if (!fun(args, &err, args2))
{
...
}
Fails to convert hw/arm/armsse.c, because Coccinelle gets confused by
ARMSSE being used both as typedef and function-like macro there.
Convert manually.
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>
Message-Id: <20200707160613.848843-29-armbru@redhat.com>
2020-07-07 18:05:56 +02:00
|
|
|
if (!object_property_set_int(OBJECT(&s->ppc_irq_orgate),
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
"num-lines", NUM_PPCS, errp)) {
|
2018-03-02 11:45:40 +01:00
|
|
|
return;
|
|
|
|
}
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
if (!qdev_realize(DEVICE(&s->ppc_irq_orgate), NULL, errp)) {
|
2018-03-02 11:45:40 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
qdev_connect_gpio_out(DEVICE(&s->ppc_irq_orgate), 0,
|
2019-02-01 15:55:42 +01:00
|
|
|
armsse_get_common_irq_in(s, 10));
|
2018-03-02 11:45:40 +01:00
|
|
|
|
2019-02-01 15:55:43 +01:00
|
|
|
/*
|
|
|
|
* 0x40010000 .. 0x4001ffff (and the 0x5001000... secure-only alias):
|
|
|
|
* private per-CPU region (all these devices are SSE-200 only):
|
|
|
|
* 0x50010000: L1 icache control registers
|
|
|
|
* 0x50011000: CPUSECCTRL (CPU local security control registers)
|
|
|
|
* 0x4001f000 and 0x5001f000: CPU_IDENTITY register block
|
2021-02-19 15:46:07 +01:00
|
|
|
* The SSE-300 has an extra:
|
|
|
|
* 0x40012000 and 0x50012000: CPU_PWRCTRL register block
|
2019-02-01 15:55:43 +01:00
|
|
|
*/
|
|
|
|
if (info->has_cachectrl) {
|
|
|
|
for (i = 0; i < info->num_cpus; i++) {
|
|
|
|
char *name = g_strdup_printf("cachectrl%d", i);
|
|
|
|
MemoryRegion *mr;
|
|
|
|
|
|
|
|
qdev_prop_set_string(DEVICE(&s->cachectrl[i]), "name", name);
|
|
|
|
g_free(name);
|
|
|
|
qdev_prop_set_uint64(DEVICE(&s->cachectrl[i]), "size", 0x1000);
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
if (!sysbus_realize(SYS_BUS_DEVICE(&s->cachectrl[i]), errp)) {
|
2019-02-01 15:55:43 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->cachectrl[i]), 0);
|
|
|
|
memory_region_add_subregion(&s->cpu_container[i], 0x50010000, mr);
|
|
|
|
}
|
|
|
|
}
|
2019-02-01 15:55:43 +01:00
|
|
|
if (info->has_cpusecctrl) {
|
|
|
|
for (i = 0; i < info->num_cpus; i++) {
|
|
|
|
char *name = g_strdup_printf("CPUSECCTRL%d", i);
|
|
|
|
MemoryRegion *mr;
|
|
|
|
|
|
|
|
qdev_prop_set_string(DEVICE(&s->cpusecctrl[i]), "name", name);
|
|
|
|
g_free(name);
|
|
|
|
qdev_prop_set_uint64(DEVICE(&s->cpusecctrl[i]), "size", 0x1000);
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpusecctrl[i]), errp)) {
|
2019-02-01 15:55:43 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->cpusecctrl[i]), 0);
|
|
|
|
memory_region_add_subregion(&s->cpu_container[i], 0x50011000, mr);
|
|
|
|
}
|
|
|
|
}
|
2019-02-01 15:55:43 +01:00
|
|
|
if (info->has_cpuid) {
|
|
|
|
for (i = 0; i < info->num_cpus; i++) {
|
|
|
|
MemoryRegion *mr;
|
|
|
|
|
|
|
|
qdev_prop_set_uint32(DEVICE(&s->cpuid[i]), "CPUID", i);
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpuid[i]), errp)) {
|
2019-02-01 15:55:43 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->cpuid[i]), 0);
|
|
|
|
memory_region_add_subregion(&s->cpu_container[i], 0x4001F000, mr);
|
|
|
|
}
|
|
|
|
}
|
2021-02-19 15:46:07 +01:00
|
|
|
if (info->has_cpu_pwrctrl) {
|
|
|
|
for (i = 0; i < info->num_cpus; i++) {
|
|
|
|
MemoryRegion *mr;
|
|
|
|
|
|
|
|
if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpu_pwrctrl[i]), errp)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->cpu_pwrctrl[i]), 0);
|
|
|
|
memory_region_add_subregion(&s->cpu_container[i], 0x40012000, mr);
|
|
|
|
}
|
|
|
|
}
|
2018-03-02 11:45:40 +01:00
|
|
|
|
2021-02-19 15:45:54 +01:00
|
|
|
if (!sysbus_realize(SYS_BUS_DEVICE(&s->apb_ppc[1]), errp)) {
|
2018-03-02 11:45:40 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-02-19 15:45:54 +01:00
|
|
|
dev_apb_ppc1 = DEVICE(&s->apb_ppc[1]);
|
2018-03-02 11:45:40 +01:00
|
|
|
qdev_connect_gpio_out_named(dev_secctl, "apb_ppc1_nonsec", 0,
|
|
|
|
qdev_get_gpio_in_named(dev_apb_ppc1,
|
|
|
|
"cfg_nonsec", 0));
|
|
|
|
qdev_connect_gpio_out_named(dev_secctl, "apb_ppc1_ap", 0,
|
|
|
|
qdev_get_gpio_in_named(dev_apb_ppc1,
|
|
|
|
"cfg_ap", 0));
|
|
|
|
qdev_connect_gpio_out_named(dev_secctl, "apb_ppc1_irq_enable", 0,
|
|
|
|
qdev_get_gpio_in_named(dev_apb_ppc1,
|
|
|
|
"irq_enable", 0));
|
|
|
|
qdev_connect_gpio_out_named(dev_secctl, "apb_ppc1_irq_clear", 0,
|
|
|
|
qdev_get_gpio_in_named(dev_apb_ppc1,
|
|
|
|
"irq_clear", 0));
|
|
|
|
qdev_connect_gpio_out(dev_splitter, 1,
|
|
|
|
qdev_get_gpio_in_named(dev_apb_ppc1,
|
|
|
|
"cfg_sec_resp", 0));
|
|
|
|
|
2021-02-19 15:45:56 +01:00
|
|
|
/*
|
|
|
|
* Now both PPCs are realized we can map the upstream ends of
|
|
|
|
* ports which correspond to entries in the devinfo array.
|
|
|
|
* The ports which are connected to non-devinfo devices have
|
|
|
|
* already been mapped.
|
|
|
|
*/
|
|
|
|
for (devinfo = info->devinfo; devinfo->name; devinfo++) {
|
|
|
|
SysBusDevice *ppc_sbd;
|
|
|
|
|
|
|
|
if (devinfo->ppc == NO_PPC) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ppc_sbd = SYS_BUS_DEVICE(&s->apb_ppc[devinfo->ppc]);
|
|
|
|
mr = sysbus_mmio_get_region(ppc_sbd, devinfo->ppc_port);
|
|
|
|
memory_region_add_subregion(&s->container, devinfo->addr, mr);
|
|
|
|
}
|
|
|
|
|
2018-03-02 11:45:40 +01:00
|
|
|
for (i = 0; i < ARRAY_SIZE(s->ppc_irq_splitter); i++) {
|
|
|
|
Object *splitter = OBJECT(&s->ppc_irq_splitter[i]);
|
|
|
|
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
if (!object_property_set_int(splitter, "num-lines", 2, errp)) {
|
2018-03-02 11:45:40 +01:00
|
|
|
return;
|
|
|
|
}
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
if (!qdev_realize(DEVICE(splitter), NULL, errp)) {
|
2018-03-02 11:45:40 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < IOTS_NUM_AHB_EXP_PPC; i++) {
|
|
|
|
char *ppcname = g_strdup_printf("ahb_ppcexp%d", i);
|
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
armsse_forward_ppc(s, ppcname, i);
|
2018-03-02 11:45:40 +01:00
|
|
|
g_free(ppcname);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < IOTS_NUM_APB_EXP_PPC; i++) {
|
|
|
|
char *ppcname = g_strdup_printf("apb_ppcexp%d", i);
|
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
armsse_forward_ppc(s, ppcname, i + IOTS_NUM_AHB_EXP_PPC);
|
2018-03-02 11:45:40 +01:00
|
|
|
g_free(ppcname);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = NUM_EXTERNAL_PPCS; i < NUM_PPCS; i++) {
|
|
|
|
/* Wire up IRQ splitter for internal PPCs */
|
|
|
|
DeviceState *devs = DEVICE(&s->ppc_irq_splitter[i]);
|
|
|
|
char *gpioname = g_strdup_printf("apb_ppc%d_irq_status",
|
|
|
|
i - NUM_EXTERNAL_PPCS);
|
2021-02-19 15:45:54 +01:00
|
|
|
TZPPC *ppc = &s->apb_ppc[i - NUM_EXTERNAL_PPCS];
|
2018-03-02 11:45:40 +01:00
|
|
|
|
|
|
|
qdev_connect_gpio_out(devs, 0,
|
|
|
|
qdev_get_gpio_in_named(dev_secctl, gpioname, 0));
|
|
|
|
qdev_connect_gpio_out(devs, 1,
|
|
|
|
qdev_get_gpio_in(DEVICE(&s->ppc_irq_orgate), i));
|
|
|
|
qdev_connect_gpio_out_named(DEVICE(ppc), "irq", 0,
|
|
|
|
qdev_get_gpio_in(devs, 0));
|
2018-05-10 19:10:56 +02:00
|
|
|
g_free(gpioname);
|
2018-03-02 11:45:40 +01:00
|
|
|
}
|
|
|
|
|
2018-06-22 14:28:40 +02:00
|
|
|
/* Wire up the splitters for the MPC IRQs */
|
2019-02-01 15:55:42 +01:00
|
|
|
for (i = 0; i < IOTS_NUM_EXP_MPC + info->sram_banks; i++) {
|
2018-06-22 14:28:40 +02:00
|
|
|
SplitIRQ *splitter = &s->mpc_irq_splitter[i];
|
|
|
|
DeviceState *dev_splitter = DEVICE(splitter);
|
|
|
|
|
qom: Use returned bool to check for failure, Coccinelle part
The previous commit enables conversion of
foo(..., &err);
if (err) {
...
}
to
if (!foo(..., errp)) {
...
}
for QOM functions that now return true / false on success / error.
Coccinelle script:
@@
identifier fun = {
object_apply_global_props, object_initialize_child_with_props,
object_initialize_child_with_propsv, object_property_get,
object_property_get_bool, object_property_parse, object_property_set,
object_property_set_bool, object_property_set_int,
object_property_set_link, object_property_set_qobject,
object_property_set_str, object_property_set_uint, object_set_props,
object_set_propv, user_creatable_add_dict,
user_creatable_complete, user_creatable_del
};
expression list args, args2;
typedef Error;
Error *err;
@@
- fun(args, &err, args2);
- if (err)
+ if (!fun(args, &err, args2))
{
...
}
Fails to convert hw/arm/armsse.c, because Coccinelle gets confused by
ARMSSE being used both as typedef and function-like macro there.
Convert manually.
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>
Message-Id: <20200707160613.848843-29-armbru@redhat.com>
2020-07-07 18:05:56 +02:00
|
|
|
if (!object_property_set_int(OBJECT(splitter), "num-lines", 2,
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
errp)) {
|
2018-06-22 14:28:40 +02:00
|
|
|
return;
|
|
|
|
}
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently 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.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
if (!qdev_realize(DEVICE(splitter), NULL, errp)) {
|
2018-06-22 14:28:40 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i < IOTS_NUM_EXP_MPC) {
|
|
|
|
/* Splitter input is from GPIO input line */
|
|
|
|
s->mpcexp_status_in[i] = qdev_get_gpio_in(dev_splitter, 0);
|
|
|
|
qdev_connect_gpio_out(dev_splitter, 0,
|
|
|
|
qdev_get_gpio_in_named(dev_secctl,
|
|
|
|
"mpcexp_status", i));
|
|
|
|
} else {
|
|
|
|
/* Splitter input is from our own MPC */
|
2019-02-01 15:55:42 +01:00
|
|
|
qdev_connect_gpio_out_named(DEVICE(&s->mpc[i - IOTS_NUM_EXP_MPC]),
|
|
|
|
"irq", 0,
|
2018-06-22 14:28:40 +02:00
|
|
|
qdev_get_gpio_in(dev_splitter, 0));
|
|
|
|
qdev_connect_gpio_out(dev_splitter, 0,
|
|
|
|
qdev_get_gpio_in_named(dev_secctl,
|
2020-11-07 20:33:59 +01:00
|
|
|
"mpc_status",
|
|
|
|
i - IOTS_NUM_EXP_MPC));
|
2018-06-22 14:28:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
qdev_connect_gpio_out(dev_splitter, 1,
|
|
|
|
qdev_get_gpio_in(DEVICE(&s->mpc_irq_orgate), i));
|
|
|
|
}
|
|
|
|
/* Create GPIO inputs which will pass the line state for our
|
|
|
|
* mpcexp_irq inputs to the correct splitter devices.
|
|
|
|
*/
|
2019-02-01 15:55:41 +01:00
|
|
|
qdev_init_gpio_in_named(dev, armsse_mpcexp_status, "mpcexp_status",
|
2018-06-22 14:28:40 +02:00
|
|
|
IOTS_NUM_EXP_MPC);
|
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
armsse_forward_sec_resp_cfg(s);
|
2018-03-02 11:45:40 +01:00
|
|
|
|
2018-08-24 14:17:44 +02:00
|
|
|
/* Forward the MSC related signals */
|
|
|
|
qdev_pass_gpios(dev_secctl, dev, "mscexp_status");
|
|
|
|
qdev_pass_gpios(dev_secctl, dev, "mscexp_clear");
|
|
|
|
qdev_pass_gpios(dev_secctl, dev, "mscexp_ns");
|
|
|
|
qdev_connect_gpio_out_named(dev_secctl, "msc_irq", 0,
|
2019-02-01 15:55:42 +01:00
|
|
|
armsse_get_common_irq_in(s, 11));
|
2018-08-24 14:17:44 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Expose our container region to the board model; this corresponds
|
|
|
|
* to the AHB Slave Expansion ports which allow bus master devices
|
|
|
|
* (eg DMA controllers) in the board model to make transactions into
|
2019-02-01 15:55:41 +01:00
|
|
|
* devices in the ARMSSE.
|
2018-08-24 14:17:44 +02:00
|
|
|
*/
|
|
|
|
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->container);
|
2018-03-02 11:45:40 +01:00
|
|
|
}
|
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
static void armsse_idau_check(IDAUInterface *ii, uint32_t address,
|
2018-03-02 11:45:40 +01:00
|
|
|
int *iregion, bool *exempt, bool *ns, bool *nsc)
|
|
|
|
{
|
2019-02-01 15:55:41 +01:00
|
|
|
/*
|
|
|
|
* For ARMSSE systems the IDAU responses are simple logical functions
|
2018-03-02 11:45:40 +01:00
|
|
|
* of the address bits. The NSC attribute is guest-adjustable via the
|
|
|
|
* NSCCFG register in the security controller.
|
|
|
|
*/
|
2020-08-25 21:20:21 +02:00
|
|
|
ARMSSE *s = ARM_SSE(ii);
|
2018-03-02 11:45:40 +01:00
|
|
|
int region = extract32(address, 28, 4);
|
|
|
|
|
|
|
|
*ns = !(region & 1);
|
|
|
|
*nsc = (region == 1 && (s->nsccfg & 1)) || (region == 3 && (s->nsccfg & 2));
|
|
|
|
/* 0xe0000000..0xe00fffff and 0xf0000000..0xf00fffff are exempt */
|
|
|
|
*exempt = (address & 0xeff00000) == 0xe0000000;
|
|
|
|
*iregion = region;
|
|
|
|
}
|
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
static const VMStateDescription armsse_vmstate = {
|
2018-03-02 11:45:40 +01:00
|
|
|
.name = "iotkit",
|
2021-01-28 12:41:31 +01:00
|
|
|
.version_id = 2,
|
|
|
|
.minimum_version_id = 2,
|
2018-03-02 11:45:40 +01:00
|
|
|
.fields = (VMStateField[]) {
|
2021-01-28 12:41:31 +01:00
|
|
|
VMSTATE_CLOCK(mainclk, ARMSSE),
|
|
|
|
VMSTATE_CLOCK(s32kclk, ARMSSE),
|
2019-02-01 15:55:41 +01:00
|
|
|
VMSTATE_UINT32(nsccfg, ARMSSE),
|
2018-03-02 11:45:40 +01:00
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
static void armsse_reset(DeviceState *dev)
|
2018-03-02 11:45:40 +01:00
|
|
|
{
|
2020-08-25 21:20:21 +02:00
|
|
|
ARMSSE *s = ARM_SSE(dev);
|
2018-03-02 11:45:40 +01:00
|
|
|
|
|
|
|
s->nsccfg = 0;
|
|
|
|
}
|
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
static void armsse_class_init(ObjectClass *klass, void *data)
|
2018-03-02 11:45:40 +01:00
|
|
|
{
|
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
|
|
|
IDAUInterfaceClass *iic = IDAU_INTERFACE_CLASS(klass);
|
2020-08-25 21:20:21 +02:00
|
|
|
ARMSSEClass *asc = ARM_SSE_CLASS(klass);
|
2019-05-17 19:40:46 +02:00
|
|
|
const ARMSSEInfo *info = data;
|
2018-03-02 11:45:40 +01:00
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
dc->realize = armsse_realize;
|
|
|
|
dc->vmsd = &armsse_vmstate;
|
2020-01-10 16:30:32 +01:00
|
|
|
device_class_set_props(dc, info->props);
|
2019-02-01 15:55:41 +01:00
|
|
|
dc->reset = armsse_reset;
|
|
|
|
iic->check = armsse_idau_check;
|
2019-05-17 19:40:46 +02:00
|
|
|
asc->info = info;
|
2018-03-02 11:45:40 +01:00
|
|
|
}
|
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
static const TypeInfo armsse_info = {
|
2020-08-25 21:20:21 +02:00
|
|
|
.name = TYPE_ARM_SSE,
|
2018-03-02 11:45:40 +01:00
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
2019-02-01 15:55:41 +01:00
|
|
|
.instance_size = sizeof(ARMSSE),
|
2020-08-28 11:02:47 +02:00
|
|
|
.class_size = sizeof(ARMSSEClass),
|
2019-02-01 15:55:41 +01:00
|
|
|
.instance_init = armsse_init,
|
2019-02-01 15:55:41 +01:00
|
|
|
.abstract = true,
|
2018-03-02 11:45:40 +01:00
|
|
|
.interfaces = (InterfaceInfo[]) {
|
|
|
|
{ TYPE_IDAU_INTERFACE },
|
|
|
|
{ }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
static void armsse_register_types(void)
|
2018-03-02 11:45:40 +01:00
|
|
|
{
|
2019-02-01 15:55:41 +01:00
|
|
|
int i;
|
|
|
|
|
|
|
|
type_register_static(&armsse_info);
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(armsse_variants); i++) {
|
|
|
|
TypeInfo ti = {
|
|
|
|
.name = armsse_variants[i].name,
|
2020-08-25 21:20:21 +02:00
|
|
|
.parent = TYPE_ARM_SSE,
|
2019-02-01 15:55:41 +01:00
|
|
|
.class_init = armsse_class_init,
|
2019-02-01 15:55:41 +01:00
|
|
|
.class_data = (void *)&armsse_variants[i],
|
|
|
|
};
|
|
|
|
type_register(&ti);
|
|
|
|
}
|
2018-03-02 11:45:40 +01:00
|
|
|
}
|
|
|
|
|
2019-02-01 15:55:41 +01:00
|
|
|
type_init(armsse_register_types);
|