PxTrapInstallHandler()

Install a traphandler for a trap.

APPLIES TO

8.2.0

SYNOPSIS
PxError_t PxTrapInstallHandler (PxUInt_t trapno, PxBool_t (* traphandler) (PxTrapTin_t, PxUInt_t, PxUInt_t, PxUInt_t, PxUInt_t *, TC_CSA_t *), PxUInt_t arg);
ARGUMENTS
trapno

Trap number

traphandler

The traphandler

arg

Traphandler’s argument

RETURN VALUES
  • PXROS error code

ERROR CODES

PXERR_ACCESS_RIGHT

The calling task has not the right to install handlers

PXERR_REQUEST_INVALID_PARAMETER

Invalid trap number

DESCRIPTION

Installs the C-function handler as trap handler for trap class trapno. Whenever this trap occurs, handler is called with 6 arguments.

  • The trap number and TIN (Trap Indication Number)

  • The user defined argument

  • The identifier of the task that caused the trap

  • The contents of DSTR (Data Synchronous Error Trap Register)

  • The contents of DEAD (Data Error Address Register)

  • A pointer to the saved CSA

The traphandler should return 1 if the trap could be handled, otherwise 0.

Handler MUST FOLLOW the standard GNU calling conventions!

The function is not protected against the abort mechanism!

The installation is NOT ATOMIC! The application MUST ENSURE that no traps of class trapno occur during a call to PxTrapInstallHandler(trapno, …​)!

IMPLEMENTATION GUIDELINES
Before call
  • The parameter trapno must be a valid trap id. (V)

  • traphandler must be a pointer to a trap handler function.(V)

After call
  • The function returns PXERR_NOERROR if the trap handler could be installed. Any other return value describes an error, which has to be interpreted (C).

Best Practice
  • The calling task must have the right to install trap handlers (PXACCESS_HANDLERS). (V)

SEE ALSO
USAGE
#include "pxdef.h"

PxError_t Err = PxTrapInstallHandler(TRAP_CLASS, myHandler, (PxArg_t) (0));

if (Err != PXERR_NOERROR) {
    // Report error
}