|
@@ -13,14 +13,14 @@
|
|
#include "encoding.h"
|
|
#include "encoding.h"
|
|
|
|
|
|
/*
|
|
/*
|
|
-* Each PLIC interrupt source can be assigned a priority by writing
|
|
|
|
|
|
+* Each PLIC interrupt source can be assigned a priority by writing
|
|
* to its 32-bit memory-mapped priority register.
|
|
* to its 32-bit memory-mapped priority register.
|
|
-* The QEMU-virt (the same as FU540-C000) supports 7 levels of priority.
|
|
|
|
-* A priority value of 0 is reserved to mean "never interrupt" and
|
|
|
|
-* effectively disables the interrupt.
|
|
|
|
-* Priority 1 is the lowest active priority, and priority 7 is the highest.
|
|
|
|
-* Ties between global interrupts of the same priority are broken by
|
|
|
|
-* the Interrupt ID; interrupts with the lowest ID have the highest
|
|
|
|
|
|
+* The QEMU-virt (the same as FU540-C000) supports 7 levels of priority.
|
|
|
|
+* A priority value of 0 is reserved to mean "never interrupt" and
|
|
|
|
+* effectively disables the interrupt.
|
|
|
|
+* Priority 1 is the lowest active priority, and priority 7 is the highest.
|
|
|
|
+* Ties between global interrupts of the same priority are broken by
|
|
|
|
+* the Interrupt ID; interrupts with the lowest ID have the highest
|
|
* effective priority.
|
|
* effective priority.
|
|
*/
|
|
*/
|
|
void plic_set_priority(int irq, int priority)
|
|
void plic_set_priority(int irq, int priority)
|
|
@@ -29,7 +29,7 @@ void plic_set_priority(int irq, int priority)
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
-* Each global interrupt can be enabled by setting the corresponding
|
|
|
|
|
|
+* Each global interrupt can be enabled by setting the corresponding
|
|
* bit in the enables registers.
|
|
* bit in the enables registers.
|
|
*/
|
|
*/
|
|
void plic_irq_enable(int irq)
|
|
void plic_irq_enable(int irq)
|
|
@@ -49,7 +49,7 @@ void plic_irq_disable(int irq)
|
|
*(uint32_t*)PLIC_ENABLE(hart) = (((*(uint32_t*)PLIC_ENABLE(hart)) & (~(1 << irq))));
|
|
*(uint32_t*)PLIC_ENABLE(hart) = (((*(uint32_t*)PLIC_ENABLE(hart)) & (~(1 << irq))));
|
|
}
|
|
}
|
|
|
|
|
|
-/*
|
|
|
|
|
|
+/*
|
|
* PLIC will mask all interrupts of a priority less than or equal to threshold.
|
|
* PLIC will mask all interrupts of a priority less than or equal to threshold.
|
|
* Maximum threshold is 7.
|
|
* Maximum threshold is 7.
|
|
* For example, a threshold value of zero permits all interrupts with
|
|
* For example, a threshold value of zero permits all interrupts with
|
|
@@ -62,16 +62,16 @@ void plic_set_threshold(int threshold)
|
|
*(uint32_t*)PLIC_THRESHOLD(hart) = threshold;
|
|
*(uint32_t*)PLIC_THRESHOLD(hart) = threshold;
|
|
}
|
|
}
|
|
|
|
|
|
-/*
|
|
|
|
|
|
+/*
|
|
* DESCRIPTION:
|
|
* DESCRIPTION:
|
|
* Query the PLIC what interrupt we should serve.
|
|
* Query the PLIC what interrupt we should serve.
|
|
* Perform an interrupt claim by reading the claim register, which
|
|
* 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.
|
|
|
|
|
|
+ * 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
|
|
* A successful claim also atomically clears the corresponding pending bit
|
|
* on the interrupt source.
|
|
* on the interrupt source.
|
|
* RETURN VALUE:
|
|
* RETURN VALUE:
|
|
- * the ID of the highest-priority pending interrupt or zero if there
|
|
|
|
|
|
+ * the ID of the highest-priority pending interrupt or zero if there
|
|
* is no pending interrupt.
|
|
* is no pending interrupt.
|
|
*/
|
|
*/
|
|
int plic_claim(void)
|
|
int plic_claim(void)
|
|
@@ -81,12 +81,12 @@ int plic_claim(void)
|
|
return irq;
|
|
return irq;
|
|
}
|
|
}
|
|
|
|
|
|
-/*
|
|
|
|
|
|
+/*
|
|
* DESCRIPTION:
|
|
* DESCRIPTION:
|
|
- * Writing the interrupt ID it received from the claim (irq) to the
|
|
|
|
- * complete register would signal the PLIC we've served this IRQ.
|
|
|
|
- * The PLIC does not check whether the completion ID is the same as the
|
|
|
|
- * last claim ID for that target. If the completion ID does not match an
|
|
|
|
|
|
+ * Writing the interrupt ID it received from the claim (irq) to the
|
|
|
|
+ * complete register would signal the PLIC we've served this IRQ.
|
|
|
|
+ * The PLIC does not check whether the completion ID is the same as the
|
|
|
|
+ * last claim ID for that target. If the completion ID does not match an
|
|
* interrupt source that is currently enabled for the target, the completion
|
|
* interrupt source that is currently enabled for the target, the completion
|
|
* is silently ignored.
|
|
* is silently ignored.
|
|
* RETURN VALUE: none
|
|
* RETURN VALUE: none
|