int2.c
2.75 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
#include <os.h>
#include <os_internal.h>
#include <rmon.h>
#include <R4300.h>
#include "corefunc.h"
/*
* int2
*
* Tests for:
* osSetEventMesg
* osSetIntMask
* __osSetCause
* __osSetCompare
* __osSetCount
*
* Assumed working:
* osCreateMesgQueue
* osRecvMesg
*
* Description:
* Check the multiple pending interrupts send correct messages that are
* ordered properly.
*/
#define NUM_MESSAGE 3
static OSMesgQueue intMesgQueue;
static OSMesg intMesgBuf[NUM_MESSAGE];
int
int2(void)
{
OSIntMask savedMask, currentMask;
OSMesg actualMesg, expectedMesg;
int i;
int retValue;
int numFailures = 0;
savedMask = osSetIntMask(OS_IM_NONE);
/*
* Create a single message queue and associate three
* interrupt events with it.
*/
osCreateMesgQueue(&intMesgQueue, intMesgBuf, NUM_MESSAGE);
osSetEventMesg(OS_EVENT_SW1, &intMesgQueue, (OSMesg)0x11111111);
osSetEventMesg(OS_EVENT_SW2, &intMesgQueue, (OSMesg)0x22222222);
osSetEventMesg(OS_EVENT_COUNTER, &intMesgQueue, (OSMesg)0x33333333);
/*
* While the interrupts are still disabled, trigger all three interrupts.
*/
__osSetCause(CAUSE_SW1 | CAUSE_SW2);
__osSetCompare(0);
__osSetCount(0);
/*
* Enable the interrupts.
*/
currentMask = osSetIntMask(OS_IM_SW1|OS_IM_SW2|OS_IM_COUNTER);
if (currentMask != OS_IM_NONE) {
osSyncPrintf("int2: expected interrupt mask 0x%x, actual 0x%x\n",
OS_IM_NONE, currentMask);
numFailures++;
}
/*
* Should get OS_EVENT_COUNTER message first ...
*/
expectedMesg = (OSMesg)0x33333333;
(void)osRecvMesg(&intMesgQueue, &actualMesg, OS_MESG_NOBLOCK);
if (expectedMesg != actualMesg) {
osSyncPrintf("int2: expected message 0x%x, actual 0x%x\n",
expectedMesg, actualMesg);
numFailures++;
}
/*
* Then OS_EVENT_SW2 message ...
*/
expectedMesg = (OSMesg)0x22222222;
(void)osRecvMesg(&intMesgQueue, &actualMesg, OS_MESG_NOBLOCK);
if (expectedMesg != actualMesg) {
osSyncPrintf("int2: expected message 0x%x, actual 0x%x\n",
expectedMesg, actualMesg);
numFailures++;
}
/*
* And finally OS_EVENT_SW1 message.
*/
expectedMesg = (OSMesg)0x11111111;
(void)osRecvMesg(&intMesgQueue, &actualMesg, OS_MESG_NOBLOCK);
if (expectedMesg != actualMesg) {
osSyncPrintf("int2: 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_SW1|OS_IM_SW2|OS_IM_COUNTER)) {
osSyncPrintf("int2: expected interrupt mask 0x%x, actual 0x%x\n",
OS_IM_SW1|OS_IM_SW2|OS_IM_COUNTER, currentMask);
numFailures++;
}
return(numFailures);
}