root/platform/g16/sub/101b/boot.c

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

DEFINITIONS

This source file includes following definitions.
  1. spytask
  2. CreateTask_spytask
  3. xblinker
  4. blinker
  5. CreateTask_blinker
  6. boot
  7. CreateTask_my
  8. sub_fc05e00c_my
  9. sub_fc05e19d_my
  10. sub_fc05e5a2_my
  11. task_Startup_my
  12. sub_fc070d8a_my
  13. init_file_modules_task
  14. kbd_p2_f_my
  15. sub_fc07147a_my

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "core.h"
   4 #include "dryos31.h"
   5 #include "gui_draw.h"
   6 #include "asmsafe.h"
   7 
   8 #define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
   9 
  10 const char * const new_sa = &_end;
  11 extern volatile int jogdial_stopped;
  12 
  13 // Forward declarations
  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 void JogDial_task_my(void);
  22 
  23 
  24 /*----------------------------------------------------------------------
  25     spytask
  26 -----------------------------------------------------------------------*/
  27 void spytask(long ua, long ub, long uc, long ud, long ue, long uf)
  28 {
  29     core_spytask();
  30 }
  31 
  32 void CreateTask_spytask()
  33 {
  34     _CreateTask("SpyTask", 0x19, 0x2000, spytask, 0);
  35 }
  36 
  37 #ifdef DEBUG_BLINKING
  38 
  39     // ASM_SAFE("BL xblinker\n")
  40     #define LED_PR     0xd20b0994       // G16 green LED on OVF bezel   
  41     #define LED_PWR    0xd20b0884       // G16 green LED on power button
  42     #define LED_ORANGE 0xd20b0888       // G16 orange LED on OVF bezel   
  43     #define XDELAY 4000000 
  44 
  45     void xblinker() 
  46     {
  47         int j = 2;
  48         while(j-- > 0) {
  49             int i;
  50             *(volatile int*)LED_ORANGE = 0x4d0002;
  51             for(i=0;i<XDELAY/10;i++) {
  52                 asm volatile(
  53                 "nop\n"
  54                 );
  55             }
  56             *(volatile int*)LED_ORANGE = 0x4c0003;
  57             for(i=0;i<XDELAY;i++) {
  58                 asm volatile(
  59                 "nop\n"
  60                 );
  61             }
  62         }
  63     }
  64 
  65     /*----------------------------------------------------------------------
  66       blinker
  67     -----------------------------------------------------------------------*/
  68 
  69     void draw_pixel_std(unsigned int , unsigned short );
  70 
  71     void __attribute__((naked,noinline)) blinker() {
  72 
  73         int led_count = 50 ;
  74         unsigned int pxl;
  75 
  76         _SleepTask(2000);
  77 
  78         while(1)
  79         {
  80             switch led_count
  81             {
  82                 case 3 :
  83                     *(volatile int*)0xd20b0994 = 0x4d0002;
  84                     break ;
  85                 case 2 :
  86                     *(volatile int*)0xd20b0994 = 0x4c0003;
  87                     break ;
  88                 case 1 :
  89                     *(volatile int*)0xd20b0994 = 0x4d0002;
  90                     break ;
  91                 case 0 :
  92                    led_count = 21 ;
  93                    *(volatile int*)0xd20b0994 = 0x4c0003;
  94 
  95                     for (pxl=0 ; pxl<0x3FFF ; pxl++)
  96                     {
  97                         draw_pixel_std(pxl, MAKE_COLOR(COLOR_GREEN,COLOR_GREEN)) ;
  98                     }
  99                     break ;
 100                 default :
 101                     break ;
 102             }
 103             led_count-- ;
 104             _SleepTask(100);
 105         }
 106     };
 107 
 108     void CreateTask_blinker() {
 109             _CreateTask("Blinker", 0x1, 0x200, blinker, 0);
 110     };
 111 #endif
 112 
 113 
 114 /*----------------------------------------------------------------------
 115     boot()
 116 
 117     Main entry point for the CHDK code
 118 -----------------------------------------------------------------------*/
 119 // G16 1.01b  0xfc02000d 33
 120 void __attribute__((naked,noinline)) boot() {
 121     asm volatile (
 122 "    ldr.w   sp, =0x80010000\n"
 123 
 124     #ifdef DEBUG_BLINKING
 125     ASM_SAFE("BL xblinker\n")
 126     #endif
 127 
 128 "    bl      sub_fc020064\n"
 129 "    ldr     r2, =0xc0242010\n"
 130 "    ldr     r1, [r2]\n"
 131 "    orr     r1, r1, #1\n"
 132 "    str     r1, [r2]\n"
 133 "    ldr     r0, =0xfcbebb70\n"   // code copied from ROM to RAM
 134 "    ldr     r1, =0x010c1000\n"   // 
 135 "    ldr     r3, =0x010df4e8\n"   //
 136 "loc_fc020024:\n"
 137 "    cmp     r1, r3\n"
 138 "    itt     lo\n"
 139 "    ldrlo   r2, [r0], #4\n"
 140 "    strlo   r2, [r1], #4\n"
 141 "    blo     loc_fc020024\n"
 142 
 143 // Install CreateTask patch
 144 // use half words in case source or destination not word aligned
 145         "adr     r0, patch_CreateTask\n"    // src: Patch data
 146         "ldr     r1, =hook_CreateTask\n"    // dest: Address to patch (hook_ has thumb bit off)
 147         "add     r2, r0, #8\n"              // two words
 148 "task_hook_loop:\n"
 149         "ldrh   r3, [r0],#2\n"
 150         "strh   r3, [r1],#2\n"
 151         "cmp    r0,r2\n"
 152         "blo    task_hook_loop\n"
 153 
 154 "    ldr     r0, =0x010c1000\n"
 155 "    ldr     r1, =0x0001e4e8\n"
 156 "    bl      sub_fc13c50e\n"
 157 "    ldr     r0, =0xfcbc22d0\n"
 158 "    ldr     r1, =0x00008000\n"
 159 "    ldr     r3, =0x000318a0\n"
 160 "loc_fc020040:\n"
 161 "    cmp     r1, r3\n"
 162 "    itt     lo\n"
 163 "    ldrlo   r2, [r0], #4\n"
 164 "    strlo   r2, [r1], #4\n"
 165 "    blo     loc_fc020040\n"
 166 "    ldr     r3, =0x000318a0\n"
 167 "    ldr     r1, =0x003077e0\n"
 168 "    mov.w   r2, #0\n"
 169 "loc_fc020056:\n"
 170 "    cmp     r3, r1\n"
 171 "    it      lo\n"
 172 "    strlo   r2, [r3], #4\n"
 173 "    blo     loc_fc020056\n"
 174 "    b.w     sub_fc05e00c_my\n"   // --->>
 175 
 176 "patch_CreateTask:\n"
 177 "    ldr.w   pc, [pc,#0]\n"             // Do jump to absolute address CreateTask_my
 178 "    .long   CreateTask_my + 1\n"       // has to be a thumb address
 179 );
 180 }
 181 
 182 void __attribute__((naked,noinline)) CreateTask_my() {
 183     asm volatile (
 184 "    push   {r0}\n"
 185                                         // R3 = Pointer to task function to create
 186 "    ldr     r0, =task_CaptSeq\n"       // DryOS original code function ptr.
 187 "    cmp     r0, r3\n"                  // is the given taskptr equal to our searched function?
 188 "    itt     eq\n"                      // EQ block
 189 "    ldreq   r3, =capt_seq_task\n"      // if so replace with our task function base ptr.
 190 "    orreq   r3, #1\n"                  // make sure it's a thumb address (may not be needed?)
 191 "    beq     exitHook\n"                // below compares not necessary if this check has found something.
 192                                         //
 193 "    LDR     R0, =task_ExpDrv\n"
 194 "    CMP     R0, R3\n"
 195 "    itt     eq\n"
 196 "    LDREQ   R3, =exp_drv_task\n"
 197 "    orreq   r3, #1\n"
 198 "    BEQ     exitHook\n"
 199 
 200 "    ldr     r0, =task_InitFileModules\n"
 201 "    cmp     r0, r3\n"
 202 "    itt     eq\n"
 203 "    ldreq   r3, =init_file_modules_task\n"
 204 "    orreq   r3, #1\n"
 205 "    BEQ     exitHook\n"
 206 
 207 "    LDR     R0, =task_FileWrite\n"
 208 "    CMP     R0, R3\n"
 209 "    itt     eq\n"
 210 "    LDREQ   R3, =filewritetask\n"
 211 "    orreq   r3, #1\n"
 212 "    BEQ     exitHook\n"
 213 
 214 /* FIXME
 215 
 216 "    LDR     R0, =task_DvlpSeqTask\n"
 217 "    CMP     R0, R3\n"
 218 "    itt     eq\n"
 219 "    LDREQ   R3, =developseq_task\n"
 220 "    orreq   r3, #1\n"
 221 "    BEQ     exitHook\n"
 222 
 223 "    LDR     R0, =task_MovieRecord\n" // NOTE : no video task hook for DIGIC6 cameras
 224 "    CMP     R0, R3\n"
 225 "    itt     eq\n"
 226 "    LDREQ   R3, =movie_record_task\n"
 227 "    BEQ     exitHook\n"
 228 
 229 */
 230 
 231 "exitHook:\n"
 232 "    pop    {r0}\n"     // restore overwritten register & execute overwritten instructions from original code
 233 "    stmdb   sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, lr}\n"
 234 "    mov     r4, r0\n"
 235 "    ldr     r0, =0x8158\n"
 236 "    ldr.w   pc, =(hook_CreateTask + 8 + 1) \n"  // Continue in firmware, thumb bit set   
 237 ".ltorg\n"
 238 );
 239 }
 240 
 241 // G16 1.01b  0xfc05e00d 61
 242 void __attribute__((naked,noinline)) sub_fc05e00c_my() {
 243     asm volatile (
 244 // no GPIO checks needed with 0x12345678 set, native fw handles long press
 245 "    push    {r4, lr}\n"
 246 #if defined(CHDK_NOT_IN_CANON_HEAP)
 247 "    ldr     r4, =0x003077e0\n"         // heap start, modify here
 248 #else
 249     "ldr     r4, =new_sa\n"             // +
 250     "ldr     r4, [r4]\n"                // +
 251 #endif
 252 "    sub     sp, #0x78\n"
 253 "    ldr     r0, =0x006ce000\n"
 254 "    ldr     r1, =0x0008eb94\n"
 255 "    subs    r0, r0, r4\n"
 256 "    cmp     r0, r1\n"
 257 "    bhs     loc_fc05e01e\n"
 258 "loc_fc05e01c:\n"
 259 "    b       loc_fc05e01c\n"
 260 "loc_fc05e01e:\n"
 261 "    ldr     r1, =0x00008074\n"
 262 "    mov.w   r0, #0x80000\n"
 263 "    str     r0, [r1]\n"
 264 "    ldr     r1, =0x00008078\n"
 265 "    ldr     r0, =0x42b21000\n"
 266 "    str     r0, [r1]\n"
 267 "    ldr     r1, =0x0000807c\n"
 268 "    ldr     r0, =0x42b23000\n"
 269 "    str     r0, [r1]\n"
 270 "    movs    r1, #0x74\n"
 271 "    add     r0, sp, #4\n"
 272 "    blx     sub_fc2a16d8\n" // j_bzero
 273 "    add     r2, sp, #4\n"
 274 "    ldr     r0, =0x0062e000\n"
 275 "    mov.w   r1, #0xa0000\n"
 276 "    stm     r2!, {r0, r1, r4}\n"
 277 "    ldr     r1, =0x0062346c\n" //  *"l4b"
 278 "    str     r0, [sp, #0x18]\n"
 279 "    movs    r0, #0x22\n"
 280 "    subs    r2, r1, r4\n"
 281 "    str     r0, [sp, #0x1c]\n"
 282 "    movs    r0, #0x98\n"
 283 "    str     r0, [sp, #0x20]\n"
 284 "    strd    r2, r1, [sp, #0x10]\n"
 285 "    movw    r0, #0x1e8\n"
 286 "    str     r0, [sp, #0x24]\n"
 287 "    movs    r0, #0xfa\n"
 288 "    str     r0, [sp, #0x28]\n"
 289 "    movs    r0, #0xb6\n"
 290 "    str     r0, [sp, #0x2c]\n"
 291 "    movs    r0, #0x85\n"
 292 "    str     r0, [sp, #0x30]\n"
 293 "    movs    r0, #0x40\n"
 294 "    str     r0, [sp, #0x34]\n"
 295 "    movs    r0, #4\n"
 296 "    str     r0, [sp, #0x38]\n"
 297 "    movs    r0, #0\n"
 298 "    str     r0, [sp, #0x3c]\n"
 299 "    movs    r0, #0x10\n"
 300 "    str     r0, [sp, #0x60]\n"
 301 //"    ldr     r1, =0xfc05e19d\n"
 302 "    ldr     r1, =sub_fc05e19d_my\n"    // -->>
 303 "    movs    r2, #0\n"
 304 "    lsls    r0, r0, #8\n"
 305 "    str     r0, [sp, #0x64]\n"
 306 "    asrs    r0, r0, #4\n"
 307 "    str     r0, [sp, #0x68]\n"
 308 "    lsls    r0, r0, #5\n"
 309 "    str     r0, [sp, #0x6c]\n"
 310 "    add     r0, sp, #4\n"
 311 "    blx     sub_fc2a0d38\n"
 312 "    add     sp, #0x78\n"
 313 "    pop     {r4, pc}\n"
 314 
 315 ".ltorg\n"
 316 );
 317 }
 318 
 319 // G16 1.01b  0xfc05e19d 54
 320 void __attribute__((naked,noinline)) sub_fc05e19d_my() {
 321     asm volatile (
 322 "    push    {r4, lr}\n"
 323 "    ldr     r4, =0xfc05e248\n" //  *"/_term"
 324 "    bl      sub_fc05f3c8\n"
 325 "    ldr     r0, =0x000080ec\n"
 326 "    ldr     r1, [r0]\n"
 327 "    ldr     r0, =0x00008074\n"
 328 "    ldr     r0, [r0]\n"
 329 "    adds    r0, #0x10\n"
 330 "    cmp     r1, r0\n"
 331 "    bhs     loc_fc05e1b8\n"
 332 "    ldr     r0, =0xfc05e258\n" //  *"USER_MEM size checking"
 333 "    bl      sub_fc05e230\n"
 334 "loc_fc05e1b8:\n"
 335 "    bl      sub_fc13c5e8\n"
 336 "    ldr     r3, =0x80000800\n"
 337 "    mov.w   r1, #-0x80000000\n"
 338 "    mov.w   r2, #-0x11111112\n"
 339 "loc_fc05e1c6:\n"
 340 "    stm     r1!, {r2}\n"
 341 "    cmp     r1, r3\n"
 342 "    blo     loc_fc05e1c6\n"
 343 "    bl      sub_fc13c5fa\n"
 344 "    bl      sub_fc13cba4\n"
 345 "    cmp     r0, #0\n"
 346 "    bge     loc_fc05e1de\n"
 347 "    ldr     r0, =0xfc05e274\n" //  *"dmSetup"
 348 "    bl      sub_fc05e230\n"
 349 "loc_fc05e1de:\n"
 350 "    bl      sub_fc05ea08\n"
 351 "    cmp     r0, #0\n"
 352 "    bge     loc_fc05e1ec\n"
 353 "    ldr     r0, =0xfc05e27c\n" //  *"termDriverInit"
 354 "    bl      sub_fc05e230\n"
 355 "loc_fc05e1ec:\n"
 356 "    mov     r0, r4\n"
 357 "    bl      sub_fc05ea9c\n"
 358 "    cmp     r0, #0\n"
 359 "    bge     loc_fc05e1fc\n"
 360 "    ldr     r0, =0xfc05e28c\n" //  *"termDeviceCreate"
 361 "    bl      sub_fc05e230\n"
 362 "loc_fc05e1fc:\n"
 363 "    mov     r0, r4\n"
 364 "    bl      sub_fc05e3d4\n"
 365 "    cmp     r0, #0\n"
 366 "    bge     loc_fc05e20c\n"
 367 "    ldr     r0, =0xfc05e2a0\n" //  *"stdioSetup"
 368 "    bl      sub_fc05e230\n"
 369 "loc_fc05e20c:\n"
 370 "    bl      sub_fc05e518\n"
 371 "    cmp     r0, #0\n"
 372 "    bge     loc_fc05e21a\n"
 373 "    ldr     r0, =0xfc05e2ac\n" //  *"stdlibSetup"
 374 "    bl      sub_fc05e230\n"
 375 "loc_fc05e21a:\n"
 376 "    bl      sub_fc0617d0\n"
 377 "    cmp     r0, #0\n"
 378 "    bge     loc_fc05e228\n"
 379 "    ldr     r0, =0xfc05e2b8\n" //  *"extlib_setup"
 380 "    bl      sub_fc05e230\n"
 381 "loc_fc05e228:\n"
 382 "    pop.w   {r4, lr}\n"
 383 "    b.w     sub_fc05e5a2_my\n"  // --->>
 384 
 385 ".ltorg\n"
 386     );
 387 }
 388 
 389 // G16 1.01b  0xffc05e5a3 27
 390 void __attribute__((naked,noinline)) sub_fc05e5a2_my() {
 391     asm volatile (
 392 "    push    {r3, lr}\n"
 393 "    bl      sub_fc05e6a4\n"
 394 "    bl      sub_fc0b5a00\n"
 395 "    cbnz    r0, loc_fc05e5b8\n"
 396 "    bl      sub_fc07e9a8\n" // IsNormalCameraMode_FW
 397 "    cbz     r0, loc_fc05e5b8\n"
 398 "    movs    r0, #1\n"
 399 "    b       loc_fc05e5ba\n"
 400 "loc_fc05e5b8:\n"
 401 "    movs    r0, #0\n"
 402 "loc_fc05e5ba:\n"
 403 "    bl      sub_fc070e98\n" // power-on mode handling & startupchecks here, no override needed with 0x12345678 set
 404 "    cbnz    r0, loc_fc05e5c6\n"
 405 "    bl      sub_fc05e692\n"
 406 "loc_fc05e5c4:\n"
 407 "    b       loc_fc05e5c4\n"
 408 "loc_fc05e5c6:\n"
 409 "    blx     sub_fc2a0d90\n"
 410 "    ldr     r1, =0x006ce000\n"
 411 "    movs    r0, #0\n"
 412 "    bl      sub_fc30d864\n"
 413 "    blx     sub_fc2a12c8\n"
 414 "    movs    r3, #0\n"
 415 "    str     r3, [sp]\n"
 416 //"    ldr     r3, =0xfc05e53d\n" //  task_Startup
 417 "    ldr     r3, =task_Startup_my\n"   //  --->>
 418 "    movs    r2, #0\n"
 419 "    movs    r1, #0x19\n"
 420 "    ldr     r0, =0xfc05e5f4\n" //  *"Startup"
 421 "    blx     sub_fc2a12e8\n" // j_CreateTask
 422 "    movs    r0, #0\n"
 423 "    pop     {r3, pc}\n"
 424 
 425 ".ltorg\n"
 426     );
 427 }
 428 
 429 // G16 1.01b  0xfc05e53d 26
 430 // task_Startup 0xfc05e53d
 431 void __attribute__((naked,noinline)) task_Startup_my() {
 432     asm volatile (
 433 "    push    {r4, lr}\n"
 434 "    bl      sub_fc0e4714\n"
 435 "    bl      sub_fc05e670\n"
 436 "    bl      sub_fc05e7e4\n"
 437 "    bl      sub_fc0e47ac\n"
 438 //"  bl      sub_fc05e83a\n"              //  startdiskboot commented out to avoid infinite boot loop
 439 
 440 // added for SD card UHS detection https://chdk.setepontos.com/index.php?topic=13089.msg132583#msg132583
 441 "    bl      sub_fc08f5b8\n"             // + switch off card per m10 and g7x ports
 442 
 443 "    bl      sub_fc0895ae\n"
 444 "    bl      sub_fc0e48f0\n"
 445 "    bl      sub_fc05e948\n"
 446 "    bl      sub_fc05e780\n"
 447 "    bl      sub_fc0e47ea\n"
 448 "    bl      sub_fc0999fc\n"
 449 "    bl      sub_fc0e48f6\n"
 450 //"    bl      sub_fc070d8a\n"
 451 "    bl      sub_fc070d8a_my\n"            // CreateTask PhySw
 452 
 453 #if defined(OPT_RUN_WITH_BATT_COVER_OPEN)
 454 "    LDR     R0, =0x1C0000\n"              // Pause for startup with battery door open
 455 "batt_delay:\n"
 456 "    NOP\n"
 457 "    SUBS    R0,R0,#1\n"
 458 "    BNE     batt_delay\n"
 459 #endif
 460 "    bl      CreateTask_spytask\n"
 461 //"    bl      init_required_fw_features\n" // added
 462 #ifdef DEBUG_BLINKING
 463 "    bl      CreateTask_blinker\n"
 464 #endif
 465 
 466 "    bl      sub_fc254046\n"
 467 "    bl      sub_fc0e490c\n"
 468 "    bl      sub_fc0b57a4\n"
 469 "    bl      sub_fc0e44fc\n"
 470 "    bl      sub_fc0b58d0\n"
 471 "    bl      sub_fc0999ae\n"
 472 "    bl      sub_fc0e44bc\n"
 473 "    bl      sub_fc05e94c\n"
 474 "    bl      sub_fc307d98\n"
 475 "    bl      sub_fc0e4496\n"
 476 "    pop.w   {r4, lr}\n"
 477 "    b.w     sub_fc0e46ea\n"
 478 
 479 ".ltorg\n"
 480     );
 481 }
 482 
 483 // G16 1.01b  0xfc070d8b 18 = taskcreate_physw
 484 void __attribute__((naked,noinline)) sub_fc070d8a_my() {
 485     asm volatile (
 486 "    push    {r3, r4, r5, lr}\n"
 487 "    bl      sub_fc0701d8\n"
 488 "    bl      sub_fc07e932\n"        // IsFactoryMode_FW
 489 "    cbnz    r0, loc_fc070d9a\n"
 490 "    bl      sub_fc07017c\n"        // OpLog.Start_FW
 491 "loc_fc070d9a:\n"
 492 "    ldr     r4, =0x00008324\n"     //  physw_run
 493 "    ldr     r0, [r4, #4]\n"
 494 "    cmp     r0, #0\n"
 495 "    bne     loc_fc070db6\n"
 496 "    movs    r3, #0\n"
 497 "    str     r3, [sp]\n"
 498 //  "    ldr     r3, =0xfc070d65\n" //  task_PhySw
 499 "    ldr     r3, =mykbd_task\n"     //   --->>
 500 "    movs    r1, #0x17\n"
 501 "    ldr     r0, =0xfc070de4\n"     //  *"PhySw"
 502 "    movw    r2, #0x2000\n"         // stack adjusted from 0x800 to 0x2000
 503 "    blx     sub_fc2a1620\n"        // j_CreateTaskStrictly
 504 "    str     r0, [r4, #4]\n"
 505 "loc_fc070db6:\n"
 506 "    pop     {r3, r4, r5, pc}\n"
 507 
 508 ".ltorg\n"
 509     );
 510 }
 511 
 512 // G16 1.01b  0xfc0b9259 16
 513 // task_InitFileModules 0xfc0b9259
 514 void __attribute__((naked,noinline)) init_file_modules_task() {
 515     asm volatile (
 516 "    push    {r4, r5, r6, lr}\n"
 517 "    bl      sub_fc0bba04\n"
 518 "    movs    r4, r0\n"
 519 "    movw    r5, #0x5006\n"
 520 "    beq     loc_fc0b926e\n"
 521 "    movs    r1, #0\n"
 522 "    mov     r0, r5\n"
 523 "    bl      _PostLogicalEventToUI\n"
 524 "loc_fc0b926e:\n"
 525 "    bl      sub_fc0bba32\n"
 526 "    bl      core_spytask_can_start\n" // + CHDK: Set "it's-safe-to-start" flag for spytask
 527 "    cmp     r4, #0\n"
 528 "    bne     loc_fc0b9282\n"
 529 "    mov     r0, r5\n"
 530 "    pop.w   {r4, r5, r6, lr}\n"
 531 "    movs    r1, #0\n"
 532 "    b.w     _PostLogicalEventToUI\n"
 533 "loc_fc0b9282:\n"
 534 "    pop     {r4, r5, r6, pc}\n"
 535 
 536 ".ltorg\n"
 537     );
 538 }
 539 
 540 /*
 541     *** Workarounds ***
 542     Stuff to avoid asserts on cameras running DryOS r54+
 543     Note : G16 runs DryOS r52 so this hooked but not needed. See : https://chdk.setepontos.com/index.php?topic=12516.0
 544 */
 545 /* FIXME if necessary
 546 void init_required_fw_features(void) {
 547 
 548     extern void _init_focus_eventflag();
 549     _init_focus_eventflag();
 550 
 551     extern void _init_nd_eventflag();
 552     extern void _init_nd_semaphore();
 553     _init_nd_eventflag();
 554     _init_nd_semaphore();
 555 
 556     extern int av_override_semaphore;
 557     extern int _CreateBinarySemaphoreStrictly(int x, int y);
 558     av_override_semaphore = _CreateBinarySemaphoreStrictly(0,0);
 559 }
 560 */
 561 
 562 // G16 1.01b  0xfc070b31 77
 563 void __attribute__((naked,noinline)) kbd_p2_f_my() {
 564     asm volatile(
 565 "    push.w  {r4, r5, r6, r7, r8, lr}\n"
 566 "    ldr     r6, =0x0003313c\n"
 567 "    sub     sp, #0x18\n"
 568 "    add     r7, sp, #8\n"
 569 "    subs    r6, #0xc\n"
 570 "    b       loc_fc070b72\n"
 571 "loc_fc070b3e:\n"
 572 "    ldr     r1, =0x0003313c\n"
 573 "    add     r3, sp, #8\n"
 574 "    ldrb.w  r0, [sp, #4]\n"
 575 "    add     r2, sp, #0x14\n"
 576 "    subs    r1, #0x18\n"
 577 "    bl      sub_fc071856\n"
 578 "    cbnz    r0, loc_fc070b58\n"
 579 "    ldr     r1, [sp, #0x14]\n"
 580 "    movs    r0, #0\n"
 581 "    bl      sub_fc070aa2\n"
 582 "loc_fc070b58:\n"
 583 "    movs    r0, #2\n"
 584 "loc_fc070b5a:\n"
 585 "    ldr.w   r1, [r7, r0, lsl #2]\n"
 586 "    cbz     r1, loc_fc070b6a\n"
 587 "    ldr.w   r2, [r6, r0, lsl #2]\n"
 588 "    bics    r2, r1\n"
 589 "    str.w   r2, [r6, r0, lsl #2]\n"
 590 "loc_fc070b6a:\n"
 591 "    subs    r0, r0, #1\n"
 592 "    sxtb    r0, r0\n"
 593 "    cmp     r0, #0\n"
 594 "    bge     loc_fc070b5a\n"
 595 "loc_fc070b72:\n"
 596 "    ldr     r0, =0x0003313c\n"
 597 "    add     r1, sp, #4\n"
 598 "    subs    r0, #0xc\n"
 599 "    bl      sub_fc071584\n"
 600 "    cmp     r0, #0\n"
 601 "    bne     loc_fc070b3e\n"
 602 "    ldr.w   r8, =0x0003313c\n"
 603 "    movs    r4, #0\n"
 604 "loc_fc070b86:\n"
 605 "    movs    r5, #0\n"
 606 "    ldr.w   r0, [r6, r4, lsl #2]\n"
 607 "    ldr.w   r1, [r8, r4, lsl #2]\n"
 608 "    ands    r0, r1\n"
 609 "    str.w   r0, [r6, r4, lsl #2]\n"
 610 "    b       loc_fc070bde\n"
 611 "loc_fc070b98:\n"
 612 "    lsrs    r0, r5\n"
 613 "    lsls    r0, r0, #0x1f\n"
 614 "    beq     loc_fc070bd6\n"
 615 "    ldr     r1, =0x0003313c\n"
 616 "    add.w   r0, r5, r4, lsl #5\n"
 617 "    add     r3, sp, #8\n"
 618 "    subs    r1, #0x18\n"
 619 "    add     r2, sp, #0x14\n"
 620 "    uxtb    r0, r0\n"
 621 "    bl      sub_fc071856\n"
 622 "    cbnz    r0, loc_fc070bba\n"
 623 "    ldr     r1, [sp, #0x14]\n"
 624 "    movs    r0, #1\n"
 625 "    bl      sub_fc070aa2\n"
 626 "loc_fc070bba:\n"
 627 "    mov     r0, r4\n"
 628 "    b       loc_fc070bd2\n"
 629 "loc_fc070bbe:\n"
 630 "    ldr.w   r1, [r7, r0, lsl #2]\n"
 631 "    cbz     r1, loc_fc070bce\n"
 632 "    ldr.w   r2, [r6, r0, lsl #2]\n"
 633 "    bics    r2, r1\n"
 634 "    str.w   r2, [r6, r0, lsl #2]\n"
 635 "loc_fc070bce:\n"
 636 "    adds    r0, r0, #1\n"
 637 "    sxtb    r0, r0\n"
 638 "loc_fc070bd2:\n"
 639 "    cmp     r0, #3\n"
 640 "    blt     loc_fc070bbe\n"
 641 "loc_fc070bd6:\n"
 642 "    ldr.w   r0, [r6, r4, lsl #2]\n"
 643 "    adds    r5, r5, #1\n"
 644 "    uxtb    r5, r5\n"
 645 "loc_fc070bde:\n"
 646 "    cmp     r0, #0\n"
 647 "    bne     loc_fc070b98\n"
 648 "    adds    r4, r4, #1\n"
 649 "    sxtb    r4, r4\n"
 650 "    cmp     r4, #3\n"
 651 "    blt     loc_fc070b86\n"
 652 "    bl      sub_fc07147a_my\n"   //  --->>
 653 "    add     sp, #0x18\n"
 654 "    pop.w   {r4, r5, r6, r7, r8, pc}\n"
 655 
 656 ".ltorg\n"
 657   );
 658 }
 659 
 660 // G16 1.01b  0xfc07147b 11
 661 void __attribute__((naked,noinline)) sub_fc07147a_my() {
 662     asm volatile(
 663 "    push    {r4, lr}\n"
 664 "    ldr     r4, =0x00009494\n"
 665 "    ldr     r0, [r4, #8]\n"
 666 "    bl      sub_fc0721b4\n"
 667 "    bl      sub_fc0c784c\n"
 668 "    ldr     r0, [r4, #0xc]\n"
 669 "    bl      sub_fc0720d0\n"
 670 "    ldr     r0, [r4, #0x10]\n"
 671 "    bl      sub_fc0720d0\n"
 672 //"    pop.w   {r4, lr}\n"
 673 //"    b.w     loc_fc06befe\n"
 674 "    bl      handle_jogdial\n"  // +
 675 "    cmp     r0, #0\n"          // +
 676 "    beq     no_scroll\n"       // +
 677 "    bl      sub_fc06befe\n"    // handles scrollwheel(s), void function, no args
 678 "no_scroll:\n"                  // +
 679 "    pop     {r4, pc}\n"        // +
 680 ".ltorg\n"
 681     );
 682 }
 683 
 684 

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