/* DESCRIPTION: Query the PLIC what interrupt we should serve. Perform an interrupt claim by reading the claim register, which returns the ID of the highest-priority pending interrupt or zero if there is no pending interrupt. A successful claim also atomically clears the corresponding pending bit on the interrupt source. RETURN VALUE: the ID of the highest-priority pending interrupt or zero if there is no pending interrupt.  */
int plic_claim(void)
/* DESCRIPTION: Query the PLIC what interrupt we should serve. Perform an interrupt claim by reading the claim register, which returns the ID of the highest-priority pending interrupt or zero if there is no pending interrupt. A successful claim also atomically clears the corresponding pending bit on the interrupt source. RETURN VALUE: the ID of the highest-priority pending interrupt or zero if there is no pending interrupt.  */
int plic_claim(void)
{
    int hart = __raw_hartid();
    int irq = *(uint32_t *)PLIC_CLAIM(hart);
    return irq;
}