2013-02-28 19:23:14 +01:00
|
|
|
/*
|
|
|
|
* Cortex-A9MPCore Snoop Control Unit (SCU) emulation.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2009 CodeSourcery.
|
|
|
|
* Copyright (c) 2011 Linaro Limited.
|
|
|
|
* Written by Paul Brook, Peter Maydell.
|
|
|
|
*
|
|
|
|
* This code is licensed under the GPL.
|
|
|
|
*/
|
|
|
|
|
2016-01-26 19:17:05 +01:00
|
|
|
#include "qemu/osdep.h"
|
2013-06-30 19:29:36 +02:00
|
|
|
#include "hw/misc/a9scu.h"
|
2019-08-12 07:23:51 +02:00
|
|
|
#include "hw/qdev-properties.h"
|
2019-08-12 07:23:45 +02:00
|
|
|
#include "migration/vmstate.h"
|
2020-09-01 16:40:57 +02:00
|
|
|
#include "qapi/error.h"
|
2020-09-01 16:41:00 +02:00
|
|
|
#include "qemu/log.h"
|
2019-05-23 16:35:07 +02:00
|
|
|
#include "qemu/module.h"
|
2013-02-28 19:23:14 +01:00
|
|
|
|
2020-09-01 16:40:57 +02:00
|
|
|
#define A9_SCU_CPU_MAX 4
|
|
|
|
|
2013-02-28 19:23:14 +01:00
|
|
|
static uint64_t a9_scu_read(void *opaque, hwaddr offset,
|
|
|
|
unsigned size)
|
|
|
|
{
|
|
|
|
A9SCUState *s = (A9SCUState *)opaque;
|
|
|
|
switch (offset) {
|
|
|
|
case 0x00: /* Control */
|
|
|
|
return s->control;
|
|
|
|
case 0x04: /* Configuration */
|
|
|
|
return (((1 << s->num_cpu) - 1) << 4) | (s->num_cpu - 1);
|
|
|
|
case 0x08: /* CPU Power Status */
|
|
|
|
return s->status;
|
|
|
|
case 0x0c: /* Invalidate All Registers In Secure State */
|
|
|
|
return 0;
|
|
|
|
case 0x40: /* Filtering Start Address Register */
|
|
|
|
case 0x44: /* Filtering End Address Register */
|
|
|
|
/* RAZ/WI, like an implementation with only one AXI master */
|
|
|
|
return 0;
|
|
|
|
case 0x50: /* SCU Access Control Register */
|
|
|
|
case 0x54: /* SCU Non-secure Access Control Register */
|
|
|
|
/* unimplemented, fall through */
|
|
|
|
default:
|
2020-09-01 16:41:00 +02:00
|
|
|
qemu_log_mask(LOG_UNIMP, "%s: Unsupported offset 0x%"HWADDR_PRIx"\n",
|
|
|
|
__func__, offset);
|
2013-02-28 19:23:14 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void a9_scu_write(void *opaque, hwaddr offset,
|
|
|
|
uint64_t value, unsigned size)
|
|
|
|
{
|
|
|
|
A9SCUState *s = (A9SCUState *)opaque;
|
|
|
|
|
|
|
|
switch (offset) {
|
|
|
|
case 0x00: /* Control */
|
|
|
|
s->control = value & 1;
|
|
|
|
break;
|
|
|
|
case 0x4: /* Configuration: RO */
|
|
|
|
break;
|
|
|
|
case 0x08: case 0x09: case 0x0A: case 0x0B: /* Power Control */
|
2020-09-01 16:40:59 +02:00
|
|
|
s->status = value;
|
2013-02-28 19:23:14 +01:00
|
|
|
break;
|
|
|
|
case 0x0c: /* Invalidate All Registers In Secure State */
|
|
|
|
/* no-op as we do not implement caches */
|
|
|
|
break;
|
|
|
|
case 0x40: /* Filtering Start Address Register */
|
|
|
|
case 0x44: /* Filtering End Address Register */
|
|
|
|
/* RAZ/WI, like an implementation with only one AXI master */
|
|
|
|
break;
|
|
|
|
case 0x50: /* SCU Access Control Register */
|
|
|
|
case 0x54: /* SCU Non-secure Access Control Register */
|
|
|
|
/* unimplemented, fall through */
|
|
|
|
default:
|
2020-09-01 16:41:00 +02:00
|
|
|
qemu_log_mask(LOG_UNIMP, "%s: Unsupported offset 0x%"HWADDR_PRIx
|
|
|
|
" value 0x%"PRIx64"\n",
|
|
|
|
__func__, offset, value);
|
2013-02-28 19:23:14 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const MemoryRegionOps a9_scu_ops = {
|
|
|
|
.read = a9_scu_read,
|
|
|
|
.write = a9_scu_write,
|
2020-09-01 16:40:59 +02:00
|
|
|
.impl = {
|
|
|
|
.min_access_size = 4,
|
|
|
|
.max_access_size = 4,
|
|
|
|
},
|
2020-09-01 16:40:58 +02:00
|
|
|
.valid = {
|
|
|
|
.min_access_size = 1,
|
|
|
|
.max_access_size = 4,
|
|
|
|
},
|
2013-02-28 19:23:14 +01:00
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void a9_scu_reset(DeviceState *dev)
|
|
|
|
{
|
|
|
|
A9SCUState *s = A9_SCU(dev);
|
|
|
|
s->control = 0;
|
|
|
|
}
|
|
|
|
|
2020-09-01 16:40:57 +02:00
|
|
|
static void a9_scu_realize(DeviceState *dev, Error **errp)
|
2013-02-28 19:23:14 +01:00
|
|
|
{
|
2020-09-01 16:40:57 +02:00
|
|
|
A9SCUState *s = A9_SCU(dev);
|
|
|
|
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
|
|
|
|
|
|
|
|
if (!s->num_cpu || s->num_cpu > A9_SCU_CPU_MAX) {
|
|
|
|
error_setg(errp, "Illegal CPU count: %u", s->num_cpu);
|
|
|
|
return;
|
|
|
|
}
|
2013-02-28 19:23:14 +01:00
|
|
|
|
2020-09-01 16:40:57 +02:00
|
|
|
memory_region_init_io(&s->iomem, OBJECT(s), &a9_scu_ops, s,
|
2013-06-07 03:25:08 +02:00
|
|
|
"a9-scu", 0x100);
|
2013-02-28 19:23:14 +01:00
|
|
|
sysbus_init_mmio(sbd, &s->iomem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_a9_scu = {
|
|
|
|
.name = "a9-scu",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_UINT32(control, A9SCUState),
|
|
|
|
VMSTATE_UINT32(status, A9SCUState),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static Property a9_scu_properties[] = {
|
|
|
|
DEFINE_PROP_UINT32("num-cpu", A9SCUState, num_cpu, 1),
|
|
|
|
DEFINE_PROP_END_OF_LIST(),
|
|
|
|
};
|
|
|
|
|
|
|
|
static void a9_scu_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
|
|
|
|
2020-01-10 16:30:32 +01:00
|
|
|
device_class_set_props(dc, a9_scu_properties);
|
2013-02-28 19:23:14 +01:00
|
|
|
dc->vmsd = &vmstate_a9_scu;
|
|
|
|
dc->reset = a9_scu_reset;
|
2020-09-01 16:40:57 +02:00
|
|
|
dc->realize = a9_scu_realize;
|
2013-02-28 19:23:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const TypeInfo a9_scu_info = {
|
|
|
|
.name = TYPE_A9_SCU,
|
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
|
|
|
.instance_size = sizeof(A9SCUState),
|
|
|
|
.class_init = a9_scu_class_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void a9mp_register_types(void)
|
|
|
|
{
|
|
|
|
type_register_static(&a9_scu_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
type_init(a9mp_register_types)
|