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
153
|
#include "stdarg.h"
#include "PR/os.h"
#include "PR/os_internal.h"
#include "PR/rdb.h"
#include "xstdio.h"
#include "PR/rcp.h"
extern void* __printfunc;
#if BUILD_VERSION <= VERSION_J
#ifndef _FINALROM
extern u32 __kmc_pt_mode;
static void* proutSyncPrintf(void* str, const char* buf, size_t n) {
u32 sent = 0;
while (sent < n) {
sent += __osRdbSend(buf + sent, n - sent, RDB_TYPE_GtoH_PRINT);
}
return 1;
}
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) {
while (*piok & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) {
}
while (!(*stat & 4)) {
}
*wport = c;
}
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;
}
#endif
void osSyncPrintf(const char* fmt, ...) {
int ans;
va_list ap;
#ifndef _FINALROM
va_start(ap, fmt);
if (__kmc_pt_mode) {
ans = _Printf(kmc_proutSyncPrintf, NULL, fmt, ap);
} else {
ans = _Printf(proutSyncPrintf, NULL, fmt, ap);
}
va_end(ap);
#endif
}
void rmonPrintf(const char* fmt, ...) {
int ans;
va_list ap;
#ifndef _FINALROM
va_start(ap, fmt);
if (__kmc_pt_mode) {
ans = _Printf(kmc_proutSyncPrintf, NULL, fmt, ap);
}
va_end(ap);
#endif
}
#else
void __osSyncVPrintf(const char* fmt, va_list ap) {
int ans;
#ifndef _FINALROM
if (__printfunc != NULL) {
ans = _Printf(__printfunc, NULL, fmt, ap);
}
#endif
}
void osSyncPrintf(const char* fmt, ...) {
int ans;
va_list ap;
#ifndef _FINALROM
va_start(ap, fmt);
__osSyncVPrintf(fmt, ap);
va_end(ap);
#endif
}
void rmonPrintf(const char* fmt, ...) {
int ans;
va_list ap;
#ifndef _FINALROM
va_start(ap, fmt);
if (__printfunc != NULL) {
ans = _Printf(__printfunc, NULL, fmt, ap);
}
va_end(ap);
#endif
}
#endif
|