root/platform/sx60hs/sub/100f/boot.c

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

DEFINITIONS

This source file includes following definitions.
  1. spytask
  2. CreateTask_spytask
  3. init_required_fw_features
  4. boot
  5. CreateTask_my
  6. sub_fc05eec0_my
  7. sub_fc05f050_my
  8. sub_fc05f0e4_my
  9. sub_fc05f456_my
  10. sub_fc07319c_my
  11. task_Startup_my
  12. sub_fc07308e_my
  13. init_file_modules_task
  14. kbd_p2_f_my
  15. sub_fc0706e8_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 /*----------------------------------------------------------------------
  22     spytask
  23 -----------------------------------------------------------------------*/
  24 void spytask(long ua, long ub, long uc, long ud, long ue, long uf)
  25 {
  26     core_spytask();
  27 }
  28 
  29 /*----------------------------------------------------------------------
  30     CreateTask_spytask
  31 -----------------------------------------------------------------------*/
  32 void CreateTask_spytask()
  33 {
  34 //    *(int*)0xd20b0884 = 0x4d0002;
  35 
  36     _CreateTask("SpyTask", 0x19, 0x2000, spytask, 0);
  37 }
  38 
  39 /*
  40     *** TEMPORARY? workaround ***
  41     Init stuff to avoid asserts on cameras running DryOS r54+
  42     https://chdk.setepontos.com/index.php?topic=12516.0
  43     Execute this only once
  44  */
  45 void init_required_fw_features(void) {
  46     extern void _init_focus_eventflag();
  47     extern void _init_nd_eventflag();
  48 //   extern void _init_nd_semaphore();
  49     //extern void _init_zoom_semaphore(); // for MoveZoomLensWithPoint
  50 
  51     _init_focus_eventflag();
  52     _init_nd_eventflag();
  53     // for MoveIrisWithAv, based on fc3d1a74 (but without registers eventprocs)
  54     extern int av_override_semaphore;
  55     extern int _CreateBinarySemaphoreStrictly(int x, int y);
  56     av_override_semaphore = _CreateBinarySemaphoreStrictly(0,0);
  57 //    _init_nd_semaphore();
  58 }
  59 ///*----------------------------------------------------------------------
  60 // Pointer to stack location where jogdial task records previous and current
  61 // jogdial positions
  62 // short *jog_position;
  63 
  64 /*----------------------------------------------------------------------
  65     boot()
  66 
  67     Main entry point for the CHDK code
  68 -----------------------------------------------------------------------*/
  69 
  70 /*************************************************************/
  71 void __attribute__((naked,noinline)) boot() {
  72 //    *(int*)0xd20b0884 = 0x4d0002;
  73     asm volatile ( // 0xfc02000c
  74 "    ldr.w   sp, =0x80010000\n"
  75 "    bl      sub_fc020064\n" 
  76 "    ldr     r2, =0xc0242010\n"
  77 "    ldr     r1, [r2]\n"
  78 "    orr     r1, r1, #1\n"
  79 "    str     r1, [r2]\n"
  80 "    ldr     r0, =0xfcd16b8c\n"
  81 "    ldr     r1, =0x010e1000\n"
  82 "    ldr     r3, =0x0110daa4\n"
  83 "loc_fc020024:\n"
  84 "    cmp     r1, r3\n"
  85 "    itt     lo\n"
  86 "    ldrlo   r2, [r0], #4\n"
  87 "    strlo   r2, [r1], #4\n"
  88 "    blo     loc_fc020024\n"
  89 // Install CreateTask patch
  90 // use half words in case source or destination not word aligned
  91         "adr     r0, patch_CreateTask\n"    // src: Patch data
  92         "ldr     r1, =hook_CreateTask\n"    // dest: Address to patch (hook_ has thumb bit off)
  93         "add     r2, r0, #8\n" // two words
  94 "task_hook_loop:\n"
  95         "ldrh   r3, [r0],#2\n"
  96         "strh   r3, [r1],#2\n"
  97         "cmp    r0,r2\n"
  98         "blo    task_hook_loop\n"
  99 "    ldr     r0, =0x010e1000\n"
 100 "    ldr     r1, =0x0002caa4\n"
 101 "    bl      sub_fc1361ce\n" 
 102 "    ldr     r0, =0xfccec580\n"
 103 "    ldr     r1, =0x00008000\n"
 104 "    ldr     r3, =0x0003260c\n"
 105 "loc_fc020040:\n"
 106 "    cmp     r1, r3\n"
 107 "    itt     lo\n"
 108 "    ldrlo   r2, [r0], #4\n"
 109 "    strlo   r2, [r1], #4\n"
 110 "    blo     loc_fc020040\n"
 111 "    ldr     r3, =0x0003260c\n"
 112 "    ldr     r1, =0x003a8bb0\n"
 113 "    mov.w   r2, #0\n"
 114 "loc_fc020056:\n"
 115 "    cmp     r3, r1\n"
 116 "    it      lo\n"
 117 "    strlo   r2, [r3], #4\n"
 118 "    blo     loc_fc020056\n"
 119 //"    b.w     loc_fc05eec0\n"
 120 "    b.w     sub_fc05eec0_my\n" // continue 
 121 
 122         "patch_CreateTask:\n"
 123         "ldr.w   pc, [pc,#0]\n"             // Do jump to absolute address CreateTask_my
 124         ".long   CreateTask_my + 1\n"           // has to be a thumb address
 125 
 126  
 127 );
 128 }
 129 
 130 /*************************************************************/
 131 void __attribute__((naked,noinline)) CreateTask_my() {
 132 //    *(int*)0xd20b0884 = 0x4d0002;
 133 asm volatile (
 134 "    push   {r0}\n"
 135 //R3 = Pointer to task function to create
 136 "    ldr     r0, =task_CaptSeq\n"       // DryOS original code function ptr.
 137 "    cmp     r0, r3\n"                  // is the given taskptr equal to our searched function?
 138 "    itt     eq\n"                      // EQ block
 139 "    ldreq   r3, =capt_seq_task\n"      // if so replace with our task function base ptr.
 140 "    orreq   r3, #1\n"                  // make sure it's a thumb address (may not be needed?)
 141 "    beq     exitHook\n"                // below compares not necessary if this check has found something.
 142 
 143 "    LDR     R0, =task_ExpDrv\n"
 144 "    CMP     R0, R3\n"
 145 "    itt     eq\n"
 146 "    LDREQ   R3, =exp_drv_task\n"
 147 "    orreq   r3, #1\n"
 148 "    BEQ     exitHook\n"
 149 /*
 150 "    LDR     R0, =task_DvlpSeqTask\n"
 151 "    CMP     R0, R3\n"
 152 "    itt     eq\n"
 153 "    LDREQ   R3, =developseq_task\n"
 154 "    orreq   r3, #1\n"
 155 "    BEQ     exitHook\n"
 156 */
 157 
 158 "    ldr     r0, =task_FileWrite\n"
 159 "    cmp     r0, r3\n"
 160 "    itt     eq\n"
 161 "    ldreq   r3, =filewritetask\n"
 162 "    orreq   r3, #1\n"
 163 "    beq     exitHook\n"
 164 /*
 165 
 166 "    LDR     R0, =task_MovieRecord\n"
 167 "    CMP     R0, R3\n"
 168 "    itt     eq\n"
 169 "    LDREQ   R3, =movie_record_task\n"
 170 "    BEQ     exitHook\n"
 171 
 172 "    LDR     R0, =task_LiveImageTask\n"
 173 "    CMP     R0, R3\n"
 174 "    itt     eq\n"
 175 "    LDREQ   R3, =liveimage_task\n"
 176 "    BEQ     exitHook\n"
 177 
 178 */
 179 "    ldr     r0, =task_InitFileModules\n"
 180 "    cmp     r0, r3\n"
 181 "    itt     eq\n"
 182 "    ldreq   r3, =init_file_modules_task\n"
 183 "    orreq   r3, #1\n"
 184 
 185 "exitHook:\n" 
 186 
 187 // restore overwritten register(s)
 188 "    pop    {r0}\n"
 189 /*                        // turn led on
 190                         "push    {r4-r5}\n"
 191                         "ldr r4, =0x4d0002\n"
 192                         "ldr r5, =0xd20b0884\n"
 193                         "str r4, [r5]\n"
 194                         "pop     {r4-r5}\n"
 195  */                   
 196 // Execute overwritten instructions from original code, then jump to firmware
 197 "    stmdb   sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, lr}\n"
 198 //"    push.w  {r1, r2, r3, r4, r5, r6, r7, r8, sb, lr}\n"
 199 "    mov     r4, r0\n"
 200 "    ldr     r0, =0x8160\n" //at fc05f1b0
 201 //"    mov     r6, r1\n"
 202 //"    mov     r5, r2\n"
 203 "    ldr.w   pc, =(hook_CreateTask + 8 + 1) \n"  // Continue in firmware
 204 ".ltorg\n"
 205 );
 206  
 207 }
 208 
 209 //fc04f194 fc05eec0
 210 void __attribute__((naked,noinline)) sub_fc05eec0_my() {
 211 //*(int*)0xd20b0884 = 0x4d0002;
 212 
 213 /* no gpio checks needed    if (*(int*)(0xd20b0000 + 0x10 * 4) & 0x10000) {
 214         // see sub_fc060338, sub_fc06082a
 215         // GPIO 0x10 (aka ON/OFF button) is not pressed -> play
 216         *(int*)(0x970c+0x4) = 0x200000;
 217     }
 218     else {
 219         // GPIO 0x10 is pressed -> rec
 220         *(int*)(0x970c+0x4) = 0x100000;
 221     }
 222 */
 223     asm volatile (
 224     "push    {r4, lr}\n"
 225 
 226 #if defined(CHDK_NOT_IN_CANON_HEAP)
 227     "ldr     r4, =0x003a8bb0\n"         // heap start, modify here
 228 #else
 229     "ldr     r4, =new_sa\n"             // +
 230     "ldr     r4, [r4]\n"                // +
 231 #endif
 232 "    sub     sp, #0x78\n"
 233 "    ldr     r0, =0x006ce000\n"
 234 "    ldr     r1, =0x0008fd8c\n"
 235 "    subs    r0, r0, r4\n"
 236 "    cmp     r0, r1\n"
 237 "    bhs     loc_fc05eed2\n"
 238 "loc_fc05eed0:\n"
 239 "    b       loc_fc05eed0\n"
 240 "loc_fc05eed2:\n"
 241 "    ldr     r1, =0x00008074\n"
 242 "    mov.w   r0, #0x80000\n"
 243 "    str     r0, [r1]\n"
 244 "    ldr     r1, =0x00008078\n"
 245 "    ldr     r0, =0x42a41000\n"
 246 "    str     r0, [r1]\n"
 247 "    ldr     r1, =0x0000807c\n"
 248 "    ldr     r0, =0x42a43000\n"
 249 "    str     r0, [r1]\n"
 250 "    movs    r1, #0x78\n"
 251 "    mov     r0, sp\n"
 252 "    blx     sub_fc2cf438\n" 
 253 "    ldr     r0, =0x0062e000\n"
 254 "    mov.w   r1, #0xa0000\n"
 255 "    stm.w   sp, {r0, r1, r4}\n"
 256 "    ldr     r1, =0x00622274\n" //  *"t"b"
 257 "    subs    r2, r1, r4\n"
 258 "    strd    r2, r1, [sp, #0xc]\n"
 259 "    str     r0, [sp, #0x14]\n"
 260 "    movs    r0, #0x22\n"
 261 "    str     r0, [sp, #0x18]\n"
 262 "    movs    r0, #0x98\n"
 263 "    str     r0, [sp, #0x1c]\n"
 264 "    movw    r0, #0x24c\n"
 265 "    str     r0, [sp, #0x20]\n"
 266 "    movs    r0, #0xfa\n"
 267 "    str     r0, [sp, #0x24]\n"
 268 "    movs    r0, #0xe8\n"
 269 "    str     r0, [sp, #0x28]\n"
 270 "    movs    r0, #0x85\n"
 271 "    str     r0, [sp, #0x2c]\n"
 272 "    movs    r0, #0x40\n"
 273 "    str     r0, [sp, #0x30]\n"
 274 "    movs    r0, #4\n"
 275 "    str     r0, [sp, #0x34]\n"
 276 "    movs    r0, #0\n"
 277 "    str     r0, [sp, #0x38]\n"
 278 "    movs    r0, #0x10\n"
 279 "    str     r0, [sp, #0x5c]\n"
 280 "    movs    r2, #0\n"
 281 "    lsls    r0, r0, #8\n"
 282 "    str     r0, [sp, #0x60]\n"
 283 //"    ldr     r1, =0xfc05f051\n"
 284     "ldr     r1, =sub_fc05f050_my\n"    // -> continue here (init_task)
 285 "    asrs    r0, r0, #4\n"
 286 "    str     r0, [sp, #0x64]\n"
 287 "    lsls    r0, r0, #5\n"
 288 "    str     r0, [sp, #0x68]\n"
 289 "    mov     r0, sp\n"
 290 "    blx     sub_fc2ce9a4\n" 
 291 "    add     sp, #0x78\n"
 292 "    pop     {r4, pc}\n"
 293     ".ltorg\n"
 294 
 295     );
 296 
 297 
 298 }
 299 
 300 
 301 //fc04f324
 302 void __attribute__((naked,noinline)) sub_fc05f050_my() {
 303 
 304 //*(int*)0xd20b0884 = 0x4d0002;
 305     asm volatile (
 306 "    push    {r4, lr}\n"
 307 "    ldr     r4, =0xfc05f0fc\n" //  *"/_term"
 308 "    bl      sub_fc0602ec\n"
 309 "    ldr     r0, =0x000080ec\n"
 310 "    ldr     r1, [r0]\n"
 311 "    ldr     r0, =0x00008074\n"
 312 "    ldr     r0, [r0]\n"
 313 "    adds    r0, #0x10\n"
 314 "    cmp     r1, r0\n"
 315 "    bhs     loc_fc05f06c\n"
 316 "    ldr     r0, =0xfc05f10c\n" //  *"USER_MEM size checking"
 317 "    bl      sub_fc05f0e4\n"
 318 "loc_fc05f06c:\n"
 319 "    bl      sub_fc1362a8\n"
 320 "    ldr     r3, =0x80000800\n"
 321 // bad capdis output
 322 //  
 323     "mov.w   r1, #0x80000000\n" //2147483648
 324     "mov.w   r2, #0xeeeeeeee\n"
 325 "loc_fc05f07a:\n"
 326 "    stm     r1!, {r2}\n"
 327 "    cmp     r1, r3\n"
 328 "    blo     loc_fc05f07a\n"
 329 "    bl      sub_fc1362ba\n" 
 330 "    bl      sub_fc136890\n" 
 331 "    cmp     r0, #0\n"
 332 "    bge     loc_fc05f092\n"
 333 "    ldr     r0, =0xfc05f128\n" //  *"dmSetup"
 334 "    bl      sub_fc05f0e4\n"
 335 "loc_fc05f092:\n"
 336 "    bl      sub_fc05f8c4\n"  
 337 "    cmp     r0, #0\n"
 338 "    bge     loc_fc05f0a0\n"
 339 "    ldr     r0, =0xfc05f130\n" //  *"termDriverInit"
 340 "    bl      sub_fc05f0e4\n"
 341 "loc_fc05f0a0:\n"
 342 "    mov     r0, r4\n"
 343 "    bl      sub_fc05f952\n" 
 344 // led works here
 345 "    cmp     r0, #0\n"
 346 "    bge     loc_fc05f0b0\n" 
 347 "    ldr     r0, =0xfc05f140\n" //  *"termDeviceCreate"
 348 "    bl      sub_fc05f0e4\n"
 349 "loc_fc05f0b0:\n"
 350 "    mov     r0, r4\n"
 351 "    bl      sub_fc05f288\n" 
 352 // led works here
 353 "    cmp     r0, #0\n"
 354 "    bge     loc_fc05f0c0\n" 
 355 "    ldr     r0, =0xfc05f154\n" //  *"stdioSetup"
 356 "    bl      sub_fc05f0e4\n"
 357 "loc_fc05f0c0:\n"
 358 "    bl      sub_fc05f3cc\n" 
 359 "    cmp     r0, #0\n"
 360 "    bge     loc_fc05f0ce\n"
 361 "    ldr     r0, =0xfc05f160\n" //  *"stdlibSetup"
 362 "    bl      sub_fc05f0e4\n"
 363 "loc_fc05f0ce:\n"
 364 "    bl      sub_fc0623e8\n"
 365 "    cmp     r0, #0\n"
 366 "    bge     loc_fc05f0dc\n"
 367 "    ldr     r0, =0xfc05f16c\n" //  *"extlib_setup"
 368 "    bl      sub_fc05f0e4\n"
 369 "loc_fc05f0dc:\n"
 370 "    pop.w   {r4, lr}\n"
 371 //"    b.w     sub_fc05f456\n"
 372     "b.w     sub_fc05f456_my\n" // -> continue (taskcreate_startup)
 373     ".ltorg\n"
 374 
 375     );
 376 
 377 }
 378 
 379 void __attribute__((naked,noinline)) sub_fc05f0e4_my() {
 380 
 381 //*(int*)0xd20b0884 = 0x4d0002;
 382 }
 383 void __attribute__((naked,noinline)) sub_fc05f456_my() {
 384 // turn on LED
 385  //   *(int*)0xd20b0884 = 0x4d0002;
 386        
 387     asm volatile (
 388 "    push    {r3, lr}\n"
 389 "    bl      sub_fc05f570\n" 
 390 "    bl      sub_fc0b9738\n" 
 391 "    cbnz    r0, loc_fc05f46c\n"
 392 "    bl      sub_fc07f062\n" // is normal camera Mode_FW
 393 "    cbz     r0, loc_fc05f46c\n"
 394 "    movs    r0, #1\n"
 395 "    b       loc_fc05f46e\n"
 396 "loc_fc05f46c:\n"
 397     "movs    r0, #0\n"
 398 "loc_fc05f46e:\n"
 399 "    bl      sub_fc07319c\n" 
 400 "    cbnz    r0, loc_fc05f47a\n"
 401 "    bl      sub_fc05f55e\n" 
 402 "loc_fc05f478:\n"
 403 "    b       loc_fc05f478\n"
 404 "loc_fc05f47a:\n"
 405 "    blx     sub_fc2ce9fc\n"
 406 "    ldr     r1, =0x006ce000\n"
 407 "    movs    r0, #0\n"
 408 "    bl      sub_fc3364fc\n" 
 409 "    blx     sub_fc2cefd0\n"
 410 "    movs    r3, #0\n"
 411 "    str     r3, [sp]\n"
 412 //"    ldr     r3, =0xfc05f3f1\n" //  task_Startup
 413     "ldr     r3, =task_Startup_my\n"
 414 "    movs    r2, #0\n"
 415 "    movs    r1, #0x19\n"
 416 "    ldr     r0, =0xfc05f4a8\n" //  *"Startup"
 417  /*                       // ###### turn led on
 418                         "push    {r4-r5}\n"
 419                         "ldr r4, =0x4d0002\n"
 420                         "ldr r5, =0xd20b0884\n"
 421                         "str r4, [r5]\n"
 422                         "pop     {r4-r5}\n"
 423 */
 424 //"    blx     sub_fc2cf018\n" // j_CreateTask
 425     "bl       _CreateTask\n"    // CreateTask
 426 "    movs    r0, #0\n"
 427 "    pop     {r3, pc}\n"
 428     ".ltorg\n"
 429     );
 430 }
 431 
 432 // override not needed
 433 #if 0
 434 void __attribute__((naked,noinline)) sub_fc07319c_my() {
 435     asm volatile (
 436     "stmdb   sp!, {r2, r3, r4, r5, r6, r7, r8, lr}\n"
 437     "mov.w   r8, #0\n"
 438     "mov     r7, r0\n"
 439     "mov     r6, r8\n"
 440     "bl      sub_fc0705ee\n" // nullsub
 441     "movs    r0, #16\n"
 442     "bl      sub_fc06fbde\n"
 443     "movs    r4, #1\n"
 444     "bic.w   r5, r4, r0\n"
 445     "movs    r0, #15\n"  
 446     "bl      sub_fc06fbde\n"    // reads GPIO (15)
 447     "bics    r4, r0\n"
 448     "cbz     r7, loc_fc0731f6\n"
 449     "orrs.w  r0, r5, r4\n"
 450     //"beq.n   loc_fc06037e\n"  // - this check fails and results in shutdown
 451     "loc_fc0731f6:\n"
 452     "bl      sub_fc0b9738\n"
 453     "movs    r3, #0\n"
 454     "mov     r2, r0\n"
 455     "strd    r8, r6, [sp]\n"
 456     "mov     r1, r4\n"
 457     "mov     r0, r5\n"
 458     //"bl      sub_fc06082a\n"  // - startupchecks
 459     //"bl      sub_fc060828\n"  // - nullsub
 460     "movs    r0, #1\n"
 461     "loc_fc073210:\n"
 462     "ldmia.w sp!, {r2, r3, r4, r5, r6, r7, r8, pc}\n"
 463     ".ltorg\n"
 464     );
 465 }
 466 #endif
 467 
 468 
 469 // task_Startup
 470 //"    ldr     r3, =0xfc05f3f1\n" //  task_Startup
 471 void __attribute__((naked,noinline)) task_Startup_my() {
 472 //    *(int*)0xd20b0884 = 0x4d0002;
 473     asm volatile (
 474 "    push    {r4, lr}\n"
 475 "    bl      sub_fc137ad4\n" // CreateTask ClockSave
 476 "    bl      sub_fc05f53c\n" // posixSetup etc
 477 //"    bl      sub_fc05f6bc\n"
 478 "    bl      sub_fc0daedc\n" // StartWDT ...
 479 "bl sub_010e6355\n" //see 0x010e63cc task_SD1stInit in RAMCODE.dis
 480 //"    bl      sub_fc05f712\n"
 481 "    bl      sub_fc08da46\n"
 482 "    bl      sub_fc0db028\n"
 483 "    bl      sub_fc05f804\n"
 484 "    bl      sub_fc05f650\n"
 485 "    bl      sub_fc0daf1a\n"
 486 "    bl      sub_fc0b947c\n"
 487 "    bl      sub_fc0db02e\n"
 488 "    bl      sub_fc07308e_my\n"
 489 "    bl      CreateTask_spytask\n"
 490 "    bl      init_required_fw_features\n"
 491 "    bl      sub_fc275708\n"
 492 "    bl      sub_fc0db044\n"
 493 "    bl      sub_fc0b9230\n"
 494 "    bl      sub_fc13788e\n"
 495 "    bl      sub_fc0b95e4\n"
 496 "    bl      sub_fc0b942e\n"
 497 "    bl      sub_fc13784a\n"
 498 "    bl      sub_fc05f808\n"
 499 "    bl      sub_fc32f656\n" 
 500 "    bl      sub_fc13781e\n"
 501 "    pop.w   {r4, lr}\n"
 502 "    b.w     sub_fc137aaa\n"  
 503     ".ltorg\n"
 504     );
 505 }
 506 //taskcreate_physw
 507 void __attribute__((naked,noinline)) sub_fc07308e_my() {
 508 //    *(int*)0xd20b0884 = 0x4d0002;
 509     asm volatile (
 510 "    push    {r3, r4, r5, lr}\n"
 511 "    bl      sub_fc07202c\n"
 512 "    bl      sub_fc07efe0\n" // IsFactoryMode_FW
 513 "    cbnz    r0, loc_fc07309e\n"
 514 "    bl      sub_fc071fd0\n" // OpLog.Start_FW
 515 "loc_fc07309e:\n"
 516 "    ldr     r4, =0x000082c8\n"
 517 "    ldr     r0, [r4, #4]\n"
 518 "    cmp     r0, #0\n"
 519 "    bne     loc_fc0730ba\n"
 520 "    movs    r3, #0\n"
 521 "    str     r3, [sp]\n"
 522 //"    ldr     r3, =0xfc073069\n" //  task_PhySw
 523         "ldr     r3, =mykbd_task\n"   // fix this!!
 524 "    movs    r1, #0x17\n"
 525 "    ldr     r0, =0xfc0730e8\n" //  *"PhySw"
 526 "    movw    r2, #0x2000\n" // adjust upward?was 800
 527 "    blx     sub_fc2cf340\n" // j_CreateTaskStrictly
 528 /*                        // ###### turn led on
 529                         "push    {r4-r5}\n"
 530                         "ldr r4, =0x4d0002\n"
 531                         "ldr r5, =0xd20b0884\n"
 532                         "str r4, [r5]\n"
 533                         "pop     {r4-r5}\n"
 534 */
 535 "    str     r0, [r4, #4]\n"
 536 "loc_fc0730ba:\n"
 537 "    pop     {r3, r4, r5, pc}\n"
 538                         ".ltorg\n"
 539     );
 540 }
 541 
 542 void __attribute__((naked,noinline)) init_file_modules_task() { //sub_fc088220_my()
 543 //fc0bda11
 544 // task_InitFileModules 0xfc0bda11
 545     asm volatile (
 546 "    push    {r4, r5, r6, lr}\n"
 547 "    bl      sub_fc0e5238\n"
 548 "    movs    r4, r0\n"
 549 "    movw    r5, #0x5006\n"
 550 "    beq     loc_fc0bda26\n"
 551 "    movs    r1, #0\n"
 552 "    mov     r0, r5\n"
 553 "    bl      _PostLogicalEventToUI\n"
 554 "loc_fc0bda26:\n"
 555 "    bl      sub_fc0e5262\n"
 556 "    BL      core_spytask_can_start\n" // + CHDK: Set "it's-safe-to-start" flag for spytask
 557 "    cmp     r4, #0\n"
 558 "    bne     loc_fc0bda3a\n"
 559 "    mov     r0, r5\n"
 560 "    pop.w   {r4, r5, r6, lr}\n"
 561 "    movs    r1, #0\n"
 562 "    b.w     _PostLogicalEventToUI\n"
 563 "loc_fc0bda3a:\n"
 564 "    pop     {r4, r5, r6, pc}\n"
 565 "    .ltorg\n"
 566     );
 567 
 568 }
 569 
 570 
 571 void __attribute__((naked,noinline)) kbd_p2_f_my() { 
 572 
 573 // kbd_p2_f 0xfc072e35
 574 
 575    asm volatile(
 576 "    stmdb   sp!, {r4, r5, r6, r7, r8, lr}\n"
 577 //"    push.w  {r4, r5, r6, r7, r8, lr}\n"
 578 "    ldr     r6, =0x00033f88\n"
 579 "    sub     sp, #0x18\n"
 580 "    add     r7, sp, #8\n"
 581 "    subs    r6, #0xc\n"
 582 "    b       loc_fc072e76\n"
 583 
 584 "loc_fc072e42:\n"
 585 "    ldr     r1, =0x00033f88\n"
 586 "    add     r3, sp, #8\n"
 587 "    ldrb.w  r0, [sp, #4]\n"
 588 "    add     r2, sp, #0x14\n"
 589 "    subs    r1, #0x18\n"
 590 "    bl      sub_fc070b4e\n"
 591 "    cbnz    r0, loc_fc072e5c\n"
 592 "    ldr     r1, [sp, #0x14]\n"
 593 "    movs    r0, #0\n"
 594 "    bl      sub_fc072da6\n"
 595 
 596 "loc_fc072e5c:\n"
 597 "    movs    r0, #2\n"
 598 "loc_fc072e5e:\n"
 599 "    ldr.w   r1, [r7, r0, lsl #2]\n"
 600 "    cbz     r1, loc_fc072e6e\n"
 601 "    ldr.w   r2, [r6, r0, lsl #2]\n"
 602 "    bics    r2, r1\n"
 603 "    str.w   r2, [r6, r0, lsl #2]\n"
 604 "loc_fc072e6e:\n"
 605 "    subs    r0, r0, #1\n"
 606 "    sxtb    r0, r0\n"
 607 "    cmp     r0, #0\n"
 608 "    bge     loc_fc072e5e\n"
 609 
 610 "loc_fc072e76:\n"
 611 "    ldr     r0, =0x00033f88\n"
 612 "    add     r1, sp, #4\n"
 613 "    subs    r0, #0xc\n"
 614 "    bl      sub_fc07084c\n"
 615 "    cmp     r0, #0\n"
 616 "    bne     loc_fc072e42\n"
 617 "    ldr.w   r8, =0x00033f88\n"
 618 "    movs    r4, #0\n"
 619 "loc_fc072e8a:\n"
 620 "    movs    r5, #0\n"
 621 "    ldr.w   r0, [r6, r4, lsl #2]\n"
 622 "    ldr.w   r1, [r8, r4, lsl #2]\n"
 623 "    ands    r0, r1\n"
 624 "    str.w   r0, [r6, r4, lsl #2]\n"
 625 "    b       loc_fc072ee2\n"
 626 "loc_fc072e9c:\n"
 627 "    lsrs    r0, r5\n"
 628 "    lsls    r0, r0, #0x1f\n"
 629 "    beq     loc_fc072eda\n"
 630 "    ldr     r1, =0x00033f88\n"
 631 "    add.w   r0, r5, r4, lsl #5\n"
 632 "    add     r3, sp, #8\n"
 633 "    subs    r1, #0x18\n"
 634 "    add     r2, sp, #0x14\n"
 635 "    uxtb    r0, r0\n"
 636 "    bl      sub_fc070b4e\n"
 637 "    cbnz    r0, loc_fc072ebe\n"
 638 "    ldr     r1, [sp, #0x14]\n"
 639 "    movs    r0, #1\n"
 640 "    bl      sub_fc072da6\n"
 641 "loc_fc072ebe:\n"
 642 "    mov     r0, r4\n"
 643 "    b       loc_fc072ed6\n"
 644 
 645 "loc_fc072ec2:\n"
 646 "    ldr.w   r1, [r7, r0, lsl #2]\n"
 647 "    cbz     r1, loc_fc072ed2\n"
 648 "    ldr.w   r2, [r6, r0, lsl #2]\n"
 649 "    bics    r2, r1\n"
 650 "    str.w   r2, [r6, r0, lsl #2]\n"
 651 "loc_fc072ed2:\n"
 652 "    adds    r0, r0, #1\n"
 653 "    sxtb    r0, r0\n"
 654 "loc_fc072ed6:\n"
 655 "    cmp     r0, #3\n"
 656 "    blt     loc_fc072ec2\n"
 657 "loc_fc072eda:\n"
 658 "    ldr.w   r0, [r6, r4, lsl #2]\n"
 659 "    adds    r5, r5, #1\n"
 660 "    uxtb    r5, r5\n"
 661 "loc_fc072ee2:\n"
 662 "    cmp     r0, #0\n"
 663 "    bne     loc_fc072e9c\n"
 664 "    adds    r4, r4, #1\n"
 665 "    sxtb    r4, r4\n"
 666 "    cmp     r4, #3\n"
 667 "    blt     loc_fc072e8a\n"
 668 //"    bl      sub_fc0706e8\n"
 669 "    bl      sub_fc0706e8_my\n"     // ->
 670 "    add     sp, #0x18\n"
 671 "    pop.w   {r4, r5, r6, r7, r8, pc}\n"
 672 ".ltorg\n"
 673     );
 674 
 675 }
 676 //extern void handle_jogdial();
 677 void __attribute__((naked,noinline)) sub_fc0706e8_my() {
 678     asm volatile(
 679 "    push    {r4, lr}\n"
 680 "    ldr     r4, =0x0000970c\n"
 681 "    ldr     r0, [r4, #0xc]\n"
 682 "    bl      sub_fc072250\n"
 683 "    bl      sub_fc0f9118\n"
 684 "    ldr     r0, [r4, #0x10]\n"
 685 "    bl      sub_fc07216c\n"
 686 //"    ldmia.w sp!, {r4, lr}\n" // - (reordered below)
 687 //"    b.w     loc_fc05cbf6\n"  // - (reordered below)
 688 "    bl      handle_jogdial\n"  // +
 689 "    cmp     r0, #0\n"          // +
 690 "    beq     no_scroll\n"       // +
 691 "    bl      sub_fc072490\n"    // handles scrollwheel(s), void function, no args
 692 "no_scroll:\n"                  // +
 693 "    pop     {r4, pc}\n"        // +
 694     );
 695 }
 696 

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