/* Handling an interrupt is a two-step process: first you claim the interrupt by reading the claim register, then you complete the interrupt by writing that source ID back to the same claim register. This automatically enables and disables the interrupt, so there's nothing else to do.  */
void plic_handle_irq(void)
/* Handling an interrupt is a two-step process: first you claim the interrupt by reading the claim register, then you complete the interrupt by writing that source ID back to the same claim register. This automatically enables and disables the interrupt, so there's nothing else to do.  */
void plic_handle_irq(void)
{
    int cpu = 0;
    unsigned int irq;
    struct plic_handler *handler = &c906_plic_handlers[cpu];
    void *claim = (void *)((rt_size_t)handler->hart_base + CONTEXT_CLAIM);
    if (c906_plic_regs == RT_NULL || !handler->present)
    {
        LOG_E("plic state not initialized.");
        return;
    }
    clear_csr(sie, SIE_SEIE);
    while ((irq = readl(claim)))
    {
        if (irq == 0)
        {
            LOG_E("irq no is zero.");
        }
        else
        {
            generic_handle_irq(irq);
        }
    }
    set_csr(sie, SIE_SEIE);
}