This source file includes following definitions.
- taskHook
- boot
- sub_FF8101A0_my
- sub_FF810FC4_my
- sub_FF814D38_my
- taskcreate_Startup_my
- task_Startup_my
- taskcreatePhySw_my
- CreateTask_spytask
- init_file_modules_task
- sub_FF872598_my
- sub_FF855974_my
- sub_FF855714_my
- sub_FF8554A4_my
- task_blinker
- CreateTask_blinker
1 #include "lolevel.h"
2 #include "platform.h"
3 #include "core.h"
4 #include "dryos31.h"
5
6 #define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
7
8 const char * const new_sa = &_end;
9
10
11 extern long wrs_kernel_bss_start;
12 extern long wrs_kernel_bss_end;
13
14
15 void CreateTask_spytask();
16 void boot();
17 void task_CaptSeqTask_my();
18
19 extern void task_CaptSeq();
20 extern void task_InitFileModules();
21 extern void task_MovieRecord();
22 extern void task_ExpDrv();
23 extern void task_FileWrite();
24
25 void taskHook(context_t **context) {
26 task_t *tcb=(task_t*)((char*)context-offsetof(task_t, context));
27
28
29
30 if(tcb->entry == task_CaptSeq) tcb->entry = (void*)task_CaptSeqTask_my;
31 if(tcb->entry == task_InitFileModules) tcb->entry = (void*)init_file_modules_task;
32 if(tcb->entry == task_MovieRecord) tcb->entry = (void*)movie_record_task;
33 if(tcb->entry == task_ExpDrv) tcb->entry = (void*)exp_drv_task;
34
35 #ifdef CAM_HAS_FILEWRITETASK_HOOK
36 if(tcb->entry == task_FileWrite) tcb->entry = (void*)filewritetask;
37 #endif
38 }
39
40 #define DEBUG_LED ((unsigned volatile *)0xC0220130)
41 #define GREEN_LED ((unsigned volatile *)0xC0220134)
42
43 void boot() {
44 asm volatile(
45 " LDR R1, =0xC0410000\n"
46 " MOV R0, #0\n"
47 " STR R0, [R1]\n"
48 " MOV R1, #0x78\n"
49 " MCR p15, 0, R1,c1,c0\n"
50 " MOV R1, #0\n"
51 " MCR p15, 0, R1,c7,c10, 4\n"
52 " MCR p15, 0, R1,c7,c5\n"
53 " MCR p15, 0, R1,c7,c6\n"
54 " MOV R0, #0x3D\n"
55 " MCR p15, 0, R0,c6,c0\n"
56 " MOV R0, #0xC000002F\n"
57 " MCR p15, 0, R0,c6,c1\n"
58 " MOV R0, #0x33\n"
59 " MCR p15, 0, R0,c6,c2\n"
60 " MOV R0, #0x40000033\n"
61 " MCR p15, 0, R0,c6,c3\n"
62 " MOV R0, #0x80000017\n"
63 " MCR p15, 0, R0,c6,c4\n"
64 " LDR R0, =0xFF80002D\n"
65 " MCR p15, 0, R0,c6,c5\n"
66 " MOV R0, #0x34\n"
67 " MCR p15, 0, R0,c2,c0\n"
68 " MOV R0, #0x34\n"
69 " MCR p15, 0, R0,c2,c0, 1\n"
70 " MOV R0, #0x34\n"
71 " MCR p15, 0, R0,c3,c0\n"
72 " LDR R0, =0x3333330\n"
73 " MCR p15, 0, R0,c5,c0, 2\n"
74 " LDR R0, =0x3333330\n"
75 " MCR p15, 0, R0,c5,c0, 3\n"
76 " MRC p15, 0, R0,c1,c0\n"
77 " ORR R0, R0, #0x1000\n"
78 " ORR R0, R0, #4\n"
79 " ORR R0, R0, #1\n"
80 " MCR p15, 0, R0,c1,c0\n"
81 " MOV R1, #0x80000006\n"
82 " MCR p15, 0, R1,c9,c1\n"
83 " MOV R1, #6\n"
84 " MCR p15, 0, R1,c9,c1, 1\n"
85 " MRC p15, 0, R1,c1,c0\n"
86 " ORR R1, R1, #0x50000\n"
87 " MCR p15, 0, R1,c1,c0\n"
88 " LDR R2, =0xC0200000\n"
89 " MOV R1, #1\n"
90 " STR R1, [R2,#0x10C]\n"
91 " MOV R1, #0xFF\n"
92 " STR R1, [R2,#0xC]\n"
93 " STR R1, [R2,#0x1C]\n"
94 " STR R1, [R2,#0x2C]\n"
95 " STR R1, [R2,#0x3C]\n"
96 " STR R1, [R2,#0x4C]\n"
97 " STR R1, [R2,#0x5C]\n"
98 " STR R1, [R2,#0x6C]\n"
99 " STR R1, [R2,#0x7C]\n"
100 " STR R1, [R2,#0x8C]\n"
101 " STR R1, [R2,#0x9C]\n"
102 " STR R1, [R2,#0xAC]\n"
103 " STR R1, [R2,#0xBC]\n"
104 " STR R1, [R2,#0xCC]\n"
105 " STR R1, [R2,#0xDC]\n"
106 " STR R1, [R2,#0xEC]\n"
107 " STR R1, [R2,#0xFC]\n"
108 " LDR R1, =0xC0400008\n"
109 " LDR R2, =0x430005\n"
110 " STR R2, [R1]\n"
111 " MOV R1, #1\n"
112 " LDR R2, =0xC0243100\n"
113 " STR R2, [R1]\n"
114 " LDR R2, =0xC0242010\n"
115 " LDR R1, [R2]\n"
116 " ORR R1, R1, #1\n"
117 " STR R1, [R2]\n"
118 " LDR R0, =0xFFB4EFA4\n"
119 " LDR R1, =0x1900\n"
120 " LDR R3, =0xCDA0\n"
121 "loc_FF81013C:\n"
122 " CMP R1, R3\n"
123 " LDRCC R2, [R0],#4\n"
124 " STRCC R2, [R1],#4\n"
125 " BCC loc_FF81013C\n"
126 " LDR R1, =0x146A2C\n"
127 " MOV R2, #0\n"
128 "loc_FF810154:\n"
129 " CMP R3, R1\n"
130 " STRCC R2, [R3],#4\n"
131 " BCC loc_FF810154\n"
132 );
133
134
135
136 *(int*)0x1934=(int)taskHook;
137
138
139
140
141 *(int*)(0x2444)= (*(int*)0xC02200F8)&1 ? 0x200000 : 0x100000;
142
143
144 asm volatile ("B sub_FF8101A0_my\n");
145 }
146
147 void __attribute__((naked,noinline)) sub_FF8101A0_my() {
148 asm volatile (
149 " LDR R0, =0xFF810218\n"
150 " MOV R1, #0\n"
151 " LDR R3, =0xFF810250\n"
152 "loc_FF8101AC:\n"
153 " CMP R0, R3\n"
154 " LDRCC R2, [R0],#4\n"
155 " STRCC R2, [R1],#4\n"
156 " BCC loc_FF8101AC\n"
157 " LDR R0, =0xFF810250\n"
158 " MOV R1, #0x4B0\n"
159 " LDR R3, =0xFF810464\n"
160 "loc_FF8101C8:\n"
161 " CMP R0, R3\n"
162 " LDRCC R2, [R0],#4\n"
163 " STRCC R2, [R1],#4\n"
164 " BCC loc_FF8101C8\n"
165 " MOV R0, #0xD2\n"
166 " MSR CPSR_cxsf, R0\n"
167 " MOV SP, #0x1000\n"
168 " MOV R0, #0xD3\n"
169 " MSR CPSR_cxsf, R0\n"
170 " MOV SP, #0x1000\n"
171 " LDR R0, =0x6C4\n"
172 " LDR R2, =0xEEEEEEEE\n"
173 " MOV R3, #0x1000\n"
174 "loc_FF8101FC:\n"
175 " CMP R0, R3\n"
176 " STRCC R2, [R0],#4\n"
177 " BCC loc_FF8101FC\n"
178 " BL sub_FF810FC4_my\n"
179 );
180 }
181
182 void __attribute__((naked,noinline)) sub_FF810FC4_my() {
183 asm volatile (
184 " STR LR, [SP,#-4]!\n"
185 " SUB SP, SP, #0x74\n"
186 " MOV R0, SP\n"
187 " MOV R1, #0x74\n"
188 " BL sub_FFACBFBC\n"
189 " MOV R0, #0x53000\n"
190 " STR R0, [SP,#4]\n"
191
192 #if defined(CHDK_NOT_IN_CANON_HEAP)
193 " LDR R0, =0x146A2C\n"
194 #else
195 "LDR R0, =new_sa\n"
196 "LDR R0, [R0]\n"
197 #endif
198 " LDR R2, =0x2F9C00\n"
199 " LDR R1, =0x2F24A8\n"
200 " STR R0, [SP,#8]\n"
201 " SUB R0, R1, R0\n"
202 " ADD R3, SP, #0xC\n"
203 " STR R2, [SP]\n"
204 " STMIA R3, {R0-R2}\n"
205 " MOV R0, #0x22\n"
206 " STR R0, [SP,#0x18]\n"
207 " MOV R0, #0x68\n"
208 " STR R0, [SP,#0x1C]\n"
209 " LDR R0, =0x19B\n"
210 " LDR R1, =sub_FF814D38_my\n"
211 " LDR PC, =0xFF811018\n"
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238 );
239 }
240 void __attribute__((naked,noinline)) sub_FF814D38_my() {
241 asm volatile (
242 " STMFD SP!, {R4,LR}\n"
243 " BL sub_FF810954\n"
244 " BL sub_FF8190B4\n"
245 " CMP R0, #0\n"
246 " LDRLT R0, =0xFF814E4C\n"
247 " BLLT sub_FF814E2C\n"
248 " BL sub_FF814974\n"
249 " CMP R0, #0\n"
250 " LDRLT R0,=0xFF814E54\n"
251 " BLLT sub_FF814E2C\n"
252 " LDR R0, =0xFF814E64\n"
253 " BL sub_FF814A5C\n"
254 " CMP R0, #0\n"
255 " LDRLT R0, =0xFF814E6C\n"
256 " BLLT sub_FF814E2C\n"
257 " LDR R0, =0xFF814E64\n"
258 " BL sub_FF813578\n"
259 " CMP R0, #0\n"
260 " LDRLT R0, =0xFF814E80\n"
261 " BLLT sub_FF814E2C\n"
262 " BL sub_FF818BCC\n"
263 " CMP R0, #0\n"
264 " LDRLT R0, =0xFF814E8C\n"
265 " BLLT sub_FF814E2C\n"
266 " BL sub_FF8114A8\n"
267 " CMP R0, #0\n"
268 " LDRLT R0, =0xFF814E98\n"
269 " BLLT sub_FF814E2C\n"
270 " LDMFD SP!, {R4,LR}\n"
271 " B taskcreate_Startup_my\n"
272 );
273 }
274
275 void __attribute__((naked,noinline)) taskcreate_Startup_my() {
276 asm volatile (
277 " STMFD SP!, {R3,LR}\n"
278
279 " BL sub_FF828F44\n"
280 " CMP R0, #0\n"
281 " BNE loc_FF81C29C\n"
282 " BL sub_FF821B88\n"
283 " CMP R0, #0\n"
284 " BNE loc_FF81C29C\n"
285 " BL sub_FF821254\n"
286 " LDR R1, =0xC0220000\n"
287 " MOV R0, #0x44\n"
288 " STR R0, [R1,#0x14]\n"
289 " STR R0, [R1,#0x1C]\n"
290 " BL sub_FF821440\n"
291 "loc_FF81C298:\n"
292 " B loc_FF81C298\n"
293 "loc_FF81C29C:\n"
294
295
296 " BL sub_FF8271FC\n"
297 " LDR R1, =0x34E000\n"
298 " MOV R0, #0\n"
299 " BL sub_FF827644\n"
300 " BL sub_FF8273F0\n"
301 " MOV R3, #0\n"
302 " STR R3, [SP]\n"
303 " LDR R3, =task_Startup_my\n"
304 " MOV R2, #0\n"
305 " MOV R1, #0x19\n"
306 " LDR R0, =0xFF81C2E0\n"
307 " BL sub_FF81AFAC\n"
308 " MOV R0, #0\n"
309 " LDMFD SP!, {R12,PC}\n"
310 );
311 }
312
313 void CreateTask_blinker();
314
315 void __attribute__((naked,noinline)) task_Startup_my() {
316 asm volatile (
317 " STMFD SP!, {R4,LR}\n"
318 " BL sub_FF815394\n"
319 " BL sub_FF822C70\n"
320 " BL sub_FF820F38\n"
321
322 " BL sub_FF829168\n"
323
324 " BL CreateTask_spytask\n"
325 " BL sub_FF829304\n"
326 " BL sub_FF81FB94\n"
327 " BL sub_FF829198\n"
328 " BL sub_FF8267FC\n"
329 " BL sub_FF829308\n"
330 " BL taskcreatePhySw_my\n"
331 #if defined(OPT_RUN_WITH_BATT_COVER_OPEN)
332
333 " LDR R0, =0x90000\n"
334 "batt_delay:\n"
335 " NOP\n"
336 " SUBS R0,R0,#1\n"
337 " BNE batt_delay\n"
338 #endif
339 " LDR PC, =0xFF81C230\n"
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355 );
356 }
357
358 void __attribute__((naked,noinline)) taskcreatePhySw_my() {
359 asm volatile (
360 " STMFD SP!, {R3-R5,LR}\n"
361 " LDR R4, =0x1C2C\n"
362 " LDR R0, [R4,#0x10]\n"
363 " CMP R0, #0\n"
364 " BNE loc_FF821ABC\n"
365 " MOV R3, #0\n"
366 " STR R3, [SP]\n"
367 " LDR R3, =mykbd_task\n"
368
369 " MOV R2, #0x2000\n"
370 " MOV R1, #0x17\n"
371 " LDR R0, =0xFF821C90\n"
372 " BL sub_FF827444\n"
373 " STR R0, [R4,#0x10]\n"
374 "loc_FF821ABC:\n"
375 " BL sub_FF87015C\n"
376 " BL sub_FF849F90\n"
377 " CMP R0, #0\n"
378 " LDREQ R1, =0xE244\n"
379 " LDMEQFD SP!, {R3-R5,LR}\n"
380 " BEQ sub_FF8700E4\n"
381 " LDMFD SP!, {R3-R5,PC}\n"
382 );
383 }
384
385 void CreateTask_spytask() {
386 _CreateTask("SpyTask", 0x19, 0x2000, core_spytask, 0);
387 }
388
389 void __attribute__((naked,noinline)) init_file_modules_task() {
390 asm volatile (
391 " STMFD SP!, {R4-R6,LR}\n"
392 " BL sub_FF87256C\n"
393 " LDR R5, =0x5006\n"
394 " MOVS R4, R0\n"
395 " MOVNE R1, #0\n"
396 " MOVNE R0, R5\n"
397 " BLNE sub_FF8773D4\n"
398 " BL sub_FF872598_my\n"
399 " BL core_spytask_can_start\n"
400 " CMP R4, #0\n"
401 " MOVEQ R0, R5\n"
402 " LDMEQFD SP!, {R4-R6,LR}\n"
403 " MOVEQ R1, #0\n"
404 " BEQ sub_FF8773D4\n"
405 " LDMFD SP!, {R4-R6,PC}\n"
406 );
407 }
408
409 void __attribute__((naked,noinline)) sub_FF872598_my() {
410 asm volatile (
411 " STMFD SP!, {R4,LR}\n"
412 " MOV R0, #3\n"
413 " BL sub_FF855974_my\n"
414 " LDR PC,=0xFF8725A8\n"
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432 );
433 }
434
435 void __attribute__((naked,noinline)) sub_FF855974_my() {
436 asm volatile (
437 " STMFD SP!, {R4-R8,LR}\n"
438 " MOV R6, R0\n"
439 " BL sub_FF8558DC\n"
440 " LDR R1, =0x10770\n"
441 " MOV R5, R0\n"
442 " ADD R4, R1, R0,LSL#7\n"
443 " LDR R0, [R4,#0x70]\n"
444 " CMP R0, #4\n"
445 " LDREQ R1, =0x6D8\n"
446 " LDREQ R0, =0xFF855400\n"
447 " BLEQ sub_FF81B284\n"
448 " MOV R1, R6\n"
449 " MOV R0, R5\n"
450 " BL sub_FF855348\n"
451 " LDR R0, [R4,#0x38]\n"
452 " BL sub_FF855EA0\n"
453 " CMP R0, #0\n"
454 " STREQ R0, [R4,#0x70]\n"
455 " MOV R0, R5\n"
456 " BL sub_FF855420\n"
457 " MOV R0, R5\n"
458 " BL sub_FF855714_my\n"
459 " LDR PC,=0xFF8559CC\n"
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493 );
494 }
495
496 void __attribute__((naked,noinline)) sub_FF855714_my() {
497 asm volatile (
498 " STMFD SP!, {R4-R6,LR}\n"
499 " MOV R5, R0\n"
500 " LDR R0, =0x10770\n"
501 " ADD R4, R0, R5,LSL#7\n"
502 " LDR R0, [R4,#0x70]\n"
503 " TST R0, #2\n"
504 " MOVNE R0, #1\n"
505 " LDMNEFD SP!, {R4-R6,PC}\n"
506 " LDR R0, [R4,#0x38]\n"
507 " MOV R1, R5\n"
508 " BL sub_FF8554A4_my\n"
509 " LDR PC, =0xFF855740\n"
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526 );
527 }
528 void __attribute__((naked,noinline)) sub_FF8554A4_my() {
529 asm volatile (
530 " STMFD SP!, {R4-R8,LR}\n"
531 " MOV R8, R0\n"
532 " LDR R0, =0x10770\n"
533 " MOV R7, #0\n"
534 " ADD R5, R0, R1,LSL#7\n"
535 " LDR R0, [R5,#0x3C]\n"
536 " MOV R6, #0\n"
537 " CMP R0, #7\n"
538 " ADDLS PC, PC, R0,LSL#2\n"
539 " B loc_FF8555F4\n"
540 " B loc_FF855504\n"
541 " B loc_FF8554EC\n"
542 " B loc_FF8554EC\n"
543 " B loc_FF8554EC\n"
544 " B loc_FF8554EC\n"
545 " B loc_FF8555EC\n"
546 " B loc_FF8554EC\n"
547 " B loc_FF8554EC\n"
548 "loc_FF8554EC:\n"
549
550 " MOV R2, #0\n"
551 " MOV R1, #0x200\n"
552 " MOV R0, #2\n"
553 " BL sub_FF86C664\n"
554 " MOVS R4, R0\n"
555 " BNE loc_FF85550C\n"
556 "loc_FF855504:\n"
557
558 " MOV R0, #0\n"
559 " LDMFD SP!, {R4-R8,PC}\n"
560 "loc_FF85550C:\n"
561 " LDR R12, [R5,#0x4C]\n"
562 " MOV R3, R4\n"
563 " MOV R2, #1\n"
564 " MOV R1, #0\n"
565 " MOV R0, R8\n"
566 " BLX R12\n"
567 " CMP R0, #1\n"
568 " BNE loc_FF855538\n"
569 " MOV R0, #2\n"
570 " BL sub_FF86C7B0\n"
571 " B loc_FF855504\n"
572 "loc_FF855538:\n"
573
574 " LDR R1, [R5,#0x68]\n"
575 " MOV R0, R8\n"
576 " BLX R1\n"
577 "MOV R1, R4\n"
578 "BL mbr_read_dryos\n"
579
580
581
582
583
584
585 "MOV R12, R4\n"
586 "MOV LR, R4\n"
587 "MOV R1, #1\n"
588 "B dg_sd_fat32_enter\n"
589 "dg_sd_fat32:\n"
590 "CMP R1, #4\n"
591 "BEQ dg_sd_fat32_end\n"
592 "ADD R12, R12, #0x10\n"
593 "ADD R1, R1, #1\n"
594 "dg_sd_fat32_enter:\n"
595 "LDRB R2, [R12, #0x1BE]\n"
596 "LDRB R3, [R12, #0x1C2]\n"
597 "CMP R3, #0xB\n"
598 "CMPNE R3, #0xC\n"
599 "BNE dg_sd_fat32\n"
600 "CMP R2, #0x00\n"
601 "CMPNE R2, #0x80\n"
602 "BNE dg_sd_fat32\n"
603
604 "MOV R4, R12\n"
605
606 "dg_sd_fat32_end:\n"
607
608 " LDRB R1, [R4,#0x1C9]\n"
609 " LDRB R3, [R4,#0x1C8]\n"
610 " LDRB R12, [R4,#0x1CC]\n"
611 " MOV R1, R1,LSL#24\n"
612 " ORR R1, R1, R3,LSL#16\n"
613 " LDRB R3, [R4,#0x1C7]\n"
614 " LDRB R2, [R4,#0x1BE]\n"
615
616 " ORR R1, R1, R3,LSL#8\n"
617 " LDRB R3, [R4,#0x1C6]\n"
618 " CMP R2, #0\n"
619 " CMPNE R2, #0x80\n"
620 " ORR R1, R1, R3\n"
621 " LDRB R3, [R4,#0x1CD]\n"
622 " MOV R3, R3,LSL#24\n"
623 " ORR R3, R3, R12,LSL#16\n"
624 " LDRB R12, [R4,#0x1CB]\n"
625 " ORR R3, R3, R12,LSL#8\n"
626 " LDRB R12, [R4,#0x1CA]\n"
627 " ORR R3, R3, R12\n"
628
629 " LDRB R12, [LR,#0x1FE]\n"
630 " LDRB LR, [LR,#0x1FF]\n"
631 " MOV R4, #0\n"
632 " BNE loc_FF8555C4\n"
633 " CMP R0, R1\n"
634 " BCC loc_FF8555C4\n"
635 " ADD R2, R1, R3\n"
636 " CMP R2, R0\n"
637 " CMPLS R12, #0x55\n"
638 " CMPEQ LR, #0xAA\n"
639 " MOVEQ R7, R1\n"
640 " MOVEQ R6, R3\n"
641 " MOVEQ R4, #1\n"
642 "loc_FF8555C4:\n"
643 " MOV R0, #2\n"
644 " BL sub_FF86C7B0\n"
645 " CMP R4, #0\n"
646 " BNE loc_FF855600\n"
647 " LDR R1, [R5,#0x68]\n"
648 " MOV R7, #0\n"
649 " MOV R0, R8\n"
650 " BLX R1\n"
651 " MOV R6, R0\n"
652 " B loc_FF855600\n"
653 "loc_FF8555EC:\n"
654
655 " MOV R6, #0x40\n"
656 " B loc_FF855600\n"
657 "loc_FF8555F4:\n"
658
659 " LDR R1, =0x5C9\n"
660 " LDR R0, =0xFF855400\n"
661 " BL sub_FF81B1CC\n"
662 "loc_FF855600:\n"
663 " STR R7, [R5,#0x44]!\n"
664 " MOV R0, #1\n"
665 " STR R6, [R5,#4]\n"
666 " LDMFD SP!, {R4-R8,PC}\n"
667 );
668 }
669
670 #if 0
671 const unsigned ledlist[]={
672 0xC0220134,
673 0xC0220130,
674 };
675
676 extern void msleep(int x);
677 void __attribute__((noinline)) task_blinker() {
678 int ledstate;
679
680 int counter = 0;
681
682 int *led = (void*) ledlist[0];
683 int i_led = 0;
684
685 int *anypointer;
686 int v1, v2, v3, v4;
687
688 ledstate = 0;
689 *led = 0x46;
690
691 while (1) {
692
693 if (ledstate == 1) {
694 ledstate = 0;
695 *led = 0x44;
696 led=(void *)ledlist[(++i_led)%2];
697
698 } else {
699 ledstate = 1;
700 *led = 0x46;
701
702 }
703
704 if (counter == 2) {
705
706
707
708
709 }
710
711 if (counter == 10) {
712
713 }
714
715 msleep(500);
716 counter++;
717 }
718 };
719
720 void CreateTask_blinker() {
721 _CreateTask("Blinker", 0x1, 0x200, task_blinker, 0);
722 };
723 #endif
724