int4.c
4.24 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: int4.c,v $
$Revision: 1.1.1.1 $
$Date: 2002/05/02 03:27:20 $
*---------------------------------------------------------------------*/
#include <os.h>
#include <os_internal.h>
#include <rmon.h>
#include <rcp.h>
#include "corefunc.h"
/*
* int4
*
* Tests for:
* osSetEventMesg
* osSetIntMask
* __osSpSetStatus
* rcp interrupts
*
* Assumed working:
* osCreateMesgQueue
* osRecvMesg
*
* Description:
* Check the multiple pending interrupts send correct messages that are
* ordered properly.
*/
#define NUM_MESSAGE 4
static OSMesgQueue intMesgQueue;
static OSMesg intMesgBuf[NUM_MESSAGE];
int
int4(void)
{
OSIntMask savedMask, currentMask;
OSMesg actualMesg, expectedMesg;
int i;
int retValue;
volatile int loop;
int numFailures = 0;
savedMask = osSetIntMask(OS_IM_NONE);
/*
* Create a single message queue and associate four
* interrupt events with it.
*/
osCreateMesgQueue(&intMesgQueue, intMesgBuf, NUM_MESSAGE);
osSetEventMesg(OS_EVENT_SP, &intMesgQueue, (OSMesg)0x11111111);
osSetEventMesg(OS_EVENT_AI, &intMesgQueue, (OSMesg)0x22222222);
osSetEventMesg(OS_EVENT_SI, &intMesgQueue, (OSMesg)0x33333333);
osSetEventMesg(OS_EVENT_PI, &intMesgQueue, (OSMesg)0x44444444);
/*
* While the interrupts are still disabled, trigger all three interrupts.
*/
__osSpSetStatus(SP_SET_SIG2);
__osSpSetStatus(SP_SET_INTR);
osAiSetFrequency(3000);
osAiSetNextBuffer(buffer, 0x60);
__osPiRawStartDma(OS_READ, 0, buffer, 0x10);
__osSiRawStartDma(OS_READ, buffer);
/*
* Loop here a bit, since AI interrupt takes some time to fire.
*/
for (loop = 0; loop < 1000000; loop++);
/*
* Enable the interrupts.
*/
currentMask = osSetIntMask(OS_IM_SP|OS_IM_AI|OS_IM_SI|OS_IM_PI);
if (currentMask != OS_IM_NONE) {
osSyncPrintf("int4: expected interrupt mask 0x%x, actual 0x%x\n",
OS_IM_NONE, currentMask);
numFailures++;
}
/*
* Should get OS_EVENT_SP message first ...
*/
expectedMesg = (OSMesg)0x11111111;
retValue = osRecvMesg(&intMesgQueue, &actualMesg, OS_MESG_NOBLOCK);
if (retValue != 0) {
osSyncPrintf("int4: expected osRecvMesg return value %d, actual %d\n",
0, retValue);
numFailures++;
}
if (expectedMesg != actualMesg) {
osSyncPrintf("int4: expected message 0x%x, actual 0x%x\n",
expectedMesg, actualMesg);
numFailures++;
}
/*
* Then OS_EVENT_AI message ...
*/
expectedMesg = (OSMesg)0x22222222;
retValue = osRecvMesg(&intMesgQueue, &actualMesg, OS_MESG_BLOCK);
if (retValue != 0) {
osSyncPrintf("int4: expected osRecvMesg return value %d, actual %d\n",
0, retValue);
numFailures++;
}
if (expectedMesg != actualMesg) {
osSyncPrintf("int4: expected message 0x%x, actual 0x%x\n",
expectedMesg, actualMesg);
numFailures++;
}
/*
* Then OS_EVENT_SI message.
*/
expectedMesg = (OSMesg)0x33333333;
retValue = osRecvMesg(&intMesgQueue, &actualMesg, OS_MESG_BLOCK);
if (retValue != 0) {
osSyncPrintf("int4: expected osRecvMesg return value %d, actual %d\n",
0, retValue);
numFailures++;
}
if (expectedMesg != actualMesg) {
osSyncPrintf("int4: expected message 0x%x, actual 0x%x\n",
expectedMesg, actualMesg);
numFailures++;
}
/*
* finally OS_EVENT_PI message ...
*/
expectedMesg = (OSMesg)0x44444444;
retValue = osRecvMesg(&intMesgQueue, &actualMesg, OS_MESG_BLOCK);
if (retValue != 0) {
osSyncPrintf("int4: expected osRecvMesg return value %d, actual %d\n",
0, retValue);
numFailures++;
}
if (expectedMesg != actualMesg) {
osSyncPrintf("int4: expected message 0x%x, actual 0x%x\n",
expectedMesg, actualMesg);
numFailures++;
}
/*
* Restore original interrupt mask and check it once more.
*/
currentMask = osSetIntMask(savedMask);
if (currentMask != (OS_IM_SP|OS_IM_AI|OS_IM_SI|OS_IM_PI)) {
osSyncPrintf("int4: expected interrupt mask 0x%x, actual 0x%x\n",
OS_IM_SP|OS_IM_AI|OS_IM_SI|OS_IM_PI, currentMask);
numFailures++;
}
return(numFailures);
}