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
|
#include "PR/os_version.h"
#if BUILD_VERSION < VERSION_J
#ident "$Revision: 3.70 $"
#ident "$Revision: 1.5 $"
#ident "$Revision: 1.2 $"
#ident "$Revision: 1.4 $"
#ident "$Revision: 1.3 $"
#endif
#ifndef _FINALROM
#include "PRinternal/dbgproto.h"
#include "PR/os_internal.h"
#include "PRinternal/rmonint.h"
#include "PR/rcp.h"
#include "PR/sptask.h"
#include "PR/rdb.h"
#include "PRinternal/macros.h"
// TODO: this comes from a header
#if BUILD_VERSION >= VERSION_J
#ident "$Revision: 1.4 $"
#endif
int __rmonActive = FALSE;
static vu32 somethingToDo;
static u32 inbuffer[280] ALIGNED(0x10);
static u8 cmdinptr;
static u8 cmdoutptr;
static int state;
static char* inPointer;
void __rmonSendHeader(KKHeader* const block, u32 blockSize, u32 type) {
int sent;
char* cPtr = (char*)block;
block->rev = KK_REV;
block->type = type;
sent = 0;
while (sent < blockSize) {
sent += __osRdbSend(cPtr + sent, blockSize - sent, RDB_TYPE_GtoH_DEBUG);
}
}
void __rmonSendReply(KKHeader* const block, u32 blockSize, u32 replyType) {
char* cPtr;
int sent = 0;
block->length = blockSize;
cPtr = (char*)&blockSize;
/* send size */
while (sent < (signed)sizeof(blockSize)) {
sent += __osRdbSend(cPtr + sent, sizeof(blockSize) - sent, RDB_TYPE_GtoH_DEBUG);
}
/* send data */
__rmonSendHeader(block, blockSize, replyType);
__rmonIOflush();
}
void __rmonSendData(char* const block, unsigned int blockSize) {
int* blockPointer = (int*)block;
unsigned int wordCount = (u32)(blockSize + 3) / 4;
u32 data;
union {
char bufBytes[4];
u32 bufWord;
} buffer;
if (((u32)block & 3) == 0) {
while (wordCount--) {
if ((u32)blockPointer >= SP_DMEM_START && (u32)blockPointer < 0x05000000) {
__osSpRawReadIo((u32)blockPointer++, &data);
__rmonIOputw(data);
} else {
__rmonIOputw(*(blockPointer++));
}
}
} else
while (wordCount--) {
__rmonMemcpy((u8*)buffer.bufBytes, (u8*)blockPointer, sizeof(buffer));
__rmonIOputw(buffer.bufWord);
blockPointer++;
}
__rmonIOflush();
}
void rmonMain(void) {
register int newChars UNUSED;
STUBBED_PRINTF(("rmon: Thread %d created\n"));
STUBBED_PRINTF(("rmon: Thread %d destroyed\n"));
somethingToDo = 0;
cmdoutptr = 0;
cmdinptr = 0;
__rmonInit();
__rmonActive = TRUE;
state = 0, newChars = 0, inPointer = (void*)&inbuffer;
for (;;) {
OSMesg work;
osRecvMesg(&__rmonMQ, &work, OS_MESG_BLOCK);
somethingToDo |= (u32)work;
if (somethingToDo & RMON_MESG_CPU_BREAK) {
somethingToDo &= ~RMON_MESG_CPU_BREAK;
__rmonHitBreak();
}
if (somethingToDo & RMON_MESG_SP_BREAK) {
somethingToDo &= ~RMON_MESG_SP_BREAK;
__rmonHitSpBreak();
}
if (somethingToDo & RMON_MESG_FAULT) {
somethingToDo &= ~RMON_MESG_FAULT;
__rmonHitCpuFault();
}
if (somethingToDo & 0x10) {
somethingToDo;
somethingToDo &= (u8)~0x10;
}
if (somethingToDo & 0x20) {
somethingToDo;
somethingToDo &= (u8)~0x20;
}
}
}
#endif
|