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

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