root/platform/sx700hs/sub/100e/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. sub_fc07a1f0_my
  12. task_Startup_my
  13. sub_fc07a0e2_my
  14. init_file_modules_task
  15. kbd_p2_f_my
  16. 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 // Adapted from sx60hs-100f for sx700hs-100e
 138 // -f=chdk -s=0xfc02000d -c=33
 139 void __attribute__((naked,noinline)) boot() {
 140 //    *(int*)0xd20b0884 = 0x4d0002;
 141     asm volatile ( // 0xfc02000c
 142 "    ldr.w   sp, =0x80010000\n"
 143 "    bl      sub_fc020064\n" 
 144 "    ldr     r2, =0xc0242010\n"
 145 "    ldr     r1, [r2]\n"
 146 "    orr     r1, r1, #1\n"
 147 "    str     r1, [r2]\n"
 148 "    ldr     r0, =0xfcc64c5c\n"
 149 "    ldr     r1, =0x010c1000\n"
 150 "    ldr     r3, =0x010df808\n"
 151 "loc_fc020024:\n"
 152 "    cmp     r1, r3\n"
 153 "    itt     lo\n"
 154 "    ldrlo   r2, [r0], #4\n"
 155 "    strlo   r2, [r1], #4\n"
 156 "    blo     loc_fc020024\n"
 157 // Install CreateTask patch
 158 // use half words in case source or destination not word aligned
 159         "adr     r0, patch_CreateTask\n"    // src: Patch data
 160         "ldr     r1, =hook_CreateTask\n"    // dest: Address to patch (hook_ has thumb bit off)
 161         "add     r2, r0, #8\n" // two words
 162 "task_hook_loop:\n"
 163         "ldrh   r3, [r0],#2\n"
 164         "strh   r3, [r1],#2\n"
 165         "cmp    r0,r2\n"
 166         "blo    task_hook_loop\n"
 167 "    ldr     r0, =0x010c1000\n"
 168 "    ldr     r1, =0x0001e808\n"
 169 "    bl      sub_fc119422\n" 
 170 "    ldr     r0, =0xfcc3dc80\n"
 171 "    ldr     r1, =0x00008000\n"
 172 "    ldr     r3, =0x0002efdc\n"
 173 "loc_fc020040:\n"
 174 "    cmp     r1, r3\n"
 175 "    itt     lo\n"
 176 "    ldrlo   r2, [r0], #4\n"
 177 "    strlo   r2, [r1], #4\n"
 178 "    blo     loc_fc020040\n"
 179 "    ldr     r3, =0x0002efdc\n"
 180 "    ldr     r1, =0x0035bb28\n"
 181 "    mov.w   r2, #0\n"
 182 "loc_fc020056:\n"
 183 "    cmp     r3, r1\n"
 184 "    it      lo\n"
 185 "    strlo   r2, [r3], #4\n"
 186 "    blo     loc_fc020056\n"
 187 //"    b.w     loc_fc05d050\n"
 188 "    b.w     sub_fc05d050_my\n" // continue 
 189 
 190         "patch_CreateTask:\n"
 191         "ldr.w   pc, [pc,#0]\n"             // Do jump to absolute address CreateTask_my
 192         ".long   CreateTask_my + 1\n"           // has to be a thumb address
 193 
 194  
 195 );
 196 }
 197 
 198 /*************************************************************/
 199 void __attribute__((naked,noinline)) CreateTask_my() {
 200 //    *(int*)0xd20b0994 = 0x4d0002;
 201 asm volatile (
 202 "    push   {r0}\n"
 203 //R3 = Pointer to task function to create
 204 
 205 "    ldr     r0, =task_CaptSeq\n"       // DryOS original code function ptr.
 206 "    cmp     r0, r3\n"                  // is the given taskptr equal to our searched function?
 207 "    itt     eq\n"                      // EQ block
 208 "    ldreq   r3, =capt_seq_task\n"      // if so replace with our task function base ptr.
 209 "    orreq   r3, #1\n"                  // make sure it's a thumb address (may not be needed?)
 210 "    beq     exitHook\n"                // below compares not necessary if this check has found something.
 211 
 212 
 213 // Appears to not be needed for sx700hs
 214 
 215 #if 0
 216 "    LDR     R0, =task_ExpDrv\n"
 217 "    CMP     R0, R3\n"
 218 "    itt     eq\n"
 219 "    LDREQ   R3, =exp_drv_task\n"
 220 "    orreq   r3, #1\n"
 221 "    BEQ     exitHook\n"
 222 #endif
 223 
 224 /*
 225 "    LDR     R0, =task_DvlpSeqTask\n"
 226 "    CMP     R0, R3\n"
 227 "    itt     eq\n"
 228 "    LDREQ   R3, =developseq_task\n"
 229 "    orreq   r3, #1\n"
 230 "    BEQ     exitHook\n"
 231 */
 232 
 233 "    ldr     r0, =task_FileWrite\n"
 234 "    cmp     r0, r3\n"
 235 "    itt     eq\n"
 236 "    ldreq   r3, =filewritetask\n"
 237 "    orreq   r3, #1\n"
 238 "    beq     exitHook\n"
 239 
 240 /*
 241 "    LDR     R0, =task_MovieRecord\n"
 242 "    CMP     R0, R3\n"
 243 "    itt     eq\n"
 244 "    LDREQ   R3, =movie_record_task\n"
 245 "    BEQ     exitHook\n"
 246 
 247 "    LDR     R0, =task_LiveImageTask\n"
 248 "    CMP     R0, R3\n"
 249 "    itt     eq\n"
 250 "    LDREQ   R3, =liveimage_task\n"
 251 "    BEQ     exitHook\n"
 252 */
 253 
 254 "    ldr     r0, =task_InitFileModules\n"
 255 "    cmp     r0, r3\n"
 256 "    itt     eq\n"
 257 "    ldreq   r3, =init_file_modules_task\n"
 258 "    orreq   r3, #1\n"
 259 
 260 "exitHook:\n" 
 261 
 262 // restore overwritten register(s)
 263 "    pop    {r0}\n"
 264 // Execute overwritten instructions from original code, then jump to firmware
 265 // NOTE number of instructions duplicated here depends on size of original ROM code
 266 // instructions. Must replace 8 bytes!
 267 "    stmdb   sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, lr}\n"
 268 "    mov     r4, r0\n"
 269 "    ldr     r0, =0x0000815c\n"
 270 "    ldr.w   pc, =(hook_CreateTask + 8 + 1) \n"  // Continue in firmware
 271 ".ltorg\n"
 272 );
 273  
 274 }
 275 
 276 //fc04f194? fc05d050 
 277 // -f=chdk -s=0xfc05d051 -c=60
 278 void __attribute__((naked,noinline)) sub_fc05d050_my() {
 279 //*(int*)0xd20b0994 = 0x4d0002;
 280 
 281 /* no gpio checks needed    if (*(int*)(0xd20b0000 + 0x10 * 4) & 0x10000) {
 282         // see sub_fc060338, sub_fc06082a
 283         // GPIO 0x10 (aka ON/OFF button) is not pressed -> play
 284         *(int*)(0x970c+0x4) = 0x200000;
 285     }
 286     else {
 287         // GPIO 0x10 is pressed -> rec
 288         *(int*)(0x970c+0x4) = 0x100000;
 289     }
 290 */
 291     asm volatile (
 292     "push    {r4, lr}\n"
 293 
 294 #if defined(CHDK_NOT_IN_CANON_HEAP)
 295     "ldr     r4, =0x0035bb28\n"         // heap start, modify here
 296 #else
 297     "ldr     r4, =new_sa\n"             // +
 298     "ldr     r4, [r4]\n"                // +
 299 #endif
 300 "    sub     sp, #0x78\n"
 301 "    ldr     r0, =0x006ce000\n"
 302 "    ldr     r1, =0x0008fd8c\n"
 303 "    subs    r0, r0, r4\n"
 304 "    cmp     r0, r1\n"
 305 "    bhs     loc_fc05d062\n"
 306 "loc_fc05d060:\n"
 307 "    b       loc_fc05d060\n"
 308 "loc_fc05d062:\n"
 309 "    ldr     r1, =0x00008074\n"
 310 "    mov.w   r0, #0x80000\n"
 311 "    str     r0, [r1]\n"
 312 "    ldr     r1, =0x00008078\n"
 313 //"    ldr     r0, =0x42a41000\n" // Typo?
 314 "    ldr     r0, =0x42a21000\n"
 315 "    str     r0, [r1]\n"
 316 "    ldr     r1, =0x0000807c\n"
 317 "    ldr     r0, =0x42a23000\n"
 318 "    str     r0, [r1]\n"
 319 "    movs    r1, #0x78\n"
 320 "    mov     r0, sp\n"
 321 "    blx     sub_fc29b46c\n" 
 322 "    ldr     r0, =0x0062e000\n"
 323 "    mov.w   r1, #0xa0000\n"
 324 "    stm.w   sp, {r0, r1, r4}\n"
 325 "    ldr     r1, =0x00622274\n" //  *"t"b"
 326 "    subs    r2, r1, r4\n"
 327 "    strd    r2, r1, [sp, #0xc]\n"
 328 "    str     r0, [sp, #0x14]\n"
 329 "    movs    r0, #0x22\n"
 330 "    str     r0, [sp, #0x18]\n"
 331 "    movs    r0, #0x98\n"
 332 "    str     r0, [sp, #0x1c]\n"
 333 "    movw    r0, #0x24c\n"
 334 "    str     r0, [sp, #0x20]\n"
 335 "    movs    r0, #0xfa\n"
 336 "    str     r0, [sp, #0x24]\n"
 337 "    movs    r0, #0xe8\n"
 338 "    str     r0, [sp, #0x28]\n"
 339 "    movs    r0, #0x85\n"
 340 "    str     r0, [sp, #0x2c]\n"
 341 "    movs    r0, #0x40\n"
 342 "    str     r0, [sp, #0x30]\n"
 343 "    movs    r0, #4\n"
 344 "    str     r0, [sp, #0x34]\n"
 345 "    movs    r0, #0\n"
 346 "    str     r0, [sp, #0x38]\n"
 347 "    movs    r0, #0x10\n"
 348 "    str     r0, [sp, #0x5c]\n"
 349 "    movs    r2, #0\n"
 350 "    lsls    r0, r0, #8\n"
 351 "    str     r0, [sp, #0x60]\n"
 352 //"    ldr     r1, =0xfc05d1e1\n"
 353     "ldr     r1, =sub_fc05d1e0_my\n"    // HHH -> continue here (init_task)
 354 "    asrs    r0, r0, #4\n"
 355 "    str     r0, [sp, #0x64]\n"
 356 "    lsls    r0, r0, #5\n"
 357 "    str     r0, [sp, #0x68]\n"
 358 "    mov     r0, sp\n"
 359 "    blx     sub_fc29aab4\n" 
 360 "    add     sp, #0x78\n"
 361 "    pop     {r4, pc}\n"
 362     ".ltorg\n"
 363 
 364     );
 365 
 366 
 367 }
 368 
 369 
 370 //fc04f324?  -f=chdk -s=0xfc05d1e1 -c=54
 371 void __attribute__((naked,noinline)) sub_fc05d1e0_my() {
 372 
 373 //*(int*)0xd20b0994 = 0x4d0002;
 374     asm volatile (
 375 "    push    {r4, lr}\n"
 376 "    ldr     r4, =0xfc05d28c\n" //  *"/_term"
 377 "    bl      sub_fc05e4a8\n"
 378 "    ldr     r0, =0x000080ec\n"
 379 "    ldr     r1, [r0]\n"
 380 "    ldr     r0, =0x00008074\n"
 381 "    ldr     r0, [r0]\n"
 382 "    adds    r0, #0x10\n"
 383 "    cmp     r1, r0\n"
 384 "    bhs     loc_fc05d1fc\n"
 385 "    ldr     r0, =0xfc05d29c\n" //  *"USER_MEM size checking"
 386 "    bl      sub_fc05d274\n"
 387 "loc_fc05d1fc:\n"
 388 "    bl      sub_fc1194fc\n"
 389 "    ldr     r3, =0x80000800\n"
 390 // bad capdis output
 391 //
 392     "mov.w   r1, #0x80000000\n" //2147483648
 393     "mov.w   r2, #0xeeeeeeee\n"
 394 "loc_fc05d20a:\n"
 395 "    stm     r1!, {r2}\n"
 396 "    cmp     r1, r3\n"
 397 "    blo     loc_fc05d20a\n"
 398 "    bl      sub_fc11950e\n"
 399 "    bl      sub_fc119550\n"
 400 "    cmp     r0, #0\n"
 401 "    bge     loc_fc05d222\n"
 402 "    ldr     r0, =0xfc05d2b8\n" //  *"dmSetup"
 403 "    bl      sub_fc05d274\n"
 404 "loc_fc05d222:\n"
 405 "    bl      sub_fc05da54\n"
 406 "    cmp     r0, #0\n"
 407 "    bge     loc_fc05d230\n"
 408 "    ldr     r0, =0xfc05d2c0\n" //  *"termDriverInit"
 409 "    bl      sub_fc05d274\n"
 410 "loc_fc05d230:\n"
 411 "   mov     r0, r4\n"
 412 "   bl      sub_fc05dae8\n"
 413 // led works here
 414 "    cmp     r0, #0\n"
 415 "    bge     loc_fc05d240\n"
 416 "    ldr     r0, =0xfc05d2d0\n" //  *"termDeviceCreate"
 417 "    bl      sub_fc05d274\n"
 418 "loc_fc05d240:\n"
 419 "    mov     r0, r4\n"
 420 "    bl      sub_fc05d418\n"
 421 // led works here
 422 "    cmp     r0, #0\n"
 423 "    bge     loc_fc05d250\n"
 424 "    ldr     r0, =0xfc05d2e4\n" //  *"stdioSetup"
 425 "    bl      sub_fc05d274\n"
 426 "loc_fc05d250:\n"
 427 "    bl      sub_fc05d55c\n"
 428 "    cmp     r0, #0\n"
 429 "    bge     loc_fc05d25e\n"
 430 "    ldr     r0, =0xfc05d2f0\n" //  *"stdlibSetup"
 431 "    bl      sub_fc05d274\n"
 432 "loc_fc05d25e:\n"
 433 "    bl      sub_fc060920\n"
 434 "    cmp     r0, #0\n"
 435 "    bge     loc_fc05d26c\n"
 436 "    ldr     r0, =0xfc05d2fc\n" //  *"extlib_setup"
 437 "    bl      sub_fc05d274\n"
 438 "loc_fc05d26c:\n"
 439 "    pop.w   {r4, lr}\n"
 440 //"    b.w     sub_fc05d5e6\n"
 441     "b.w     sub_fc05d5e6_my\n" // -> continue (taskcreate_startup)
 442     ".ltorg\n"
 443 
 444     );
 445 }
 446 
 447 // -f=chdk -s=0xfc05d5e7 -c=27
 448 void __attribute__((naked,noinline)) sub_fc05d5e6_my() {
 449 
 450 //*(int*)0xd20b0994 = 0x4d0002;
 451        
 452     asm volatile (
 453 "    push    {r3, lr}\n"
 454 "    bl      sub_fc05d700\n"
 455 "    bl      sub_fc0a6ee4\n"
 456 "    cbnz    r0, loc_fc05d5fc\n"
 457 "    bl      sub_fc07bf42\n" // IsNormalCameraMode_FW
 458 "    cbz     r0, loc_fc05d5fc\n"
 459 "    movs    r0, #1\n"
 460 "    b       loc_fc05d5fe\n"
 461 "loc_fc05d5fc:\n"
 462     "movs    r0, #0\n"
 463 "loc_fc05d5fe:\n"
 464 "    bl      sub_fc07a1f0\n"
 465 "    cbnz    r0, loc_fc05d60a\n"
 466 "    bl      sub_fc05d6ee\n"
 467 "loc_fc05d608:\n"
 468 "    b       loc_fc05d608\n"
 469 "loc_fc05d60a:\n"
 470 "    blx     sub_fc29ab0c\n"
 471 "    ldr     r1, =0x006ce000\n"
 472 "    movs    r0, #0\n"
 473 "    bl      sub_fc30f790\n"
 474 "    blx     sub_fc29b06c\n"
 475 "    movs    r3, #0\n"
 476 "    str     r3, [sp]\n"
 477 //"    ldr     r3, =0xfc05d581\n" //  task_Startup
 478     "ldr     r3, =task_Startup_my\n"
 479 "    movs    r2, #0\n"
 480 "    movs    r1, #0x19\n"
 481 "    ldr     r0, =0xfc05d638\n" //  *"Startup"
 482  /*                       // ###### turn led on
 483                         "push    {r4-r5}\n"
 484                         "ldr r4, =0x4d0002\n"
 485                         "ldr r5, =0xd20b0994\n"
 486                         "str r4, [r5]\n"
 487                         "pop     {r4-r5}\n"
 488 */
 489 //"    blx     sub_fc29b09c\n" // j_CreateTask
 490     "bl       _CreateTask\n"    // CreateTask
 491 "    movs    r0, #0\n"
 492 "    pop     {r3, pc}\n"
 493     ".ltorg\n"
 494     );
 495 
 496 }
 497 
 498 
 499 
 500 // Search for NotifyMask
 501 // override not needed
 502 // -f=chdk -s=0xfc07a1f1 -c=28
 503 #if 0
 504 void __attribute__((naked,noinline)) sub_fc07a1f0_my() {
 505     asm volatile (
 506 /*
 507     "stmdb   sp!, {r2, r3, r4, r5, r6, r7, r8, lr}\n"
 508     "mov.w   r8, #0\n"
 509     "mov     r7, r0\n"
 510     "mov     r6, r8\n"
 511     "bl      sub_fc0705ee\n" // nullsub
 512     "movs    r0, #16\n"
 513     "bl      sub_fc06fbde\n"
 514     "movs    r4, #1\n"
 515     "bic.w   r5, r4, r0\n"
 516     "movs    r0, #15\n"  
 517     "bl      sub_fc06fbde\n"    // reads GPIO (15)
 518     "bics    r4, r0\n"
 519     "cbz     r7, loc_fc0731f6\n"
 520     "orrs.w  r0, r5, r4\n"
 521     //"beq.n   loc_fc06037e\n"  // - this check fails and results in shutdown
 522     "loc_fc0731f6:\n"
 523     "bl      sub_fc0b9738\n"
 524     "movs    r3, #0\n"
 525     "mov     r2, r0\n"
 526     "strd    r8, r6, [sp]\n"
 527     "mov     r1, r4\n"
 528     "mov     r0, r5\n"
 529     //"bl      sub_fc06082a\n"  // - startupchecks
 530     //"bl      sub_fc060828\n"  // - nullsub
 531     "movs    r0, #1\n"
 532     "loc_fc073210:\n"
 533     "ldmia.w sp!, {r2, r3, r4, r5, r6, r7, r8, pc}\n"
 534 */
 535 "    push.w  {r2, r3, r4, r5, r6, r7, r8, lr}\n"
 536 "    mov     r7, r0\n"
 537 "    mov.w   r8, #0\n"
 538 "    bl      sub_fc06e01e\n"
 539 "    movs    r0, #0x10\n"
 540 "    bl      sub_fc06e6ea\n"
 541 "    movs    r4, #1\n"
 542 "    bic.w   r5, r4, r0\n"
 543 "    movs    r0, #0xf\n"
 544 "    bl      sub_fc06e6ea\n"
 545 "    bic.w   r6, r4, r0\n"
 546 "    movs    r0, #0x17\n"
 547 "    bl      sub_fc06e6ea\n"
 548 "    bics    r4, r0\n"
 549 "    cbz     r7, loc_fc07a226\n"
 550 "    orr.w   r0, r5, r6\n"
 551 "    orrs    r0, r4\n"
 552 //"    beq     loc_fc07a240\n"
 553 "loc_fc07a226:\n"
 554 "    bl      sub_fc0a6ee4\n"
 555 "    movs    r3, #0\n"
 556 "    mov     r2, r0\n"
 557 "    strd    r4, r8, [sp]\n"
 558 "    mov     r1, r6\n"
 559 "    mov     r0, r5\n"
 560 //"    bl      sub_fc06e022\n"
 561 //"    bl      sub_fc06e020\n"
 562 "    movs    r0, #1\n"
 563 "loc_fc07a240:\n"
 564 "    pop.w   {r2, r3, r4, r5, r6, r7, r8, pc}\n"
 565     ".ltorg\n"
 566     );
 567 }
 568 #endif
 569 
 570 // Done till here
 571 
 572 // task_Startup
 573 //  -f=chdk -s=task_Startup -c=26
 574 //"    ldr     r3, =0xfc05f3f1\n" //  task_Startup
 575 void __attribute__((naked,noinline)) task_Startup_my() {
 576 //    *(int*)0xd20b0994 = 0x4d0002;
 577     asm volatile (
 578 "    push    {r4, lr}\n"
 579 "    bl      sub_fc11a874\n"
 580 "    bl      sub_fc05d6cc\n"
 581 //"    bl      sub_fc05d84c\n"
 582 "    bl      sub_fc0c8edc\n"
 583 "bl sub_fc0945ad\n" //see 0xfc094615 task_SD1stInit in ROMCODE.dis
 584 //"    bl      sub_fc05d8a2\n" // nStartDiskBoot
 585 "    bl      sub_fc0871d2\n"
 586 "    bl      sub_fc11a90c\n"
 587 "    bl      sub_fc05d994\n"
 588 "    bl      sub_fc05d7e0\n"
 589 "    bl      sub_fc0c8f1a\n" 
 590 "    bl      sub_fc0a6c34\n"
 591 "    bl      sub_fc11a912\n"
 592 //"    bl      sub_fc07a0e2\n" // Canon FW
 593 "    bl      sub_fc07a0e2_my\n" // CHDK
 594 "    bl      CreateTask_spytask\n"
 595 "    bl      init_required_fw_features\n"
 596 //"    bl      CreateTask_blinker\n"
 597 "    bl      sub_fc25b2b0\n"
 598 "    bl      sub_fc11a928\n"
 599 "    bl      sub_fc0a6bd0\n"
 600 "    bl      sub_fc11a62c\n"
 601 "    bl      sub_fc0a6d94\n"
 602 "    bl      sub_fc0c8e8e\n"
 603 "    bl      sub_fc11a5e8\n"
 604 "    bl      sub_fc05d998\n"
 605 "    bl      sub_fc300e3c\n"
 606 "    bl      sub_fc11a5bc\n"
 607 "    pop.w   {r4, lr}\n"
 608 //"    b.w     loc_fc11a84a\n"
 609 "    ldr     pc,=0xfc11a84b\n"
 610     ".ltorg\n"
 611     );
 612 }
 613 
 614 //taskcreate_physw  -f=chdk -s=0xfc07a0e3 -c=18
 615 void __attribute__((naked,noinline)) sub_fc07a0e2_my() {
 616 //    *(int*)0xd20b0994 = 0x4d0002;
 617     asm volatile (
 618 "    push    {r3, r4, r5, lr}\n"
 619 "    bl      sub_fc06f9d4\n"
 620 "    bl      sub_fc07bec0\n" // IsFactoryMode_FW
 621 "    cbnz    r0, loc_fc07a0f2\n"
 622 "    bl      sub_fc06f978\n"  // OpLog.Start_FW
 623 "loc_fc07a0f2:\n"
 624 "    ldr     r4, =0x000082c8\n"
 625 "    ldr     r0, [r4, #4]\n"
 626 "    cmp     r0, #0\n"
 627 "    bne     loc_fc07a10e\n"
 628 "    movs    r3, #0\n"
 629 "    str     r3, [sp]\n"
 630 //"    ldr     r3, =0xfc07a0bd\n" //  task_PhySw
 631        "    ldr     r3, =mykbd_task\n" // fix this!!
 632 "    movs    r1, #0x17\n"
 633 "    ldr     r0, =0xfc07a13c\n" //  *"PhySw"
 634 "    movw    r2, #0x2000\n" // adjust upward?was 800
 635 "    blx     sub_fc29b35c\n" // j_CreateTaskStrictly
 636 "    str     r0, [r4, #4]\n"
 637 
 638 /*                        // ###### turn led on
 639                         "push    {r4-r5}\n"
 640                         "ldr r4, =0x4d0002\n"
 641                         "ldr r5, =0xd20b0884\n"
 642                         "str r4, [r5]\n"
 643                         "pop     {r4-r5}\n"
 644 */
 645 
 646 "loc_fc07a10e:\n"
 647 "    pop     {r3, r4, r5, pc}\n"
 648                         ".ltorg\n"
 649     );
 650 }
 651 
 652  //-f=chdk -s=task_InitFileModules -c=16
 653 // task_InitFileModules 0xfc0aa0a1
 654 void __attribute__((naked,noinline)) init_file_modules_task() { 
 655     asm volatile (
 656 "    push    {r4, r5, r6, lr}\n"
 657 "    bl      sub_fc0ac164\n"
 658 "    movs    r4, r0\n"
 659 "    movw    r5, #0x5006\n"
 660 "    beq     loc_fc0aa0b6\n"
 661 "    movs    r1, #0\n"
 662 "    mov     r0, r5\n"
 663 "    bl      _PostLogicalEventToUI\n"
 664 "loc_fc0aa0b6:\n"
 665 "    bl      sub_fc0ac18e\n"
 666 "    BL      core_spytask_can_start\n" // + CHDK: Set "it's-safe-to-start" flag for spytask
 667 "    cmp     r4, #0\n"
 668 "    bne     loc_fc0aa0ca\n"
 669 "    mov     r0, r5\n"
 670 "    pop.w   {r4, r5, r6, lr}\n"
 671 "    movs    r1, #0\n"
 672 "    b.w     _PostLogicalEventToUI\n"
 673 "loc_fc0aa0ca:\n"
 674 "    pop     {r4, r5, r6, pc}\n"
 675 "    .ltorg\n"
 676     );
 677 
 678 }
 679 
 680 
 681 #ifdef CAM_HAS_JOGDIAL
 682 // jogdial override code called from kbd task
 683 // sx700v100e -f=chdk -s=kbd_p2_f -c=77
 684 // kbd_p2_f 0xfc079e89
 685 void __attribute__((naked,noinline)) kbd_p2_f_my() { 
 686    asm volatile(
 687 "    push.w  {r4, r5, r6, r7, r8, lr}\n"
 688 "    ldr     r6, =0x000308d4\n"
 689 "    sub     sp, #0x18\n"
 690 "    add     r7, sp, #8\n"
 691 "    subs    r6, #0xc\n"
 692 "    b       loc_fc079eca\n"
 693 "loc_fc079e96:\n"
 694 "    ldr     r1, =0x000308d4\n"
 695 "    add     r3, sp, #8\n"
 696 "    ldrb.w  r0, [sp, #4]\n"
 697 "    add     r2, sp, #0x14\n"
 698 "    subs    r1, #0x18\n"
 699 "    bl      sub_fc06e51c\n"
 700 "    cbnz    r0, loc_fc079eb0\n"
 701 "    ldr     r1, [sp, #0x14]\n"
 702 "    movs    r0, #0\n"
 703 "    bl      sub_fc079dfa\n"
 704 "loc_fc079eb0:\n"
 705 "    movs    r0, #2\n"
 706 "loc_fc079eb2:\n"
 707 "    ldr.w   r1, [r7, r0, lsl #2]\n"
 708 "    cbz     r1, loc_fc079ec2\n"
 709 "    ldr.w   r2, [r6, r0, lsl #2]\n"
 710 "    bics    r2, r1\n"
 711 "    str.w   r2, [r6, r0, lsl #2]\n"
 712 "loc_fc079ec2:\n"
 713 "    subs    r0, r0, #1\n"
 714 "    sxtb    r0, r0\n"
 715 "    cmp     r0, #0\n"
 716 "    bge     loc_fc079eb2\n"
 717 "loc_fc079eca:\n"
 718 "    ldr     r0, =0x000308d4\n"
 719 "    add     r1, sp, #4\n"
 720 "    subs    r0, #0xc\n"
 721 "    bl      sub_fc06e268\n"
 722 "    cmp     r0, #0\n"
 723 "    bne     loc_fc079e96\n"
 724 "    ldr.w   r8, =0x000308d4\n"
 725 "    movs    r4, #0\n"
 726 "loc_fc079ede:\n"
 727 "    movs    r5, #0\n"
 728 "    ldr.w   r0, [r6, r4, lsl #2]\n"
 729 "    ldr.w   r1, [r8, r4, lsl #2]\n"
 730 "    ands    r0, r1\n"
 731 "    str.w   r0, [r6, r4, lsl #2]\n"
 732 "    b       loc_fc079f36\n"
 733 "loc_fc079ef0:\n"
 734 "    lsrs    r0, r5\n"
 735 "    lsls    r0, r0, #0x1f\n"
 736 "    beq     loc_fc079f2e\n"
 737 "    ldr     r1, =0x000308d4\n"
 738 "    add.w   r0, r5, r4, lsl #5\n"
 739 "    add     r3, sp, #8\n"
 740 "    subs    r1, #0x18\n"
 741 "    add     r2, sp, #0x14\n"
 742 "    uxtb    r0, r0\n"
 743 "    bl      sub_fc06e51c\n"
 744 "    cbnz    r0, loc_fc079f12\n"
 745 "    ldr     r1, [sp, #0x14]\n"
 746 "    movs    r0, #1\n"
 747 "    bl      sub_fc079dfa\n"
 748 "loc_fc079f12:\n"
 749 "    mov     r0, r4\n"
 750 "    b       loc_fc079f2a\n"
 751 "loc_fc079f16:\n"
 752 "    ldr.w   r1, [r7, r0, lsl #2]\n"
 753 "    cbz     r1, loc_fc079f26\n"
 754 "    ldr.w   r2, [r6, r0, lsl #2]\n"
 755 "    bics    r2, r1\n"
 756 "    str.w   r2, [r6, r0, lsl #2]\n"
 757 "loc_fc079f26:\n"
 758 "    adds    r0, r0, #1\n"
 759 "    sxtb    r0, r0\n"
 760 "loc_fc079f2a:\n"
 761 "    cmp     r0, #3\n"
 762 "    blt     loc_fc079f16\n"
 763 "loc_fc079f2e:\n"
 764 "    ldr.w   r0, [r6, r4, lsl #2]\n"
 765 "    adds    r5, r5, #1\n"
 766 "    uxtb    r5, r5\n"
 767 "loc_fc079f36:\n"
 768 "    cmp     r0, #0\n"
 769 "    bne     loc_fc079ef0\n"
 770 "    adds    r4, r4, #1\n"
 771 "    sxtb    r4, r4\n"
 772 "    cmp     r4, #3\n"
 773 "    blt     loc_fc079ede\n"
 774 //"    bl      sub_fc06e104\n"
 775 "    bl      sub_fc06e104_my\n" // --->>
 776 "    add     sp, #0x18\n"
 777 "    pop.w   {r4, r5, r6, r7, r8, pc}\n"
 778 
 779 ".ltorg\n"
 780     );
 781 
 782 }
 783 
 784 //extern void handle_jogdial();
 785 //sx700100e -f=chdk -s=0xfc06e105 -c=9
 786 void __attribute__((naked,noinline)) sub_fc06e104_my() {
 787     asm volatile(
 788 "    push    {r4, lr}\n"
 789 "    ldr     r4, =0x00009334\n"
 790 "    ldr     r0, [r4, #8]\n"
 791 "    bl      sub_fc070a80\n"
 792 "    bl      sub_fc0e4108\n"
 793 "    ldr     r0, [r4, #0xc]\n"
 794 "    bl      sub_fc07099c\n"
 795 //"    pop.w   {r4, lr}\n"      // - (reordered below) 
 796 //"    b.w     loc_fc06bf5e\n"  // - (reordered below)
 797 "    bl      handle_jogdial\n"  // +
 798 "    cmp     r0, #0\n"          // +
 799 "    beq     no_scroll\n"       // +
 800 "    bl      sub_fc06bf5e\n"    // handles scrollwheel(s), void function, no args
 801 "no_scroll:\n"                  // +
 802 "    pop     {r4, pc}\n"        // +
 803 ".ltorg\n"
 804     );
 805 }
 806 #endif

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