rsp.c
2.74 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
#include <ultra64.h>
#include <assert.h>
#include <PR/ramrom.h>
#include "gng.h"
#ifdef __sgi__
#include <bstring.h>
#endif
#include <sptask.h>
#include <os_internal.h>
#include "rcp.h"
extern int __osSpDeviceBusy(void);
extern s32 __osSpRawWriteIo(u32 devAddr, u32 data);
extern s32 __osSpRawReadIo(u32 devAddr, u32 *data);
extern char *rspcodeSegment;
extern OSIoMesg dmaIOMessageBuf;
extern char _rspcodeSegmentRomStart[];
extern OSMesgQueue dmaMessageQ;
extern OSMesg dummyMessage;
int rsp(void)
{
u32 data;
u32 status=0;
int errCount = 0;
int noErrCount = 0;
int i, j;
int offset = 0;
u32 rom_addr;
char message[256];
char trapbit=0;
if (ZaruReadReg2(REG_TRAPRSP) !=0) trapbit=1;
rom_addr = (u32) _rspcodeSegmentRomStart;
for (j=0; j<391; j++) {
/*
* Start rom->rdram dma of RSP data (DMem) and
* wait for it to finish. First 64 bit word is
* length in bytes of data.
*/
osPiStartDma(&dmaIOMessageBuf, OS_MESG_PRI_NORMAL, OS_READ,
rom_addr, rspcodeSegment, 0x1008, &dmaMessageQ);
(void)osRecvMesg(&dmaMessageQ, &dummyMessage, OS_MESG_BLOCK);
osWritebackDCacheAll();
offset = *((u64 *) rspcodeSegment);
rom_addr += offset + sizeof(u64);
/* Load DMem */
while(__osSpRawStartDma((u32) OS_WRITE,
(u32) SP_DMEM_START,
(u64 *) rspcodeSegment + 1,
(u32) offset) == -1)
;
while(__osSpDeviceBusy())
;
/*
* Start rom->rdram dma of RSP code (IMem) and
* wait for it to finish.
*/
osPiStartDma(&dmaIOMessageBuf, OS_MESG_PRI_NORMAL, OS_READ,
rom_addr, rspcodeSegment, 0x1008, &dmaMessageQ);
(void)osRecvMesg(&dmaMessageQ, &dummyMessage, OS_MESG_BLOCK);
osWritebackDCacheAll();
offset = *((u64 *) rspcodeSegment);
rom_addr += offset + sizeof(u64);
/* Load IMem */
while(__osSpRawStartDma((u32) OS_WRITE,
(u32) SP_IMEM_START,
(u64 *) rspcodeSegment + 1,
(u32) SP_UCODE_SIZE) == -1)
;
while(__osSpDeviceBusy())
;
/*
* Set PC and run
*/
__osSpRawWriteIo(0x04080000, 0x00000000); /* Initialize PC */
__osSpRawWriteIo(0x04040010, 0x00000005); /* Clear break and halt */
do {
__osSpRawReadIo(0x04040010, &status); /* Check break status */
} while (!(status & 0x2));
/* Check results in DMem */
osWritebackDCacheAll();
__osSpRawReadIo((0x04000f84), &data);
if ((j==5) && (trapbit==1)) data=0; /* sasano trap */
if (data!=0x0000feed && data!=0xfeed0000) {
errCount++;
sprintf(message, "RSP diagnostic\nsub-test %d failed\n", j);
gng_report(message, 1, GNG_PASS_FAIL_BIT, 0);
} else {
noErrCount++;
}
}
PRINTF("%d RSP tests out of 392 pass.\n", noErrCount+1);
/* if (ZaruReadReg2(REG_TRAPRSP) !=0) errCount++;*/
return(errCount);
}