[Sifive E21] Unregister existing vector handler and register a new one

Hi,

I’m using Sifive E21 single hart processor. I’m registering an ISR for I3C in the bootloader. After jumping to the actual firmware, I want to use a different handler for this. So, I want to un-register existing one and register the new handler. For this, I don’t see any existing functions in e21_sdk for unregistering vector handlers. Is there any way we could do this?

I tried directly registering the new handler without un-registering but it’s not working.

Thanks and Regards,
Kurra Aravind Kumar Goud.

Hi Kurra,

In the SiFive E21 processor, the interrupt vector table is generally managed directly through the control registers, so you won’t find a high-level API for unregistering handlers in the SDK. Instead, you can manually overwrite the interrupt vector address to change the handler.

Here’s a simplified example of how you might do this in C: HealthCare gov
#define I3C_INTERRUPT_VECTOR_INDEX <your_index_here>
#define I3C_VECTOR_TABLE_BASE <your_vector_table_base_address>

void (*new_i3c_handler)(void);

void register_new_i3c_handler(void (*handler)(void)) {
new_i3c_handler = handler;
// Assuming the vector table is at I3C_VECTOR_TABLE_BASE
*((void (**)(void)) (I3C_VECTOR_TABLE_BASE + I3C_INTERRUPT_VECTOR_INDEX * sizeof(void *))) = new_i3c_handler;
}

Hope this helps,
Best regards,
Emma Fox