aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorAlistair Francis <alistair.francis@wdc.com>2022-01-06 07:39:30 +1000
committerAlistair Francis <alistair.francis@wdc.com>2022-01-08 15:46:09 +1000
commit83b92b8efca6634406361d62dbf9d3e8369a2a20 (patch)
tree5dcf13a278dc98549b0521ae662a79e385d7257b /hw
parente6b0408a1728c001a0cc0568b9daae5f92e239ee (diff)
downloadqemu-83b92b8efca6634406361d62dbf9d3e8369a2a20.zip
qemu-83b92b8efca6634406361d62dbf9d3e8369a2a20.tar.gz
qemu-83b92b8efca6634406361d62dbf9d3e8369a2a20.tar.bz2
hw/intc: sifive_plic: Add a reset function
Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Message-Id: <20220105213937.1113508-2-alistair.francis@opensource.wdc.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/intc/sifive_plic.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c
index 877e768..a9f7a1b 100644
--- a/hw/intc/sifive_plic.c
+++ b/hw/intc/sifive_plic.c
@@ -355,6 +355,23 @@ static const MemoryRegionOps sifive_plic_ops = {
}
};
+static void sifive_plic_reset(DeviceState *dev)
+{
+ SiFivePLICState *s = SIFIVE_PLIC(dev);
+ int i;
+
+ memset(s->source_priority, 0, sizeof(uint32_t) * s->num_sources);
+ memset(s->target_priority, 0, sizeof(uint32_t) * s->num_addrs);
+ memset(s->pending, 0, sizeof(uint32_t) * s->bitfield_words);
+ memset(s->claimed, 0, sizeof(uint32_t) * s->bitfield_words);
+ memset(s->enable, 0, sizeof(uint32_t) * s->num_enables);
+
+ for (i = 0; i < s->num_harts; i++) {
+ qemu_set_irq(s->m_external_irqs[i], 0);
+ qemu_set_irq(s->s_external_irqs[i], 0);
+ }
+}
+
/*
* parse PLIC hart/mode address offset config
*
@@ -501,6 +518,7 @@ static void sifive_plic_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
+ dc->reset = sifive_plic_reset;
device_class_set_props(dc, sifive_plic_properties);
dc->realize = sifive_plic_realize;
dc->vmsd = &vmstate_sifive_plic;