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
|
#include "m_Do/m_Do_printf/m_Do_printf.h"
#include "global.h"
#include "m_Do/m_Do_ext/m_Do_ext.h"
#include "os/OS.h"
asm void OSSwitchFiberEx(u32, u32, u32, u32, u32, u32) {
nofralloc
#include "m_Do/m_Do_printf/asm/func_80006798.s"
}
void my_PutString(const char* message) {
fputs(message, &lbl_803D29B0.stdout);
}
void OSVAttention(const char* fmt, __va_list_struct* va_list) {
mDoPrintf_vprintf(fmt, va_list);
}
extern "C" {
asm void OSAttention(const char* msg, ...) {
nofralloc
#include "m_Do/m_Do_printf/asm/func_80006814.s"
}
void OSReportDisable(void) {
lbl_80450B98 = true;
}
void OSReportEnable(void) {
lbl_80450B98 = false;
}
void OSReportForceEnableOn(void) {
lbl_80450B9C = true;
}
void OSReportForceEnableOff(void) {
lbl_80450B9C = false;
}
}; // extern "C"
void OSReportInit(void) {
if (lbl_80450BB4 == false) {
lbl_80450BB4 = true;
}
}
void mDoPrintf_vprintf_Interrupt(const char* format, __va_list_struct* list) {
s32 enable;
enable = OSDisableInterrupts();
if (lbl_80450BB5 == false) {
lbl_80450BB5 = true;
OSSwitchFiberEx((u32)format, (u32)list, 0, 0, (u32)&vprintf,
(u32)&lbl_803DB740.stack[0x800]);
lbl_80450BB5 = false;
}
OSRestoreInterrupts(enable);
}
void mDoPrintf_vprintf_Thread(const char* format, __va_list_struct* list) {
vprintf(format, list);
}
void mDoPrintf_vprintf(const char* format, __va_list_struct* list) {
OSThread* thread;
u8* stack_pointer;
thread = mDoExt_GetCurrentRunningThread();
if (thread == NULL) {
mDoPrintf_vprintf_Interrupt(format, list);
} else {
stack_pointer = OSGetStackPointer();
if ((stack_pointer < thread->stack_end + 0xa00) || (stack_pointer > thread->stack_base)) {
mDoPrintf_vprintf_Interrupt(format, list);
} else {
mDoPrintf_vprintf_Thread(format, list);
}
}
}
extern "C" {
void mDoPrintf_VReport(const char* format, __va_list_struct* list) {
OSThread* thread;
if (lbl_80450BB4 == false) {
OSReportInit();
}
if ((lbl_80450B9C) || (lbl_80450B98 == false)) {
thread = mDoExt_GetCurrentRunningThread();
if ((lbl_80450BA0 == NULL) || (lbl_80450BA0 == thread)) {
mDoPrintf_vprintf(format, list);
lbl_80450BA4++; // increment print counts
}
}
}
void OSVReport(const char* format, __va_list_struct* list) {
mDoPrintf_VReport(format, list);
}
asm void OSReport(const char* fmt, ...) {
nofralloc
#include "m_Do/m_Do_printf/asm/func_80006ABC.s"
}
asm void OSReport_FatalError(const char* fmt, ...) {
nofralloc
#include "m_Do/m_Do_printf/asm/func_80006B3C.s"
}
asm void OSReport_Error(const char* fmt, ...) {
nofralloc
#include "m_Do/m_Do_printf/asm/func_80006C0C.s"
}
asm void OSReport_Warning(const char* fmt, ...) {
nofralloc
#include "m_Do/m_Do_printf/asm/func_80006CEC.s"
}
asm void OSReport_System(const char* fmt, ...) {
nofralloc
#include "m_Do/m_Do_printf/asm/func_80006DCC.s"
}
asm void OSPanic(const char* file, s32 line, const char* fmt, ...) {
nofralloc
#include "m_Do/m_Do_printf/asm/func_80006E7C.s"
}
}; // extern "C"
|