root/platform/sx700hs/sub/100d/boot.c

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

DEFINITIONS

This source file includes following definitions.
  1. spytask
  2. CreateTask_spytask
  3. task_blinker
  4. CreateTask_blinker
  5. init_required_fw_features
  6. boot
  7. CreateTask_my
  8. sub_fc05d050_my
  9. sub_fc05d1e0_my
  10. sub_fc05d5e6_my
  11. task_Startup_my
  12. sub_fc07a0e2_my
  13. init_file_modules_task
  14. kbd_p2_f_my
  15. sub_fc06e104_my

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "core.h"
   4 //#include "dryos31.h"
   5 
   6 #define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
   7 
   8 const char * const new_sa = &_end;
   9 
  10 // Forward declarations
  11 extern volatile int jogdial_stopped;
  12 void JogDial_task_my(void);
  13 
  14 extern void task_CaptSeq();
  15 extern void task_InitFileModules();
  16 extern void task_RotaryEncoder();
  17 extern void task_MovieRecord();
  18 //extern void task_LiveImageTask();
  19 extern void task_ExpDrv();
  20 
  21 extern void handle_jogdial();
  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 /*----------------------------------------------------------------------
  33     CreateTask_spytask
  34 -----------------------------------------------------------------------*/
  35 void CreateTask_spytask()
  36 {
  37 //    *(int*)0xd20b0994 = 0x4d0002;
  38 
  39     _CreateTask("SpyTask", 0x19, 0x2000, spytask, 0);
  40 }
  41 
  42 //unsigned rbval=0;
  43 void task_blinker()
  44 {
  45 #if 0
  46     unsigned v=*(volatile unsigned *)(0x9808);
  47     unsigned pat=0;
  48     if(v & 0x80000){
  49         pat |=1;
  50     }
  51     if(v & 0x100000){
  52         pat |=2;
  53     }
  54     if(v & 0x200000){
  55         pat |=4;
  56     }
  57     if(v & 0x400000){
  58         pat |=8;
  59     }
  60     if(v & 0x800000){
  61         pat |=0x10;
  62     }
  63     while(1) {
  64         int i;
  65         for(i=0;i<5;i++) {
  66             *(volatile int*)0xd20b0994 = 0x4d0002;
  67             if((pat >> i) & 1) {
  68                 msleep(1000);
  69             } else {
  70                 msleep(250);
  71             }
  72             *(volatile int*)0xd20b0994 = 0x4c0003;
  73             msleep(500);
  74         }
  75         msleep(5000);
  76     }
  77 #endif
  78 #if 0
  79     int delay=1000;
  80     if(rbval == 0x12345678) {
  81         delay=100;
  82     }
  83     while(1) {
  84         *(volatile int*)0xd20b0994 = 0x4d0002;
  85         msleep(delay);
  86         *(volatile int*)0xd20b0994 = 0x4c0003;
  87         msleep(delay);
  88     }
  89 #endif
  90     while(1) {
  91         *(volatile int*)0xd20b0994 = 0x4d0002;
  92         msleep(250);
  93         *(volatile int*)0xd20b0994 = 0x4c0003;
  94         msleep(250);
  95     }
  96 }
  97 
  98 void CreateTask_blinker()
  99 {
 100     _CreateTask("blinker", 0x19, 0x200, task_blinker, 0);
 101 }
 102 
 103 
 104 
 105 /*
 106     *** TEMPORARY? workaround ***
 107     Init stuff to avoid asserts on cameras running DryOS r54+
 108     https://chdk.setepontos.com/index.php?topic=12516.0
 109     Execute this only once
 110  */
 111 void init_required_fw_features(void) {
 112    extern void _init_focus_eventflag();
 113    extern void _init_nd_eventflag();
 114 //   extern void _init_nd_semaphore();
 115     //extern void _init_zoom_semaphore(); // for MoveZoomLensWithPoint
 116 
 117     _init_focus_eventflag();
 118     _init_nd_eventflag();
 119     // for MoveIrisWithAv, based on fc3d1a74 (but without registers eventprocs)
 120     extern int av_override_semaphore;
 121     extern int _CreateBinarySemaphoreStrictly(int x, int y);
 122     av_override_semaphore = _CreateBinarySemaphoreStrictly(0,0);
 123 //    _init_nd_semaphore();
 124 }
 125 ///*----------------------------------------------------------------------
 126 // Pointer to stack location where jogdial task records previous and current
 127 // jogdial positions
 128 // short *jog_position;
 129 
 130 /*----------------------------------------------------------------------
 131     boot()
 132 
 133     Main entry point for the CHDK code
 134 -----------------------------------------------------------------------*/
 135 
 136 /*************************************************************/
 137 // -f=chdk -s=0xfc02000d -c=33
 138 void __attribute__((naked,noinline)) boot() {
 139     asm volatile (
 140 "    ldr.w   sp, =0x80010000\n"
 141 "    bl      sub_fc020064\n"
 142 "    ldr     r2, =0xc0242010\n"
 143 "    ldr     r1, [r2]\n"
 144 "    orr     r1, r1, #1\n"
 145 "    str     r1, [r2]\n"
 146 "    ldr     r0, =0xfcc64f9c\n"
 147 "    ldr     r1, =0x010c1000\n"
 148 "    ldr     r3, =0x010df808\n"
 149 "loc_fc020024:\n"
 150 "    cmp     r1, r3\n"
 151 "    itt     lo\n"
 152 "    ldrlo   r2, [r0], #4\n"
 153 "    strlo   r2, [r1], #4\n"
 154 "    blo     loc_fc020024\n"
 155 // Install CreateTask patch
 156 // use half words in case source or destination not word aligned
 157         "adr     r0, patch_CreateTask\n"    // src: Patch data
 158         "ldr     r1, =hook_CreateTask\n"    // dest: Address to patch (hook_ has thumb bit off)
 159         "add     r2, r0, #8\n" // two words
 160 "task_hook_loop:\n"
 161         "ldrh   r3, [r0],#2\n"
 162         "strh   r3, [r1],#2\n"
 163         "cmp    r0,r2\n"
 164         "blo    task_hook_loop\n"
 165 "    ldr     r0, =0x010c1000\n"
 166 "    ldr     r1, =0x0001e808\n"
 167 "    bl      sub_fc1194ee\n"
 168 "    ldr     r0, =0xfcc3dfc0\n"
 169 "    ldr     r1, =0x00008000\n"
 170 "    ldr     r3, =0x0002efdc\n"
 171 "loc_fc020040:\n"
 172 "    cmp     r1, r3\n"
 173 "    itt     lo\n"
 174 "    ldrlo   r2, [r0], #4\n"
 175 "    strlo   r2, [r1], #4\n"
 176 "    blo     loc_fc020040\n"
 177 "    ldr     r3, =0x0002efdc\n"
 178 "    ldr     r1, =0x0035bb28\n"
 179 "    mov.w   r2, #0\n"
 180 "loc_fc020056:\n"
 181 "    cmp     r3, r1\n"
 182 "    it      lo\n"
 183 "    strlo   r2, [r3], #4\n"
 184 "    blo     loc_fc020056\n"
 185 //"    b.w     loc_fc05d050\n"
 186 "    b.w     sub_fc05d050_my\n"
 187         "patch_CreateTask:\n"
 188         "ldr.w   pc, [pc,#0]\n"             // Do jump to absolute address CreateTask_my
 189         ".long   CreateTask_my + 1\n"           // has to be a thumb address
 190     );
 191 }
 192 
 193 /*************************************************************/
 194 void __attribute__((naked,noinline)) CreateTask_my() {
 195 //    *(int*)0xd20b0994 = 0x4d0002;
 196 asm volatile (
 197 "    push   {r0}\n"
 198 //R3 = Pointer to task function to create
 199 
 200 "    ldr     r0, =task_CaptSeq\n"       // DryOS original code function ptr.
 201 "    cmp     r0, r3\n"                  // is the given taskptr equal to our searched function?
 202 "    itt     eq\n"                      // EQ block
 203 "    ldreq   r3, =capt_seq_task\n"      // if so replace with our task function base ptr.
 204 "    orreq   r3, #1\n"                  // make sure it's a thumb address (may not be needed?)
 205 "    beq     exitHook\n"                // below compares not necessary if this check has found something.
 206 
 207 
 208 // Appears to not be needed for sx700hs
 209 
 210 #if 0
 211 "    LDR     R0, =task_ExpDrv\n"
 212 "    CMP     R0, R3\n"
 213 "    itt     eq\n"
 214 "    LDREQ   R3, =exp_drv_task\n"
 215 "    orreq   r3, #1\n"
 216 "    BEQ     exitHook\n"
 217 #endif
 218 
 219 /*
 220 "    LDR     R0, =task_DvlpSeqTask\n"
 221 "    CMP     R0, R3\n"
 222 "    itt     eq\n"
 223 "    LDREQ   R3, =developseq_task\n"
 224 "    orreq   r3, #1\n"
 225 "    BEQ     exitHook\n"
 226 */
 227 
 228 "    ldr     r0, =task_FileWrite\n"
 229 "    cmp     r0, r3\n"
 230 "    itt     eq\n"
 231 "    ldreq   r3, =filewritetask\n"
 232 "    orreq   r3, #1\n"
 233 "    beq     exitHook\n"
 234 
 235 /*
 236 "    LDR     R0, =task_MovieRecord\n"
 237 "    CMP     R0, R3\n"
 238 "    itt     eq\n"
 239 "    LDREQ   R3, =movie_record_task\n"
 240 "    BEQ     exitHook\n"
 241 
 242 "    LDR     R0, =task_LiveImageTask\n"
 243 "    CMP     R0, R3\n"
 244 "    itt     eq\n"
 245 "    LDREQ   R3, =liveimage_task\n"
 246 "    BEQ     exitHook\n"
 247 */
 248 
 249 "    ldr     r0, =task_InitFileModules\n"
 250 "    cmp     r0, r3\n"
 251 "    itt     eq\n"
 252 "    ldreq   r3, =init_file_modules_task\n"
 253 "    orreq   r3, #1\n"
 254 
 255 "exitHook:\n" 
 256 
 257 // restore overwritten register(s)
 258 "    pop    {r0}\n"
 259 // Execute overwritten instructions from original code, then jump to firmware
 260 // NOTE number of instructions duplicated here depends on size of original ROM code
 261 // instructions. Must replace 8 bytes!
 262 "    stmdb   sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, lr}\n"
 263 "    mov     r4, r0\n"
 264 "    ldr     r0, =0x0000815c\n"
 265 "    ldr.w   pc, =(hook_CreateTask + 8 + 1) \n"  // Continue in firmware
 266 ".ltorg\n"
 267 );
 268  
 269 }
 270 
 271 // -f=chdk -s=0xfc05d051 -c=60
 272 void __attribute__((naked,noinline)) sub_fc05d050_my() {
 273     asm volatile (
 274 "    push    {r4, lr}\n"
 275 #if defined(CHDK_NOT_IN_CANON_HEAP)
 276     "ldr     r4, =0x0035bb28\n"         // heap start, modify here
 277 #else
 278     "ldr     r4, =new_sa\n"             // +
 279     "ldr     r4, [r4]\n"                // +
 280 #endif
 281 "    sub     sp, #0x78\n"
 282 "    ldr     r0, =0x006ce000\n"
 283 "    ldr     r1, =0x0008fd8c\n"
 284 "    subs    r0, r0, r4\n"
 285 "    cmp     r0, r1\n"
 286 "    bhs     loc_fc05d062\n"
 287 "loc_fc05d060:\n"
 288 "    b       loc_fc05d060\n"
 289 "loc_fc05d062:\n"
 290 "    ldr     r1, =0x00008074\n"
 291 "    mov.w   r0, #0x80000\n"
 292 "    str     r0, [r1]\n"
 293 "    ldr     r1, =0x00008078\n"
 294 "    ldr     r0, =0x42a21000\n"
 295 "    str     r0, [r1]\n"
 296 "    ldr     r1, =0x0000807c\n"
 297 "    ldr     r0, =0x42a23000\n"
 298 "    str     r0, [r1]\n"
 299 "    movs    r1, #0x78\n"
 300 "    mov     r0, sp\n"
 301 "    blx     sub_fc29b568\n" // j_bzero
 302 "    ldr     r0, =0x0062e000\n"
 303 "    mov.w   r1, #0xa0000\n"
 304 "    stm.w   sp, {r0, r1, r4}\n"
 305 "    ldr     r1, =0x00622274\n" //  *"t"b"
 306 "    subs    r2, r1, r4\n"
 307 "    strd    r2, r1, [sp, #0xc]\n"
 308 "    str     r0, [sp, #0x14]\n"
 309 "    movs    r0, #0x22\n"
 310 "    str     r0, [sp, #0x18]\n"
 311 "    movs    r0, #0x98\n"
 312 "    str     r0, [sp, #0x1c]\n"
 313 "    movw    r0, #0x24c\n"
 314 "    str     r0, [sp, #0x20]\n"
 315 "    movs    r0, #0xfa\n"
 316 "    str     r0, [sp, #0x24]\n"
 317 "    movs    r0, #0xe8\n"
 318 "    str     r0, [sp, #0x28]\n"
 319 "    movs    r0, #0x85\n"
 320 "    str     r0, [sp, #0x2c]\n"
 321 "    movs    r0, #0x40\n"
 322 "    str     r0, [sp, #0x30]\n"
 323 "    movs    r0, #4\n"
 324 "    str     r0, [sp, #0x34]\n"
 325 "    movs    r0, #0\n"
 326 "    str     r0, [sp, #0x38]\n"
 327 "    movs    r0, #0x10\n"
 328 "    str     r0, [sp, #0x5c]\n"
 329 "    movs    r2, #0\n"
 330 "    lsls    r0, r0, #8\n"
 331 "    str     r0, [sp, #0x60]\n"
 332 //"    ldr     r1, =0xfc05d1e1\n"
 333     "ldr     r1, =sub_fc05d1e0_my\n"    // HHH -> continue here (init_task)
 334 "    asrs    r0, r0, #4\n"
 335 "    str     r0, [sp, #0x64]\n"
 336 "    lsls    r0, r0, #5\n"
 337 "    str     r0, [sp, #0x68]\n"
 338 "    mov     r0, sp\n"
 339 "    blx     sub_fc29abb0\n"
 340 "    add     sp, #0x78\n"
 341 "    pop     {r4, pc}\n"
 342     ".ltorg\n"
 343 
 344     );
 345 
 346 
 347 }
 348 
 349 
 350 //fc04f324?  -f=chdk -s=0xfc05d1e1 -c=54
 351 void __attribute__((naked,noinline)) sub_fc05d1e0_my() {
 352     asm volatile (
 353 "    push    {r4, lr}\n"
 354 "    ldr     r4, =0xfc05d28c\n" //  *"/_term"
 355 "    bl      sub_fc05e4a8\n"
 356 "    ldr     r0, =0x000080ec\n"
 357 "    ldr     r1, [r0]\n"
 358 "    ldr     r0, =0x00008074\n"
 359 "    ldr     r0, [r0]\n"
 360 "    adds    r0, #0x10\n"
 361 "    cmp     r1, r0\n"
 362 "    bhs     loc_fc05d1fc\n"
 363 "    ldr     r0, =0xfc05d29c\n" //  *"USER_MEM size checking"
 364 "    bl      sub_fc05d274\n"
 365 "loc_fc05d1fc:\n"
 366 "    bl      sub_fc1195c8\n"
 367 "    ldr     r3, =0x80000800\n"
 368 // bad capdis output
 369 //"    mov.w   r1, #-0x80000000\n"
 370 //"    mov.w   r2, #-0x11111112\n"
 371     "mov.w   r1, #0x80000000\n" //2147483648
 372     "mov.w   r2, #0xeeeeeeee\n"
 373 "loc_fc05d20a:\n"
 374 "    stm     r1!, {r2}\n"
 375 "    cmp     r1, r3\n"
 376 "    blo     loc_fc05d20a\n"
 377 "    bl      sub_fc1195da\n"
 378 "    bl      sub_fc11961c\n"
 379 "    cmp     r0, #0\n"
 380 "    bge     loc_fc05d222\n"
 381 "    ldr     r0, =0xfc05d2b8\n" //  *"dmSetup"
 382 "    bl      sub_fc05d274\n"
 383 "loc_fc05d222:\n"
 384 "    bl      sub_fc05da54\n"
 385 "    cmp     r0, #0\n"
 386 "    bge     loc_fc05d230\n"
 387 "    ldr     r0, =0xfc05d2c0\n" //  *"termDriverInit"
 388 "    bl      sub_fc05d274\n"
 389 "loc_fc05d230:\n"
 390 "    mov     r0, r4\n"
 391 "    bl      sub_fc05dae8\n"
 392 "    cmp     r0, #0\n"
 393 "    bge     loc_fc05d240\n"
 394 "    ldr     r0, =0xfc05d2d0\n" //  *"termDeviceCreate"
 395 "    bl      sub_fc05d274\n"
 396 "loc_fc05d240:\n"
 397 "    mov     r0, r4\n"
 398 "    bl      sub_fc05d418\n"
 399 "    cmp     r0, #0\n"
 400 "    bge     loc_fc05d250\n"
 401 "    ldr     r0, =0xfc05d2e4\n" //  *"stdioSetup"
 402 "    bl      sub_fc05d274\n"
 403 "loc_fc05d250:\n"
 404 "    bl      sub_fc05d55c\n"
 405 "    cmp     r0, #0\n"
 406 "    bge     loc_fc05d25e\n"
 407 "    ldr     r0, =0xfc05d2f0\n" //  *"stdlibSetup"
 408 "    bl      sub_fc05d274\n"
 409 "loc_fc05d25e:\n"
 410 "    bl      sub_fc060920\n"
 411 "    cmp     r0, #0\n"
 412 "    bge     loc_fc05d26c\n"
 413 "    ldr     r0, =0xfc05d2fc\n" //  *"extlib_setup"
 414 "    bl      sub_fc05d274\n"
 415 "loc_fc05d26c:\n"
 416 "    pop.w   {r4, lr}\n"
 417 "    b.w     sub_fc05d5e6_my\n"
 418     ".ltorg\n"
 419     );
 420 }
 421 
 422 // -f=chdk -s=0xfc05d5e7 -c=27
 423 void __attribute__((naked,noinline)) sub_fc05d5e6_my() {
 424     asm volatile (
 425 "    push    {r3, lr}\n"
 426 "    bl      sub_fc05d700\n"
 427 "    bl      sub_fc0a6f3c\n"
 428 "    cbnz    r0, loc_fc05d5fc\n"
 429 "    bl      sub_fc07bf42\n" // IsNormalCameraMode_FW
 430 "    cbz     r0, loc_fc05d5fc\n"
 431 "    movs    r0, #1\n"
 432 "    b       loc_fc05d5fe\n"
 433 "loc_fc05d5fc:\n"
 434 "    movs    r0, #0\n"
 435 "loc_fc05d5fe:\n"
 436 "    bl      sub_fc07a1f0\n"
 437 "    cbnz    r0, loc_fc05d60a\n"
 438 "    bl      sub_fc05d6ee\n"
 439 "loc_fc05d608:\n"
 440 "    b       loc_fc05d608\n"
 441 "loc_fc05d60a:\n"
 442 "    blx     sub_fc29ac08\n"
 443 "    ldr     r1, =0x006ce000\n"
 444 "    movs    r0, #0\n"
 445 "    bl      sub_fc30f8b8\n"
 446 "    blx     sub_fc29b160\n"
 447 "    movs    r3, #0\n"
 448 "    str     r3, [sp]\n"
 449 //"    ldr     r3, =0xfc05d581\n" //  task_Startup
 450     "ldr     r3, =task_Startup_my\n"
 451 "    movs    r2, #0\n"
 452 "    movs    r1, #0x19\n"
 453 "    ldr     r0, =0xfc05d638\n" //  *"Startup"
 454 //"    blx     sub_fc29b190\n" // j_CreateTask
 455 "    bl      _CreateTask\n"
 456 "    movs    r0, #0\n"
 457 "    pop     {r3, pc}\n"
 458     ".ltorg\n"
 459     );
 460 
 461 }
 462 
 463 
 464 
 465 // task_Startup
 466 //  -f=chdk -s=task_Startup -c=26
 467 //"    ldr     r3, =0xfc05f3f1\n" //  task_Startup
 468 void __attribute__((naked,noinline)) task_Startup_my() {
 469     asm volatile (
 470 "    push    {r4, lr}\n"
 471 "    bl      sub_fc11a940\n"
 472 "    bl      sub_fc05d6cc\n"
 473 //"    bl      sub_fc05d84c\n" //  nullsub
 474 "    bl      sub_fc0c8f3c\n"
 475 "bl sub_fc0945b5\n" // sd reset, see fc09461e task_SD1stInit
 476 //"    bl      sub_fc05d8a2\n"  // StartDiskboot
 477 "    bl      sub_fc0871d2\n"
 478 "    bl      sub_fc11a9d8\n"
 479 "    bl      sub_fc05d994\n"
 480 "    bl      sub_fc05d7e0\n"
 481 "    bl      sub_fc0c8f7a\n"
 482 "    bl      sub_fc0a6c8c\n"
 483 "    bl      sub_fc11a9de\n"
 484 //"    bl      sub_fc07a0e2\n"
 485 "    bl      sub_fc07a0e2_my\n" // create physw
 486 "    bl      CreateTask_spytask\n"
 487 "    bl      init_required_fw_features\n"
 488 //"    bl      CreateTask_blinker\n"
 489 "    bl      sub_fc25b37c\n"
 490 "    bl      sub_fc11a9f4\n"
 491 "    bl      sub_fc0a6c28\n"
 492 "    bl      sub_fc11a6f8\n"
 493 "    bl      sub_fc0a6dec\n"
 494 "    bl      sub_fc0c8eee\n"
 495 "    bl      sub_fc11a6b4\n"
 496 "    bl      sub_fc05d998\n"
 497 "    bl      sub_fc300f40\n"
 498 "    bl      sub_fc11a688\n"
 499 "    pop.w   {r4, lr}\n"
 500 //"    b.w     loc_fc11a916\n"
 501 "    ldr     pc,=0xfc11a917\n"
 502     ".ltorg\n"
 503     );
 504 }
 505 
 506 //taskcreate_physw  -f=chdk -s=0xfc07a0e3 -c=18
 507 void __attribute__((naked,noinline)) sub_fc07a0e2_my() {
 508 //    *(int*)0xd20b0994 = 0x4d0002;
 509     asm volatile (
 510 "    push    {r3, r4, r5, lr}\n"
 511 "    bl      sub_fc06f9d4\n"
 512 "    bl      sub_fc07bec0\n" // IsFactoryMode_FW
 513 "    cbnz    r0, loc_fc07a0f2\n"
 514 "    bl      sub_fc06f978\n" // OpLog.Start_FW
 515 "loc_fc07a0f2:\n"
 516 "    ldr     r4, =0x000082c8\n" //  physw_run
 517 "    ldr     r0, [r4, #4]\n"
 518 "    cmp     r0, #0\n"
 519 "    bne     loc_fc07a10e\n"
 520 "    movs    r3, #0\n"
 521 "    str     r3, [sp]\n"
 522 //"    ldr     r3, =0xfc07a0bd\n" //  task_PhySw
 523        "    ldr     r3, =mykbd_task\n"
 524 "    movs    r1, #0x17\n"
 525 "    ldr     r0, =0xfc07a13c\n" //  *"PhySw"
 526 //"    movw    r2, #0x800\n"
 527 "    movw    r2, #0x2000\n" // increased stack size
 528 "    blx     sub_fc29b450\n" // j_CreateTaskStrictly
 529 "    str     r0, [r4, #4]\n"
 530 "loc_fc07a10e:\n"
 531 "    pop     {r3, r4, r5, pc}\n"
 532         ".ltorg\n"
 533     );
 534 }
 535 
 536  //-f=chdk -s=task_InitFileModules -c=16
 537 // task_InitFileModules 0xfc0aa0f9
 538 void __attribute__((naked,noinline)) init_file_modules_task() { 
 539     asm volatile (
 540 "    push    {r4, r5, r6, lr}\n"
 541 "    bl      sub_fc0ac1bc\n"
 542 "    movs    r4, r0\n"
 543 "    movw    r5, #0x5006\n"
 544 "    beq     loc_fc0aa10e\n"
 545 "    movs    r1, #0\n"
 546 "    mov     r0, r5\n"
 547 "    bl      _PostLogicalEventToUI\n"
 548 "loc_fc0aa10e:\n"
 549 "    bl      sub_fc0ac1e6\n"
 550 "    BL      core_spytask_can_start\n" // + CHDK: Set "it's-safe-to-start" flag for spytask
 551 "    cmp     r4, #0\n"
 552 "    bne     loc_fc0aa122\n"
 553 "    mov     r0, r5\n"
 554 "    pop.w   {r4, r5, r6, lr}\n"
 555 "    movs    r1, #0\n"
 556 "    b.w     _PostLogicalEventToUI\n"
 557 "loc_fc0aa122:\n"
 558 "    pop     {r4, r5, r6, pc}\n"
 559 "    .ltorg\n"
 560     );
 561 
 562 }
 563 
 564 
 565 #ifdef CAM_HAS_JOGDIAL
 566 // jogdial override code called from kbd task
 567 // sx700v100d -f=chdk -s=kbd_p2_f -c=77
 568 // kbd_p2_f 0xfc079e89
 569 void __attribute__((naked,noinline)) kbd_p2_f_my() { 
 570    asm volatile(
 571 "    push.w  {r4, r5, r6, r7, r8, lr}\n"
 572 "    ldr     r6, =0x000308d4\n"
 573 "    sub     sp, #0x18\n"
 574 "    add     r7, sp, #8\n"
 575 "    subs    r6, #0xc\n"
 576 "    b       loc_fc079eca\n"
 577 "loc_fc079e96:\n"
 578 "    ldr     r1, =0x000308d4\n"
 579 "    add     r3, sp, #8\n"
 580 "    ldrb.w  r0, [sp, #4]\n"
 581 "    add     r2, sp, #0x14\n"
 582 "    subs    r1, #0x18\n"
 583 "    bl      sub_fc06e51c\n"
 584 "    cbnz    r0, loc_fc079eb0\n"
 585 "    ldr     r1, [sp, #0x14]\n"
 586 "    movs    r0, #0\n"
 587 "    bl      sub_fc079dfa\n"
 588 "loc_fc079eb0:\n"
 589 "    movs    r0, #2\n"
 590 "loc_fc079eb2:\n"
 591 "    ldr.w   r1, [r7, r0, lsl #2]\n"
 592 "    cbz     r1, loc_fc079ec2\n"
 593 "    ldr.w   r2, [r6, r0, lsl #2]\n"
 594 "    bics    r2, r1\n"
 595 "    str.w   r2, [r6, r0, lsl #2]\n"
 596 "loc_fc079ec2:\n"
 597 "    subs    r0, r0, #1\n"
 598 "    sxtb    r0, r0\n"
 599 "    cmp     r0, #0\n"
 600 "    bge     loc_fc079eb2\n"
 601 "loc_fc079eca:\n"
 602 "    ldr     r0, =0x000308d4\n"
 603 "    add     r1, sp, #4\n"
 604 "    subs    r0, #0xc\n"
 605 "    bl      sub_fc06e268\n"
 606 "    cmp     r0, #0\n"
 607 "    bne     loc_fc079e96\n"
 608 "    ldr.w   r8, =0x000308d4\n"
 609 "    movs    r4, #0\n"
 610 "loc_fc079ede:\n"
 611 "    movs    r5, #0\n"
 612 "    ldr.w   r0, [r6, r4, lsl #2]\n"
 613 "    ldr.w   r1, [r8, r4, lsl #2]\n"
 614 "    ands    r0, r1\n"
 615 "    str.w   r0, [r6, r4, lsl #2]\n"
 616 "    b       loc_fc079f36\n"
 617 "loc_fc079ef0:\n"
 618 "    lsrs    r0, r5\n"
 619 "    lsls    r0, r0, #0x1f\n"
 620 "    beq     loc_fc079f2e\n"
 621 "    ldr     r1, =0x000308d4\n"
 622 "    add.w   r0, r5, r4, lsl #5\n"
 623 "    add     r3, sp, #8\n"
 624 "    subs    r1, #0x18\n"
 625 "    add     r2, sp, #0x14\n"
 626 "    uxtb    r0, r0\n"
 627 "    bl      sub_fc06e51c\n"
 628 "    cbnz    r0, loc_fc079f12\n"
 629 "    ldr     r1, [sp, #0x14]\n"
 630 "    movs    r0, #1\n"
 631 "    bl      sub_fc079dfa\n"
 632 "loc_fc079f12:\n"
 633 "    mov     r0, r4\n"
 634 "    b       loc_fc079f2a\n"
 635 "loc_fc079f16:\n"
 636 "    ldr.w   r1, [r7, r0, lsl #2]\n"
 637 "    cbz     r1, loc_fc079f26\n"
 638 "    ldr.w   r2, [r6, r0, lsl #2]\n"
 639 "    bics    r2, r1\n"
 640 "    str.w   r2, [r6, r0, lsl #2]\n"
 641 "loc_fc079f26:\n"
 642 "    adds    r0, r0, #1\n"
 643 "    sxtb    r0, r0\n"
 644 "loc_fc079f2a:\n"
 645 "    cmp     r0, #3\n"
 646 "    blt     loc_fc079f16\n"
 647 "loc_fc079f2e:\n"
 648 "    ldr.w   r0, [r6, r4, lsl #2]\n"
 649 "    adds    r5, r5, #1\n"
 650 "    uxtb    r5, r5\n"
 651 "loc_fc079f36:\n"
 652 "    cmp     r0, #0\n"
 653 "    bne     loc_fc079ef0\n"
 654 "    adds    r4, r4, #1\n"
 655 "    sxtb    r4, r4\n"
 656 "    cmp     r4, #3\n"
 657 "    blt     loc_fc079ede\n"
 658 //"    bl      sub_fc06e104\n"
 659 "    bl      sub_fc06e104_my\n" // --->>
 660 "    add     sp, #0x18\n"
 661 "    pop.w   {r4, r5, r6, r7, r8, pc}\n"
 662 ".ltorg\n"
 663     );
 664 }
 665 
 666 //extern void handle_jogdial();
 667 //sx700100d -f=chdk -s=0xfc06e105 -c=9
 668 void __attribute__((naked,noinline)) sub_fc06e104_my() {
 669     asm volatile(
 670 "    push    {r4, lr}\n"
 671 "    ldr     r4, =0x00009334\n"
 672 "    ldr     r0, [r4, #8]\n"
 673 "    bl      sub_fc070a80\n"
 674 "    bl      sub_fc0e4168\n"
 675 "    ldr     r0, [r4, #0xc]\n"
 676 "    bl      sub_fc07099c\n"
 677 //"    pop.w   {r4, lr}\n"      // - (reordered below)
 678 //"    b.w     loc_fc06bf5e\n"  // - (reordered below)
 679 "    bl      handle_jogdial\n"  // +
 680 "    cmp     r0, #0\n"          // +
 681 "    beq     no_scroll\n"       // +
 682 "    bl      sub_fc06bf5e\n"    // handles scrollwheel(s), void function, no args
 683 "no_scroll:\n"                  // +
 684 "    pop     {r4, pc}\n"        // +
 685 ".ltorg\n"
 686     );
 687 }
 688 #endif

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