Skip to content

Commit

Permalink
drivers: intc_plic: claim interrupt from hart that serviced it
Browse files Browse the repository at this point in the history
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 <conor.paxton@microchip.com>
  • Loading branch information
con-pax committed Dec 8, 2023
1 parent a376880 commit 644efbc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion drivers/interrupt_controller/intc_plic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down

0 comments on commit 644efbc

Please sign in to comment.