MAX78000: ICC Implementation
This commit implements the Instruction Cache Controller for the MAX78000 Signed-off-by: Jackson Donaldson <jcksn@duck.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 20250704223239.248781-3-jcksn@duck.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
51eb283dd0
commit
3ec680e64c
5 changed files with 158 additions and 0 deletions
|
|
@ -366,6 +366,7 @@ config ALLWINNER_R40
|
|||
config MAX78000_SOC
|
||||
bool
|
||||
select ARM_V7M
|
||||
select MAX78000_ICC
|
||||
|
||||
config RASPI
|
||||
bool
|
||||
|
|
|
|||
|
|
@ -47,6 +47,9 @@ config A9SCU
|
|||
config ARM11SCU
|
||||
bool
|
||||
|
||||
config MAX78000_ICC
|
||||
bool
|
||||
|
||||
config MOS6522
|
||||
bool
|
||||
|
||||
|
|
|
|||
120
hw/misc/max78000_icc.c
Normal file
120
hw/misc/max78000_icc.c
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
* MAX78000 Instruction Cache
|
||||
*
|
||||
* Copyright (c) 2025 Jackson Donaldson <jcksn@duck.com>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/log.h"
|
||||
#include "trace.h"
|
||||
#include "hw/irq.h"
|
||||
#include "migration/vmstate.h"
|
||||
#include "hw/misc/max78000_icc.h"
|
||||
|
||||
|
||||
static uint64_t max78000_icc_read(void *opaque, hwaddr addr,
|
||||
unsigned int size)
|
||||
{
|
||||
Max78000IccState *s = opaque;
|
||||
switch (addr) {
|
||||
case ICC_INFO:
|
||||
return s->info;
|
||||
|
||||
case ICC_SZ:
|
||||
return s->sz;
|
||||
|
||||
case ICC_CTRL:
|
||||
return s->ctrl;
|
||||
|
||||
default:
|
||||
qemu_log_mask(LOG_GUEST_ERROR,
|
||||
"%s: Bad offset 0x%" HWADDR_PRIx "\n",
|
||||
__func__, addr);
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void max78000_icc_write(void *opaque, hwaddr addr,
|
||||
uint64_t val64, unsigned int size)
|
||||
{
|
||||
Max78000IccState *s = opaque;
|
||||
|
||||
switch (addr) {
|
||||
case ICC_CTRL:
|
||||
s->ctrl = 0x10000 | (val64 & 1);
|
||||
break;
|
||||
|
||||
case ICC_INVALIDATE:
|
||||
break;
|
||||
|
||||
default:
|
||||
qemu_log_mask(LOG_GUEST_ERROR,
|
||||
"%s: Bad offset 0x%" HWADDR_PRIx "\n",
|
||||
__func__, addr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static const MemoryRegionOps max78000_icc_ops = {
|
||||
.read = max78000_icc_read,
|
||||
.write = max78000_icc_write,
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
.valid.min_access_size = 4,
|
||||
.valid.max_access_size = 4,
|
||||
};
|
||||
|
||||
static const VMStateDescription max78000_icc_vmstate = {
|
||||
.name = TYPE_MAX78000_ICC,
|
||||
.version_id = 1,
|
||||
.minimum_version_id = 1,
|
||||
.fields = (const VMStateField[]) {
|
||||
VMSTATE_UINT32(info, Max78000IccState),
|
||||
VMSTATE_UINT32(sz, Max78000IccState),
|
||||
VMSTATE_UINT32(ctrl, Max78000IccState),
|
||||
VMSTATE_END_OF_LIST()
|
||||
}
|
||||
};
|
||||
|
||||
static void max78000_icc_reset_hold(Object *obj, ResetType type)
|
||||
{
|
||||
Max78000IccState *s = MAX78000_ICC(obj);
|
||||
s->info = 0;
|
||||
s->sz = 0x10000010;
|
||||
s->ctrl = 0x10000;
|
||||
}
|
||||
|
||||
static void max78000_icc_init(Object *obj)
|
||||
{
|
||||
Max78000IccState *s = MAX78000_ICC(obj);
|
||||
|
||||
memory_region_init_io(&s->mmio, obj, &max78000_icc_ops, s,
|
||||
TYPE_MAX78000_ICC, 0x800);
|
||||
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio);
|
||||
}
|
||||
|
||||
static void max78000_icc_class_init(ObjectClass *klass, const void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
ResettableClass *rc = RESETTABLE_CLASS(klass);
|
||||
|
||||
rc->phases.hold = max78000_icc_reset_hold;
|
||||
dc->vmsd = &max78000_icc_vmstate;
|
||||
}
|
||||
|
||||
static const TypeInfo max78000_icc_info = {
|
||||
.name = TYPE_MAX78000_ICC,
|
||||
.parent = TYPE_SYS_BUS_DEVICE,
|
||||
.instance_size = sizeof(Max78000IccState),
|
||||
.instance_init = max78000_icc_init,
|
||||
.class_init = max78000_icc_class_init,
|
||||
};
|
||||
|
||||
static void max78000_icc_register_types(void)
|
||||
{
|
||||
type_register_static(&max78000_icc_info);
|
||||
}
|
||||
|
||||
type_init(max78000_icc_register_types)
|
||||
|
|
@ -70,6 +70,7 @@ system_ss.add(when: 'CONFIG_IMX', if_true: files(
|
|||
'imx_ccm.c',
|
||||
'imx_rngc.c',
|
||||
))
|
||||
system_ss.add(when: 'CONFIG_MAX78000_ICC', if_true: files('max78000_icc.c'))
|
||||
system_ss.add(when: 'CONFIG_NPCM7XX', if_true: files(
|
||||
'npcm_clk.c',
|
||||
'npcm_gcr.c',
|
||||
|
|
|
|||
33
include/hw/misc/max78000_icc.h
Normal file
33
include/hw/misc/max78000_icc.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* MAX78000 Instruction Cache
|
||||
*
|
||||
* Copyright (c) 2025 Jackson Donaldson <jcksn@duck.com>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef HW_MAX78000_ICC_H
|
||||
#define HW_MAX78000_ICC_H
|
||||
|
||||
#include "hw/sysbus.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
#define TYPE_MAX78000_ICC "max78000-icc"
|
||||
OBJECT_DECLARE_SIMPLE_TYPE(Max78000IccState, MAX78000_ICC)
|
||||
|
||||
#define ICC_INFO 0x0
|
||||
#define ICC_SZ 0x4
|
||||
#define ICC_CTRL 0x100
|
||||
#define ICC_INVALIDATE 0x700
|
||||
|
||||
struct Max78000IccState {
|
||||
SysBusDevice parent_obj;
|
||||
|
||||
MemoryRegion mmio;
|
||||
|
||||
uint32_t info;
|
||||
uint32_t sz;
|
||||
uint32_t ctrl;
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue