Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to use excHookAdd()

509 views
Skip to first unread message

Wu, Huang

unread,
Mar 19, 1999, 3:00:00 AM3/19/99
to
Hello vxWorks world,
Does anyone know how to use excHookAdd() in a task? I have written a test
code, but the exception handler is not called when an exception occurs.
Is there anyone who likes to share their successful story with me?

Thanks in advance

Huang

#include "vxWorks.h"
#include "taskLib.h"
#include "stdio.h"
#include "arch/mc68k/archMc68k.h"
#include "arch/mc68k/regsMc68k.h"
#include "arch/mc68k/esfMc68k.h"
#include "semLib.h"
#include "excLib.h"

/* Globals */
SEM_ID syncSem;

/* Forward declarations */
void myHandler (int, int, ESF68K_BA *);
void testExc (void);
void fuBar (void);

/* Function: myHandler
* Purpose : User-defined handler executes after a hardware exception oc
curs.
* Returns : N/A
*/
void myHandler (int task, int vector, ESF68K_BA * pEsf)
{

printf ("\n\n");
printf ("USER-DEFINED HANDLER...\n");
printf (" Offending task ID: 0x%x\n", task);
printf (" Exception vector: %d\n", vector);
printf (" Status reg: %d\n", pEsf->sr);

semGive (syncSem); /* activate fuBar() */
}

/* function: testExc
* Purpose : Test the execution of a user-defined exception handler insta
lled
* vio excHookAdd(). This routine will generate an exception wh ich,
* in turn, will invoke the user-defined exception handler. The
* user-defined handler will give a semaphore which unblocks an other
* task - fuBar(). fuBar() will then generate another exceptio n.
* Returns : N/A
*/


void testExc (void)
{
unsigned long goomBah;

/* add the exception hook routine in this task */
excHookAdd ((FUNCPTR) myHandler);

/* create semaphore */
syncSem = semBCreate (SEM_Q_FIFO, SEM_EMPTY);

/* spawn a task which will be called after the hook activates */
taskSpawn ("tFuBar", 100, 0, 2000, (FUNCPTR)fuBar, 0,0,0,0,0,0,0,0,0, 0);

/* this is a NON-EXISTANT ADDR*/
goomBah = *(unsigned long *)0xfffff98;
}

/* function: fuBar
* Purpose : Pend on a semaphore given by a user-defined exception handle r.
* After getting the semaphore, force another exception.
* Returns : N/A
*/


void fuBar (void)
{
unsigned long goomBah = 0x0000ffff;

/* wait for exception event to occur */
semTake (syncSem, WAIT_FOREVER);

printf ("\nfuBar() got the semaphore\n");

/* a brief delay to give the system a chance to recover before */
/* we generate the next exception. */
taskDelay (10);

/* assign to a NON-EXISTANT ADDRESS */
*(unsigned long *)0xfffff98 = goomBah;


}

I


0 new messages