T-Kernel Specification (1.B0.02)
T-Kernel Specification (1.B0.02)
T-Kernel Specification (1.B0.02)
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
186 CHAPTER 4. T-KERNEL/OS FUNCTIONS<br />
When the TA ASM attribute is designated, in principle the OS is not involved in interrupt handler<br />
starting. When an interrupt is raised, the interrupt handling function in the CPU hardware (depending<br />
on the implementation, processing by T-Monitor may be included) directly starts the interrupt handler<br />
defined by this system call. Accordingly, processing for saving and restoring registers used by the<br />
interrupt handler is necessary at the beginning and end of the interrupt handler. An interrupt handler<br />
is terminated by execution of the tk ret int system call or by the CPU interrupt return instruction<br />
(or equivalent means).<br />
Provision of a means for return from an interrupt handler without using tk ret int and without OS<br />
intervention is mandatory. Note that if tk ret int is not used, delayed dispatching is not necessary.<br />
Support for return from an interrupt handler using tk ret int is mandatory, and in this case delayed<br />
dispatching is necessary.<br />
When the TA HLNG attribute is designated, the interrupt handler is started via a high-level language<br />
support routine. The high-level language support routine takes care of saving and restoring register<br />
values. The interrupt handler terminates by a simple return from a function. The interrupt handler<br />
takes the following format when the TA HLNG attribute is designated.<br />
void inthdr( UINT dintno )<br />
{<br />
/*<br />
Processing<br />
*/<br />
return; /* exit interrupt handler */<br />
}<br />
The parameter dintno passed to an interrupt handler is a number identifying the interrupt that was<br />
raised, and is the same as that designated with tk def int. Depending on the implementation, other<br />
information about the interrupt may be passed in addition to dintno. If such information is used, it<br />
must be defined for each implementation in a second parameter or subsequent parameters passed to the<br />
interrupt handler.<br />
If the TA HLNG attribute is designated, it is assumed that the CPU interrupt flag will be set to interrupts<br />
disabled state from the time the interrupt is raised until the interrupt handler is called. In other words,<br />
as soon as an interrupt is raised, the state goes to multiple interrupts disabled, and this state remains<br />
when the interrupt handler is called. If multiple interrupts are enabled, the interrupt handler must<br />
include processing that enables interrupts by manipulating the CPU interrupt flag.<br />
Also in the case of the TA HLNG attribute, upon entry into the interrupt handler, system call issuing<br />
must be possible. Note, however, that assuming standard provision of the functionality described above,<br />
extensions are allowable such as adding a function for entering an interrupt handler with multiple<br />
interrupts enabled.<br />
When the TA ASM attribute is designated, the state upon entry into the interrupt handler is defined<br />
for each implementation. Such matters as the stack and register status upon interrupt handler entry,<br />
whether system calls can be made, the method of invoking system calls, and the method of returning<br />
from the interrupt handler without OS intervention must all be defined explicitly.<br />
In the case of the TA ASM attribute, depending on the implementation there may be cases where interrupt<br />
handler execution is not considered to be a task-independent portion. In such a case the following points<br />
need to be noted carefully.<br />
• If interrupts are enabled, there is a possibility that task dispatching will occur.<br />
• When a system call is invoked, it will be processed as having been called from a task portion or<br />
quasi-task portion.<br />
Copyright c○ 2002, 2003 by T-Engine Forum<br />
T-<strong>Kernel</strong> <strong>1.B0.02</strong>