intcheck.c
3.13 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
/**************************************************************************
$B%+!<%H%j%C%83d$j9~$_!J#I#N#T#1!K$N8!::(B
$B2~D{MzNr!'(B
$B#9#6(B/$B#1#0(B $B8!::;~$KJL%9%l%C%I$r:n@.$7$F(B,$B$=$3$G3d$j9~$_8!::$r$*$3$J$&(B
*************************************************************************/
#include <ultra64.h>
#include <PR/os_internal.h>
#include "gng.h"
extern int Int1Check( void );
static void IntProc( void *arg );
static void MakeIntThread( void );
static OSMesgQueue IntMessageQ;
static OSMesg IntMessageBuf;
static OSThread IntThread;
static u64 IntThreadStack[STACKSIZE/sizeof(u64)];
const OSMesg TimerInt = (OSMesg)1; /* $B%$%Y%s%HH/@8;~$N%a%C%;!<%8(B */
const OSMesg CartridgeInt = (OSMesg)2;
/**************************************************************************
$B%+!<%H%j%C%83d$j9~$_!J#I#N#T#1!K8!::$r$*$3$J$&4X?t(B
************************************************************************/
int Int1Check( void ){
OSTimer Timer; /* $B;~4V$G3d$j9~$_BT$A$r;_$a$k0Y$N%?%$%^(B */
OSMesg Message; /* $B3d$j9~$_8!::$G<u$1$?%a%C%;!<%8(B */
int ReturnValue; /* $B8!::7k2L(B */
/* $BDL?.MQ%a%C%;!<%8%-%e!<:n@.(B */
osCreateMesgQueue( &IntMessageQ, &IntMessageBuf, 1 );
/* $B#I#N#T%9%l%C%I:n@.(B */
osCreateThread( &IntThread, 31, IntProc, NULL,
IntThreadStack+STACKSIZE/sizeof(u64), 31 );
/* $B#I#N#T%9%l%C%I5/F0(B */
osStartThread( &IntThread );
/* $B#0!%#5IC%?%$%^$r8!::%-%e!<$K4XO"$E$1$k(B */
osSetTimer( &Timer, OS_USEC_TO_CYCLES(500000), 0, &IntMessageQ, TimerInt );
/* $B%a%C%;!<%8<u?.BT$A(B */
osRecvMesg( &IntMessageQ, &Message, OS_MESG_BLOCK );
/* $B>e$G@_Dj$7$?%?%$%^$r;_$a$k(B */
osStopTimer( &Timer );
/* $B8!::7k2LH=Dj(B */
if( Message == CartridgeInt ){
ReturnValue = GNG_TEST_SUCCESS;
}else{
ReturnValue = GNG_TEST_FAILURE;
}
return ReturnValue;
}
/**************************************************************************
$B#I#N#T8!::%9%l%C%IK\BN(B
************************************************************************/
static void IntProc(void *arg){
extern s32 clearint1( void );
static OSMesgQueue CartMessageQ ; /*$B#I#N#T3d$j9~$_<u?.MQ%a%C%;!<%8%-%e!<(B*/
static OSMesg CartMessageBuf;
/* $B%+!<%H%j%C%83d$j9~$_<u?.MQ%a%C%;!<%8%-%e!<:n@.(B */
osCreateMesgQueue(&CartMessageQ, &CartMessageBuf, 1);
osSetEventMesg(OS_EVENT_CART, &CartMessageQ, NULL );
/* $B3d$j9~$_=hM}%k!<%A%s$NIUM?(B */
#ifdef __sgi__
__osSetHWIntrRoutine(1, clearint1);
#else
__osSetHWIntrRoutine(1, clearint1, NULL);
#endif
/* Cause the interrupt (IO_WRITE does the PHYS_TO_K1 conversion) */
IO_WRITE((u32)(INT1_ADDR), INT1_SET_DATA);
/* now block for either the cartridge interrupt or the timer interrupt */
osRecvMesg(&CartMessageQ, NULL, OS_MESG_BLOCK);
/* $BJV;v$7$F$*$7$^$$(B */
osSendMesg( &IntMessageQ, CartridgeInt, OS_MESG_BLOCK );
osDestroyThread( NULL );
/*$B$3$3$K$OMh$J$$$O$:%@%@%@%@%@(B */
for(; ;);
}