Interrupt handler for RTOS (#pragma rtos_interrupt)


The interrupt handler for Renesas RTOS for the RL78 family can be specified.

[Function]

-

Interprets the function name specified with the #pragma rtos_interrupt directive as the interrupt handler for Renesas RTOS for the RL78 family.

-

When the vector table is specified, the address of the described function name is registered in the specified interrupt vector table.

-

The code for the body (function definition) of an interrupt handler is output to the .text or .textf section.
The section name can be changed through #pragma section.
Note however when the vector table is specified, the start address of the interrupt handler should be a location that can be accessed in 16-bit addressing.

-

When the vector table is specified, the specification becomes __near forcibly, regardless of whether __far is specified explicitly or implicitly. No warning message is output.

-

When the vector table is not specified, the __near or __far specification by the function takes priority, regardless of whether the specification is explicit or implicit.

-

The interrupt handler for RTOS generates codes in the following order.

(a)

Calls kernel symbol __kernel_int_entry using call !!addr20 instruction
When the vector table is specified, the interrupt address is passed to __kernel_int_entry as an argument.
When the vector table is not specified, no argument is passed to __kernel_int_entry.

(b)

Secures the local variable area (only when there is a local variable)

(c)

Executes the body of the function

(d)

Releases the local variable area (only when there is a local variable)

(e)

Unconditionally jumps to label _ret_int using br !!addr20 instruction

[Effect]

-

The interrupt handler for RTOS can be described in the C source level.

[Usage]

-

The interrupt address and function name is specified by the #pragma directive.

#pragma rtos_interrupt  [(]function-name[(vect=addressNote)][)]

Note

address : Binary, octal, decimal, or hexadecimal constant
Only an even value from 0 to 0x7c can be specified as the constant
(a value outside this range will cause an error).

-

Write a #pragma directive before the function definition.

[Restrictions]

-

If the function specified with #pragma rtos_interrupt is called in the same way as a normal function, a compilation error will occur.

#pragma rtos_interrupt func (vect=8)
void func(void) {}
 
void xxx()
{
        func();                 //Error
}

-

The parameters and return value of a function should be declared as void (e.g., void func (void);).
If the type is not void, a compilation error will occur.

-

If an interrupt handler for RTOS is specified with __inline, __callt or another type of #pragma, a compilation error will occur.

-

After the #pragma rtos_interrupt declaration line, a call or a definition of _kernel_int_exit or _kernel_int_entry as a function or a variable will generate an error.

#pragma rtos_interrupt func (vect=8)
void func(void) {
        _kernel_int_entry();    //Error
        _kernel_int_exit();     //Error
}
 
void    _kernel_int_entry(){}   //Error
void    _kernel_int_exit(){}    //Error

[Example]

The following shows an example in which the vector table is specified and no function is called in an interrupt handler.

 

[ Input program ]

#include "iodefine.h"
 
#pragma rtos_interrupt inthdr (vect=INTP0)
volatile int g;
 
void inthdr(void) {
        volatile int a;
        a = 1;
        g = 1;
}

 

[ Output program ]

        .SECTION .textf,TEXTF
_inthdr .vector 0x0008
_inthdr:
        push    ax                      ;ax register is saved
        movw    ax, #0x0008
        call    !!__kernel_int_entry    ;Registers other than ax are saved
        push    hl                      ;The area for local variables is allocated
        onew    ax
        movw    [sp+0x00], ax
        movw    !LOWW(_g), ax
        pop     hl                      ;The area for local variables is released
        br      !!__kernel_int_exit     ;Processing is specified so that all registers
                                        ;are restored when the interrupted task 
                                        ;resumes execution

 

The following shows an example in which the vector table is not specified and no function is called in an interrupt handler.

 

[ Input program ]

#include "iodefine.h"
 
#pragma rtos_interrupt inthdr
volatile int g;
 
void inthdr(void) {
        volatile int a;
        a = 1;
        g = 1;
}

 

[ Output program ]

        .SECTION .textf,TEXTF
_inthdr:
        call    !!__kernel_int_entry    ;Registers other than ax are saved
        push    hl                      ;The area for local variables is allocated
        onew    ax
        movw    [sp+0x00], ax
        movw    !LOWW(_g), ax
        pop     hl                      ;The area for local variables is released
        br      !!__kernel_int_exit     ;Processing is specified so that all registers
                                        ;are restored when the interrupted task 
                                        ;resumes execution