This is Unofficial EPICS BASE Doxygen Site
veclist.c
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2002 The University of Chicago, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * EPICS BASE Versions 3.13.7
7 * and higher are distributed subject to a Software License Agreement found
8 * in file LICENSE that is included with this distribution.
9 \*************************************************************************/
10 /*
11  * list fuctions attached to the interrupt vector table
12  *
13  * Created 28Mar89 Jeffrey O. Hill
14  * johill@lanl.gov
15  * (505) 665 1831
16  *
17  */
18 
19 #include "vxWorks.h"
20 #include "stdio.h"
21 #include "string.h"
22 #include "intLib.h"
23 #include "vxLib.h"
24 #include "iv.h"
25 #include "ctype.h"
26 #include "sysSymTbl.h"
27 
28 /*
29  *
30  * VME bus dependent
31  *
32  */
33 #define NVEC 0x100
34 
35 static char *ignore_list[] = {"_excStub","_excIntStub"};
36 
37 int veclist(int);
38 int cISRTest(FUNCPTR proutine, FUNCPTR *ppisr, void **pparam);
39 static void *fetch_pointer(unsigned char *);
40 
41 
42 /*
43  *
44  * veclist()
45  *
46  */
47 int veclist(int all)
48 {
49  int vec;
50  int value;
51  SYM_TYPE type;
52  char name[MAX_SYS_SYM_LEN];
53  char function_type[10];
54  FUNCPTR proutine;
55  FUNCPTR pCISR;
56  int cRoutine;
57  void *pparam;
58  int status;
59  unsigned i;
60 
61  for(vec=0; vec<NVEC; vec++){
62  proutine = intVecGet((FUNCPTR *)INUM_TO_IVEC(vec));
63 
64  status = cISRTest(proutine, &pCISR, &pparam);
65  if(status == OK){
66  cRoutine = TRUE;
67  proutine = pCISR;
68  strcpy(function_type, "C");
69  }
70  else{
71  cRoutine = FALSE;
72  strcpy(function_type, "MACRO");
73  pCISR = NULL;
74  }
75 
76  status = symFindByValue(
77  sysSymTbl,
78  (int)proutine,
79  name,
80  &value,
81  &type);
82  if(status<0 || value != (int)proutine){
83  sprintf(name, "0x%X", (unsigned int) proutine);
84  }
85  else if(!all){
86  int match = FALSE;
87 
88  for(i=0; i<NELEMENTS(ignore_list); i++){
89  if(!strcmp(ignore_list[i],name)){
90  match = TRUE;
91  break;
92  }
93  }
94  if(match){
95  continue;
96  }
97  }
98  printf( "vec 0x%02X %5s ISR %s",
99  vec,
100  function_type,
101  name);
102  if(cRoutine){
103  printf("(0x%X)", (unsigned int) pparam);
104  }
105  printf("\n");
106  }
107 
108  return OK;
109 }
110 
111 
112 
113 /*
114  * cISRTest()
115  *
116  * test to see if a C routine is attached
117  * to this interrupt vector
118  */
119 #define ISR_PATTERN 0xaaaaaaaa
120 #define PARAM_PATTERN 0x55555555
121 int cISRTest(FUNCPTR proutine, FUNCPTR *ppisr, void **pparam)
122 {
123  static FUNCPTR handler = NULL;
124  STATUS status;
125  unsigned char *pchk;
126  unsigned char *pref;
127  unsigned char val;
128  int found_isr;
129  int found_param;
130 
131  if(handler == NULL){
132 #if CPU_FAMILY != PPC
133  handler = (FUNCPTR) intHandlerCreate(
134  (FUNCPTR) ISR_PATTERN,
135  PARAM_PATTERN);
136 #endif
137  if(handler == NULL){
138  return ERROR;
139  }
140  }
141 
142  found_isr = FALSE;
143  found_param = FALSE;
144  pchk = (unsigned char *) proutine;
145  pref = (unsigned char *) handler;
146  for( ;
147  found_isr==FALSE || found_param==FALSE;
148  pchk++, pref++){
149 
150  status = vxMemProbe(
151  (char *) pchk,
152  READ,
153  sizeof(val),
154  (char *) &val);
155  if(status < 0){
156  return ERROR;
157  }
158 
159  if(val != *pref){
160  if(*pref == (unsigned char) ISR_PATTERN){
161  *ppisr = (FUNCPTR) fetch_pointer(pchk);
162  pref += sizeof(*ppisr)-1;
163  pchk += sizeof(*ppisr)-1;
164  found_isr = TRUE;
165  }
166  else if(*pref == (unsigned char) PARAM_PATTERN){
167  *pparam = fetch_pointer(pchk);
168  pref += sizeof(*pparam)-1;
169  pchk += sizeof(*pparam)-1;
170  found_param = TRUE;
171  }
172  else{
173  return ERROR;
174  }
175  }
176  }
177 
178  return OK;
179 }
180 
181 
182 
183 /*
184  * fetch_pointer()
185  *
186  * fetch pointer given low byte with correct byte ordering
187  *
188  */
189 struct char_array{
190  unsigned char byte[4];
191 };
192 union pointer{
193  void *ptr_overlay;
194  struct char_array char_overlay;
195 };
196 
197 static
198 void *fetch_pointer(unsigned char *plow_byte)
199 {
200  union pointer p;
201  size_t i;
202 
203  for(i=0; i < sizeof(p); i++){
204  p.char_overlay.byte[i] = plow_byte[i];
205  }
206 
207  return p.ptr_overlay;
208 }
Definition: link.h:174
#define FALSE
Definition: dbDefs.h:32
#define ISR_PATTERN
Definition: veclist.c:119
pvd::Status status
int i
Definition: scan.c:967
int veclist(int)
Definition: veclist.c:47
#define printf
Definition: epicsStdio.h:41
pvd::StructureConstPtr type
unsigned char byte[4]
Definition: veclist.c:190
#define NULL
Definition: catime.c:38
#define PARAM_PATTERN
Definition: veclist.c:120
#define NVEC
Definition: veclist.c:33
#define NELEMENTS(A)
Definition: aToIPAddr.c:21
void * ptr_overlay
Definition: veclist.c:193
Definition: caget.c:45
#define TRUE
Definition: dbDefs.h:27
int cISRTest(FUNCPTR proutine, FUNCPTR *ppisr, void **pparam)
Definition: veclist.c:121