source: trunk/platform/ixus90_sd790/sub/100d/boot.c @ 225

Revision 225, 22.1 KB checked in by msl, 3 years ago (diff)

Aktualisierung auf Rev. 868 offizieller Trunk

Line 
1#include "lolevel.h"
2#include "platform.h"
3#include "core.h"
4
5const char * const new_sa = &_end;
6
7void __attribute__((naked,noinline)) jogdial_task_my();
8
9// Forward declarations
10//void CreateTask_PhySw();
11void CreateTask_spytask();
12
13void taskCreateHook(unsigned int *p)
14{
15        p-=16;
16        if (p[0]==0xFF821ADC)  p[0]=(unsigned int)mykbd_task;
17        if (p[0]==0xFF842C84)  p[0]=(unsigned int)jogdial_task_my;
18        if (p[0]==0xFF85A278)  p[0]=(unsigned int)movie_record_task;
19        if (p[0]==0xFF85E2b0)  p[0]=(unsigned int)capt_seq_task;
20        if (p[0]==0xFF8791D0)  p[0]=(unsigned int)init_file_modules_task;
21        if (p[0]==0xFF8b6A80)  p[0]=(unsigned int)exp_drv_task;
22}
23
24void boot();
25
26void boot() { //#fs
27    long *canon_data_src = (void*)0xFFB1CDDC;
28    long *canon_data_dst = (void*)0x1900;
29    long canon_data_len = 0xF134 - 0x1900; // data_end - data_start
30    long *canon_bss_start = (void*)0xF134; // just after data
31    long canon_bss_len = 0xCBC48 - 0xF134; //0xFEBC;
32
33    long i;
34
35    // Code taken from VxWorks CHDK. Changes CPU speed?
36    asm volatile (
37        "MRC     p15, 0, R0,c1,c0\n"
38        "ORR     R0, R0, #0x1000\n"
39        "ORR     R0, R0, #4\n"
40        "ORR     R0, R0, #1\n"
41        "MCR     p15, 0, R0,c1,c0\n"
42    :::"r0");
43
44    for(i=0;i<canon_data_len/4;i++)
45        canon_data_dst[i]=canon_data_src[i];
46
47    for(i=0;i<canon_bss_len/4;i++)
48        canon_bss_start[i]=0;
49
50        // asm volatile ("B   sub_FF810000\n" );
51
52         // Captain Hook
53         *(int*)0x1930 = (int)taskCreateHook;
54
55    // jump to init-sequence that follows the data-copy-routine
56    asm volatile ("B  sub_FF8101A4_my\n" );
57}; //#fe
58
59
60// init
61void __attribute__((naked,noinline)) sub_FF8101A4_my() { //#fs
62        asm volatile (
63
64"loc_FF8101A4:\n" //                               ; CODE XREF: ROM:FF810160j
65        "LDR     R0, =0xFF81021C\n"
66        "MOV     R1, #0\n"
67        "LDR     R3, =0xFF810254\n"
68
69"loc_FF8101B0:\n" //                               ; CODE XREF: ROM:FF8101BCj
70        "CMP     R0, R3\n"
71        "LDRCC   R2, [R0],#4\n"
72        "STRCC   R2, [R1],#4\n"
73        "BCC     loc_FF8101B0\n"
74        "LDR     R0, =0xFF810254\n"
75        "MOV     R1, #0x4B0\n"
76        "LDR     R3, =0xFF810468\n"
77
78"loc_FF8101CC:\n" //                               ; CODE XREF: ROM:FF8101D8j
79        "CMP     R0, R3\n"
80        "LDRCC   R2, [R0],#4\n"
81        "STRCC   R2, [R1],#4\n"
82        "BCC     loc_FF8101CC\n"
83        "MOV     R0, #0xD2\n"
84        "MSR     CPSR_cxsf, R0\n"
85        "MOV     SP, #0x1000\n"
86        "MOV     R0, #0xD3\n"
87        "MSR     CPSR_cxsf, R0\n"
88        "MOV     SP, #0x1000\n"
89//        "LDR     R0, loc_FF810210\n" // =0x6C4\n" //loc_FF810210\n"
90                          "LDR     R0, =0x6C4\n" // +
91        "LDR     R2, =0xEEEEEEEE\n"
92        "MOV     R3, #0x1000\n"
93
94"loc_FF810200:\n" //                               ; CODE XREF: ROM:FF810208j
95        "CMP     R0, R3\n"
96        "STRCC   R2, [R0],#4\n"
97        "BCC     loc_FF810200\n"
98        "BL      sub_FF810FA0_my\n"
99        );
100        // Working
101} //#fe
102
103void __attribute__((naked,noinline)) sub_FF810FA0_my() { //#fs
104        asm volatile (
105        "STR     LR, [SP,#-4]!\n"
106        "SUB     SP, SP, #0x74\n"
107        "MOV     R0, SP\n"
108        "MOV     R1, #0x74\n"
109        "BL      sub_FFAACA58\n"
110        "MOV     R0, #0x53000\n"
111        "STR     R0, [SP,#0x74-0x70]\n"
112        //"LDR     R0, =0xCBC48\n"
113        "LDR     R0, =new_sa\n"
114        "LDR     R0, [R0]\n"
115        "LDR     R2, =0x279C00\n"
116        "LDR     R1, =0x272968\n"
117        "STR     R0, [SP,#0x74-0x6C]\n"
118        "SUB     R0, R1, R0\n"
119        "ADD     R3, SP, #0x74-0x68\n"
120        "STR     R2, [SP,#0x74-0x74]\n"
121        "STMIA   R3, {R0-R2}\n"
122        "MOV     R0, #0x22\n"
123        "STR     R0, [SP,#0x74-0x5C]\n"
124        "MOV     R0, #0x68\n"
125        "STR     R0, [SP,#0x74-0x58]\n"
126        "LDR     R0, =0x19B\n"
127        "MOV     R1, #0x64\n"
128        //"STRD    R0, [SP,#0x74-0x54]\n"
129        "STR     R0, [SP,#0x74-0x54]\n"
130        "STR     R1, [SP,#0x74-0x50]\n"
131        "MOV     R0, #0x78\n"
132        //"STRD    R0, [SP,#0x74-0x4C]\n"
133        "STR     R0, [SP,#0x74-0x4C]\n"
134        "STR     R1, [SP,#0x74-0x48]\n"
135        "MOV     R0, #0\n"
136        "STR     R0, [SP,#0x74-0x44]\n"
137        "STR     R0, [SP,#0x74-0x40]\n"
138        "MOV     R0, #0x10\n"
139        "STR     R0, [SP,#0x74-0x18]\n"
140        "MOV     R0, #0x800\n"
141        "STR     R0, [SP,#0x74-0x14]\n"
142        "MOV     R0, #0xA0\n"
143        "STR     R0, [SP,#0x74-0x10]\n"
144        "MOV     R0, #0x280\n"
145        "STR     R0, [SP,#0x74-0xC]\n"
146        //"LDR     R1, =0xFF814DA4\n"
147        "LDR     R1, =uHwSetup_my\n"
148        "MOV     R0, SP\n"
149        "MOV     R2, #0\n"
150        "BL      sub_FF812D58\n"
151
152        "ADD     SP, SP, #0x74\n"
153        "LDR     PC, [SP],#4\n"
154        );
155        // Working
156}; //#fe
157
158// Extracted method: uHwSetup (FF814DA4)
159void __attribute__((naked,noinline)) uHwSetup_my() { //#fs
160        asm volatile (
161        "STMFD   SP!, {R4,LR}\n"
162        "BL      sub_FF81094C\n"
163        "BL      sub_FF819664\n"
164        "CMP     R0, #0\n"
165        "LDRLT   R0, =0xFF814EB8\n" //    ; "dmSetup"\n"
166        "BLLT    sub_FF814E98\n"
167        "BL      sub_FF8149C8\n"
168        "CMP     R0, #0\n"
169        "LDRLT   R0, =0xFF814EC0\n" // ; "termDriverInit"\n"
170        "BLLT    sub_FF814E98\n"
171        "LDR     R0, =0xFF814ED0\n" //      ; "/_term"\n"
172        "BL      sub_FF814AB4\n"
173        "CMP     R0, #0\n"
174        "LDRLT   R0, =0xFF814ED8\n" // ; "termDeviceCreate"\n"
175        "BLLT    sub_FF814E98\n"
176        "LDR     R0, =0xFF814ED0\n" //      ; "/_term"\n"
177        "BL      sub_FF813564\n"
178        "CMP     R0, #0\n"
179        "LDRLT   R0, =0xFF814EEC\n" // ; "stdioSetup"\n"
180        "BLLT    sub_FF814E98\n"
181        "BL      sub_FF8191EC\n"
182        "CMP     R0, #0\n"
183        "LDRLT   R0, =0xFF814EF8\n" // ; "stdlibSetup"\n"
184        "BLLT    sub_FF814E98\n"
185        "BL      sub_FF8114B8\n"
186        "CMP     R0, #0\n"
187        "LDRLT   R0, =0xFF814F04\n" // ; "armlib_setup"\n"
188        "BLLT    sub_FF814E98\n"
189        "LDMFD   SP!, {R4,LR}\n"
190        "B       taskcreate_Startup_my\n"
191        );
192}; //#fe
193
194// Extracted method: taskcreate_Startup (FF81CCBC)
195void __attribute__((naked,noinline)) taskcreate_Startup_my() { //#fs
196        asm volatile (
197        "STMFD   SP!, {R3-R5,LR}\n"
198        "BL      sub_FF821C00\n"
199        "BL      sub_FF829EF0\n"
200        "CMP     R0, #0\n"
201        "BNE     loc_FF81CCFC\n"
202        "LDR     R4, =0xC0220000\n"
203        "LDR     R0, [R4,#0xFC]\n"
204        "TST     R0, #1\n"
205        "MOVEQ   R0, #0x12C\n"
206        "BLEQ    sub_FF828400\n"
207        "BL      sub_FF821BFC\n"
208        "CMP     R0, #0\n"
209        "BNE     loc_FF81CCFC\n"
210        "MOV     R0, #0x44\n"
211        "STR     R0, [R4,#0x4C]\n"
212
213"loc_FF81CCF8:\n" //                               ; CODE XREF: taskcreate_Startup:loc_FF81CCF8j
214        "B       loc_FF81CCF8\n"
215
216"loc_FF81CCFC:\n" //                               ; CODE XREF: taskcreate_Startup+10j
217        "BL      sub_FF821C08\n"
218        "BL      sub_FF821C04\n"
219        "BL      sub_FF828278\n"
220        "LDR     R1, =0x2CE000\n"
221        "MOV     R0, #0\n"
222        "BL      sub_FF8284C0\n"
223        "BL      sub_FF82846C\n"
224        "MOV     R3, #0\n"
225        "STR     R3, [SP,#0x10-0x10]\n"
226        "LDR     R3, =task_Startup_my\n" //task_Startup
227        "MOV     R2, #0\n"
228        "MOV     R1, #0x19\n"
229        "LDR     R0, =0xFF81CD44\n"   // ; "Startup"\n"
230        "BL      sub_FF81B818\n"
231        "MOV     R0, #0\n"
232        //"LDMFD   SP!, {R3-R5,PC}\n"
233        "LDMFD   SP!, {ip, pc}\n"
234                );
235}; //#fe
236
237// Extracted method: task_Startup (FF81CC60)
238void __attribute__((naked,noinline)) task_Startup_my() { //#fs
239        asm volatile (
240        "STMFD   SP!, {R4,LR}\n"
241        "BL      sub_FF81516C\n" // clockSave
242        "BL      sub_FF822D60\n"
243        "BL      sub_FF81FE00\n"
244        //"BL      sub_FF829F30\n"                      // hl??
245        "BL      sub_FF82A0F8\n"
246        //"BL      sub_FF829FB8\n" // StartDiskBoot
247        );
248
249                CreateTask_spytask();
250
251        asm volatile (
252        "BL      sub_FF82A2AC\n"
253        "BL      sub_FF82A148\n" // good question.... equiv of touch_wheel.c ?
254        "BL      sub_FF8277B8\n"
255        "BL      sub_FF82A2B0\n"
256                );
257
258//              CreateTask_PhySw();
259
260                asm volatile (
261        "BL      sub_FF821B10\n" // taskcreate_PhySw
262        "BL      sub_FF824CC8\n" // task_ShootSeqTask
263        "BL      sub_FF82A2C8\n"
264        //"BL      sub_FF81FB20\n" // nullsub_2
265        "BL      sub_FF820FCC\n"
266        "BL      sub_FF829CB8\n" // taskcreate_Bye
267        "BL      sub_FF821640\n"
268        "BL      sub_FF820EBC\n" // taskcreate_TempCheck\n"
269        "BL      sub_FF82AD6C\n"
270        "BL      sub_FF820E78\n"
271        //"LDMFD   SP!, {R4,LR}\n"
272        "BL       sub_FF815070\n"
273                "LDMFD   SP!, {R4,PC}\n"
274        );
275}; //#fe
276
277void CreateTask_spytask() { //#fs
278    _CreateTask("SpyTask", 0x19, 0x2000, core_spytask, 0);
279}; //#fe
280
281//void CreateTask_PhySw() { //#fs
282//    _CreateTask("PhySw", 0x18, 0x800, mykbd_task, 0);
283//}; //#fe
284
285
286// -----------------
287// SDHC-Boot-Support
288// -----------------
289
290// 0xFF8791d0
291void __attribute__((naked,noinline)) init_file_modules_task() { //#fs 
292        asm volatile (
293        "STMFD   SP!, {R4-R6,LR}\n"
294        "BL      sub_FF86DAE8\n"
295        "LDR     R5, =0x5006\n"
296        "MOVS    R4, R0\n"
297        "MOVNE   R1, #0\n"
298        "MOVNE   R0, R5\n"
299        "BLNE    _PostLogicalEventToUI\n"
300        "BL      sub_FF86DB14_my\n"
301        "BL      core_spytask_can_start\n"  // CHDK: Set "it's-safe-to-start" -flag for spytask
302        "CMP     R4, #0\n"
303        "MOVEQ   R0, R5\n"
304        "LDMEQFD SP!, {R4-R6,LR}\n"
305        "MOVEQ   R1, #0\n"
306        "BEQ     _PostLogicalEventToUI\n"
307        "LDMFD   SP!, {R4-R6,PC}\n"
308        );
309}; //#fe
310
311void __attribute__((naked,noinline)) sub_FF86DB14_my() { //#fs 
312        asm volatile (
313        "STMFD   SP!, {R4,LR}\n"
314        "BL      sub_FF84F174_my\n"  // continue to SDHC-hook here
315        "LDR     R4, =0x57D0\n"
316        "LDR     R0, [R4,#4]\n"
317        "CMP     R0, #0\n"
318        "BNE     loc_FF86DB44\n"
319        "BL      sub_FF881C08\n"
320        "BL      sub_FF9055FC\n"
321        "BL      sub_FF881C08\n"
322        "BL      sub_FF84CB64\n"
323        "BL      sub_FF881C18\n"
324        "BL      sub_FF9056C8\n"
325
326"loc_FF86DB44:\n" //                            ; CODE XREF: sub_FF86DB14+14j
327        "MOV     R0, #1\n"
328        "STR     R0, [R4]\n"
329        "LDMFD   SP!, {R4,PC}\n"
330        );
331}; //#fe
332
333void __attribute__((naked,noinline)) sub_FF84F174_my() { //#fs 
334        asm volatile (
335        "STMFD   SP!, {R4-R6,LR}\n"
336        "MOV     R6, #0\n"
337        "MOV     R0, R6\n"
338        "BL      sub_FF84EC34\n"
339        "LDR     R4, =0x11890\n"
340        "MOV     R5, #0\n"
341        "LDR     R0, [R4,#0x38]\n"
342        "BL      sub_FF84F668\n"
343        "CMP     R0, #0\n"
344        "LDREQ   R0, =0x29D4\n"
345        "STREQ   R5, [R0,#0x10]\n"
346        "STREQ   R5, [R0,#0x14]\n"
347        "STREQ   R5, [R0,#0x18]\n"
348        "MOV     R0, R6\n"
349        "BL      sub_FF84EC74\n" //uMounter (u=unknown, just to prevent misunderstandings)
350        "MOV     R0, R6\n"
351        "BL      sub_FF84EFB0_my\n" // continue to SDHC-hook here!
352        "MOV     R5, R0\n"
353        "MOV     R0, R6\n"
354        "BL      sub_FF84F01C\n"
355        "LDR     R1, [R4,#0x3C]\n"
356        "AND     R2, R5, R0\n"
357        "CMP     R1, #0\n"
358        "MOV     R0, #0\n"
359        "MOVEQ   R0, #0x80000001\n"
360        "BEQ     loc_FF84F208\n"
361        "LDR     R3, [R4,#0x2C]\n"
362        "CMP     R3, #2\n"
363        "MOVEQ   R0, #4\n"
364        "CMP     R1, #5\n"
365        "ORRNE   R0, R0, #1\n"
366        "BICEQ   R0, R0, #1\n"
367        "CMP     R2, #0\n"
368        "BICEQ   R0, R0, #2\n"
369        "ORREQ   R0, R0, #0x80000000\n"
370        "BICNE   R0, R0, #0x80000000\n"
371        "ORRNE   R0, R0, #2\n"
372
373"loc_FF84F208:\n" //                            ; CODE XREF: sub_FF84F174+64j
374        "STR     R0, [R4,#0x40]\n"
375        "LDMFD   SP!, {R4-R6,PC}\n"
376        );
377}; //#fe
378
379void __attribute__((naked,noinline)) sub_FF84EFB0_my() { //#fs 
380        asm volatile (
381        "STMFD   SP!, {R4-R6,LR}\n"
382        "LDR     R5, =0x29D4\n"
383        "MOV     R6, R0\n"
384        "LDR     R0, [R5,#0x14]\n"
385        "CMP     R0, #0\n"
386        "MOVNE   R0, #1\n"
387        "LDMNEFD SP!, {R4-R6,PC}\n"
388        "MOV     R0, #0x17\n"
389        "MUL     R1, R0, R6\n"
390        "LDR     R0, =0x11890\n"
391        "ADD     R4, R0, R1,LSL#2\n"
392        "LDR     R0, [R4,#0x38]\n"
393        "MOV     R1, R6\n"
394        "BL      sub_FF84ED40_my\n" //continue to SDHC-hook here
395        "CMP     R0, #0\n"
396        "LDMEQFD SP!, {R4-R6,PC}\n"
397        "LDR     R0, [R4,#0x38]\n"
398        "MOV     R1, R6\n"
399        "BL      sub_FF84EEA8\n"
400        "CMP     R0, #0\n"
401        "LDMEQFD SP!, {R4-R6,PC}\n"
402        "MOV     R0, R6\n"
403        "BL      sub_FF84E83C\n"
404        "CMP     R0, #0\n"
405        "MOVNE   R1, #1\n"
406        "STRNE   R1, [R5,#0x14]\n"
407        "LDMFD   SP!, {R4-R6,PC}\n"
408        );
409}; //#fe
410
411
412
413void __attribute__((naked,noinline)) sub_FF84ED40_my() { //#fs  ; Partition t
414        asm volatile (
415        "STMFD   SP!, {R4-R8,LR}\n"
416        "MOV     R8, R0\n"
417        "MOV     R0, #0x17\n"
418        "MUL     R1, R0, R1\n"
419        "LDR     R0, =0x11890\n"
420        "MOV     R6, #0\n"
421        "ADD     R7, R0, R1,LSL#2\n"
422        "LDR     R0, [R7,#0x3C]\n"
423        "MOV     R5, #0\n"
424        "CMP     R0, #6\n"
425        "ADDLS   PC, PC, R0,LSL#2\n"
426        "B       loc_FF84EE8C\n"
427 
428
429"loc_FF84ED70:\n" //                            ; CODE XREF: sub_FF84ED40+28j
430        "B       loc_FF84EDA4\n"
431 
432
433"loc_FF84ED74:\n" //                            ; CODE XREF: sub_FF84ED40+28j
434        "B       loc_FF84ED8C\n"
435 
436
437"loc_FF84ED78:\n" //                            ; CODE XREF: sub_FF84ED40+28j
438        "B       loc_FF84ED8C\n"
439 
440
441"loc_FF84ED7C:\n" //                            ; CODE XREF: sub_FF84ED40+28j
442        "B       loc_FF84ED8C\n"
443 
444
445"loc_FF84ED80:\n" //                            ; CODE XREF: sub_FF84ED40+28j
446        "B       loc_FF84ED8C\n"
447 
448
449"loc_FF84ED84:\n" //                            ; CODE XREF: sub_FF84ED40+28j
450        "B       loc_FF84EE84\n"
451 
452
453"loc_FF84ED88:\n" //                            ; CODE XREF: sub_FF84ED40+28j
454        "B       loc_FF84ED8C\n"
455
456"loc_FF84ED8C:\n" //                            ; CODE XREF: sub_FF84ED40+28j
457
458
459        "MOV     R2, #0\n"
460        "MOV     R1, #0x200\n"
461        "MOV     R0, #3\n"
462        "BL      sub_FF867C94\n"
463        "MOVS    R4, R0\n"
464        "BNE     loc_FF84EDAC\n"
465
466"loc_FF84EDA4:\n" //                            ; CODE XREF: sub_FF84ED40+28j
467
468
469        "MOV     R0, #0\n"
470        "LDMFD   SP!, {R4-R8,PC}\n"
471 
472
473"loc_FF84EDAC:\n" //                            ; CODE XREF: sub_FF84ED40+60j
474        "LDR     R12, [R7,#0x4C]\n"
475        "MOV     R3, R4\n"
476        "MOV     R2, #1\n"
477        "MOV     R1, #0\n"
478        "MOV     R0, R8\n"
479        //"BLX     R12 //\n"
480        "MOV     LR, PC\n"
481        "MOV     PC, R12\n"
482        "CMP     R0, #1\n"
483        "BNE     loc_FF84EDD8\n"
484        "MOV     R0, #3\n"
485        "BL      sub_FF867DD4\n"
486        "B       loc_FF84EDA4\n"
487 
488
489"loc_FF84EDD8:\n" //                            ; CODE XREF: sub_FF84ED40+88j
490        "MOV     R0, R8\n"
491        "BL      sub_FF922E24\n"
492       
493                  "MOV   R1, R4\n"           //  pointer to MBR in R1
494                  "BL    mbr_read_dryos\n"   //  total sectors count in R0 before and after call
495
496        // Start of DataGhost's FAT32 autodetection code
497        // Policy: If there is a partition which has type W95 FAT32, use the first one of those for image storage
498        // According to the code below, we can use R1, R2, R3 and R12.
499        // LR wasn't really used anywhere but for storing a part of the partition signature. This is the only thing
500        // that won't work with an offset, but since we can load from LR+offset into LR, we can use this to do that :)
501        "MOV     R12, R4\n"                    // Copy the MBR start address so we have something to work with
502        "MOV     LR, R4\n"                     // Save old offset for MBR signature
503        "MOV     R1, #1\n"                     // Note the current partition number
504        "B       dg_sd_fat32_enter\n"          // We actually need to check the first partition as well, no increments yet!
505   "dg_sd_fat32:\n"
506        "CMP     R1, #4\n"                     // Did we already see the 4th partition?
507        "BEQ     dg_sd_fat32_end\n"            // Yes, break. We didn't find anything, so don't change anything.
508        "ADD     R12, R12, #0x10\n"            // Second partition
509        "ADD     R1, R1, #1\n"                 // Second partition for the loop
510   "dg_sd_fat32_enter:\n"
511        "LDRB    R2, [R12, #0x1BE]\n"          // Partition status
512        "LDRB    R3, [R12, #0x1C2]\n"          // Partition type (FAT32 = 0xB)
513        "CMP     R3, #0xB\n"                   // Is this a FAT32 partition?
514                "CMPNE   R3, #0xC\n"                   // Not 0xB, is it 0xC (FAT32 LBA) then?
515        "BNE     dg_sd_fat32\n"                // No, it isn't.
516        "CMP     R2, #0x00\n"                  // It is, check the validity of the partition type
517        "CMPNE   R2, #0x80\n"
518        "BNE     dg_sd_fat32\n"                // Invalid, go to next partition
519                                               // This partition is valid, it's the first one, bingo!
520        "MOV     R4, R12\n"                    // Move the new MBR offset for the partition detection.
521       
522   "dg_sd_fat32_end:\n"
523        // End of DataGhost's FAT32 autodetection code             
524        "LDRB    R1, [R4,#0x1C9]\n"
525        "LDRB    R3, [R4,#0x1C8]\n"
526        "LDRB    R12, [R4,#0x1CC]\n"
527        "MOV     R1, R1,LSL#24\n"
528        "ORR     R1, R1, R3,LSL#16\n"
529        "LDRB    R3, [R4,#0x1C7]\n"
530        "LDRB    R2, [R4,#0x1BE]\n"
531        //"LDRB    LR, [R4,#0x1FF]\n"
532        "ORR     R1, R1, R3,LSL#8\n"
533        "LDRB    R3, [R4,#0x1C6]\n"
534        "CMP     R2, #0\n"
535        "CMPNE   R2, #0x80\n"
536        "ORR     R1, R1, R3\n"
537        "LDRB    R3, [R4,#0x1CD]\n"
538        "MOV     R3, R3,LSL#24\n"
539        "ORR     R3, R3, R12,LSL#16\n"
540        "LDRB    R12, [R4,#0x1CB]\n"
541        "ORR     R3, R3, R12,LSL#8\n"
542        "LDRB    R12, [R4,#0x1CA]\n"
543        "ORR     R3, R3, R12\n"
544        //"LDRB    R12, [R4,#0x1FE]\n"
545
546        "LDRB    R12, [LR,#0x1FE]\n"
547        "LDRB    LR, [LR,#0x1FF]\n"
548
549        "MOV     R4, #0\n"
550        "BNE     loc_FF84EE60\n"
551        "CMP     R0, R1\n"
552        "BCC     loc_FF84EE60\n"
553        "ADD     R2, R1, R3\n"
554        "CMP     R2, R0\n"
555        "CMPLS   R12, #0x55\n"
556        "CMPEQ   LR, #0xAA\n"
557        "MOVEQ   R6, R1\n"
558        "MOVEQ   R5, R3\n"
559        "MOVEQ   R4, #1\n"
560
561"loc_FF84EE60:\n" //                            ; CODE XREF: sub_FF84ED40+F8j
562
563        "MOV     R0, #3\n"
564        "BL      sub_FF867DD4\n"
565        "CMP     R4, #0\n"
566        "BNE     loc_FF84EE98\n"
567        "MOV     R6, #0\n"
568        "MOV     R0, R8\n"
569        "BL      sub_FF922E24\n"
570        "MOV     R5, R0\n"
571        "B       loc_FF84EE98\n"
572 
573
574"loc_FF84EE84:\n" //                            ; CODE XREF: sub_FF84ED40+28j
575
576
577        "MOV     R5, #0x40\n"
578        "B       loc_FF84EE98\n"
579 
580
581"loc_FF84EE8C:\n" //                            ; CODE XREF: sub_FF84ED40+28j
582
583
584        "MOV     R1, #0x374\n"
585        "LDR     R0, =0xFF84ED34\n" // aMounter_c  ; "Mounter.c"\n"
586        "BL      _DebugAssert\n"
587
588"loc_FF84EE98:\n" //                            ; CODE XREF: sub_FF84ED40+12Cj
589
590        "STR     R6, [R7,#0x44]!\n"
591        "MOV     R0, #1\n"
592        "STR     R5, [R7,#4]\n"
593        "LDMFD   SP!, {R4-R8,PC}\n"
594
595        );
596}; //#fe
597
598// Extracted method: sub_FF842A44 + 240
599// Extracted method: sub_FF842C84
600void __attribute__((naked,noinline)) jogdial_task_my()
601{
602        asm volatile (
603                "STMFD   SP!, {R3-R11,LR}\n"
604                "BL      sub_FF842e34\n" // LOCATION: JogDial.c:14
605                "LDR     R11, =0x80000B01\n"
606                "LDR     R8, =0xffab07cc\n"             // HL
607                "LDR     R7, =0xC0240000\n"             // HL
608                "LDR     R6, =0x22A0\n"                         // HL
609                "MOV     R9, #1\n"
610                "MOV     R10, #0\n"
611
612                "loc_FF842CA4:\n"
613                "LDR     R3, =0x1A1\n"                  // HL
614                "LDR     R0, [R6,#0xC]\n"
615                "LDR     R2, =0xFF842EDC\n" // HL?, "JogDial.c"
616                "MOV     R1, #0\n"
617                "BL      sub_FF81BBD8\n"                        // HL
618                //"MOV     R0, #40\n"
619                "MOV     R0, #40\n" // +
620                "BL      _SleepTask\n" // LOCATION: KerSys.c:0
621
622                //------------------  added code ---------------------
623                "labelA:\n"
624                "LDR     R0, =jogdial_stopped\n"
625                "LDR     R0, [R0]\n"
626                "CMP     R0, #1\n"
627                "BNE     labelB\n"
628                "MOV     R0, #40\n"
629                "BL      _SleepTask\n"
630                "B       labelA\n"
631                "labelB:\n"
632                //------------------  original code ------------------
633
634                "LDR     R0, [R7,#0x104]\n"
635                "MOV     R0, R0,ASR#16\n"
636                "STRH    R0, [R6]\n"
637                "LDRSH   R2, [R6,#2]\n"
638                "SUB     R1, R0, R2\n"
639                "CMP     R1, #0\n"
640                "BEQ     loc_FF842D68\n"
641                "MOV     R5, R1\n"
642                "RSBLT   R5, R5, #0\n"
643                "MOVLE   R4, #0\n"
644                "MOVGT   R4, #1\n"
645                "CMP     R5, #0xFF\n"
646                "BLS     loc_FF842D1C\n"
647                "CMP     R1, #0\n"
648                "RSBLE   R1, R2, #0xFF\n"
649                "ADDLE   R1, R1, #0x7F00\n"
650                "ADDLE   R0, R1, R0\n"
651                "RSBGT   R0, R0, #0xFF\n"
652                "ADDGT   R0, R0, #0x7F00\n"
653                "ADDGT   R0, R0, R2\n"
654                "ADD     R5, R0, #0x8000\n"
655                "ADD     R5, R5, #1\n"
656                "EOR     R4, R4, #1\n"
657
658                "loc_FF842D1C:\n"
659                "LDR     R0, [R6,#0x14]\n"
660                "CMP     R0, #0\n"
661                "BEQ     loc_FF842D60\n"
662                "LDR     R0, [R6,#0x1C]\n"
663                "CMP     R0, #0\n"
664                "BEQ     loc_FF842D48\n"
665                "LDR     R1, [R8,R4,LSL#2]\n"
666                "CMP     R1, R0\n"
667                "BEQ     loc_FF842D50\n"
668                "LDR     R0, =0xB01\n"
669                "BL      sub_FF875370\n"
670
671                "loc_FF842D48:\n"
672                "MOV     R0, R11\n"
673                "BL      sub_FF875370\n"
674
675                "loc_FF842D50:\n"
676                "LDR     R0, [R8,R4,LSL#2]\n"
677                "MOV     R1, R5\n"
678                "STR     R0, [R6,#0x1C]\n"
679                "BL      sub_FF8752b8\n"
680
681                "loc_FF842D60:\n"
682                "LDRH    R0, [R6]\n"
683                "STRH    R0, [R6,#2]\n"
684
685                "loc_FF842D68:\n"
686                "STR     R10, [R7,#0x100]\n"
687                "STR     R9, [R7,#0x108]\n"
688                "LDR     R0, [R6,#0x10]\n"
689                "CMP     R0, #0\n"
690                "BLNE    _SleepTask\n" // LOCATION: KerSys.c:0
691                "B       loc_FF842CA4\n"
692                );
693}
Note: See TracBrowser for help on using the repository browser.