TOC PREV NEXT INDEX DOC LIST MASTER INDEX



Interrupt Handling

The following section demonstrates how to configure the interrupt related functionality for a MARK application. The example sources can be found in the ada_examples.ss/<view>/interrupts/.

This section consists of the following topics:


Ada.Interrupts.Names

In the systems_programming.ss view the ada.interrupts.names package contains the names of all the interrupts used in the system.

It may be necessary to tailor your board support package including ada.interrupts.names to your specific implementation.

In order to support the package Ada.Interrupts, each interrupt must be either reserved or available for attaching interrupt handlers. In the systems_programming.ss view the package Apex_Systems_Programming.Interrupts_Id can be edited. This package contains an array of interrupts (Interrupt_Ids) and an indication if these interrupts should be reserved (Interrupt_Ids_Reserved := True) or if they should not be reserved (Interrupt_Ids_Reserved := False). All other interrupts are treated in the opposite fashion.

Ada.Interrupts.Rational.Set_Reserve_Handler

It is possible to change the value of one of the previously reserved handlers by making a call to the Rational specific procedure Set_Reserve_Handler.

For example, the "power" example uses the Decrementer interrupt which is normally reserved for use by delay clauses. The following code fragment makes the Decrementer a non reserved interrupt to allow a handler to be attached.


Enabling Interrupts

By default, interrupts are enabled after kernel initialization. It is possible to disable interrupts until the interrupt handlers have been installed by the application. The application will then explicitly enable interrupts.

In the krn_conf.ss view, the constant USER_INTR_STATUS in the V_Krn_Conf package is set to the interrupt status instantiated for the execution of the user program.

The default must be changed from:

To:

In the test program, add the following code to enable interrupts. It is assumed that the handlers will be attached during library level package elaboration. The rts_vads_exec.ss view must be imported. This is where the V_Interrupts package is located.


Protected Objects

There are two ways to attach handlers to interrupts. The Ada 95 protected object mechanism provides language support for attaching handlers.

See ada_examples.ss for an example.


Improving the Quality of Generated Code

There are two mechanisms that can be used to increase the quality of the generated code:

Pragmas

Use care when suppressing compiler generated checks. The application must be carefully checked to empirically prove the runtime checks are not required.

The pragma Suppress(All_Checks) can be applied to the package spec and body so that no stack checks or constraint checks are generated by the compiler. This pragma can not suppress elaboration due to required LRM language semantics.

The pragma Suppress_Elaboration_Checks can be added immediately following the "end Package_Name;" statement in the package body and spec.

Choosing the right Interrupt_Handler_Wrapper

The following is an explanation on choosing the right wrappers. To summarize, there are two variables: floating point (True/False) and Additional interrupt locking required (True/False). In this case, the PowerPC blocks interrupts when an interrupt is generated so additional locking is not required. The interrupt handler does not use floating point. See Apex_Systems_Programming.Interrupt_Wrappers.


Vads Exec V_Interrupts.Attach_Isr

Alternatively the Vads Exec service Attach_Isr can be called to attach a handler to an interrupt. The above example has been changed to use Attach_Isr instead of protected objects.


Rational Software Corporation 
http://www.rational.com
support@rational.com
techpubs@rational.com
Copyright © 1993-2001, Rational Software Corporation. All rights reserved.
TOC PREV NEXT INDEX DOC LIST MASTER INDEX TECHNOTES APEX TIPS