From 644efbcb7bfd36b9cb5f8b8afef16c3a62e27675 Mon Sep 17 00:00:00 2001 From: Conor Paxton Date: Wed, 29 Nov 2023 21:39:33 +0000 Subject: [PATCH] drivers: intc_plic: claim interrupt from hart that serviced it The plic has a very simple mechanism to claim an interrupt as well as to complete and clear it. The same register is read from/ written to to achieve this. Get the ID of the HART that serviced the interrupt and write to the claim complete register in the correct context Signed-off-by: Conor Paxton --- drivers/interrupt_controller/intc_plic.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/interrupt_controller/intc_plic.c b/drivers/interrupt_controller/intc_plic.c index 1c3d809f34723a2..7077c73f76713f9 100644 --- a/drivers/interrupt_controller/intc_plic.c +++ b/drivers/interrupt_controller/intc_plic.c @@ -134,7 +134,17 @@ static inline mem_addr_t get_claim_complete_addr(const struct device *dev) { const struct plic_config *config = dev->config; - return config->reg + CONTEXT_CLAIM; + /* + * We want to return the claim complete addr for the hart's context. + * We are making a few assumptions here: + * 1. for hart 0, return the first context claim complete. + * 2. for any other hart, we assume they have two privileged mode contexts + * which are contiguous, where the m mode context is first. + * We return the m mode context. + */ + + return config->reg + get_first_context(arch_proc_id()) * CONTEXT_SIZE + + CONTEXT_CLAIM; }