This source file includes following definitions.
- sub_FF82786C_my
- open_crash
- write_crash
- close_crash
- assert_hook
- abort_hook
- panic_hook
- panic_hook_dump
- abort_hook_dump
- sub_FF82A1FC_my
- taskcreate_WdtReset_my
- WdtPrint_my
- sub_FF81351C_my
- sub_FF810904_my
- sub_FF814970_my
1 #include "lolevel.h"
2 #include "stdlib.h"
3 #include "script.h"
4 #include "console.h"
5
6
7 void __attribute__((naked,noinline)) sub_FF82786C_my() {
8 asm volatile (
9 "stmdb sp!, {r4, lr} \n"
10 "mov r0, #12 \n"
11 "BL sub_FF8627FC \n"
12
13
14 "ldr r0, =assert_hook \n"
15 "mov r1, #0 \n"
16 "BL sub_FF81BDD8 \n"
17
18
19 "ldr r0, =abort_hook \n"
20 "BL sub_FF862240 \n"
21
22
23 "ldr r0, =panic_hook \n"
24 "BL sub_FF86224C \n"
25 "ldmia sp!, {r4, pc} \n"
26 );
27 }
28
29
30 static int crash_fd = 0;
31 void open_crash() {
32 crash_fd = open("A/crash.log", O_WRONLY|O_CREAT|O_APPEND, 0777);
33 }
34 void write_crash(char* buf, int len) {
35 write(crash_fd, buf, len);
36 }
37 void close_crash() {
38 close(crash_fd);
39 }
40
41
42
43
44
45 extern void _OpLog_WriteToSD(int);
46
47 void assert_hook() {
48 asm volatile(
49 "stmdb sp!, {r0, r1} \n"
50 );
51 console_add_line("assert failed: game over :(");
52 _OpLog_WriteToSD(0);
53 msleep(1000);
54 asm volatile(
55 "ldmia sp!, {r0, r1} \n"
56 "BL sub_FF862858 \n"
57 );
58 console_add_line("assert done");
59 }
60
61 void abort_hook() {
62 asm volatile(
63 "stmdb sp!, {r0} \n"
64 );
65
66 console_add_line("abort error: game over :(");
67 _OpLog_WriteToSD(0);
68 msleep(1000);
69 asm volatile(
70 "ldmia sp!, {r0} \n"
71 "BL sub_FF862C50 \n"
72 );
73
74 console_add_line("abort done");
75 }
76
77 void panic_hook_dump();
78 void panic_hook() {
79 asm volatile(
80 "stmdb sp!, {r0, r1} \n"
81 );
82 console_add_line("dryos panic: game over :(");
83 _OpLog_WriteToSD(0);
84 msleep(1000);
85 asm volatile(
86 "ldmia sp!, {r0, r1} \n"
87 "BL sub_FF862FCC \n"
88 );
89 console_add_line("panic done");
90 }
91 #if 0
92
93
94
95 void __attribute__((naked,noinline)) panic_hook_dump() {
96 asm volatile (
97 "stmdb sp!, {r2, r3, r4, r5, r6, r7, r8, lr} \n"
98 "ldr r5, =0x00005574 \n"
99 "mov r7, r0 \n"
100 "ldr r0, [r5] \n"
101 "mov r8, r1 \n"
102 "cmp r0, #1 \n"
103 "BEQ sub_FF863114 \n"
104 "mov r0, #1 \n"
105 "str r0, [r5] \n"
106 "ldr r0, =0xff8632e0 \n"
107 "mov r2, r8 \n"
108 "mov r1, r7 \n"
109
110 "BL sub_FF81351C_my \n"
111 "ldr r0, [r5, #8] \n"
112 "BL sub_FF82789C \n"
113 "ldr r0, =0xff862798 \n"
114 "ldr r1, [r5, #8] \n"
115
116 "BL sub_FF81351C_my \n"
117 "mov r1, sp \n"
118 "add r2, r1, #128 \n"
119 "ldr r0, =0xff86330c \n"
120 "str r1, [sp, #4] \n"
121
122 "BL sub_FF81351C_my \n"
123 "ldr r4, [sp, #4] \n"
124 "B loc_FF863040 \n"
125 "loc_FF863030:\n"
126 "ldr r0, =0xff862c0c \n"
127 "ldr r1, [r4] \n"
128
129 "BL sub_FF81351C_my \n"
130 "add r4, r4, #4 \n"
131 "loc_FF863040:\n"
132 "ldr r0, [sp, #4] \n"
133 "add r0, r0, #128 \n"
134 "cmp r4, r0 \n"
135 "BCC loc_FF863030 \n"
136
137 "B sub_FF863050 \n"
138 );
139 }
140
141
142
143
144 void __attribute__((naked,noinline)) abort_hook_dump() {
145 asm volatile (
146 "stmdb sp!, {r4, r5, r6, r7, r8, r9, sl, lr} \n"
147 "ldr r8, =0x00005574 \n"
148 "mov r4, r0 \n"
149 "ldr r0, [r8] \n"
150 "sub sp, sp, #128 \n"
151 "cmp r0, #1 \n"
152 "BEQ sub_FF862FC4 \n"
153 "mov r0, #1 \n"
154 "str r0, [r8] \n"
155 "ldr r0, [r4] \n"
156 "cmp r0, #4 \n"
157 "ldreq r5, =0xff862f44 \n"
158 "BEQ loc_FF862C90 \n"
159 "cmp r0, #12 \n"
160 "ldreq r5, =0xff862f5c \n"
161 "ldrne r5, =0xff862f6c \n"
162 "loc_FF862C90:\n"
163 "ldr r0, [r4, #4] \n"
164 "cmp r0, #0 \n"
165 "movne r7, #2326528 \n"
166 "BNE loc_FF862CBC \n"
167 "BL sub_FF812128 \n"
168 "ldr r0, [r4, #8] \n"
169 "add r1, sp, #80 \n"
170 "BL sub_FF81339C \n"
171 "ldr r0, [sp, #108] \n"
172 "ldr r1, [sp, #112] \n"
173 "add r7, r0, r1 \n"
174 "loc_FF862CBC:\n"
175 "mov r1, r5 \n"
176 "ldr r0, =0xff862f78 \n"
177
178 "BL sub_FF81351C_my \n"
179 "ldr r0, [r8, #8] \n"
180 "BL sub_FF82789C \n"
181 "ldr r0, =0xff862798 \n"
182 "ldr r1, [r8, #8] \n"
183
184 "BL sub_FF81351C_my \n"
185 "ldr r0, [r4, #4] \n"
186 "ldr r9, =0xff810218 \n"
187 "cmp r0, #0 \n"
188 "ldrne r0, [r9] \n"
189 "ldrne r0, [r0] \n"
190 "movne r1, r0, lsr #2 \n"
191 "ldrne r0, =0xff8627b0 \n"
192 "BNE loc_FF862D10 \n"
193 "ldr r1, [r4, #8] \n"
194 "ldr r0, =0xff862be8 \n"
195
196 "BL sub_FF81351C_my \n"
197 "ldr r1, [sp, #124] \n"
198 "ldr r0, =0xff862bf8 \n"
199 "loc_FF862D10:\n"
200
201 "BL sub_FF81351C_my \n"
202 "ldr r0, =0xff862f90 \n"
203
204 "BL sub_FF81351C_my \n"
205 "mov r5, #0 \n"
206 "loc_FF862D20:\n"
207 "ldr r0, [r4, #12] \n"
208 "ldr r1, [r0, r5, lsl #2] \n"
209 "ldr r0, =0xff862c0c \n"
210
211 "BL sub_FF81351C_my \n"
212 "add r5, r5, #1 \n"
213 "cmp r5, #15 \n"
214 "BLT loc_FF862D20 \n"
215 "ldr r0, [r4, #12] \n"
216 "ldr r1, [r0, #60] \n"
217 "ldr r0, =0xff862c0c \n"
218
219 "BL sub_FF81351C_my \n"
220 "ldr r0, [r4, #12] \n"
221 "ldr r1, [r0, #64] \n"
222 "ldr r0, =0xff862c0c \n"
223
224 "BL sub_FF81351C_my \n"
225 "ldr r0, [r4, #12] \n"
226 "ldr r5, [r0, #52] \n"
227 "ldr r0, =0xff862c14 \n"
228 "mov sl, r5 \n"
229
230 "BL sub_FF81351C_my \n"
231 "mov r6, #0 \n"
232 "loc_FF862D74:\n"
233 "cmp r5, r7 \n"
234 "BHI loc_FF862D98 \n"
235 "ldr r1, [r5] \n"
236 "ldr r0, =0xff862c0c \n"
237
238 "BL sub_FF81351C_my \n"
239 "add r6, r6, #1 \n"
240 "cmp r6, #32 \n"
241 "add r5, r5, #4 \n"
242 "BLT loc_FF862D74 \n"
243 "loc_FF862D98:\n"
244 "ldr r0, [r4, #4] \n"
245 "cmp r0, #0 \n"
246 "BNE sub_FF862DBC \n"
247 "ldr r0, [r8, #16] \n"
248 "cmp r0, #12 \n"
249 "BEQ sub_FF862DC8 \n"
250 "ldr r0, =0xff862268 \n"
251 "mov r1, #0 \n"
252 "B sub_FF862DB8 \n"
253 );
254 }
255 #endif
256
257
258
259
260 void __attribute__((naked,noinline)) sub_FF82A1FC_my() {
261 asm volatile (
262 "stmdb sp!, {r4, lr} \n"
263 "mov r1, #4 \n"
264 "mov r0, #2 \n"
265
266 "BL taskcreate_WdtReset_my \n"
267 "BL sub_FF86BA8C \n"
268 "BL sub_FF86900C \n"
269 "BL sub_FF864D60 \n"
270 "BL sub_FF83F1FC \n"
271 "BL sub_FF86BC74 \n"
272 "ldr r2, =0x12cea600 \n"
273 "ldr r1, =0x7fe8177f \n"
274 "BL sub_FF828348 \n"
275 "BL sub_FF8411E0 \n"
276 "BL sub_FF846238 \n"
277 "BL sub_FF821748 \n"
278 "BL sub_FF845CC0 \n"
279 "mov r0, #1 \n"
280 "BL sub_FF842BBC \n"
281 "BL sub_FF83D9E8 \n"
282 "BL sub_FF8362B4 \n"
283 "BL sub_FF840988 \n"
284 "BL sub_FF84074C \n"
285 "BL sub_FF840A40 \n"
286 "BL sub_FF8450B0 \n"
287 "BL sub_FF855E80 \n"
288 "BL sub_FF841FC4 \n"
289 "BL sub_FF86CA3C \n"
290 "ldmia sp!, {r4, lr} \n"
291 "B sub_FF82A1E0 \n"
292 );
293 }
294
295
296
297 void __attribute__((naked,noinline)) taskcreate_WdtReset_my() {
298 asm volatile (
299 "mov r1, r1, lsl #8 \n"
300 "stmdb sp!, {r3, r4, r5, lr} \n"
301 "orr r0, r1, r0, lsl #4 \n"
302 "ldr r4, =0x00005770 \n"
303 "ldr r1, =0xc0410000 \n"
304 "orr r0, r0, #-1073741824 \n"
305 "str r0, [r4, #8] \n"
306 "str r0, [r1] \n"
307 "mov r0, #0 \n"
308 "BL sub_FF8280C8 \n"
309 "str r0, [r4, #16] \n"
310 "mov r0, #0 \n"
311 "str r0, [r4, #12] \n"
312 "ldr r0, =0xff86bba0 \n"
313 "mov r3, #0 \n"
314 "ldr r2, =0xff86b9a0 \n"
315 "mov r1, #3 \n"
316 "BL sub_FF81B5A0 \n"
317 "mov r3, #0 \n"
318 "str r3, [sp] \n"
319 "ldr r3, =0xff86b9cc \n"
320 "mov r2, #512 \n"
321 "mov r1, #24 \n"
322 "ldr r0, =0xff86bba8 \n"
323 "BL sub_FF81BBB8 \n"
324 "mov r1, #0 \n"
325 "mov r0, #0 \n"
326 "BL sub_FF81BC34 \n"
327 "str r0, [r4, #20] \n"
328 "mov r3, #0 \n"
329 "str r3, [sp] \n"
330
331 "ldr r3, =WdtPrint_my \n"
332 "ldr r0, =0xff86bbb4 \n"
333 "mov r2, #512 \n"
334 "mov r1, #1 \n"
335 "BL sub_FF81BBB8 \n"
336 "mov r0, #0 \n"
337 "ldmia sp!, {r3, r4, r5, pc} \n"
338 );
339 }
340
341
342
343 void __attribute__((naked,noinline)) WdtPrint_my() {
344 asm volatile (
345 "stmdb sp!, {r3, r4, r5, r6, r7, lr} \n"
346 "ldr r5, =0x0001a0c0 \n"
347 "mov r6, #0 \n"
348 "loc_FF86B924:\n"
349 "mov r0, #0 \n"
350 "loc_FF86B928:\n"
351 "str r6, [r5, r0, lsl #4] \n"
352 "add r0, r0, #1 \n"
353 "cmp r0, #10 \n"
354 "BLT loc_FF86B928 \n"
355 "ldr r4, =0x00005770 \n"
356 "mov r1, #0 \n"
357 "ldr r0, [r4, #20] \n"
358 "BL sub_FF81B774 \n"
359 "mov r0, #800 \n"
360 "BL sub_FF8284B4 \n"
361 "mov r0, #10 \n"
362 "str r0, [r4, #4] \n"
363
364 "ldr r0, =0xff86bb4c \n"
365 "BL console_add_line \n"
366 "ldr r0, =0xff86bb4c \n"
367 "BL sub_FF81351C_my \n"
368 "mov r0, #0 \n"
369 "BL _OpLog_WriteToSD \n"
370
371 "mov r4, #0 \n"
372 "B loc_FF86B98C \n"
373 "loc_FF86B968:\n"
374 "str r3, [sp] \n"
375 "ldr r2, [r0, #8] \n"
376 "ldr r3, [r0, #12] \n"
377 "ldr r1, [r5, r4, lsl #4] \n"
378 "ldr r0, =0xff86bb6c \n"
379 "BL sub_FF81351C_my\n"
380 "add r4, r4, #1 \n"
381 "cmp r4, #10 \n"
382 "BGE loc_FF86B924 \n"
383 "loc_FF86B98C:\n"
384 "add r0, r5, r4, lsl #4 \n"
385 "ldr r3, [r0, #4] \n"
386 "cmp r3, #0 \n"
387 "BNE loc_FF86B968 \n"
388 "B loc_FF86B924 \n"
389 );
390 }
391
392
393
394
395
396 void __attribute__((naked,noinline)) sub_FF81351C_my() {
397 asm volatile (
398 "stmdb sp!, {r0, r1, r2, r3} \n"
399 "stmdb sp!, {r4, lr} \n"
400 );
401 open_crash();
402 asm volatile (
403 "sub sp, sp, #24 \n"
404 "mov r0, #2 \n"
405 "strh r0, [sp, #16] \n"
406 "mrs r4, CPSR \n"
407 "orr r0, r4, #128 \n"
408 "msr CPSR_c, r0 \n"
409 "ldr r2, [sp, #32] \n"
410
411 "ldr r0, =sub_FF810904_my \n"
412 "add r3, sp, #36 \n"
413 "mov r1, sp \n"
414 "BL sub_FF818B80 \n"
415 "msr CPSR_c, r4 \n"
416 "add sp, sp, #24 \n"
417 );
418 close_crash();
419 asm volatile (
420 "ldr r4, [sp], #4 \n"
421 "ldr pc, [sp], #20 \n"
422 );
423 }
424
425
426
427
428
429 void __attribute__((naked,noinline)) sub_FF810904_my() {
430 asm volatile (
431 "mov r0, r1 \n"
432 "mov r1, r2 \n"
433 "ldr r2, =0x00001900 \n"
434 "ldr r2, [r2] \n"
435
436
437
438 "B sub_FF814970_my \n"
439
440 );
441 }
442
443
444
445
446 void __attribute__((naked,noinline)) sub_FF814970_my() {
447 asm volatile (
448 "mov r2, r1 \n"
449 "mov r1, r0 \n"
450 "stmdb sp!, {r3, lr} \n"
451 "mov r3, sp \n"
452
453
454 "mov r0, r1 \n"
455 "mov r1, r2 \n"
456 "BL write_crash \n"
457 "cmp r0, #0 \n"
458 "ldrge r0, [sp] \n"
459 "mvnlt r0, #0 \n"
460 "ldmia sp!, {ip, pc} \n"
461 );
462 }