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

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