ide_init.c
3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
* FILE: ide_init.c:
*
* diagInit(): Common initialization for all diagnostic modules.
*/
#include "setjmp.h"
#include "diag.h"
#include "stdio.h"
extern jmp_buf intr_jump;
static int badTestNumber(int testNum);
int ideSubTestNum = 0;
diagInit(test_refs, initFcn, dispatchFcn)
TEST_REF test_refs[]; /* array of test numbers for this module */
int (*initFcn)(); /* pointer to this module's init function */
int (*dispatchFcn)(); /* ptr to this module's dispatch function */
{
return (diaginit(test_refs, initFcn, dispatchFcn));
}
diaginit(test_refs, initFcn, dispatchFcn)
TEST_REF test_refs[]; /* array of test numbers for this module */
int (*initFcn)(); /* pointer to this module's init function */
int (*dispatchFcn)(); /* ptr to this module's dispatch function */
{
int testIndex, skipIndex;
if (pGlobalComm->init) {
/*
* Execute the caller's diagnostic module specific initialization
* function. It is probably just a function from the graphics
* utilities library libgm.a (ucode init, gate array initializations,
* etc...).
*/
(*initFcn)();
}
if (pGlobalComm->entryNum < 0) {
/*
* Run a single test and return. Make sure the requested number
* exists within the diagnostic module's test_refs[] array, though.
*/
testIndex = 0;
ideSubTestNum = -(pGlobalComm->entryNum);
while ((test_refs[testIndex].num != TEST_NULL) &&
(test_refs[testIndex].num != ideSubTestNum)) {
testIndex++;
}
if (test_refs[testIndex].num != ideSubTestNum) {
badTestNumber(ideSubTestNum);
return;
}
(*dispatchFcn)(&test_refs[testIndex]);
return;
} else if (pGlobalComm->entryNum == 0) {
ideSubTestNum = test_refs[0].num; /* run all the tests */
testIndex = 0;
} else {
/*
* Start at a specific test. Make sure the requested number exists
* within this diagnostic module's test_refs[] array, though.
*/
testIndex = 0;
ideSubTestNum = pGlobalComm->entryNum;
while ((test_refs[testIndex].num != TEST_NULL) &&
(test_refs[testIndex].num != ideSubTestNum)) {
testIndex++;
}
if (test_refs[testIndex].num != ideSubTestNum) {
badTestNumber(ideSubTestNum);
return;
}
}
/*
* Before entering the loop which runs the diagnostic sequence, advance a
* pointer into the "Skip numbers" array to point to the first test
* greater than or equal to the first test to be run. Thereafter, we can
* just advance the skipIndex each time through the loop (if necessary).
*/
skipIndex = 0;
while ((pGlobalComm->skipNums[skipIndex] != TEST_NULL) &&
(pGlobalComm->skipNums[skipIndex] < ideSubTestNum)) {
skipIndex++;
}
/*
* Now execute the diagnostic sequence.
*/
while (test_refs[testIndex].num != TEST_NULL) {
if (pGlobalComm->skipNums[skipIndex] == test_refs[testIndex].num) {
/*
* Skip this test & setup to run the next.
*/
skipIndex++;
testIndex++;
} else {
/*
* Call the diagnostic module's dispatch routine and pass it the
* test number to be executed.
*/
(*dispatchFcn)(&test_refs[testIndex]);
testIndex++;
}
}
}
diagExit()
{
return (diagexit());
}
diagexit()
{
fflush(stdout);
fflush(stderr);
longjmp(intr_jump, 1);
}
/*
* Print out an info message indicating that the server screwed up and called
* for a test number that doesn't correspond to the diagnostic module's test
* numbering scheme.
*/
static int badTestNumber(int testNum)
{
errlog(INFO,
"diagInit(): Unknown test number %d requested by server.\n",
testNum);
}