root/platform/sx710hs/sub/101a/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_fc055894_my
  6. sub_fc055a24_my
  7. sub_fc055e2e_my
  8. sub_fc0cf0ee_my
  9. task_Startup_my
  10. sub_fc0cf014_my
  11. init_file_modules_task
  12. init_required_fw_features
  13. kbd_p2_f_my
  14. sub_fc086af2_my

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "core.h"
   4 
   5 const char * const new_sa = &_end;
   6 
   7 // Forward declarations
   8 
   9 extern void task_CaptSeq();
  10 extern void task_InitFileModules();
  11 extern void task_RotaryEncoder();
  12 extern void task_MovieRecord();
  13 extern void task_ExpDrv();
  14 
  15 extern void handle_jogdial();
  16 
  17 /*----------------------------------------------------------------------
  18     spytask
  19 -----------------------------------------------------------------------*/
  20 void spytask(long ua, long ub, long uc, long ud, long ue, long uf)
  21 {
  22     core_spytask();
  23 }
  24 
  25 /*----------------------------------------------------------------------
  26     CreateTask_spytask
  27 -----------------------------------------------------------------------*/
  28 void CreateTask_spytask()
  29 {
  30     _CreateTask("SpyTask", 0x19, 0x2000, spytask, 0);
  31 }
  32 
  33 //unsigned rbval=0;
  34 /*
  35 void task_blinker()
  36 {
  37 #if 0
  38     unsigned v=*(volatile unsigned *)(0x9808);
  39     unsigned pat=0;
  40     if(v & 0x80000){
  41         pat |=1;
  42     }
  43     if(v & 0x100000){
  44         pat |=2;
  45     }
  46     if(v & 0x200000){
  47         pat |=4;
  48     }
  49     if(v & 0x400000){
  50         pat |=8;
  51     }
  52     if(v & 0x800000){
  53         pat |=0x10;
  54     }
  55     while(1) {
  56         int i;
  57         for(i=0;i<5;i++) {
  58             *(volatile int*)0xd20b0994 = 0x4d0002;
  59             if((pat >> i) & 1) {
  60                 msleep(1000);
  61             } else {
  62                 msleep(250);
  63             }
  64             *(volatile int*)0xd20b0994 = 0x4c0003;
  65             msleep(500);
  66         }
  67         msleep(5000);
  68     }
  69 #endif
  70 #if 0
  71     int delay=1000;
  72     if(rbval == 0x12345678) {
  73         delay=100;
  74     }
  75     while(1) {
  76         *(volatile int*)0xd20b0994 = 0x4d0002;
  77         msleep(delay);
  78         *(volatile int*)0xd20b0994 = 0x4c0003;
  79         msleep(delay);
  80     }
  81 #endif
  82     while(1) {
  83         *(volatile int*)0xd20b0994 = 0x4d0002;
  84         msleep(250);
  85         *(volatile int*)0xd20b0994 = 0x4c0003;
  86         msleep(250);
  87     }
  88 }
  89 
  90 void CreateTask_blinker()
  91 {
  92     _CreateTask("blinker", 0x19, 0x200, task_blinker, 0);
  93 }
  94 */
  95 
  96 /*----------------------------------------------------------------------
  97     boot()
  98 
  99     Main entry point for the CHDK code
 100 -----------------------------------------------------------------------*/
 101 
 102 /*************************************************************/
 103 //  -f=chdk -s=0xfc02000d -c=43
 104 void __attribute__((naked,noinline)) boot() {
 105     asm volatile ( // 0xfc02000c
 106 "    movw    r0, #0x4000\n"
 107 "    movt    r0, #0\n"
 108 "    mov     sp, r0\n"
 109 "    bl      sub_fc02007e\n"
 110 "    ldr     r2, =0xc0242010\n"
 111 "    ldr     r1, [r2]\n"
 112 "    orr     r1, r1, #1\n"
 113 "    str     r1, [r2]\n"
 114 "    ldr     r0, =0xfcd4742c\n" // code copied from ROM
 115 "    ldr     r1, =0x010e1000\n" // to RAM
 116 "    ldr     r3, =0x01107bd0\n"
 117 "loc_fc02002a:\n"
 118 "    cmp     r1, r3\n"
 119 "    itt     lo\n"
 120 "    ldrlo   r2, [r0], #4\n"
 121 "    strlo   r2, [r1], #4\n"
 122 "    blo     loc_fc02002a\n"
 123 "    ldr     r0, =0x010e1000\n"
 124 "    ldr     r1, =0x00026bd0\n"
 125 "    bl      sub_fc11f606\n"    // cache stuff for RAM code
 126 "    ldr     r0, =0xfcd6dffc\n" // code copied from ROM
 127 "    ldr     r1, =0xbfe10800\n" // to TCM
 128 "    ldr     r3, =0xbfe17419\n"
 129 "loc_fc020046:\n"
 130 "    cmp     r1, r3\n"
 131 "    itt     lo\n"
 132 "    ldrlo   r2, [r0], #4\n"
 133 "    strlo   r2, [r1], #4\n"
 134 "    blo     loc_fc020046\n"
 135 // Install CreateTask patch
 136 // use half words in case source or destination not word aligned
 137         "adr     r0, patch_CreateTask\n"    // src: Patch data
 138         "ldr     r1, =hook_CreateTask\n"    // dest: Address to patch (hook_ has thumb bit off)
 139         "add     r2, r0, #8\n" // two words
 140 "task_hook_loop:\n"
 141         "ldrh   r3, [r0],#2\n"
 142         "strh   r3, [r1],#2\n"
 143         "cmp    r0,r2\n"
 144         "blo    task_hook_loop\n"
 145 "    ldr     r0, =0xfcd1e5d4\n"
 146 "    ldr     r1, =0x00008000\n" // DATA copied
 147 "    ldr     r3, =0x00030e58\n" // to RAM
 148 "loc_fc02005a:\n"
 149 "    cmp     r1, r3\n"
 150 "    itt     lo\n"
 151 "    ldrlo   r2, [r0], #4\n"
 152 "    strlo   r2, [r1], #4\n"
 153 "    blo     loc_fc02005a\n"
 154 "    ldr     r3, =0x00030e58\n" // BSS
 155 "    ldr     r1, =0x003c3998\n"
 156 "    mov.w   r2, #0\n"
 157 "loc_fc020070:\n"
 158 "    cmp     r3, r1\n"
 159 "    it      lo\n"
 160 "    strlo   r2, [r3], #4\n"
 161 "    blo     loc_fc020070\n"
 162 "    b.w     sub_fc055894_my\n"
 163 
 164         "patch_CreateTask:\n"
 165         "ldr.w   pc, [pc,#0]\n"             // Do jump to absolute address CreateTask_my
 166         ".long   CreateTask_my + 1\n"           // has to be a thumb address
 167 );
 168 }
 169 
 170 /*************************************************************/
 171 void __attribute__((naked,noinline)) CreateTask_my() {
 172 asm volatile (
 173 "    push   {r0}\n"
 174 //R3 = Pointer to task function to create
 175 "    ldr     r0, =task_CaptSeq\n"       // DryOS original code function ptr.
 176 "    cmp     r0, r3\n"                  // is the given taskptr equal to our searched function?
 177 "    itt     eq\n"                      // EQ block
 178 "    ldreq   r3, =capt_seq_task\n"      // if so replace with our task function base ptr.
 179 "    orreq   r3, #1\n"                  // make sure it's a thumb address (may not be needed?)
 180 "    beq     exitHook\n"                // below compares not necessary if this check has found something.
 181 
 182 // exp_drv not needed for extended exposure, probably works up to 1024s, but required for < 1/3200
 183 "    LDR     R0, =task_ExpDrv\n"
 184 "    CMP     R0, R3\n"
 185 "    itt     eq\n"
 186 "    LDREQ   R3, =exp_drv_task\n"
 187 "    orreq   r3, #1\n"
 188 "    BEQ     exitHook\n"
 189 
 190 // not needed in sx710
 191 /*
 192 "    LDR     R0, =task_DvlpSeqTask\n"
 193 "    CMP     R0, R3\n"
 194 "    itt     eq\n"
 195 "    LDREQ   R3, =developseq_task\n"
 196 "    orreq   r3, #1\n"
 197 "    BEQ     exitHook\n"
 198 */
 199 
 200 "    ldr     r0, =task_FileWrite\n"
 201 "    cmp     r0, r3\n"
 202 "    itt     eq\n"
 203 "    ldreq   r3, =filewritetask\n"
 204 "    orreq   r3, #1\n"
 205 "    beq     exitHook\n"
 206 
 207 // not implemented
 208 /*
 209 "    LDR     R0, =task_MovieRecord\n"
 210 "    CMP     R0, R3\n"
 211 "    LDREQ   R3, =movie_record_task\n"
 212 "    BEQ     exitHook\n"
 213 */
 214 
 215 "    ldr     r0, =task_InitFileModules\n"
 216 "    cmp     r0, r3\n"
 217 "    itt     eq\n"
 218 "    ldreq   r3, =init_file_modules_task\n"
 219 "    orreq   r3, #1\n"
 220 "exitHook:\n" 
 221 // restore overwritten register(s)
 222 "    pop    {r0}\n"
 223 // Execute overwritten instructions from original code, then jump to firmware
 224 // NOTE number of instructions duplicated here depends on size of original ROM code
 225 // instructions. Must replace 8 bytes!
 226 "    stmdb   sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, lr}\n"
 227 "    mov     r4, r0\n"
 228 "    ldr     r0, =0x8160\n"
 229 "    ldr.w   pc, =(hook_CreateTask + 8 + 1) \n"  // Continue in firmware (thumb bit set)
 230 ".ltorg\n"
 231 );
 232 }
 233 
 234 // -f=chdk -s=0xfc055895 -c=60
 235 void __attribute__((naked,noinline)) sub_fc055894_my() {
 236 // startup key checks handled in sub_fc0cf0ee_my
 237     asm volatile (
 238 "    push    {r4, lr}\n"
 239 #if defined(CHDK_NOT_IN_CANON_HEAP)
 240 "    ldr     r4, =0x003c3998\n"
 241 #else
 242     "ldr     r4, =new_sa\n"             // +
 243     "ldr     r4, [r4]\n"                // +
 244 #endif
 245 "    sub     sp, #0x78\n"
 246 "    ldr     r0, =0x006ce000\n"
 247 "    ldr     r1, =0x000b1fec\n"
 248 "    subs    r0, r0, r4\n"
 249 "    cmp     r0, r1\n"
 250 "    bhs     loc_fc0558a6\n"
 251 "loc_fc0558a4:\n"
 252 "    b       loc_fc0558a4\n"
 253 "loc_fc0558a6:\n"
 254 "    ldr     r1, =0x00008074\n"
 255 "    mov.w   r0, #0x80000\n"
 256 "    str     r0, [r1]\n"
 257 "    ldr     r1, =0x00008078\n"
 258 "    ldr     r0, =0x421bcb00\n"
 259 "    str     r0, [r1]\n"
 260 "    ldr     r1, =0x0000807c\n"
 261 "    ldr     r0, =0x421beb00\n"
 262 "    str     r0, [r1]\n"
 263 "    movs    r1, #0x78\n"
 264 "    mov     r0, sp\n"
 265 "    blx     sub_fc2c7da0\n" // j_bzero
 266 "    ldr     r0, =0x0060e000\n"
 267 "    mov.w   r1, #0xc0000\n"
 268 "    stm.w   sp, {r0, r1, r4}\n"
 269 "    ldr     r1, =0x00600014\n"
 270 "    subs    r2, r1, r4\n"
 271 "    strd    r2, r1, [sp, #0xc]\n"
 272 "    str     r0, [sp, #0x14]\n"
 273 "    movs    r0, #0x22\n"
 274 "    str     r0, [sp, #0x18]\n"
 275 "    movs    r0, #0xca\n"
 276 "    str     r0, [sp, #0x1c]\n"
 277 "    movw    r0, #0x2b0\n"
 278 "    str     r0, [sp, #0x20]\n"
 279 "    movs    r0, #0xfa\n"
 280 "    str     r0, [sp, #0x24]\n"
 281 "    movw    r0, #0x11a\n"
 282 "    str     r0, [sp, #0x28]\n"
 283 "    movs    r0, #0x85\n"
 284 "    str     r0, [sp, #0x2c]\n"
 285 "    movs    r0, #0x40\n"
 286 "    str     r0, [sp, #0x30]\n"
 287 "    movs    r0, #4\n"
 288 "    str     r0, [sp, #0x34]\n"
 289 "    movs    r0, #0\n"
 290 "    str     r0, [sp, #0x38]\n"
 291 "    movs    r0, #0x10\n"
 292 "    str     r0, [sp, #0x5c]\n"
 293 "    movs    r2, #0\n"
 294 "    lsls    r0, r0, #8\n"
 295 "    str     r0, [sp, #0x60]\n"
 296 //"    ldr     r1, =0xfc055a25\n"
 297 "    ldr     r1, =sub_fc055a24_my\n"
 298 "    asrs    r0, r0, #4\n"
 299 "    str     r0, [sp, #0x64]\n"
 300 "    lsls    r0, r0, #5\n"
 301 "    str     r0, [sp, #0x68]\n"
 302 "    mov     r0, sp\n"
 303 "    blx     sub_fc2c7564\n"
 304 "    add     sp, #0x78\n"
 305 "    pop     {r4, pc}\n"
 306 ".ltorg\n"
 307     );
 308 }
 309 
 310 //  -f=chdk -s=0xfc055a25 -c=62
 311 void __attribute__((naked,noinline)) sub_fc055a24_my() {
 312     asm volatile (
 313 "    push    {r4, lr}\n"
 314 "    ldr     r4, =0xfc055acc\n" //  *"/_term"
 315 "    bl      sub_fc056cc8\n"
 316 "    ldr     r0, =0x000080ec\n"
 317 "    ldr     r1, [r0]\n"
 318 "    ldr     r0, =0x00008074\n"
 319 "    ldr     r0, [r0]\n"
 320 "    adds    r0, #0x10\n"
 321 "    cmp     r1, r0\n"
 322 "    bhs     loc_fc055a40\n"
 323 "    ldr     r0, =0xfc055adc\n" //  *"USER_MEM size checking"
 324 "    bl      sub_fc055ab6\n"
 325 "loc_fc055a40:\n"
 326 "    bl      sub_fc11f6e0\n"
 327 "    ldr     r1, =0xbfe10000\n"
 328 // note capdis bad output
 329 //"    mov.w   r2, #-0x11111112\n"
 330 "    mov.w   r2, #0xeeeeeeee\n"
 331 "    ldr     r3, =0xbfe10800\n"
 332 "loc_fc055a4c:\n"
 333 "    stm     r1!, {r2}\n"
 334 "    cmp     r1, r3\n"
 335 "    blo     loc_fc055a4c\n"
 336 "    bl      sub_fc11f6f2\n"
 337 "    bl      sub_fc38d1c4\n"
 338 "    cmp     r0, #0\n"
 339 "    bge     loc_fc055a64\n"
 340 "    ldr     r0, =0xfc055afc\n" //  *"dmSetup"
 341 "    bl      sub_fc055ab6\n"
 342 "loc_fc055a64:\n"
 343 "    bl      sub_fc056268\n"
 344 "    cmp     r0, #0\n"
 345 "    bge     loc_fc055a72\n"
 346 "    ldr     r0, =0xfc055b04\n" //  *"termDriverInit"
 347 "    bl      sub_fc055ab6\n"
 348 "loc_fc055a72:\n"
 349 "    mov     r0, r4\n"
 350 "    bl      sub_fc0562f6\n"
 351 "    cmp     r0, #0\n"
 352 "    bge     loc_fc055a82\n"
 353 "    ldr     r0, =0xfc055b14\n" //  *"termDeviceCreate"
 354 "    bl      sub_fc055ab6\n"
 355 "loc_fc055a82:\n"
 356 "    mov     r0, r4\n"
 357 "    bl      sub_fc055c60\n"
 358 "    cmp     r0, #0\n"
 359 "    bge     loc_fc055a92\n"
 360 "    ldr     r0, =0xfc055b28\n" //  *"stdioSetup"
 361 "    bl      sub_fc055ab6\n"
 362 "loc_fc055a92:\n"
 363 "    bl      sub_fc055da4\n"
 364 "    cmp     r0, #0\n"
 365 "    bge     loc_fc055aa0\n"
 366 "    ldr     r0, =0xfc055b34\n" //  *"stdlibSetup"
 367 "    bl      sub_fc055ab6\n"
 368 "loc_fc055aa0:\n"
 369 "    bl      sub_fc058e3c\n"
 370 "    cmp     r0, #0\n"
 371 "    bge     loc_fc055aae\n"
 372 "    ldr     r0, =0xfc055b40\n" //  *"extlib_setup"
 373 "    bl      sub_fc055ab6\n"
 374 "loc_fc055aae:\n"
 375 "    pop.w   {r4, lr}\n"
 376 //"    b.w     loc_fc055e2e\n"
 377 "    b.w     sub_fc055e2e_my\n"
 378     ".ltorg\n"
 379     );
 380 }
 381 
 382 //  -f=chdk -s=0xfc055e2f -c=20
 383 void __attribute__((naked,noinline)) sub_fc055e2e_my() {
 384     asm volatile (
 385 "    push    {r3, lr}\n"
 386 "    bl      sub_fc055f34\n"
 387 "    bl      sub_fc078bfc\n" // IsNormalCameraMode_FW
 388 "    bl      sub_fc0cf0ee_my\n" // startup checks equivalent of g7x fc0781f4, but doesn't seem affected by *(0x4ffc)=0x12345678
 389 "    cbnz    r0, loc_fc055e44\n"
 390 "    bl      sub_fc055f22\n"
 391 "loc_fc055e42:\n"
 392 "    b       loc_fc055e42\n"
 393 "loc_fc055e44:\n"
 394 "    blx     sub_fc2c75bc\n"
 395 "    ldr     r1, =0x006ce000\n"
 396 "    movs    r0, #0\n"
 397 "    bl      sub_fc329108\n"
 398 "    movs    r3, #0\n"
 399 "    str     r3, [sp]\n"
 400 //"    ldr     r3, =0xfc055dc9\n" //  task_Startup
 401 "    ldr     r3, =task_Startup_my\n" //  ->
 402 "    movs    r2, #0\n"
 403 "    movs    r1, #0x19\n"
 404 "    ldr     r0, =0xfc055e6c\n" //  *"Startup"
 405 "    bl      _CreateTask\n"
 406 //"    blx     sub_fc2c79b0\n" // j_CreateTask
 407 "    movs    r0, #0\n"
 408 "    pop     {r3, pc}\n"
 409     ".ltorg\n"
 410     );
 411 }
 412 // -f=chdk -s=0xfc0cf0ef -c=40
 413 void __attribute__((naked,noinline)) sub_fc0cf0ee_my() {
 414     asm volatile (
 415 "    push.w  {r3, r4, r5, r6, r7, r8, sb, sl, fp, lr}\n"
 416 "    movs    r4, #0\n"
 417 "    mov     sl, r0\n"
 418 "    mov     r5, r4\n"
 419 "    mov     sb, r4\n"
 420 //"    bl      sub_fc086a00\n" // nullsub
 421 "    movs    r0, #0x10\n"
 422 "    bl      sub_fc0847ea\n"
 423 "    movs    r6, #1\n"
 424 "    bic.w   r8, r6, r0\n"
 425 "    movs    r0, #0xf\n"
 426 "    bl      sub_fc0847ea\n"
 427 "    bic.w   r7, r6, r0\n"
 428 "    movs    r0, #0\n"
 429 "    bl      sub_fc0869fc\n" // ret 1
 430 "    cbz     r0, loc_fc0cf126\n"
 431 "    movs    r0, #0x17\n"
 432 "    bl      sub_fc0847ea\n"
 433 "    bic.w   r5, r6, r0\n"
 434 "loc_fc0cf126:\n"
 435 "    movs    r0, #1\n"
 436 "    bl      sub_fc0869fc\n" // ret 1
 437 "    cbz     r0, loc_fc0cf13a\n"
 438 "    movw    r0, #0x1d8\n"
 439 "    bl      sub_fc0847ea\n"
 440 "    bic.w   r4, r6, r0\n"
 441 "loc_fc0cf13a:\n"
 442 "    cmp.w   sl, #0\n" 
 443 "    beq     loc_fc0cf14a\n"// skips checks if not IsNormalCameraMode
 444 "    orr.w   r0, r8, r7\n"
 445 "    orrs    r0, r5\n"
 446 "    orrs    r0, r4\n" // check all hardware related bits checked above
 447 //"    beq     loc_fc0cf15e\n" // old behavior, skip to return if none set
 448 "    bne     loc_fc0cf14a\n" // new behavior, go to final code if any set
 449 // otherwise, act as if play was held
 450     "mov  r7, #1\n"
 451 "loc_fc0cf14a:\n"
 452 "    mov     r3, sb\n"
 453 "    mov     r2, r5\n"
 454 "    mov     r1, r7\n"
 455 "    mov     r0, r8\n"
 456 "    str     r4, [sp]\n"
 457 "    bl      sub_fc086a04\n"
 458 //"    bl      sub_fc086a02\n" // nullsub
 459 "    movs    r0, #1\n"
 460 //"loc_fc0cf15e:\n"
 461 "    pop.w   {r3, r4, r5, r6, r7, r8, sb, sl, fp, pc}\n"
 462     ".ltorg\n"
 463     );
 464 }
 465 
 466 // -f=chdk -s=task_Startup -c=26
 467 void __attribute__((naked,noinline)) task_Startup_my() {
 468     asm volatile (
 469 "    push    {r4, lr}\n"
 470 "    bl      sub_fc0cf4d8\n" // CreateTask ClockSave
 471 "    bl      sub_fc055f00\n" // ??
 472 //"    bl      sub_fc056060\n" // ->nullsub
 473 "    bl      sub_fc38d978\n" // ??
 474 // added for SD card UHS detection https://chdk.setepontos.com/index.php?topic=13089.msg132583#msg132583
 475 "bl sub_010e173f\n" // ref in sub_010e182c following SD1stInit create
 476 //"    bl      sub_fc0560b6\n" StartDiskboot
 477 //"    bl      CreateTask_blinker\n"
 478 "    bl      sub_fc0b337a\n"
 479 "    bl      sub_fc0cf7dc\n"
 480 "    bl      sub_fc0561a8\n"
 481 "    bl      sub_fc055ff0\n" // "InitExDrivers.c"
 482 "    bl      sub_fc38d9b6\n" // -> StartWDT
 483 "    bl      sub_fc0917c4\n"
 484 "    bl      sub_fc0cf7e2\n"
 485 "    bl      sub_fc0cf014_my\n" // CreateTask PhySw
 486 "    bl      CreateTask_spytask\n" 
 487 "    bl      init_required_fw_features\n" // added
 488 "    bl      sub_fc26731c\n" // SsTask etc
 489 "    bl      sub_fc0cf7f8\n"
 490 "    bl      sub_fc11fac8\n"
 491 "    bl      sub_fc0b2fb0\n" // "Battery.c"
 492 "    bl      sub_fc0cf636\n" // "Bye"
 493 "    bl      sub_fc0b332a\n"
 494 "    bl      sub_fc0b2f6c\n" // BatteryTask
 495 "    bl      sub_fc0561ac\n"
 496 "    bl      sub_fc2d3378\n"
 497 "    bl      sub_fc0b2f40\n"
 498 "    pop.w   {r4, lr}\n"
 499 //"    b.w     loc_fc0cf4ae\n"
 500 "    ldr     pc,=0xfc0cf4af\n"
 501     ".ltorg\n"
 502     );
 503 }
 504 
 505 // -f=chdk -s=0xfc0cf015 -c=18
 506 //taskcreate_physw
 507 void __attribute__((naked,noinline)) sub_fc0cf014_my() {
 508     asm volatile (
 509 "    push    {r3, r4, r5, lr}\n"
 510 "    bl      sub_fc087d58\n"
 511 "    bl      sub_fc078b7a\n" // IsFactoryMode_FW
 512 "    cbnz    r0, loc_fc0cf024\n"
 513 "    bl      sub_fc087cfc\n" // OpLog.Start_FW
 514 "loc_fc0cf024:\n"
 515 "    ldr     r4, =0x000082c8\n" //  physw_run
 516 "    ldr     r0, [r4, #4]\n"
 517 "    cmp     r0, #0\n"
 518 "    bne     loc_fc0cf040\n"
 519 "    movs    r3, #0\n"
 520 "    str     r3, [sp]\n"
 521 //"    ldr     r3, =0xfc0cefc7\n" //  task_PhySw
 522 "    ldr     r3, =mykbd_task\n"
 523 "    movs    r1, #0x17\n"
 524 "    ldr     r0, =0xfc0cf36c\n" //  *"PhySw"
 525 //"    movw    r2, #0x800\n"
 526 "    movw    r2, #0x2000\n" // adjusted 0x800 -> 0x2000
 527 "    blx     sub_fc2c7cc8\n" // j_CreateTaskStrictly
 528 "    str     r0, [r4, #4]\n"
 529 "loc_fc0cf040:\n"
 530 "    pop     {r3, r4, r5, pc}\n"
 531     ".ltorg\n"
 532     );
 533 }
 534  
 535 // -f=chdk -s=task_InitFileModules -c=16
 536 void __attribute__((naked,noinline)) init_file_modules_task() {
 537     asm volatile (
 538 // task_InitFileModules 0xfc0d4309
 539 "    push    {r4, r5, r6, lr}\n"
 540 "    bl      sub_fc0d985c\n"
 541 "    movs    r4, r0\n"
 542 "    movw    r5, #0x5006\n"
 543 "    beq     loc_fc0d431e\n"
 544 "    movs    r1, #0\n"
 545 "    mov     r0, r5\n"
 546 "    bl      _PostLogicalEventToUI\n"
 547 "loc_fc0d431e:\n"
 548 "    bl      sub_fc0d9886\n"
 549 "    BL      core_spytask_can_start\n" // + CHDK: Set "it's-safe-to-start" flag for spytask
 550 "    cmp     r4, #0\n"
 551 "    bne     loc_fc0d4332\n"
 552 "    mov     r0, r5\n"
 553 "    pop.w   {r4, r5, r6, lr}\n"
 554 "    movs    r1, #0\n"
 555 "    b.w     _PostLogicalEventToUI\n"
 556 "loc_fc0d4332:\n"
 557 "    pop     {r4, r5, r6, pc}\n"
 558     ".ltorg\n"
 559     );
 560 }
 561 /*
 562     *** TEMPORARY? workaround ***
 563     Init stuff to avoid asserts on cameras running DryOS r54+
 564     https://chdk.setepontos.com/index.php?topic=12516.0
 565     Execute this only once
 566  */
 567 void init_required_fw_features(void) {
 568     extern void _init_focus_eventflag();
 569     extern void _init_nd_eventflag();
 570 //    extern void _init_nd_semaphore();
 571     //extern void _init_zoom_semaphore(); // for MoveZoomLensWithPoint
 572 
 573     _init_focus_eventflag();
 574     _init_nd_eventflag();
 575     // for MoveIrisWithAv, based on fc54057c from Mecha.Create (but without registering eventprocs)
 576     extern int av_override_semaphore;
 577     extern int _CreateBinarySemaphoreStrictly(int x, int y);
 578     av_override_semaphore = _CreateBinarySemaphoreStrictly(0,0);
 579 //    _init_nd_semaphore();
 580 }
 581 
 582 #ifdef CAM_HAS_JOGDIAL
 583 // jogdial override code called from kbd task
 584 // -f=chdk -s=kbd_p2_f -c=77
 585 // kbd_p2_f 0xfc0ced65
 586 void __attribute__((naked,noinline)) kbd_p2_f_my() {
 587     asm volatile(
 588 "    push.w  {r4, r5, r6, r7, r8, lr}\n"
 589 "    ldr     r6, =0x00032734\n"
 590 "    sub     sp, #0x18\n"
 591 "    add     r7, sp, #8\n"
 592 "    subs    r6, #0xc\n"
 593 "    b       loc_fc0ceda6\n"
 594 "loc_fc0ced72:\n"
 595 "    ldr     r1, =0x00032734\n"
 596 "    add     r3, sp, #8\n"
 597 "    ldrb.w  r0, [sp, #4]\n"
 598 "    add     r2, sp, #0x14\n"
 599 "    subs    r1, #0x18\n"
 600 "    bl      sub_fc086f30\n"
 601 "    cbnz    r0, loc_fc0ced8c\n"
 602 "    ldr     r1, [sp, #0x14]\n"
 603 "    movs    r0, #0\n"
 604 "    bl      sub_fc0cecd6\n"
 605 "loc_fc0ced8c:\n"
 606 "    movs    r0, #2\n"
 607 "loc_fc0ced8e:\n"
 608 "    ldr.w   r1, [r7, r0, lsl #2]\n"
 609 "    cbz     r1, loc_fc0ced9e\n"
 610 "    ldr.w   r2, [r6, r0, lsl #2]\n"
 611 "    bics    r2, r1\n"
 612 "    str.w   r2, [r6, r0, lsl #2]\n"
 613 "loc_fc0ced9e:\n"
 614 "    subs    r0, r0, #1\n"
 615 "    sxtb    r0, r0\n"
 616 "    cmp     r0, #0\n"
 617 "    bge     loc_fc0ced8e\n"
 618 "loc_fc0ceda6:\n"
 619 "    ldr     r0, =0x00032734\n"
 620 "    add     r1, sp, #4\n"
 621 "    subs    r0, #0xc\n"
 622 "    bl      sub_fc086c7c\n"
 623 "    cmp     r0, #0\n"
 624 "    bne     loc_fc0ced72\n"
 625 "    ldr.w   r8, =0x00032734\n"
 626 "    movs    r4, #0\n"
 627 "loc_fc0cedba:\n"
 628 "    movs    r5, #0\n"
 629 "    ldr.w   r0, [r6, r4, lsl #2]\n"
 630 "    ldr.w   r1, [r8, r4, lsl #2]\n"
 631 "    ands    r0, r1\n"
 632 "    str.w   r0, [r6, r4, lsl #2]\n"
 633 "    b       loc_fc0cee12\n"
 634 "loc_fc0cedcc:\n"
 635 "    lsrs    r0, r5\n"
 636 "    lsls    r0, r0, #0x1f\n"
 637 "    beq     loc_fc0cee0a\n"
 638 "    ldr     r1, =0x00032734\n"
 639 "    add.w   r0, r5, r4, lsl #5\n"
 640 "    add     r3, sp, #8\n"
 641 "    subs    r1, #0x18\n"
 642 "    add     r2, sp, #0x14\n"
 643 "    uxtb    r0, r0\n"
 644 "    bl      sub_fc086f30\n"
 645 "    cbnz    r0, loc_fc0cedee\n"
 646 "    ldr     r1, [sp, #0x14]\n"
 647 "    movs    r0, #1\n"
 648 "    bl      sub_fc0cecd6\n"
 649 "loc_fc0cedee:\n"
 650 "    mov     r0, r4\n"
 651 "    b       loc_fc0cee06\n"
 652 "loc_fc0cedf2:\n"
 653 "    ldr.w   r1, [r7, r0, lsl #2]\n"
 654 "    cbz     r1, loc_fc0cee02\n"
 655 "    ldr.w   r2, [r6, r0, lsl #2]\n"
 656 "    bics    r2, r1\n"
 657 "    str.w   r2, [r6, r0, lsl #2]\n"
 658 "loc_fc0cee02:\n"
 659 "    adds    r0, r0, #1\n"
 660 "    sxtb    r0, r0\n"
 661 "loc_fc0cee06:\n"
 662 "    cmp     r0, #3\n"
 663 "    blt     loc_fc0cedf2\n"
 664 "loc_fc0cee0a:\n"
 665 "    ldr.w   r0, [r6, r4, lsl #2]\n"
 666 "    adds    r5, r5, #1\n"
 667 "    uxtb    r5, r5\n"
 668 "loc_fc0cee12:\n"
 669 "    cmp     r0, #0\n"
 670 "    bne     loc_fc0cedcc\n"
 671 "    adds    r4, r4, #1\n"
 672 "    sxtb    r4, r4\n"
 673 "    cmp     r4, #3\n"
 674 "    blt     loc_fc0cedba\n"
 675 //"    bl      sub_fc086af2\n"
 676 "    bl      sub_fc086af2_my\n"
 677 "    add     sp, #0x18\n"
 678 "    pop.w   {r4, r5, r6, r7, r8, pc}\n"
 679 ".ltorg\n"
 680     );
 681 }
 682 
 683 // -f=chdk -s=0xfc086af3 -c=10
 684 void __attribute__((naked,noinline)) sub_fc086af2_my() {
 685     asm volatile(
 686 "    push    {r4, lr}\n"
 687 "    ldr     r4, =0x0000960c\n"
 688 "    subs    r4, #0x10\n"
 689 "    ldr     r0, [r4, #8]\n"
 690 "    bl      sub_fc08b410\n"
 691 "    bl      sub_fc0f232c\n"
 692 "    ldr     r0, [r4, #0xc]\n"
 693 "    bl      sub_fc08b340\n"
 694 // re-ordered
 695 //"    pop.w   {r4, lr}\n"
 696 //"    b.w     loc_fc08b6f6\n"
 697 "    bl      handle_jogdial\n"  // +
 698 "    cmp     r0, #0\n"          // +
 699 "    beq     no_scroll\n"       // +
 700 "    bl      sub_fc08b6f6\n"    // handles scrollwheel(s), void function, no args
 701 "no_scroll:\n"                  // +
 702 "    pop     {r4, pc}\n"        // +
 703 ".ltorg\n"
 704     );
 705 }
 706 #endif

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