#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  veclist veclist/veclist.c
# Wrapped by thor@ymir on Thu Apr 28 11:31:37 1994
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test ! -d 'veclist' ; then
    echo shar: Creating directory \"'veclist'\"
    mkdir 'veclist'
fi
if test -f 'veclist/veclist.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'veclist/veclist.c'\"
else
echo shar: Extracting \"'veclist/veclist.c'\" \(3665 characters\)
sed "s/^X//" >'veclist/veclist.c' <<'END_OF_FILE'
X/*
X *	@(#)veclist.c	1.10
X *
X *	list fuctions attached to the interrupt vector table
X *
X *	Created 28Mar89	Jeffrey O. Hill
X *	hill@atdiv.lanl.gov
X *	(505) 665 1831
X *
X *	.01 010393 Applied fix for zero C ISR param causes incorrect 
X *		   identification as MACRO ISR problem. 
X */
X
X/*
X * 
X *	makefile
X *
X *
X * V5VW = /.../vx/v502b
X *
X * veclist.o:
X *	cc68k -c -DCPU_FAMILY=MC680X0 -I$(V5VW)/h veclist.c
X * 
X *
X */
X
X#include "vxWorks.h"
X#include "stdio.h"
X#include "intLib.h"
X#include "vxLib.h"
X#include "iv.h"
X#include "ctype.h"
X#include "sysSymTbl.h"
X
Xstatic char *sccsID = 
X	"@(#)veclist.c	1.10\t1/3/94 J. Hill hill@atdiv.lanl.gov";
X
X/*
X *
X * VME bus dependent
X *
X */
X#define NVEC 0x100
X
Xstatic char *ignore_list[] = {"_excStub","_excIntStub"};
X
Xint		veclist(int);
Xint		cISRTest(FUNCPTR proutine, FUNCPTR *ppisr, void **pparam);
Xstatic void 	*fetch_pointer(unsigned char *);
X
X
X/*
X *
X * veclist()
X *
X */
Xint veclist(int all)
X{
X  	int		vec;
X	int		value;
X	SYM_TYPE	type;
X	char		name[MAX_SYS_SYM_LEN];
X	char		function_type[10];
X	FUNCPTR		proutine;
X	FUNCPTR		pCISR;
X	int		cRoutine;
X	void		*pparam;
X	int		status;
X	int		i;
X
X  	for(vec=0; vec<NVEC; vec++){
X    		proutine = intVecGet((FUNCPTR *)INUM_TO_IVEC(vec));
X
X		status = cISRTest(proutine, &pCISR, &pparam);
X		if(status == OK){
X			cRoutine = TRUE;
X			proutine = pCISR;
X			strcpy(function_type, "C");
X		}
X		else{
X			cRoutine = FALSE;
X			strcpy(function_type, "MACRO");
X			pCISR = NULL;
X		}
X 
X		status = symFindByValue(
X				sysSymTbl, 
X				(int)proutine, 
X				name,
X				&value,
X				&type);
X		if(status<0 || value != (int)proutine){
X			sprintf(name, "0x%X", (unsigned int) proutine);
X		}
X		else if(!all){
X			int	match = FALSE;
X
X			for(i=0; i<NELEMENTS(ignore_list); i++){
X				if(!strcmp(ignore_list[i],name)){
X					match = TRUE;
X					break;
X				}
X			}
X			if(match){
X				continue;
X			}
X		}
X       		printf(	"vec 0x%02X %5s ISR %s", 
X			vec, 
X			function_type,
X			name);
X		if(cRoutine){
X			printf("(0x%X)", (unsigned int) pparam);
X		}
X		printf("\n");
X	}
X
X	return OK;
X}
X
X
X
X/*
X * cISRTest()
X *
X * test to see if a C routine is attached
X * to this interrupt vector
X */
X#define ISR_PATTERN	0xaaaaaaaa
X#define PARAM_PATTERN	0x55555555 
Xint	cISRTest(FUNCPTR proutine, FUNCPTR *ppisr, void **pparam)
X{
X	static FUNCPTR	handler = NULL;
X	STATUS		status;
X	unsigned char	*pchk;
X	unsigned char	*pref;
X	unsigned char	val;
X	int		found_isr;
X	int		found_param;
X
X	if(handler == NULL){
X		handler = (FUNCPTR) intHandlerCreate(
X				(FUNCPTR) ISR_PATTERN, 
X				PARAM_PATTERN);
X		if(handler == NULL){
X			return ERROR;
X		}
X	}
X
X	found_isr = FALSE;
X	found_param = FALSE;
X	pchk = (unsigned char *) proutine;
X	pref = (unsigned char *) handler; 
X	for(	;
X		found_isr==FALSE || found_param==FALSE;
X		pchk++, pref++){
X
X		status = vxMemProbe(	
X				pchk,
X				READ,
X				sizeof(val),
X				&val);
X		if(status < 0){
X			return ERROR;
X		}
X
X		if(val != *pref){
X			if(*pref == (unsigned char) ISR_PATTERN){
X				*ppisr = fetch_pointer(pchk);
X				pref += sizeof(*ppisr)-1;
X				pchk += sizeof(*ppisr)-1;
X				found_isr = TRUE;	
X			}
X			else if(*pref == (unsigned char) PARAM_PATTERN){
X				*pparam = fetch_pointer(pchk);
X				pref += sizeof(*pparam)-1;
X				pchk += sizeof(*pparam)-1;
X				found_param = TRUE;
X			}
X			else{	
X				return ERROR;
X			}
X		}
X	}
X
X	return OK;
X}
X
X
X
X/*
X * fetch_pointer()
X *
X * fetch pointer given low byte with correct byte ordering
X *
X */
Xstruct char_array{
X	unsigned char byte[4];
X};
Xunion pointer{
X	void 			*ptr_overlay;
X	struct char_array 	char_overlay;
X};
X
XLOCAL
Xvoid *fetch_pointer(unsigned char *plow_byte)
X{
X	union pointer	p;
X	int		i;
X
X	for(i=0; i < sizeof(p); i++){
X		p.char_overlay.byte[i] = plow_byte[i];
X	}
X
X	return p.ptr_overlay;
X}
END_OF_FILE
if test 3665 -ne `wc -c <'veclist/veclist.c'`; then
    echo shar: \"'veclist/veclist.c'\" unpacked with wrong size!
fi
# end of 'veclist/veclist.c'
fi
echo shar: End of shell archive.
exit 0
