root/platform/sx280hs/sub/102c/boot.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. spytask
  2. CreateTask_spytask
  3. boot
  4. CreateTask_my
  5. sub_fc04f194_my
  6. sub_fc04f324_my
  7. sub_fc04f72a_my
  8. sub_fc060338_my
  9. sub_fc04f6c4_my
  10. sub_fc06021a_my
  11. init_file_modules_task
  12. kbd_p2_f_my
  13. sub_fc060900_my
  14. tricinittask

   1 
   2 #include "lolevel.h"
   3 #include "platform.h"
   4 #include "core.h"
   5 #include "dryos31.h"
   6 
   7 #define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
   8 
   9 const char * const new_sa = &_end;
  10 
  11 // Forward declarations
  12 extern volatile int jogdial_stopped;
  13 void JogDial_task_my(void);
  14 
  15 extern void task_CaptSeq();
  16 extern void task_InitFileModules();
  17 extern void task_RotaryEncoder();
  18 extern void task_MovieRecord();
  19 extern void task_ExpDrv();
  20 
  21 /*----------------------------------------------------------------------
  22     spytask
  23 -----------------------------------------------------------------------*/
  24 void spytask(long ua, long ub, long uc, long ud, long ue, long uf)
  25 {
  26     core_spytask();
  27 }
  28 
  29 /*----------------------------------------------------------------------
  30     CreateTask_spytask
  31 -----------------------------------------------------------------------*/
  32 void CreateTask_spytask()
  33 {
  34     _CreateTask("SpyTask", 0x19, 0x2000, spytask, 0);
  35 }
  36 
  37 ///*----------------------------------------------------------------------
  38 // Pointer to stack location where jogdial task records previous and current
  39 // jogdial positions
  40 // short *jog_position;
  41 
  42 /*----------------------------------------------------------------------
  43     boot()
  44 
  45     Main entry point for the CHDK code
  46 -----------------------------------------------------------------------*/
  47 
  48 /*************************************************************/
  49 void __attribute__((naked,noinline)) boot() {
  50     asm volatile ( // 0xfc02000c
  51 "    ldr.w   sp, =0x80010000\n" // top of data tcm?
  52 "    BL      sub_fc020064\n" // ITCM setup (vectors?)
  53 "    ldr     r2, =0xc0242010\n"
  54 "    ldr     r1, [r2, #0]\n"
  55 "    orr.w   r1, r1, #1\n"
  56 "    str     r1, [r2, #0]\n" // interrupt related?
  57 "    ldr     r0, =0xfc953974\n"
  58 "    ldr     r1, =0x010c1000\n"
  59 "    ldr     r3, =0x010e03c4\n"
  60 "    loc_fc020024:\n"
  61 "    cmp     r1, r3\n"
  62 "    itt     cc\n"
  63 "    ldrcc.w r2, [r0], #4\n"
  64 "    strcc.w r2, [r1], #4\n"
  65 "    bcc.n   loc_fc020024\n" // copy dryos kernel to RAM
  66 
  67 // Install CreateTask patch
  68 // use half words in case source or destination not word aligned
  69         "adr     r0, patch_CreateTask\n"    // src: Patch data
  70         "ldr     r1, =hook_CreateTask\n"    // dest: Address to patch (hook_ has thumb bit off)
  71         "add     r2, r0, #8\n" // two words
  72 "task_hook_loop:\n"
  73         "ldrh   r3, [r0],#2\n"
  74         "strh   r3, [r1],#2\n"
  75         "cmp    r0,r2\n"
  76         "blo    task_hook_loop\n"
  77 
  78 "    ldr     r0, =0x010c1000\n"
  79 "    ldr     r1, =0x0001f3c4\n"
  80 "    BL      sub_fc12dd3a\n" // clean data cache (on the kernel area)
  81 "    ldr     r0, =0xfc932514\n"
  82 "    ldr     r1, =0x00008000\n" // end of ITCM
  83 "    ldr     r3, =0x00029460\n"
  84 "    loc_fc020040:\n"
  85 "    cmp     r1, r3\n"
  86 "    itt     cc\n"
  87 "    ldrcc.w r2, [r0], #4\n"
  88 "    strcc.w r2, [r1], #4\n"
  89 "    bcc.n   loc_fc020040\n" // copy pre-initialized data
  90 "    ldr     r3, =0x00029460\n"
  91 "    ldr     r1, =0x002bd558\n"
  92 "    mov.w   r2, #0\n"
  93 "    loc_fc020056:\n"
  94 "    cmp     r3, r1\n"
  95 "    it      cc\n"
  96 "    strcc.w r2, [r3], #4\n"
  97 "    bcc.n   loc_fc020056\n" // zero-fill the above area
  98 "    b.w     sub_fc04f194_my\n" // continue 
  99 
 100         "patch_CreateTask:\n"
 101         "ldr.w   pc, [pc,#0]\n"             // Do jump to absolute address CreateTask_my
 102         ".long   CreateTask_my + 1\n"           // has to be a thumb address
 103 );
 104 }
 105 
 106 /*************************************************************/
 107 void __attribute__((naked,noinline)) CreateTask_my() {
 108 asm volatile (
 109 "    push   {r0}\n"
 110 //R3 = Pointer to task function to create
 111 "    ldr     r0, =task_CaptSeq\n"       // DryOS original code function ptr.
 112 "    cmp     r0, r3\n"                  // is the given taskptr equal to our searched function?
 113 "    itt     eq\n"                      // EQ block
 114 "    ldreq   r3, =capt_seq_task\n"      // if so replace with our task function base ptr.
 115 "    orreq   r3, #1\n"                  // make sure it's a thumb address (may not be needed?)
 116 "    beq     exitHook\n"                // below compares not necessary if this check has found something.
 117 
 118 "    LDR     R0, =task_ExpDrv\n"
 119 "    CMP     R0, R3\n"
 120 "    itt     eq\n"
 121 "    LDREQ   R3, =exp_drv_task\n"
 122 "    orreq   r3, #1\n"
 123 "    BEQ     exitHook\n"
 124 
 125 "    LDR     R0, =task_DvlpSeqTask\n"
 126 "    CMP     R0, R3\n"
 127 "    itt     eq\n"
 128 "    LDREQ   R3, =developseq_task\n"
 129 "    orreq   r3, #1\n"
 130 "    BEQ     exitHook\n"
 131 
 132 "    LDR     R0, =task_TricInitTask\n"
 133 "    CMP     R0, R3\n"
 134 "    itt     eq\n"
 135 "    LDREQ   R3, =tricinittask\n"
 136 "    orreq   r3, #1\n"
 137 "    BEQ     exitHook\n"
 138 
 139 "    LDR     R0, =task_FileWrite\n"
 140 "    CMP     R0, R3\n"
 141 "    itt     eq\n"
 142 "    LDREQ   R3, =filewritetask\n"
 143 "    orreq   r3, #1\n"
 144 "    BEQ     exitHook\n"
 145 
 146 
 147 
 148 "    LDR     R0, =task_MovieRecord\n"
 149 "    CMP     R0, R3\n"
 150 "    itt     eq\n"
 151 "    LDREQ   R3, =movie_record_task\n"
 152 "    orreq   r3, #1\n"
 153 "    BEQ     exitHook\n"
 154 
 155 
 156 "    ldr     r0, =task_InitFileModules\n"
 157 "    cmp     r0, r3\n"
 158 "    itt     eq\n"
 159 "    ldreq   r3, =init_file_modules_task\n"
 160 "    orreq   r3, #1\n"
 161 "exitHook:\n" 
 162 // restore overwritten register(s)
 163 "    pop    {r0}\n"
 164 // Execute overwritten instructions from original code, then jump to firmware
 165 "    stmdb   sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, lr}\n"
 166 "    mov     r4, r0\n"
 167 "    ldr     r0, =0x8154\n"
 168 "    ldr.w   pc, =(hook_CreateTask + 8 + 1) \n"  // Continue in firmware, thumb bit set
 169 ".ltorg\n"
 170 );
 171 }
 172 
 173 //fc04f194
 174 void __attribute__((naked,noinline)) sub_fc04f194_my() {
 175 
 176     if (*(int*)(0xd20b0000 + 0x10 * 4) & 0x10000) {
 177         // see sub_fc060338, sub_fc06082a
 178         // GPIO 0x10 (aka ON/OFF button) is not pressed -> play
 179         *(int*)(0x92a0+0x4) = 0x200000;
 180     }
 181     else {
 182         // GPIO 0x10 is pressed -> rec
 183         *(int*)(0x92a0+0x4) = 0x100000;
 184     }
 185     asm volatile (
 186     "push    {r4, lr}\n"
 187 #if defined(CHDK_NOT_IN_CANON_HEAP)
 188     "ldr     r4, =0x002bd558\n"         // heap start, modify here
 189 #else
 190     "ldr     r4, =new_sa\n"             // +
 191     "ldr     r4, [r4]\n"                // +
 192 #endif
 193     "sub     sp, #0x78\n"
 194     "ldr     r0, =0x005ce000\n"
 195     "ldr     r1, =0x00071b34\n"
 196     "subs    r0, r0, r4\n"
 197     "cmp     r0, r1\n"
 198     "bcs.n   loc_fc04f1a6\n"
 199     "loc_fc04f1a4:\n"
 200     "b.n     loc_fc04f1a4\n"            // too small heap, go into infinite loop
 201     "loc_fc04f1a6:\n"
 202     "ldr     r1, =0x00008070\n"
 203     "mov.w   r0, #0x80000\n"
 204     "str     r0, [r1, #0]\n"
 205     "ldr     r1, =0x00008074\n"
 206     "ldr     r0, =0x42b21000\n"         // SD boot sector is copied here later
 207     "str     r0, [r1, #0]\n"
 208     "ldr     r1, =0x00008078 \n"
 209     "ldr     r0, =0x42b23000\n"         // copy of FAT?
 210     "str     r0, [r1, #0]\n"
 211     "movs    r1, #0x74\n"
 212     "add     r0, sp, #4\n"
 213     "blx     sub_fc251dcc\n"            // zerofill, ARM veneer for an ARM function
 214     "add     r2, sp, #4\n"
 215     "ldr     r0, =0x0054b000\n"
 216     "mov.w   r1, #0x83000\n"
 217     "stmia   r2!, {r0, r1, r4}\n"
 218     "ldr     r1, =0x005404cc\n"
 219     "str     r0, [sp, #24]\n"
 220     "movs    r0, #0x22\n"
 221     "subs    r2, r1, r4\n"
 222     "str     r0, [sp, #28]\n"
 223     "movs    r0, #0x98\n"
 224     "str     r0, [sp, #32]\n"
 225     "strd    r2, r1, [sp, #16]\n"
 226     "movw    r0, #0x1e8\n"
 227     "str     r0, [sp, #36]\n"
 228     "movs    r0, #0xf6\n"
 229     "str     r0, [sp, #40]\n"
 230     "movs    r0, #0xb6\n"
 231     "str     r0, [sp, #44]\n"
 232     "movs    r0, #0x85\n"
 233     "str     r0, [sp, #48]\n"
 234     "movs    r0, #0x40\n"
 235     "str     r0, [sp, #52]\n"
 236     "movs    r0, #4\n"
 237     "str     r0, [sp, #56]\n"
 238     "movs    r0, #0\n"
 239     "str     r0, [sp, #60]\n"
 240     "movs    r0, #16\n"
 241     "str     r0, [sp, #96]\n"
 242     "ldr     r1, =sub_fc04f324_my\n"    // -> continue here (init_task)
 243     "movs    r2, #0\n"
 244     "lsls    r0, r0, #7\n"
 245     "str     r0, [sp, #100]\n"
 246     "asrs    r0, r0, #3\n"
 247     "str     r0, [sp, #104]\n"
 248     "lsls    r0, r0, #5\n"
 249     "str     r0, [sp, #108]\n"
 250     "add     r0, sp, #4\n"
 251     "blx     sub_fc251414\n"
 252     "add     sp, #0x78\n"
 253     "pop     {r4, pc}\n"
 254     ".ltorg\n"
 255     );
 256 }
 257 
 258 //fc04f324
 259 void __attribute__((naked,noinline)) sub_fc04f324_my() {
 260     asm volatile (
 261     "push    {r4, lr}\n"
 262     "ldr     r4, =0xfc04f3d0\n" // "/_term"
 263     "bl      sub_fc050c14\n"
 264     "ldr     r0, =0x000080e8\n"
 265     "ldr     r1, [r0, #0]\n"
 266     "ldr     r0, =0x00008070\n"
 267     "ldr     r0, [r0, #0]\n"
 268     "adds    r0, #16\n"
 269     "cmp     r1, r0\n"
 270     "bcs.n   loc_fc04f340\n"
 271     "ldr     r0, =0xfc04f3e0\n" // "USER_MEM size checking"
 272     "bl      sub_fc04f3b8\n"
 273     "loc_fc04f340:\n"
 274     "bl      sub_fc12de14\n"
 275     "ldr     r3, =0x80000800\n"
 276     "mov.w   r1, #0x80000000\n"
 277     "mov.w   r2, #0xeeeeeeee\n"
 278     "loc_fc04f34e:\n"
 279     "stmia   r1!, {r2}\n"
 280     "cmp     r1, r3\n"
 281     "bcc.n   loc_fc04f34e\n"
 282     "bl      sub_fc12de26\n"
 283     "bl      sub_fc0b9f4c\n"
 284     "cmp     r0, #0\n"
 285     "bge.n   loc_fc04f366\n"
 286     "ldr     r0, =0xfc04f3fc\n" // "dmSetup"
 287     "bl      sub_fc04f3b8\n"
 288     "loc_fc04f366:\n"
 289     "bl      sub_fc04fb90\n"
 290     "cmp     r0, #0\n"
 291     "bge.n   loc_fc04f374\n"
 292     "ldr     r0, =0xfc04f404\n" // "termDriverInit"
 293     "bl      sub_fc04f3b8\n"
 294     "loc_fc04f374:\n"
 295     "mov     r0, r4\n"
 296     "bl      sub_fc04fc24\n"
 297     "cmp     r0, #0\n"
 298     "bge.n   loc_fc04f384\n"
 299     "ldr     r0, =0xfc04f414\n" // "termDeviceCreate"
 300     "bl      sub_fc04f3b8\n"
 301     "loc_fc04f384:\n"
 302     "mov     r0, r4\n"
 303     "bl      sub_fc04f55c\n"
 304     "cmp     r0, #0\n"
 305     "bge.n   loc_fc04f394\n"
 306     "ldr     r0, =0xfc04f428\n" // "stdioSetup"
 307     "bl      sub_fc04f3b8\n"
 308     "loc_fc04f394:\n"
 309     "bl      sub_fc04f6a0\n"
 310     "cmp     r0, #0\n"
 311     "bge.n   loc_fc04f3a2\n"
 312     "ldr     r0, =0xfc04f434\n" // "stdlibSetup"
 313     "bl      sub_fc04f3b8\n"
 314     "loc_fc04f3a2:\n"
 315     "bl      sub_fc053604\n"
 316     "cmp     r0, #0\n"
 317     "bge.n   loc_fc04f3b0\n"
 318     "ldr     r0, =0xfc04f440\n" // "extlib_setup"
 319     "bl      sub_fc04f3b8\n"
 320     "loc_fc04f3b0:\n"
 321     "ldmia.w sp!, {r4, lr}\n"
 322     "b.w     sub_fc04f72a_my\n" // -> continue (taskcreate_startup)
 323     ".ltorg\n"
 324     );
 325 }
 326 
 327 void __attribute__((naked,noinline)) sub_fc04f72a_my() {
 328     asm volatile (
 329     "push    {r3, lr}\n"
 330     "bl      sub_fc04f82c\n"
 331     "bl      sub_fc095cbe\n"
 332     "cbnz    r0, loc_fc04f740\n"
 333     "bl      sub_fc07205c\n"    // IsNormalCameraMode
 334     "cbz     r0, loc_fc04f740\n"
 335     "movs    r0, #1\n"
 336     "b.n     loc_fc04f742\n"
 337     "loc_fc04f740:\n"
 338     "movs    r0, #0\n"
 339     "loc_fc04f742:\n"
 340     "bl      sub_fc060338_my\n" // -> power-on mode handling & startupchecks here
 341     "cbnz    r0, loc_fc04f74e\n"
 342     "bl      sub_fc04f81a\n"
 343     "loc_fc04f74c:\n"
 344     "b.n     loc_fc04f74c\n"    // infinite loop
 345     "loc_fc04f74e:\n"
 346     "blx     sub_fc251474\n"
 347     "ldr     r1, =0x005ce000\n" // could be removed, but doesn't matter
 348     "movs    r0, #0\n"
 349     "bl      sub_fc2b7bf4\n"    // could be removed, but doesn't matter
 350     "blx     sub_fc251b9c\n"    // kersys.c
 351     "movs    r3, #0\n"
 352     "str     r3, [sp, #0]\n"
 353     "ldr     r3, =sub_fc04f6c4_my\n"
 354     "movs    r2, #0\n"
 355     "movs    r1, #25\n"
 356     "ldr     r0, =0xfc04f77c\n" // "Startup"
 357     "blx     sub_fc25198c\n"    // CreateTask
 358     "movs    r0, #0\n"
 359     "pop     {r3, pc}\n"
 360     ".ltorg\n"
 361     );
 362 }
 363 
 364 void __attribute__((naked,noinline)) sub_fc060338_my() {
 365     asm volatile (
 366     "stmdb   sp!, {r2, r3, r4, r5, r6, r7, r8, lr}\n"
 367     "mov.w   r8, #0\n"
 368     "mov     r7, r0\n"
 369     "mov     r6, r8\n"
 370     "bl      sub_fc060826\n" // nullsub
 371     "movs    r0, #16\n"
 372     "bl      sub_fc05f5c2\n"
 373     "movs    r4, #1\n"
 374     "bic.w   r5, r4, r0\n"
 375     "movs    r0, #15\n"
 376     "bl      sub_fc05f5c2\n"    // reads GPIO (15)
 377     "bics    r4, r0\n"
 378     "cbz     r7, loc_fc060364\n"
 379     "orrs.w  r0, r5, r4\n"
 380     //"beq.n   loc_fc06037e\n"  // - this check fails and results in shutdown
 381     "loc_fc060364:\n"
 382     "bl      sub_fc095cbe\n"
 383     "movs    r3, #0\n"
 384     "mov     r2, r0\n"
 385     "strd    r8, r6, [sp]\n"
 386     "mov     r1, r4\n"
 387     "mov     r0, r5\n"
 388     //"bl      sub_fc06082a\n"  // - startupchecks
 389     //"bl      sub_fc060828\n"  // - nullsub
 390     "movs    r0, #1\n"
 391     "loc_fc06037e:\n"
 392     "ldmia.w sp!, {r2, r3, r4, r5, r6, r7, r8, pc}\n"
 393     ".ltorg\n"
 394     );
 395 }
 396 
 397 
 398 // task_Startup
 399 void __attribute__((naked,noinline)) sub_fc04f6c4_my() {
 400     asm volatile (
 401     "push    {r4, lr}\n"
 402     "bl      sub_fc0ba768\n"
 403     "bl      sub_fc04f7f8\n"
 404     "bl      sub_fc04f96c\n"
 405     "bl      sub_fc095d10\n"
 406     //"bl      sub_fc04f9c2\n"      // - startdiskboot
 407     "bl      sub_fc07aff2\n"
 408     "bl      sub_fc0ba800\n"
 409     "bl      sub_fc04fad0\n"
 410     "bl      sub_fc04f908\n"
 411     "bl      sub_fc095d4e\n"
 412     "bl      sub_fc095998\n"
 413     "bl      sub_fc0ba806\n"
 414     "BL      CreateTask_spytask\n"  // +
 415     "bl      sub_fc06021a_my\n"     // -> taskcreate_physw
 416     "bl      sub_fc20d318\n"
 417     "bl      sub_fc0ba81c\n"
 418     "bl      sub_fc095750\n"
 419 
 420 #if defined(OPT_RUN_WITH_BATT_COVER_OPEN)
 421 "   mov     r0, #0x100000 \n"       // +
 422 "batt_loop1: \n"                    // +
 423 "   nop\n"                          // +
 424 "   SUBS    R0,R0,#1 \n"            // +
 425 "   BNE     batt_loop1 \n"          // +
 426 #endif
 427 
 428     "bl      sub_fc12ed44\n"
 429     "bl      sub_fc095b24\n"
 430     "bl      sub_fc09594a\n"
 431     "bl      sub_fc12ed04\n"
 432     "bl      sub_fc04fad4\n"
 433     "bl      sub_fc2a3c36\n"
 434     "bl      sub_fc12ecde\n"
 435     "ldmia.w sp!, {r4, lr}\n"
 436     //"b.w     sub_fc0ba73e\n"      // - (not recognized automatically yet, transformed into ldr pc)
 437     "ldr     pc, =0xfc0ba73f\n"     // + thumb address must be used
 438     ".ltorg\n"
 439     );
 440 }
 441 
 442 //taskcreate_physw
 443 void __attribute__((naked,noinline)) sub_fc06021a_my() {
 444     asm volatile (
 445     "push    {r3, r4, r5, lr}\n"
 446     "ldr     r4, =0x8328\n"
 447     "ldr     r0, [r4, #4]\n"
 448     "cbnz    r0, loc_fc060236\n"
 449     "movs    r3, #0\n"
 450     "str     r3, [sp, #0]\n"
 451     "ldr     r3, =mykbd_task\n"
 452     "movs    r1, #23\n"
 453     "ldr     r0, =0xfc06027c\n" // "PhySw"
 454     "movw    r2, #0x2000\n"     // original value 0x800
 455     "blx     sub_fc251c94\n"
 456     "str     r0, [r4, #4]\n"
 457     "loc_fc060236:\n"
 458     "bl      sub_fc061aac\n"
 459     "bl      sub_fc071fe6\n"
 460     "cmp     r0, #0\n"
 461     "bne.n   loc_fc06024e\n"
 462     "ldr     r1, =0x2ae94\n"
 463     "ldmia.w sp!, {r3, r4, r5, lr}\n"
 464     "subs    r1, #24\n"
 465     //"b.w     sub_fc061a54\n"  // - the stub generator needs fixing to support this
 466     "ldr     pc, =0xfc061a55\n" // + thumb address must be used
 467     "loc_fc06024e:\n"
 468     "pop     {r3, r4, r5, pc}\n"
 469     ".ltorg\n"
 470     );
 471 }
 472 
 473 void __attribute__((naked,noinline)) init_file_modules_task() { //sub_fc088220_my()
 474     asm volatile (
 475 "    push    {r4, r5, r6, lr}\n"
 476 "    bl      sub_fc09ad60\n"
 477 "    movs    r4, r0\n"
 478 "    movw    r5, #0x5006\n"
 479 "    beq.n   loc_fc088236\n"
 480 "    movs    r1, #0\n"
 481 "    mov     r0, r5\n"
 482 "    bl      sub_fc2a6188\n"
 483 "loc_fc088236:\n"
 484 "    bl      sub_fc09ad96\n"
 485 "    BL      core_spytask_can_start\n" // + CHDK: Set "it's-safe-to-start" flag for spytask
 486 "    cmp     r4, #0\n"
 487 "    bne.n   loc_fc08824a\n"
 488 "    mov     r0, r5\n"
 489 "    ldmia.w sp!, {r4, r5, r6, lr}\n"
 490 "    movs    r1, #0\n"
 491 "    b.w     sub_fc2a6188\n"
 492 "loc_fc08824a:\n"
 493 "    pop     {r4, r5, r6, pc}\n"
 494     );
 495 }
 496 
 497 void __attribute__((naked,noinline)) kbd_p2_f_my() { // 0xfc05ffc0
 498     asm volatile(
 499 "    stmdb   sp!, {r4, r5, r6, r7, r8, lr}\n"
 500 "    ldr     r6, =0x2ae94\n"
 501 "    sub     sp, #0x18\n"
 502 "    add     r7, sp, #8\n"
 503 "    subs    r6, #0xc\n"
 504 "    b.n     loc_fc060002\n"
 505 "loc_fc05ffce:\n"
 506 "    ldr     r1, =0x2ae94\n"
 507 "    add     r3, sp, #8\n"
 508 "    ldrb.w  r0, [sp, #4]\n"
 509 "    add     r2, sp, #0x14\n"
 510 "    subs    r1, #0x18\n"
 511 "    bl      sub_fc060ca4\n"
 512 "    cbnz    r0, loc_fc05ffe8\n"
 513 "    ldr     r1, [sp, #0x14]\n"
 514 "    movs    r0, #0\n"
 515 "    bl      sub_fc05ff32\n"
 516 "loc_fc05ffe8:\n"
 517 "    movs    r0, #2\n"
 518 "loc_fc05ffea:\n"
 519 "    ldr.w   r1, [r7, r0, lsl #2]\n"
 520 "    cbz     r1, loc_fc05fffa\n"
 521 "    ldr.w   r2, [r6, r0, lsl #2]\n"
 522 "    bics    r2, r1\n"
 523 "    str.w   r2, [r6, r0, lsl #2]\n"
 524 "loc_fc05fffa:\n"
 525 "    subs    r0, r0, #1\n"
 526 "    sxtb    r0, r0\n"
 527 "    cmp     r0, #0\n"
 528 "    bge.n   loc_fc05ffea\n"
 529 "loc_fc060002:\n"
 530 "    ldr     r0, =0x2ae94\n"
 531 "    add     r1, sp, #4\n"
 532 "    subs    r0, #0xc\n"
 533 "    bl      sub_fc0609d6\n"
 534 "    cmp     r0, #0\n"
 535 "    bne.n   loc_fc05ffce\n"
 536 "    ldr     r8, =0x2ae94\n"
 537 "    movs    r4, #0\n"
 538 "loc_fc060016:\n"
 539 "    movs    r5, #0\n"
 540 "    ldr.w   r0, [r6, r4, lsl #2]\n"
 541 "    ldr.w   r1, [r8, r4, lsl #2]\n"
 542 "    ands    r0, r1\n"
 543 "    str.w   r0, [r6, r4, lsl #2]\n"
 544 "    b.n     loc_fc06006e\n"
 545 "loc_fc060028:\n"
 546 "    lsrs    r0, r5\n"
 547 "    lsls    r0, r0, #0x1f\n"
 548 "    beq.n   loc_fc060066\n"
 549 "    ldr     r1, =0x2ae94\n"
 550 "    add.w   r0, r5, r4, lsl #5\n"
 551 "    add     r3, sp, #8\n"
 552 "    subs    r1, #0x18\n"
 553 "    add     r2, sp, #0x14\n"
 554 "    uxtb    r0, r0\n"
 555 "    bl      sub_fc060ca4\n"
 556 "    cbnz    r0, loc_fc06004a\n"
 557 "    ldr     r1, [sp, #0x14]\n"
 558 "    movs    r0, #1\n"
 559 "    bl      sub_fc05ff32\n"
 560 "loc_fc06004a:\n"
 561 "    mov     r0, r4\n"
 562 "    b.n     loc_fc060062\n"
 563 "loc_fc06004e:\n"
 564 "    ldr.w   r1, [r7, r0, lsl #2]\n"
 565 "    cbz     r1, loc_fc06005e\n"
 566 "    ldr.w   r2, [r6, r0, lsl #2]\n"
 567 "    bics    r2, r1\n"
 568 "    str.w   r2, [r6, r0, lsl #2]\n"
 569 "loc_fc06005e:\n"
 570 "    adds    r0, r0, #1\n"
 571 "    sxtb    r0, r0\n"
 572 "loc_fc060062:\n"
 573 "    cmp     r0, #3\n"
 574 "    blt.n   loc_fc06004e\n"
 575 "loc_fc060066:\n"
 576 "    ldr.w   r0, [r6, r4, lsl #2]\n"
 577 "    adds    r5, r5, #1\n"
 578 "    uxtb    r5, r5\n"
 579 "loc_fc06006e:\n"
 580 "    cmp     r0, #0\n"
 581 "    bne.n   loc_fc060028\n"
 582 "    adds    r4, r4, #1\n"
 583 "    sxtb    r4, r4\n"
 584 "    cmp     r4, #3\n"
 585 "    blt.n   loc_fc060016\n"
 586 "    bl      sub_fc060900_my\n"     // ->
 587 "    add     sp, #0x18\n"
 588 "    ldmia.w sp!, {r4, r5, r6, r7, r8, pc}\n"
 589 ".ltorg\n"
 590     );
 591 }
 592 
 593 void __attribute__((naked,noinline)) sub_fc060900_my() {
 594     asm volatile(
 595 "    push    {r4, lr}\n"
 596 "    ldr     r4, =0x92a0\n"
 597 "    ldr     r0, [r4, #8]\n"
 598 "    bl      sub_fc0629f4\n"
 599 "    bl      sub_fc0a0fa0\n"
 600 "    ldr     r0, [r4, #12]\n"
 601 "    bl      sub_fc062910\n"
 602 //"    ldmia.w sp!, {r4, lr}\n" // - (reordered below)
 603 //"    b.w     loc_fc05cbf6\n"  // - (reordered below)
 604 "    bl      handle_jogdial\n"  // +
 605 "    cmp     r0, #0\n"          // +
 606 "    beq     no_scroll\n"       // +
 607 "    bl      sub_fc05cbf6\n"    // handles scrollwheel(s), void function, no args
 608 "no_scroll:\n"                  // +
 609 "    pop     {r4, pc}\n"        // +
 610     );
 611 }
 612 
 613 
 614 // following is for supporting "firmware update" boot
 615 void __attribute__((naked,noinline)) tricinittask() {
 616     asm volatile(
 617 // capdis -f=chdk -s=task_TricInitTask -c=35 -stubs PRIMARY.BIN 0xfc000000
 618 // task_TricInitTask 0xfc373dc1
 619 "    push.w  {r1, r2, r3, r4, r5, r6, r7, r8, sb, sl, fp, lr}\n"
 620 "    blx     sub_fc251ad4\n"
 621 "    movs    r0, #8\n"
 622 "    ldr     r1, =0xfc374010\n" //  *"InitTskStart"
 623 "    bl      sub_fc28b7ee\n"
 624 "    ldr.w   fp, =0x0001bf74\n"
 625 "    movw    sl, #0x1000\n"
 626 "    ldr     r4, =0x0001bf70\n"
 627 "    movs    r2, #0\n"
 628 "    ldr     r1, =0x0003830f\n"
 629 "    ldr     r0, [r4]\n"
 630 "    blx     sub_fc251d4c\n" // j_WaitForAnyEventFlag
 631 "    lsls    r0, r0, #0x1f\n"
 632 "    beq     loc_fc373dfa\n"
 633 "    movs    r0, #8\n"
 634 "    ldr     r1, =0xfc374028\n" //  *"ER IniTskWait"
 635 "    bl      sub_fc28b84a\n"
 636 "    ldr     r1, =0x0001bf5c\n"
 637 "    movs    r0, #0\n"
 638 "    str     r0, [r1]\n"
 639 "    pop.w   {r1, r2, r3, r4, r5, r6, r7, r8, sb, sl, fp, pc}\n"
 640 "loc_fc373dfa:\n"
 641 "    ldr     r4, =0x0001bf70\n"
 642 "    add     r1, sp, #8\n"
 643 "    ldr     r0, [r4]\n"
 644 "    blx     sub_fc251bec\n" // j_GetEventFlagValue
 645 "    ldr     r1, [sp, #8]\n"
 646 "    ldr     r0, [r4]\n"
 647 "    blx     sub_fc251c1c\n" // j_ClearEventFlag
 648 "    ldr     r6, [sp, #8]\n"
 649 "    lsls    r0, r6, #0x1e\n"
 650 "    beq     sub_fc373ed2\n" // loc -> sub
 651 "    lsls    r0, r6, #0x1f\n"
 652 "    beq     sub_fc373e1c\n" // loc -> sub
 653 
 654 "    ldr     r0, =0xd2020074\n" // +
 655 "    ldr     r0, [r0]\n"        // + nonzero when core already running
 656 "    subs    r0, #0\n"          // +
 657 "    beq     tric1\n"           // +
 658 "    ldr     r0, [r4]\n"        // +
 659 "    mov     r1, #0x80\n"       // +
 660 "    bl      _SetEventFlag\n"   // + core already initialized, set the SmacIdleCmp eventflag here
 661 "tric1:\n"                      // +
 662 
 663 "    bl      sub_fc374160\n"
 664 //"    b       loc_fc373e5e\n" // -
 665 "    ldr     pc, =0xfc373e5f\n" // -> continue in rom
 666     );
 667 }
 668 
 669 
 670 

/* [<][>][^][v][top][bottom][index][help] */