blob: 4328da9d8f80fc25340650d57ac9965e338a52bb (
plain)
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
|
#ifndef _FINALROM
#include "PR/os_internal.h"
#include "PR/rcp.h"
#include "PRinternal/osint.h"
typedef struct {
/* 0x0 */ unsigned int inst1;
/* 0x4 */ unsigned int inst2;
/* 0x8 */ unsigned int inst3;
/* 0xC */ unsigned int inst4;
} __osExceptionVector;
extern __osExceptionVector __ptExceptionPreamble[];
static volatile unsigned int* stat = (unsigned*)0xbff08004;
static volatile unsigned int* wport = (unsigned*)0xbff08000;
static volatile unsigned int* piok = (unsigned*)PHYS_TO_K1(PI_STATUS_REG);
static void rmonPutchar(char c) {
u32 data;
while (TRUE) {
osPiReadIo(stat, &data);
if (data & 4) {
osPiWriteIo(wport, c);
break;
}
}
}
static void* kmc_proutSyncPrintf(void* str, const char* buf, int n) {
int i;
char c;
char* p;
char* q;
char xbuf[128];
static int column = 0;
p = &xbuf;
for (i = 0; i < n; i++) {
c = *buf++;
switch (c) {
case '\n':
*p++ = '\n';
column = 0;
break;
case '\t':
do {
*p++ = ' ';
} while (++column % 8);
break;
default:
column++;
*p++ = c;
break;
}
if (c == '\n' || (p - xbuf) > 100) {
rmonPutchar((p - xbuf) - 1);
q = xbuf;
while (q != p) {
rmonPutchar(*q++);
}
p = xbuf;
}
}
if (p != xbuf) {
rmonPutchar((p - xbuf) - 1);
q = xbuf;
while (q != p) {
rmonPutchar(*q++);
}
}
return (void*)1;
}
extern u32 __kmc_pt_mode;
void __osInitialize_kmc(void) {
if (!__kmc_pt_mode) {
int (*fnc)();
unsigned int* src;
unsigned int* dst;
unsigned int monadr;
volatile unsigned int* mon;
volatile unsigned int* stat;
stat = (unsigned*)0xbff08004;
mon = (unsigned*)0xBFF00000;
if (*mon != 0x4B4D4300) {
return;
}
src = (unsigned*)__ptExceptionPreamble;
dst = (unsigned*)E_VEC;
*dst++ = *src++;
*dst++ = *src++;
*dst++ = *src++;
src += 2;
dst += 2;
*dst++ = *src++;
*dst++ = *src++;
*dst++ = *src++;
osWritebackDCache(E_VEC, 0x24);
osInvalICache(E_VEC, 0x24);
__kmc_pt_mode = TRUE;
if ((*stat & 0x10) == 0) {
monadr = *(mon + 1);
if (monadr != 0xBFF00000) {
unsigned int* src;
unsigned int* dst = monadr | 0x20000000;
unsigned int ct = 0x2000 / 4;
src = 0xBFF00000;
while (ct != 0) {
*dst++ = *src++;
ct--;
}
}
fnc = monadr + 8;
fnc(0x4B4D4300, 0);
}
__printfunc = kmc_proutSyncPrintf;
}
}
int __checkHardware_kmc(void) {
volatile unsigned int* mon = (unsigned*)0xBFF00000;
if (*mon == 0x4B4D4300) {
mon = (unsigned*)0xBFF00010;
if (*mon == 0xB0FFB000) {
return TRUE;
} else {
return FALSE;
}
} else {
return FALSE;
}
}
#endif
|