Is it possible to change the interrupt vector table dynamically?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is it possible to change the interrupt vector table dynamically?

2,093 Views
SVC2
Contributor II

Hi,

 

Is it possible to change the interrupt vector table dynamically?

 

For example, say I have a file Vector.s with the vector table (5282 processor):

 

Code:
 VECTOR_TABLE:_VECTOR_TABLE:INITSP:   .long  ___SP_AFTER_RESET        INITPC:   .long  _start                                        //… etc etc...vector4D: .long  _asm_isr_handler        //… etc etc...


 
I would like to call a function InitialiseUART0(). Within this function, I would like to replace the vector entry with my ISR.

            vector4D:  .long _asm_isr_handle

                                       to

       vector4D:  .long _uart0_isr

 

Is it possible? How?

 

Thanks,

SVC

 

 

Labels (1)
0 Kudos
3 Replies

672 Views
ChrisJohns
Contributor I
Yes you can but you need to move the vector table to RAM. There are a couple of approaches that can be used.

If you have the RAM and can spare 4K the best solution is to copy the vector to RAM and update the VBR register to point to it. Typically RAM is at address 0 and this is the best place to locate the vector table in RAM (alignment issues with the VBR). Once located in RAM you can change entries as you like. Most operating systems such as the RTEMS kernel do this.

A second way if you do not have enough RAM for the whole table is have a second small table in RAM and to set the ROM based vector to point to a redirector piece of code. This code jumps to the address in the smaller RAM table for the specific interrupt.
0 Kudos

672 Views
SVC2
Contributor II
My vector table is in RAM!
 
But how do I change it's entry (syntactically)?
 
Thanks,
S
 
0 Kudos

672 Views
ChrisJohns
Contributor I
I assume syntactically means with code so in C you would:

#include <stdint.h>
extern uint32_t VECTOR_TABLE[256];
void _uart0_isr ();
void foo ()
{
  VECTOR_TABLE[0x4d] = _uart0_isr;
}

For an assembler version I compiled the code with:

  /opt/rtems-4.10/bin/m68k-rtems4.10-gcc -save-temps -c -o2 vector.c

and looked at the assembler output in vector.s:

foo:
        link.w %fp,#0
        move.l #_uart0_isr,%d0
        move.l %d0,VECTOR_TABLE+308
        unlk %fp
        rts

0 Kudos