-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[hal] Modification in interrupt handler assignment #311
Comments
We have discussed this issue and agree on:
We have concerns on how to achieve this. Options that are being discussed:
|
We decided:
|
We further discussed this topic today. #include "core.h"
#include "i2c.h"
int32_t handlers[ INTR__size ];
int32_t priority[ INTR__size ];
void plic_init(){
handlers[INTR_ID_I2C_REQ] = &i2c_intr_handler_general
handlers[INTR_ID_I2C_ABC] = &i2c_intr_handler_general
. . .
priority[INTR_ID_I2C_JKL] = 1;
. . .
} And in the peripherals HAL simply have the handlers defined. This way, there is no need to include the PLIC/FIC modules from the peripherals and they are the only file that needs to be modified in case of a change. The priorities, if they have to be changed on runtime, can be done through a PLIC SDK. |
we should also generates those ranges rather than using fixed ones (hjson file) |
We just met with @StefanoAlbini96 and @ruben-roalvarez We analyzed an issue with the previous idea: When you want to extend X-HEEP, you would need to modify the PLIC. This left us 3 possible alternatives:
We considered option 3) would be the most reasonable because: We will leave this in pause until Jose comes back so we can further discuss these options.
|
Today in the firmware meeting we further discussed this issue. To avoid calling the PLIC from all examples, a good compromise is stick to the previous proposal (making assignments in the vector inside the PLIC init) but leaving weak implementations ONLY FOR THE EXTERNAL INTERRUPTS. This way, only for the external apps we should make the assignment at SDK/application level. |
Will be closed when #363 is merged |
Currently, the interrupt handlers are defined as weak functions in
plic.c
:Added to an array of function pointer:
and then, when an interrupt happens, the PLIC checks which pin triggered the interrupt. Then locates that pin inside one of the possible ranges:
Each of which correspond to one of the handler functions. The function is then called through the pointer
The weak implementations can then be redefined in the application to attend the interrupt.
A problem appears when the application uses an external peripheral. The
handler_irq_ext
has no way of determining which pin was the source of the interrupt and, therefore, if it corresponds to it.One possible solution is to pass the id of the pin to the handler:
A minor inconvenience of this solution is that it requires every handler to take a parameter (to use the function-pointer-array), despite they will not use it.
A similar problem could appear if in a project a new interrupt is added (i.e. displaces the
EXT_IRQ_START
forward).This happened once with the DMA in #219. Luckily for us, this is a modification inside the X-HEEP project, so it will be merged into the HAL. If the same modification was done in an outside project, they would have to fight each revendorization.My proposal to this is:
e.g.
This way, the PLIC does not need to know which peripherals its attending.
Furthermore, we could define ranges of interrupts:
This way the PLIC does not need to know the ranges either. This would require that the function loops from one id to the other filling the array with the desired handler.
Further features we noticed are:
@JoseCalero, I could get into this straight away if you agree. This way we waive @StefanoAlbini96 and I can get this change before I re-vendorize both in the DMA branch and in the CGRA-X-HEEP project.
The text was updated successfully, but these errors were encountered: