root/platform/sx50hs/sub/100c/boot.c

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

DEFINITIONS

This source file includes following definitions.
  1. spytask
  2. CreateTask_spytask
  3. boot
  4. CreateTask_my
  5. sub_FF00038C_my
  6. sub_FF00116C_my
  7. sub_FF00421C_my
  8. sub_FF00AE5C_my
  9. sub_FF01A018_my
  10. task_Startup_my
  11. taskcreatePhySw_my
  12. init_file_modules_task
  13. JogDial_task_my

   1 /*
   2  * boot.c - auto-generated by CHDK code_gen.
   3  */
   4 #include "lolevel.h"
   5 #include "platform.h"
   6 #include "core.h"
   7 #include "dryos31.h"
   8 
   9 #define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
  10 
  11 const char * const new_sa = &_end;
  12 
  13 // Forward declarations
  14 extern volatile int jogdial_stopped;
  15 void JogDial_task_my(void);
  16 
  17 extern void task_CaptSeq();
  18 extern void task_InitFileModules();
  19 extern void task_RotaryEncoder();
  20 extern void task_MovieRecord();
  21 extern void task_ExpDrv();
  22 extern void task_FileWrite();
  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     _CreateTask("SpyTask", 0x19, 0x2000, spytask, 0);
  38 }
  39 
  40 ///*----------------------------------------------------------------------
  41 // Pointer to stack location where jogdial task records previous and current
  42 // jogdial positions
  43 short *jog_position;
  44 
  45 /*----------------------------------------------------------------------
  46     boot()
  47 
  48     Main entry point for the CHDK code
  49 -----------------------------------------------------------------------*/
  50 
  51 /*************************************************************/
  52 //** boot @ 0xFF00000C - 0xFF000184, length=95
  53 void __attribute__((naked,noinline)) boot() {
  54 asm volatile (
  55 "    LDR     R1, =0xC0410000 \n"
  56 "    MOV     R0, #0 \n"
  57 "    STR     R0, [R1] \n"
  58 "    MOV     R1, #0x78 \n"
  59 "    MCR     p15, 0, R1, c1, c0 \n"
  60 "    MOV     R1, #0 \n"
  61 "    MCR     p15, 0, R1, c7, c10, 4 \n"
  62 "    MCR     p15, 0, R1, c7, c5 \n"
  63 "    MCR     p15, 0, R1, c7, c6 \n"
  64 "    MOV     R0, #0x3D \n"
  65 "    MCR     p15, 0, R0, c6, c0 \n"
  66 "    MOV     R0, #0xC000002F \n"
  67 "    MCR     p15, 0, R0, c6, c1 \n"
  68 "    MOV     R0, #0x37 \n"
  69 "    MCR     p15, 0, R0, c6, c2 \n"
  70 "    MOV     R0, #0x40000037 \n"
  71 "    MCR     p15, 0, R0, c6, c3 \n"
  72 "    MOV     R0, #0x80000017 \n"
  73 "    MCR     p15, 0, R0, c6, c4 \n"
  74 "    LDR     R0, =0xFF00002F \n"
  75 "    MCR     p15, 0, R0, c6, c5 \n"
  76 "    LDR     R0, =0xD000002B \n"
  77 "    MCR     p15, 0, R0, c6, c7 \n"
  78 "    MOV     R0, #0x34 \n"
  79 "    MCR     p15, 0, R0, c2, c0 \n"
  80 "    MOV     R0, #0x34 \n"
  81 "    MCR     p15, 0, R0, c2, c0, 1 \n"
  82 "    MOV     R0, #0x34 \n"
  83 "    MCR     p15, 0, R0, c3, c0 \n"
  84 "    LDR     R0, =0x33333330 \n"
  85 "    MCR     p15, 0, R0, c5, c0, 2 \n"
  86 "    LDR     R0, =0x33333330 \n"
  87 "    MCR     p15, 0, R0, c5, c0, 3 \n"
  88 "    MRC     p15, 0, R0, c1, c0 \n"
  89 "    ORR     R0, R0, #0x1000 \n"
  90 "    ORR     R0, R0, #4 \n"
  91 "    ORR     R0, R0, #1 \n"
  92 "    MCR     p15, 0, R0, c1, c0 \n"
  93 "    MOV     R1, #0x80000006 \n"
  94 "    MCR     p15, 0, R1, c9, c1 \n"
  95 "    MOV     R1, #6 \n"
  96 "    MCR     p15, 0, R1, c9, c1, 1 \n"
  97 "    MRC     p15, 0, R1, c1, c0 \n"
  98 "    ORR     R1, R1, #0x50000 \n"
  99 "    MCR     p15, 0, R1, c1, c0 \n"
 100 "    LDR     R2, =0xC0200000 \n"
 101 "    MOV     R1, #1 \n"
 102 "    STR     R1, [R2, #0x10C] \n"
 103 "    MOV     R1, #0xFF \n"
 104 "    STR     R1, [R2, #0xC] \n"
 105 "    STR     R1, [R2, #0x1C] \n"
 106 "    STR     R1, [R2, #0x2C] \n"
 107 "    STR     R1, [R2, #0x3C] \n"
 108 "    STR     R1, [R2, #0x4C] \n"
 109 "    STR     R1, [R2, #0x5C] \n"
 110 "    STR     R1, [R2, #0x6C] \n"
 111 "    STR     R1, [R2, #0x7C] \n"
 112 "    STR     R1, [R2, #0x8C] \n"
 113 "    STR     R1, [R2, #0x9C] \n"
 114 "    STR     R1, [R2, #0xAC] \n"
 115 "    STR     R1, [R2, #0xBC] \n"
 116 "    STR     R1, [R2, #0xCC] \n"
 117 "    STR     R1, [R2, #0xDC] \n"
 118 "    STR     R1, [R2, #0xEC] \n"
 119 "    STR     R1, [R2, #0xFC] \n"
 120 "    LDR     R1, =0xC0400008 \n"
 121 "    LDR     R2, =0x430005 \n"
 122 "    STR     R2, [R1] \n"
 123 "    MOV     R1, #1 \n"
 124 "    LDR     R2, =0xC0243100 \n"
 125 "    STR     R2, [R1] \n"
 126 "    LDR     R2, =0xC0242010 \n"
 127 "    LDR     R1, [R2] \n"
 128 "    ORR     R1, R1, #1 \n"
 129 "    STR     R1, [R2] \n"
 130 "    LDR     R0, =0xFF746AC8 \n"
 131 "    LDR     R1, =0x685000 \n"
 132 "    LDR     R3, =0x6946B4 \n"
 133 
 134 "loc_FF000144:\n"
 135 "    CMP     R1, R3 \n"
 136 "    LDRCC   R2, [R0], #4 \n"
 137 "    STRCC   R2, [R1], #4 \n"
 138 "    BCC     loc_FF000144 \n"
 139 "    LDR     R0, =0xFF731694 \n"
 140 "    LDR     R1, =0x1900 \n"
 141 "    LDR     R3, =0x16D34 \n"
 142 
 143 "loc_FF000160:\n"
 144 "    CMP     R1, R3 \n"
 145 "    LDRCC   R2, [R0], #4 \n"
 146 "    STRCC   R2, [R1], #4 \n"
 147 "    BCC     loc_FF000160 \n"
 148 "    LDR     R1, =0x1B3DD4 \n"
 149 "    MOV     R2, #0 \n"
 150 
 151 "loc_FF000178:\n"
 152 "    CMP     R3, R1 \n"
 153 "    STRCC   R2, [R3], #4 \n"
 154 "    BCC     loc_FF000178 \n"
 155 /* Install task hooks via 0x193x is not possible with this new dryos version
 156    So the below code patches the CreateTask function in RAM to install our
 157    hook -- ERR99
 158 */
 159 // Install CreateTask patch
 160 "    LDR     R0, =patch_CreateTask\n"   // Patch data
 161 "    LDM     R0, {R1,R2}\n"             // Get two patch instructions
 162 "    LDR     R0, =hook_CreateTask\n"    // Address to patch
 163 "    STM     R0, {R1,R2}\n"             // Store patch instructions
 164 
 165 "    B       sub_FF00038C_my \n"  // --> Patched. Old value = 0xFF00038C.
 166 
 167 "patch_CreateTask:\n"
 168 "    LDR     PC, [PC,#-0x4]\n"          // Do jump to absolute address CreateTask_my
 169 "    .long   CreateTask_my\n"
 170 );
 171 }
 172 
 173 /*************************************************************/
 174 //** CreateTask_my @ 0x0068AB8C - 0x0068AB90, length=2
 175 void __attribute__((naked,noinline)) CreateTask_my() {
 176 asm volatile (
 177 "    STMFD   SP!, {R0}\n"
 178 //R3 = Pointer to task function to create
 179 
 180 /*** INSTALL capt_seq_task() hook ***/
 181 "    LDR     R0, =task_CaptSeq\n"       // DryOS original code function ptr.
 182 "    CMP     R0, R3\n"                  // is the given taskptr equal to our searched function?
 183 "    LDREQ   R3, =capt_seq_task\n"      // if so replace with our task function base ptr.
 184 "    BEQ     exitHook\n"                // below compares not necessary if this check has found something.
 185 
 186 /*** INSTALL exp_drv_task() hook ***/
 187 "    LDR     R0, =task_ExpDrv\n"
 188 "    CMP     R0, R3\n"
 189 "    LDREQ   R3, =exp_drv_task\n"
 190 "    BEQ     exitHook\n"
 191 
 192 /*** INSTALL filewrite() hook ***/
 193 "    LDR     R0, =task_FileWrite\n"
 194 "    CMP     R0, R3\n"
 195 "    LDREQ   R3, =filewritetask\n"
 196 "    BEQ     exitHook\n"
 197 
 198 /*** INSTALL JogDial() hook ***/
 199 "    LDR     R0, =task_RotaryEncoder\n"
 200 "    CMP     R0, R3\n"
 201 "    LDREQ   R3, =JogDial_task_my\n"
 202 "    BEQ     exitHook\n"
 203 
 204 /*** INSTALL movie_record_task() hook ***/
 205 "    LDR     R0, =task_MovieRecord\n"
 206 "    CMP     R0, R3\n"
 207 "    LDREQ   R3, =movie_record_task\n"
 208 "    BEQ     exitHook\n"
 209 
 210 /*** INSTALL init_file_modules_task() hook ***/
 211 "    LDR     R0, =task_InitFileModules\n"
 212 "    CMP     R0, R3\n"
 213 "    LDREQ   R3, =init_file_modules_task\n"
 214 
 215 "exitHook:\n" 
 216 // restore overwritten registers
 217 "    LDMFD   SP!, {R0}\n"
 218 // Execute overwritten instructions from original code, then jump to firmware
 219 "    STMFD   SP!, {R1-R9,LR} \n"
 220 "    MOV     R4, R0 \n"
 221 "    LDR     PC, =0x0068AB94 \n"  // Continue in firmware
 222 );
 223 }
 224 
 225 /*************************************************************/
 226 //** sub_FF00038C_my @ 0xFF00038C - 0xFF0003F4, length=27
 227 void __attribute__((naked,noinline)) sub_FF00038C_my() {
 228 
 229     if ( (*(int*)0xC022F48C & 0x800000) )
 230         *(int*)(0x2E0C+0x8) = 0x200000;     // Playmode "PhySwConfig.c" SX50 FF05CE8C
 231     else
 232         *(int*)(0x2E0C+0x8) = 0x100000;     // Shootingmode
 233 
 234 asm volatile (
 235 "    LDR     R0, =0xFF000404 \n"
 236 "    MOV     R1, #0 \n"
 237 "    LDR     R3, =0xFF00043C \n"
 238 
 239 "loc_FF000398:\n"
 240 "    CMP     R0, R3 \n"
 241 "    LDRCC   R2, [R0], #4 \n"
 242 "    STRCC   R2, [R1], #4 \n"
 243 "    BCC     loc_FF000398 \n"
 244 "    LDR     R0, =0xFF00043C \n"
 245 "    MOV     R1, #0x4B0 \n"
 246 "    LDR     R3, =0xFF000624 \n"
 247 
 248 "loc_FF0003B4:\n"
 249 "    CMP     R0, R3 \n"
 250 "    LDRCC   R2, [R0], #4 \n"
 251 "    STRCC   R2, [R1], #4 \n"
 252 "    BCC     loc_FF0003B4 \n"
 253 "    MOV     R0, #0xD2 \n"
 254 "    MSR     CPSR_cxsf, R0 \n"
 255 "    MOV     SP, #0x1000 \n"
 256 "    MOV     R0, #0xD3 \n"
 257 "    MSR     CPSR_cxsf, R0 \n"
 258 "    MOV     SP, #0x1000 \n"
 259 "    LDR     R0, =0x698 \n"
 260 "    LDR     R2, =0xEEEEEEEE \n"
 261 "    MOV     R3, #0x1000 \n"
 262 
 263 "loc_FF0003E8:\n"
 264 "    CMP     R0, R3 \n"
 265 "    STRCC   R2, [R0], #4 \n"
 266 "    BCC     loc_FF0003E8 \n"
 267 "    BL      sub_FF00116C_my \n"  // --> Patched. Old value = 0xFF00116C.
 268 );
 269 }
 270 
 271 /*************************************************************/
 272 //** sub_FF00116C_my @ 0xFF00116C - 0xFF001218, length=44
 273 void __attribute__((naked,noinline)) sub_FF00116C_my() {
 274 asm volatile (
 275 "    STR     LR, [SP, #-4]! \n"
 276 "    SUB     SP, SP, #0x74 \n"
 277 "    MOV     R1, #0x74 \n"
 278 "    MOV     R0, SP \n"
 279 "    BL      sub_00690440 \n"
 280 "    MOV     R0, #0x67000 \n"
 281 "    STR     R0, [SP, #4] \n"
 282 
 283 #if defined(CHDK_NOT_IN_CANON_HEAP) // use original heap offset if CHDK is loaded in high memory
 284 "    LDR     R0, =0x1B3DD4 \n"
 285 #else
 286 "    LDR     R0, =new_sa\n"   // otherwise use patched value
 287 "    LDR     R0, [R0]\n"      // 
 288 #endif
 289 
 290 "    LDR     R2, =0x55D440 \n"
 291 "    STR     R0, [SP, #8] \n"
 292 "    SUB     R0, R2, R0 \n"
 293 "    STR     R0, [SP, #0xC] \n"
 294 "    MOV     R0, #0x22 \n"
 295 "    STR     R0, [SP, #0x18] \n"
 296 "    MOV     R0, #0x7C \n"
 297 "    STR     R0, [SP, #0x1C] \n"
 298 "    LDR     R1, =0x565C00 \n"
 299 "    LDR     R0, =0x1CD \n"
 300 "    STR     R1, [SP] \n"
 301 "    STR     R0, [SP, #0x20] \n"
 302 "    MOV     R0, #0x96 \n"
 303 "    STR     R2, [SP, #0x10] \n"
 304 "    STR     R1, [SP, #0x14] \n"
 305 "    STR     R0, [SP, #0x24] \n"
 306 "    STR     R0, [SP, #0x28] \n"
 307 "    MOV     R0, #0x64 \n"
 308 "    STR     R0, [SP, #0x2C] \n"
 309 "    MOV     R0, #0 \n"
 310 "    STR     R0, [SP, #0x30] \n"
 311 "    STR     R0, [SP, #0x34] \n"
 312 "    MOV     R0, #0x10 \n"
 313 "    STR     R0, [SP, #0x5C] \n"
 314 "    MOV     R0, #0x800 \n"
 315 "    STR     R0, [SP, #0x60] \n"
 316 "    MOV     R0, #0xA0 \n"
 317 "    STR     R0, [SP, #0x64] \n"
 318 "    MOV     R0, #0x280 \n"
 319 "    STR     R0, [SP, #0x68] \n"
 320 "    LDR     R1, =sub_FF00421C_my \n"  // --> Patched. Old value = 0xFF00421C.
 321 "    MOV     R2, #0 \n"
 322 "    MOV     R0, SP \n"
 323 "    BL      sub_006867E8 \n"
 324 "    ADD     SP, SP, #0x74 \n"
 325 "    LDR     PC, [SP], #4 \n"
 326 );
 327 }
 328 
 329 /*************************************************************/
 330 //** sub_FF00421C_my @ 0xFF00421C - 0xFF004290, length=30
 331 void __attribute__((naked,noinline)) sub_FF00421C_my() {
 332 asm volatile (
 333 "    STMFD   SP!, {R4,LR} \n"
 334 "    BL      sub_FF000AE8 \n"
 335 "    BL      sub_FF005358 \n"
 336 "    CMP     R0, #0 \n"
 337 "    LDRLT   R0, =0xFF004330 /*'dmSetup'*/ \n"
 338 "    BLLT    _err_init_task \n"
 339 "    BL      sub_FF003E54 \n"
 340 "    CMP     R0, #0 \n"
 341 "    LDRLT   R0, =0xFF004338 /*'termDriverInit'*/ \n"
 342 "    BLLT    _err_init_task \n"
 343 "    LDR     R0, =0xFF004348 /*'/_term'*/ \n"
 344 "    BL      sub_FF003F3C \n"
 345 "    CMP     R0, #0 \n"
 346 "    LDRLT   R0, =0xFF004350 /*'termDeviceCreate'*/ \n"
 347 "    BLLT    _err_init_task \n"
 348 "    LDR     R0, =0xFF004348 /*'/_term'*/ \n"
 349 "    BL      sub_FF00295C \n"
 350 "    CMP     R0, #0 \n"
 351 "    LDRLT   R0, =0xFF004364 /*'stdioSetup'*/ \n"
 352 "    BLLT    _err_init_task \n"
 353 "    BL      sub_FF004CF4 \n"
 354 "    CMP     R0, #0 \n"
 355 "    LDRLT   R0, =0xFF004370 /*'stdlibSetup'*/ \n"
 356 "    BLLT    _err_init_task \n"
 357 "    BL      sub_FF00165C \n"
 358 "    CMP     R0, #0 \n"
 359 "    LDRLT   R0, =0xFF00437C /*'armlib_setup'*/ \n"
 360 "    BLLT    _err_init_task \n"
 361 "    LDMFD   SP!, {R4,LR} \n"
 362 "    B       sub_FF00AE5C_my \n"  // --> Patched. Old value = 0xFF00AE5C.
 363 );
 364 }
 365 
 366 /*************************************************************/
 367 //** sub_FF00AE5C_my @ 0xFF00AE5C - 0xFF00AED4, length=31
 368 void __attribute__((naked,noinline)) sub_FF00AE5C_my() {
 369 asm volatile (
 370 "    STMFD   SP!, {R3,LR} \n"
 371 "    BL      sub_FF022240 \n"
 372 "    CMP     R0, #0 \n"
 373 "    BNE     loc_FF00AE7C \n"
 374 "    BL      sub_FF01BB6C /*_IsNormalCameraMode_FW*/ \n"
 375 "    CMP     R0, #0 \n"
 376 "    MOVNE   R0, #1 \n"
 377 "    BNE     loc_FF00AE80 \n"
 378 
 379 "loc_FF00AE7C:\n"
 380 "    MOV     R0, #0 \n"
 381 
 382 "loc_FF00AE80:\n"
 383 "    BL      sub_FF01A018_my \n"  // --> Patched. Old value = 0xFF01A018.
 384 "    CMP     R0, #0 \n"
 385 "    BNE     loc_FF00AEA0 \n"
 386 "    BL      sub_FF0193AC \n"
 387 "    LDR     R1, =0x83DC00 \n"
 388 "    MOV     R0, #0x54 \n"
 389 "    BL      sub_FF020808 \n"
 390 
 391 "loc_FF00AE9C:\n"
 392 "    B       loc_FF00AE9C \n"
 393 
 394 "loc_FF00AEA0:\n"
 395 "    BL      sub_0068C314 \n"
 396 "    LDR     R1, =0x5CE000 \n"
 397 "    MOV     R0, #0 \n"
 398 "    BL      sub_FF020604 \n"
 399 "    BL      sub_0068C52C \n"
 400 "    MOV     R3, #0 \n"
 401 "    STR     R3, [SP] \n"
 402 "    LDR     R3, =task_Startup_my \n"  // --> Patched. Old value = 0xFF00ADF4.
 403 "    MOV     R2, #0 \n"
 404 "    MOV     R1, #0x19 \n"
 405 "    LDR     R0, =0xFF00AEE4 /*'Startup'*/ \n"
 406 "    BL      _CreateTask \n"
 407 "    MOV     R0, #0 \n"
 408 "    LDMFD   SP!, {R3,PC} \n"
 409 );
 410 }
 411 
 412 /*************************************************************/
 413 //** sub_FF01A018_my @ 0xFF01A018 - 0xFF01A070, length=23
 414 void __attribute__((naked,noinline)) sub_FF01A018_my() {
 415 asm volatile (
 416 "    STMFD   SP!, {R4-R6,LR} \n"
 417 "    MOV     R6, R0 \n"
 418 //"  BL      _sub_FF05CE84 \n"  // --> Nullsub call removed.
 419 "    MOV     R0, #0x4B \n"
 420 "    BL      sub_FF020818 \n"
 421 "    MOV     R4, #1 \n"
 422 "    BIC     R5, R4, R0 \n"
 423 "    MOV     R0, #0x4C \n"
 424 "    BL      sub_FF020818 \n"
 425 "    CMP     R6, #0 \n"
 426 "    BIC     R4, R4, R0 \n"
 427 "    BEQ     loc_FF01A050 \n"
 428 "    ORRS    R0, R5, R4 \n"
 429 "    LDMEQFD SP!, {R4-R6,PC} \n"
 430 
 431 "loc_FF01A050:\n"
 432 "    BL      sub_FF022240 \n"
 433 "    MOV     R2, R0 \n"
 434 "    MOV     R3, #0 \n"
 435 "    MOV     R1, R4 \n"
 436 "    MOV     R0, R5 \n"
 437 //"  BL      _sub_FF05CE8C \n"  // disable startup checks
 438 //"  BL      _sub_FF05CE88 \n"  // --> Nullsub call removed.
 439 "    MOV     R0, #1 \n"
 440 "    LDMFD   SP!, {R4-R6,PC} \n"
 441 );
 442 }
 443 
 444 /*************************************************************/
 445 //** task_Startup_my @ 0xFF00ADF4 - 0xFF00AE58, length=26
 446 void __attribute__((naked,noinline)) task_Startup_my() {
 447 asm volatile (
 448 "    STMFD   SP!, {R4,LR} \n"
 449 "    BL      sub_FF00485C \n"
 450 "    BL      sub_FF01B190 \n"
 451 "    BL      sub_FF0192D0 \n"
 452 //"  BL      _sub_FF05DB40 \n"  // --> Nullsub call removed.
 453 "    BL      sub_FF022474 \n"
 454 //"  BL      _sub_FF02231C \n"  // CheckForDiskBootBinStuff
 455 "    BL      sub_FF0225E0 \n"
 456 "    BL      sub_FF0227AC \n"
 457 //"  BL      _sub_FF0225D4 \n"  // --> Nullsub call removed.
 458 "    BL      sub_FF0224A4 \n"
 459 "    BL      sub_FF020538 \n"
 460 "    BL      sub_FF0227B4 \n"
 461 "    BL      CreateTask_spytask\n" // added
 462 "    BL      taskcreatePhySw_my \n"  // --> Patched. Old value = 0xFF019EC0.
 463 "    BL      sub_FF01DA78 \n"
 464 "    BL      sub_FF0AF590 \n"
 465 "    BL      sub_FF016E50 \n"
 466 "    BL      sub_FF018C38 \n"
 467 "    BL      sub_FF022000 \n"
 468 "    BL      sub_FF019284 \n"
 469 "    BL      sub_FF018BD4 \n"
 470 //"  BL      _sub_FF0225D8 \n"  // --> Nullsub call removed.
 471 "    BL      sub_FF017AFC \n"
 472 "    BL      sub_FF018B98 \n"
 473 "    LDMFD   SP!, {R4,LR} \n"
 474 "    B       sub_FF004998 \n"
 475 );
 476 }
 477 
 478 /*************************************************************/
 479 //** taskcreatePhySw_my @ 0xFF019EC0 - 0xFF019F14, length=22
 480 void __attribute__((naked,noinline)) taskcreatePhySw_my() {
 481 asm volatile (
 482 "    STMFD   SP!, {R3-R5,LR} \n"
 483 "    LDR     R4, =0x1D64 \n"
 484 "    LDR     R0, [R4, #4] \n"
 485 "    CMP     R0, #0 \n"
 486 "    BNE     loc_FF019EF4 \n"
 487 "    MOV     R3, #0 \n"
 488 "    STR     R3, [SP] \n"
 489 "    LDR     R3, =mykbd_task \n"  // --> Patched. Old value = 0xFF019E8C.
 490 "    MOV     R2, #0x2000 \n"  // --> Patched. Old value = 0x800. stack size for new task_PhySw so we don't have to do stack switch
 491 "    MOV     R1, #0x17 \n"
 492 "    LDR     R0, =0xFF01A168 /*'PhySw'*/ \n"
 493 "    BL      sub_0068AF04 /*_CreateTaskStrictly*/ \n"
 494 "    STR     R0, [R4, #4] \n"
 495 
 496 "loc_FF019EF4:\n"
 497 "    BL      sub_FF05DF88 \n"
 498 "    BL      sub_FF09948C \n"
 499 "    BL      sub_FF01BABC /*_IsFactoryMode_FW*/ \n"
 500 "    CMP     R0, #0 \n"
 501 "    BNE     loc_FF019F14 \n"
 502 "    LDR     R1, =0x3AE98 \n"
 503 "    MOV     R0, #0 \n"
 504 "    BL      sub_FF0993F8 /*_OpLog.Start_FW*/ \n"
 505 
 506 "loc_FF019F14:\n"
 507 "    LDMFD   SP!, {R3-R5,PC} \n"
 508 );
 509 }
 510 
 511 /*************************************************************/
 512 //** init_file_modules_task @ 0xFF04A93C - 0xFF04A970, length=14
 513 void __attribute__((naked,noinline)) init_file_modules_task() {
 514 asm volatile (
 515 "    STMFD   SP!, {R4-R6,LR} \n"
 516 "    BL      sub_FF09BA04 \n"
 517 "    LDR     R5, =0x5006 \n"
 518 "    MOVS    R4, R0 \n"
 519 "    MOVNE   R1, #0 \n"
 520 "    MOVNE   R0, R5 \n"
 521 "    BLNE    _PostLogicalEventToUI \n"
 522 "    BL      sub_FF09BA30 \n"
 523 "    BL      core_spytask_can_start\n"  // CHDK: Set "it's-safe-to-start" flag for spytask
 524 "    CMP     R4, #0 \n"
 525 "    LDMNEFD SP!, {R4-R6,PC} \n"
 526 "    MOV     R0, R5 \n"
 527 "    LDMFD   SP!, {R4-R6,LR} \n"
 528 "    MOV     R1, #0 \n"
 529 "    B       _PostLogicalEventToUI \n"
 530 );
 531 }
 532 
 533 /*************************************************************/
 534 //** JogDial_task_my @ 0xFF05DC5C - 0xFF05DF84, length=203
 535 void __attribute__((naked,noinline)) JogDial_task_my() {
 536 asm volatile (
 537 "    STMFD   SP!, {R4-R11,LR} \n"
 538 "    SUB     SP, SP, #0x1C \n"
 539 "    BL      sub_FF05DFF4 \n"
 540 "    LDR     R12, =0x2E30 \n"
 541 "    LDR     R6, =0xFF49E790 \n"
 542 "    MOV     R0, #0 \n"
 543 "    ADD     R10, SP, #8 \n"
 544 "    ADD     R9, SP, #0xC \n"
 545 
 546 // Save pointer for kbd.c routine
 547 "    LDR     R2, =jog_position \n"
 548 "    STR     R9, [R2] \n"
 549 
 550 "loc_FF05DC7C:\n"
 551 "    ADD     R2, SP, #0x14 \n"
 552 "    MOV     R1, #0 \n"
 553 "    ADD     R4, R2, R0, LSL#1 \n"
 554 "    ADD     R3, SP, #0x10 \n"
 555 "    STRH    R1, [R4] \n"
 556 "    ADD     R4, R3, R0, LSL#1 \n"
 557 "    STRH    R1, [R4] \n"
 558 "    STR     R1, [R9, R0, LSL#2] \n"
 559 "    STR     R1, [R10, R0, LSL#2] \n"
 560 "    ADD     R0, R0, #1 \n"
 561 "    CMP     R0, #1 \n"
 562 "    BLT     loc_FF05DC7C \n"
 563 
 564 "loc_FF05DCAC:\n"
 565 "    LDR     R0, =0x2E30 \n"
 566 "    MOV     R2, #0 \n"
 567 "    LDR     R0, [R0, #8] \n"
 568 "    MOV     R1, SP \n"
 569 "    BL      sub_0068BDE0 /*_ReceiveMessageQueue*/ \n"
 570 "    CMP     R0, #0 \n"
 571 "    LDRNE   R1, =0x20B \n"
 572 "    LDRNE   R0, =0xFF05DF0C /*'RotaryEncoder.c'*/ \n"
 573 "    BLNE    _DebugAssert \n"
 574 "    LDR     R0, [SP] \n"
 575 "    AND     R4, R0, #0xFF \n"
 576 "    AND     R0, R0, #0xFF00 \n"
 577 "    CMP     R0, #0x100 \n"
 578 "    BEQ     loc_FF05DD1C \n"
 579 "    CMP     R0, #0x200 \n"
 580 "    BEQ     loc_FF05DD54 \n"
 581 "    CMP     R0, #0x300 \n"
 582 "    BEQ     loc_FF05DF58 \n"
 583 "    CMP     R0, #0x400 \n"
 584 "    BNE     loc_FF05DCAC \n"
 585 "    CMP     R4, #0 \n"
 586 "    LDRNE   R1, =0x285 \n"
 587 "    LDRNE   R0, =0xFF05DF0C /*'RotaryEncoder.c'*/ \n"
 588 "    BLNE    _DebugAssert \n"
 589 "    RSB     R0, R4, R4, LSL#3 \n"
 590 "    LDR     R0, [R6, R0, LSL#2] \n"
 591 
 592 "loc_FF05DD14:\n"
 593 "    BL      sub_FF05DFD8 \n"
 594 "    B       loc_FF05DCAC \n"
 595 
 596 "loc_FF05DD1C:\n"
 597 //------------------  added code ---------------------
 598 "labelA:\n"
 599 "    LDR     R0, =jogdial_stopped\n"
 600 "    LDR     R0, [R0]\n"
 601 "    CMP     R0, #1\n"
 602 "    BNE     labelB\n"
 603 "    MOV     R0, #40\n"
 604 "    BL      _SleepTask\n"
 605 "    B       labelA\n"
 606 "labelB:\n"
 607 //------------------  original code ------------------
 608 "    LDR     R0, =0x2E3C \n"
 609 "    LDR     R0, [R0, R4, LSL#2] \n"
 610 "    BL      sub_FF020DF4 /*_CancelTimer*/ \n"
 611 "    LDR     R2, =0xFF05DBA8 \n"
 612 "    ORR     R3, R4, #0x200 \n"
 613 "    MOV     R1, R2 \n"
 614 "    MOV     R0, #0x28 \n"
 615 "    BL      sub_FF020D10 /*_SetTimerAfter*/ \n"
 616 "    TST     R0, #1 \n"
 617 "    CMPNE   R0, #0x15 \n"
 618 "    STR     R0, [R10, R4, LSL#2] \n"
 619 "    BEQ     loc_FF05DCAC \n"
 620 "    LDR     R1, =0x21D \n"
 621 "    B       loc_FF05DEF8 \n"
 622 
 623 "loc_FF05DD54:\n"
 624 "    RSB     R5, R4, R4, LSL#3 \n"
 625 "    LDR     R0, [R6, R5, LSL#2] \n"
 626 "    LDR     R1, =0xC0240000 \n"
 627 "    ADD     R0, R1, R0, LSL#8 \n"
 628 "    LDR     R0, [R0, #0x104] \n"
 629 "    MOV     R1, R0, ASR#16 \n"
 630 "    ADD     R0, SP, #0x14 \n"
 631 "    ADD     R11, R0, R4, LSL#1 \n"
 632 "    ADD     R0, SP, #0x10 \n"
 633 "    ADD     R0, R0, R4, LSL#1 \n"
 634 "    STRH    R1, [R11] \n"
 635 "    STR     R0, [SP, #0x18] \n"
 636 "    LDRSH   R3, [R0] \n"
 637 "    SUB     R2, R1, R3 \n"
 638 "    CMP     R2, #0 \n"
 639 "    BNE     loc_FF05DDD8 \n"
 640 "    LDR     R0, [R9, R4, LSL#2] \n"
 641 "    CMP     R0, #0 \n"
 642 "    BEQ     loc_FF05DEB4 \n"
 643 "    LDR     R7, =0x2E3C \n"
 644 "    LDR     R0, [R7, R4, LSL#2] \n"
 645 "    BL      sub_FF020DF4 /*_CancelTimer*/ \n"
 646 "    LDR     R2, =0xFF05DBB4 \n"
 647 "    ORR     R3, R4, #0x300 \n"
 648 "    MOV     R1, R2 \n"
 649 "    MOV     R0, #0x1F4 \n"
 650 "    BL      sub_FF020D10 /*_SetTimerAfter*/ \n"
 651 "    TST     R0, #1 \n"
 652 "    CMPNE   R0, #0x15 \n"
 653 "    STR     R0, [R7, R4, LSL#2] \n"
 654 "    BEQ     loc_FF05DEB4 \n"
 655 "    LDR     R1, =0x236 \n"
 656 "    B       loc_FF05DEAC \n"
 657 
 658 "loc_FF05DDD8:\n"
 659 "    MOV     R0, R2 \n"
 660 "    RSBLT   R0, R0, #0 \n"
 661 "    MOVLE   R7, #0 \n"
 662 "    MOVGT   R7, #1 \n"
 663 "    CMP     R0, #0xFF \n"
 664 "    BLS     loc_FF05DE14 \n"
 665 "    LDR     R0, =0x7FFF \n"
 666 "    CMP     R2, #0 \n"
 667 "    SUBLE   R0, R0, R3 \n"
 668 "    ADDLE   R0, R0, R1 \n"
 669 "    SUBGT   R0, R0, R1 \n"
 670 "    ADDGT   R0, R0, R3 \n"
 671 "    MVN     R1, #0x8000 \n"
 672 "    SUB     R0, R0, R1 \n"
 673 "    EOR     R7, R7, #1 \n"
 674 
 675 "loc_FF05DE14:\n"
 676 "    STR     R0, [SP, #4] \n"
 677 "    LDR     R0, [R9, R4, LSL#2] \n"
 678 "    CMP     R0, #0 \n"
 679 "    ADDEQ   R0, R6, R5, LSL#2 \n"
 680 "    LDREQ   R0, [R0, #8] \n"
 681 "    BEQ     loc_FF05DE4C \n"
 682 "    ADD     R8, R6, R5, LSL#2 \n"
 683 "    ADD     R1, R8, R7, LSL#2 \n"
 684 "    LDR     R1, [R1, #0x10] \n"
 685 "    CMP     R1, R0 \n"
 686 "    BEQ     loc_FF05DE50 \n"
 687 "    LDR     R0, [R8, #0xC] \n"
 688 "    BL      sub_FF019F18 \n"
 689 "    LDR     R0, [R8, #8] \n"
 690 
 691 "loc_FF05DE4C:\n"
 692 "    BL      sub_FF019F18 \n"
 693 
 694 "loc_FF05DE50:\n"
 695 "    ADD     R0, R6, R5, LSL#2 \n"
 696 "    ADD     R7, R0, R7, LSL#2 \n"
 697 "    LDR     R0, [R7, #0x10] \n"
 698 "    LDR     R1, [SP, #4] \n"
 699 "    BL      sub_FF019F28 \n"
 700 "    LDR     R0, [R7, #0x10] \n"
 701 "    LDR     R7, =0x2E3C \n"
 702 "    STR     R0, [R9, R4, LSL#2] \n"
 703 "    LDRH    R1, [R11] \n"
 704 "    LDR     R0, [SP, #0x18] \n"
 705 "    STRH    R1, [R0] \n"
 706 "    LDR     R0, [R7, R4, LSL#2] \n"
 707 "    BL      sub_FF020DF4 /*_CancelTimer*/ \n"
 708 "    LDR     R2, =0xFF05DBB4 \n"
 709 "    ORR     R3, R4, #0x300 \n"
 710 "    MOV     R1, R2 \n"
 711 "    MOV     R0, #0x1F4 \n"
 712 "    BL      sub_FF020D10 /*_SetTimerAfter*/ \n"
 713 "    TST     R0, #1 \n"
 714 "    CMPNE   R0, #0x15 \n"
 715 "    STR     R0, [R7, R4, LSL#2] \n"
 716 "    BEQ     loc_FF05DEB4 \n"
 717 "    LDR     R1, =0x267 \n"
 718 
 719 "loc_FF05DEAC:\n"
 720 "    LDR     R0, =0xFF05DF0C /*'RotaryEncoder.c'*/ \n"
 721 "    BL      _DebugAssert \n"
 722 
 723 "loc_FF05DEB4:\n"
 724 "    ADD     R0, R6, R5, LSL#2 \n"
 725 "    LDR     R0, [R0, #0x18] \n"
 726 "    CMP     R0, #1 \n"
 727 "    BNE     loc_FF05DF50 \n"
 728 "    LDR     R0, =0x2E30 \n"
 729 "    LDR     R0, [R0, #0x10] \n"
 730 "    CMP     R0, #0 \n"
 731 "    BEQ     loc_FF05DF50 \n"
 732 "    LDR     R2, =0xFF05DBA8 \n"
 733 "    ORR     R3, R4, #0x400 \n"
 734 "    MOV     R1, R2 \n"
 735 "    BL      sub_FF020D10 /*_SetTimerAfter*/ \n"
 736 "    TST     R0, #1 \n"
 737 "    CMPNE   R0, #0x15 \n"
 738 "    STR     R0, [R10, R4, LSL#2] \n"
 739 "    BEQ     loc_FF05DCAC \n"
 740 "    LDR     R1, =0x26E \n"
 741 
 742 "loc_FF05DEF8:\n"
 743 "    LDR     R0, =0xFF05DF0C /*'RotaryEncoder.c'*/ \n"
 744 "    BL      _DebugAssert \n"
 745 "    B       loc_FF05DCAC \n"
 746 
 747 "loc_FF05DF50:\n"
 748 "    LDR     R0, [R6, R5, LSL#2] \n"
 749 "    B       loc_FF05DD14 \n"
 750 
 751 "loc_FF05DF58:\n"
 752 "    LDR     R0, [R9, R4, LSL#2] \n"
 753 "    CMP     R0, #0 \n"
 754 "    MOVEQ   R1, #0x278 \n"
 755 "    LDREQ   R0, =0xFF05DF0C /*'RotaryEncoder.c'*/ \n"
 756 "    BLEQ    _DebugAssert \n"
 757 "    RSB     R0, R4, R4, LSL#3 \n"
 758 "    ADD     R0, R6, R0, LSL#2 \n"
 759 "    LDR     R0, [R0, #0xC] \n"
 760 "    BL      sub_FF019F18 \n"
 761 "    MOV     R0, #0 \n"
 762 "    STR     R0, [R9, R4, LSL#2] \n"
 763 "    B       loc_FF05DCAC \n"
 764 );
 765 }

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