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

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