root/platform/sx170is/sub/101a/boot.c

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

DEFINITIONS

This source file includes following definitions.
  1. CreateTask_spytask
  2. boot
  3. CreateTask_my
  4. sub_FF8103C4_my
  5. sub_FF8128DC_my
  6. sub_FF8149AC_my
  7. sub_FF817CEC_my
  8. sub_FF81BB18_my
  9. task_Startup_my
  10. taskcreatePhySw_my
  11. init_file_modules_task
  12. 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 
  16 /*----------------------------------------------------------------------
  17     CreateTask_spytask
  18 -----------------------------------------------------------------------*/
  19 void CreateTask_spytask()
  20 {
  21     _CreateTask("SpyTask", 0x19, 0x2000, core_spytask, 0);
  22 }
  23 
  24 ///*----------------------------------------------------------------------
  25 // Pointer to stack location where jogdial task records previous and current
  26 // jogdial positions
  27 short *jog_position;
  28 
  29 /*----------------------------------------------------------------------
  30     boot()
  31 
  32     Main entry point for the CHDK code
  33 -----------------------------------------------------------------------*/
  34 
  35 /*************************************************************/
  36 //** boot @ 0xFF81000C - 0xFF81017C, length=93
  37 void __attribute__((naked,noinline)) boot() {
  38 asm volatile (
  39 "    LDR     R1, =0xC0410000 \n"
  40 "    MOV     R0, #0 \n"
  41 "    STR     R0, [R1] \n"
  42 "    MOV     R1, #0x78 \n"
  43 "    MCR     p15, 0, R1, c1, c0 \n"
  44 "    MOV     R1, #0 \n"
  45 "    MCR     p15, 0, R1, c7, c10, 4 \n"
  46 "    MCR     p15, 0, R1, c7, c5 \n"
  47 "    MCR     p15, 0, R1, c7, c6 \n"
  48 "    MOV     R0, #0x3D \n"
  49 "    MCR     p15, 0, R0, c6, c0 \n"
  50 "    MOV     R0, #0xC000002F \n"
  51 "    MCR     p15, 0, R0, c6, c1 \n"
  52 "    MOV     R0, #0x33 \n"
  53 "    MCR     p15, 0, R0, c6, c2 \n"
  54 "    MOV     R0, #0x40000033 \n"
  55 "    MCR     p15, 0, R0, c6, c3 \n"
  56 "    MOV     R0, #0x80000017 \n"
  57 "    MCR     p15, 0, R0, c6, c4 \n"
  58 "    LDR     R0, =0xFF80002D \n"
  59 "    MCR     p15, 0, R0, c6, c5 \n"
  60 "    MOV     R0, #0x34 \n"
  61 "    MCR     p15, 0, R0, c2, c0 \n"
  62 "    MOV     R0, #0x34 \n"
  63 "    MCR     p15, 0, R0, c2, c0, 1 \n"
  64 "    MOV     R0, #0x34 \n"
  65 "    MCR     p15, 0, R0, c3, c0 \n"
  66 "    LDR     R0, =0x3333330 \n"
  67 "    MCR     p15, 0, R0, c5, c0, 2 \n"
  68 "    LDR     R0, =0x3333330 \n"
  69 "    MCR     p15, 0, R0, c5, c0, 3 \n"
  70 "    MRC     p15, 0, R0, c1, c0 \n"
  71 "    ORR     R0, R0, #0x1000 \n"
  72 "    ORR     R0, R0, #4 \n"
  73 "    ORR     R0, R0, #1 \n"
  74 "    MCR     p15, 0, R0, c1, c0 \n"
  75 "    MOV     R1, #0x80000006 \n"
  76 "    MCR     p15, 0, R1, c9, c1 \n"
  77 "    MOV     R1, #6 \n"
  78 "    MCR     p15, 0, R1, c9, c1, 1 \n"
  79 "    MRC     p15, 0, R1, c1, c0 \n"
  80 "    ORR     R1, R1, #0x50000 \n"
  81 "    MCR     p15, 0, R1, c1, c0 \n"
  82 "    LDR     R2, =0xC0200000 \n"
  83 "    MOV     R1, #1 \n"
  84 "    STR     R1, [R2, #0x10C] \n"
  85 "    MOV     R1, #0xFF \n"
  86 "    STR     R1, [R2, #0xC] \n"
  87 "    STR     R1, [R2, #0x1C] \n"
  88 "    STR     R1, [R2, #0x2C] \n"
  89 "    STR     R1, [R2, #0x3C] \n"
  90 "    STR     R1, [R2, #0x4C] \n"
  91 "    STR     R1, [R2, #0x5C] \n"
  92 "    STR     R1, [R2, #0x6C] \n"
  93 "    STR     R1, [R2, #0x7C] \n"
  94 "    STR     R1, [R2, #0x8C] \n"
  95 "    STR     R1, [R2, #0x9C] \n"
  96 "    STR     R1, [R2, #0xAC] \n"
  97 "    STR     R1, [R2, #0xBC] \n"
  98 "    STR     R1, [R2, #0xCC] \n"
  99 "    STR     R1, [R2, #0xDC] \n"
 100 "    STR     R1, [R2, #0xEC] \n"
 101 "    STR     R1, [R2, #0xFC] \n"
 102 "    LDR     R1, =0xC0400008 \n"
 103 "    LDR     R2, =0x430005 \n"
 104 "    STR     R2, [R1] \n"
 105 "    MOV     R1, #1 \n"
 106 "    LDR     R2, =0xC0243100 \n"
 107 "    STR     R2, [R1] \n"
 108 "    LDR     R2, =0xC0242010 \n"
 109 "    LDR     R1, [R2] \n"
 110 "    ORR     R1, R1, #1 \n"
 111 "    STR     R1, [R2] \n"
 112 "    LDR     R0, =0xFFCD5E9C \n"
 113 "    LDR     R1, =0x3F1000 \n"
 114 "    LDR     R3, =0x400670 \n"
 115 
 116 "loc_FF81013C:\n"
 117 "    CMP     R1, R3 \n"
 118 "    LDRCC   R2, [R0], #4 \n"
 119 "    STRCC   R2, [R1], #4 \n"
 120 "    BCC     loc_FF81013C \n"
 121 "    LDR     R0, =0xFFCC6904 \n"
 122 "    LDR     R1, =0x1900 \n"
 123 "    LDR     R3, =0x10E98 \n"
 124 
 125 "loc_FF810158:\n"
 126 "    CMP     R1, R3 \n"
 127 "    LDRCC   R2, [R0], #4 \n"
 128 "    STRCC   R2, [R1], #4 \n"
 129 "    BCC     loc_FF810158 \n"
 130 "    LDR     R1, =0x16FB10 \n"
 131 "    MOV     R2, #0 \n"
 132 
 133 "loc_FF810170:\n"
 134 "    CMP     R3, R1 \n"
 135 "    STRCC   R2, [R3], #4 \n"
 136 "    BCC     loc_FF810170 \n"
 137 /* Install task hooks via 0x193x is not possible with this new dryos version
 138    So the below code patches the CreateTask function in RAM to install our
 139    hook -- ERR99
 140 */
 141 // Install CreateTask patch
 142 "    LDR     R0, =patch_CreateTask\n"   // Patch data
 143 "    LDM     R0, {R1,R2}\n"             // Get two patch instructions
 144 "    LDR     R0, =hook_CreateTask\n"    // Address to patch
 145 "    STM     R0, {R1,R2}\n"             // Store patch instructions
 146 
 147 "    B       sub_FF8103C4_my \n"  // --> Patched. Old value = 0xFF8103C4.
 148 
 149 "patch_CreateTask:\n"
 150 "    LDR     PC, [PC,#-0x4]\n"          // Do jump to absolute address CreateTask_my
 151 "    .long   CreateTask_my\n"
 152 );
 153 }
 154 
 155 /*************************************************************/
 156 //** CreateTask_my @ 0x003F5778 - 0x003F577C, length=2
 157 void __attribute__((naked,noinline)) CreateTask_my() {
 158 asm volatile (
 159 "    STMFD   SP!, {R0}\n"
 160 //R3 = Pointer to task function to create
 161 
 162 /*** INSTALL capt_seq_task() hook ***/
 163 "    LDR     R0, =task_CaptSeq\n"       // DryOS original code function ptr.
 164 "    CMP     R0, R3\n"                  // is the given taskptr equal to our searched function?
 165 "    LDREQ   R3, =capt_seq_task\n"      // if so replace with our task function base ptr.
 166 "    BEQ     exitHook\n"                // below compares not necessary if this check has found something.
 167 
 168 /*** INSTALL task_developseq() hook ***/
 169 "    LDR     R0, =task_DvlpSeqTask\n"
 170 "    CMP     R0, R3\n"
 171 "    LDREQ   R3, =task_developseq_my\n"
 172 "    BEQ     exitHook\n"
 173 
 174 /*** INSTALL exp_drv_task() hook ***/
 175 "    LDR     R0, =task_ExpDrv\n"
 176 "    CMP     R0, R3\n"
 177 "    LDREQ   R3, =exp_drv_task\n"
 178 "    BEQ     exitHook\n"
 179 
 180 /*** INSTALL filewrite() hook ***/
 181 "    LDR     R0, =task_FileWrite\n"
 182 "    CMP     R0, R3\n"
 183 "    LDREQ   R3, =filewritetask\n"
 184 "    BEQ     exitHook\n"
 185 
 186 /*** INSTALL JogDial() hook ***/
 187 "    LDR     R0, =task_RotaryEncoder\n"
 188 "    CMP     R0, R3\n"
 189 "    LDREQ   R3, =JogDial_task_my\n"
 190 "    BEQ     exitHook\n"
 191 
 192 /*** INSTALL movie_record_task() hook ***/
 193 // "    LDR     R0, =task_MovieRecord\n"
 194 // "    CMP     R0, R3\n"
 195 // "    LDREQ   R3, =movie_record_task\n"
 196 // "    BEQ     exitHook\n"
 197 
 198 /*** INSTALL init_file_modules_task() hook ***/
 199 "    LDR     R0, =task_InitFileModules\n"
 200 "    CMP     R0, R3\n"
 201 "    LDREQ   R3, =init_file_modules_task\n"
 202 
 203 "exitHook:\n"
 204 // restore overwritten registers
 205 "    LDMFD   SP!, {R0}\n"
 206 // Execute overwritten instructions from original code, then jump to firmware
 207 "    STMFD   SP!, {R1-R9,LR} \n"
 208 "    MOV     R4, R0 \n"
 209 "    LDR     PC, =0x003F5780 \n"  // Continue in firmware
 210 );
 211 }
 212 
 213 /*************************************************************/
 214 //** sub_FF8103C4_my @ 0xFF8103C4 - 0xFF81042C, length=27
 215 void __attribute__((naked,noinline)) sub_FF8103C4_my() {
 216 
 217     //Replacement of sub_ for correct power-on.
 218     //(short press = playback mode, long press = record mode)
 219 
 220     // look at power-on switch sub_FF81BB18
 221     // value and pointer from sub_FF858620
 222     *(int*)(0x2b20+0x4) = (*(int*)0xC0220114)&1 ? 0x200000 : 0x100000;
 223 
 224 asm volatile (
 225 "    LDR     R0, =0xFF81043C \n"
 226 "    MOV     R1, #0 \n"
 227 "    LDR     R3, =0xFF810474 \n"
 228 
 229 "loc_FF8103D0:\n"
 230 "    CMP     R0, R3 \n"
 231 "    LDRCC   R2, [R0], #4 \n"
 232 "    STRCC   R2, [R1], #4 \n"
 233 "    BCC     loc_FF8103D0 \n"
 234 "    LDR     R0, =0xFF810474 \n"
 235 "    MOV     R1, #0x1B0 \n"
 236 "    LDR     R3, =0xFF81065C \n"
 237 
 238 "loc_FF8103EC:\n"
 239 "    CMP     R0, R3 \n"
 240 "    LDRCC   R2, [R0], #4 \n"
 241 "    STRCC   R2, [R1], #4 \n"
 242 "    BCC     loc_FF8103EC \n"
 243 "    MOV     R0, #0xD2 \n"
 244 "    MSR     CPSR_cxsf, R0 \n"
 245 "    MOV     SP, #0x1000 \n"
 246 "    MOV     R0, #0xD3 \n"
 247 "    MSR     CPSR_cxsf, R0 \n"
 248 "    MOV     SP, #0x1000 \n"
 249 "    LDR     R0, =0x398 \n"
 250 "    LDR     R2, =0xEEEEEEEE \n"
 251 "    MOV     R3, #0x1000 \n"
 252 
 253 "loc_FF810420:\n"
 254 "    CMP     R0, R3 \n"
 255 "    STRCC   R2, [R0], #4 \n"
 256 "    BCC     loc_FF810420 \n"
 257 "    B       sub_FF8128DC_my \n"  // --> Patched. Old value = 0xFF8128DC.
 258 );
 259 }
 260 
 261 /*************************************************************/
 262 //** sub_FF8128DC_my @ 0xFF8128DC - 0xFF812A54, length=95
 263 void __attribute__((naked,noinline)) sub_FF8128DC_my() {
 264 asm volatile (
 265 "    LDR     R0, =0x1A54 \n"
 266 "    STR     LR, [SP, #-4]! \n"
 267 "    SUB     SP, SP, #0x74 \n"
 268 "    MOV     R1, #0x80000 \n"
 269 "    STR     R1, [R0] \n"
 270 "    LDR     R0, =0x4090E980 \n"
 271 "    LDR     R1, =0x1A58 \n"
 272 "    STR     R0, [R1] \n"
 273 "    LDR     R1, =0x1A5C \n"
 274 "    ADD     R0, R0, #0x2000 \n"
 275 "    STR     R0, [R1] \n"
 276 "    MOV     R1, #0x74 \n"
 277 "    MOV     R0, SP \n"
 278 "    BL      sub_003FC330 \n"
 279 "    MOV     R0, #0x57000 \n"
 280 "    STR     R0, [SP, #4] \n"
 281 
 282 #if defined(CHDK_NOT_IN_CANON_HEAP) // use original heap offset if CHDK is loaded in high memory
 283 "    LDR     R0, =0x16FB10 \n"
 284 #else
 285 "    LDR     R0, =new_sa\n"   // otherwise use patched value
 286 "    LDR     R0, [R0]\n"      //
 287 #endif
 288 
 289 "    LDR     R2, =0x2EE7B0 \n"
 290 "    STR     R0, [SP, #8] \n"
 291 "    SUB     R0, R2, R0 \n"
 292 "    STR     R0, [SP, #0xC] \n"
 293 "    MOV     R0, #0x22 \n"
 294 "    STR     R0, [SP, #0x18] \n"
 295 "    MOV     R0, #0x7C \n"
 296 "    STR     R0, [SP, #0x1C] \n"
 297 "    LDR     R1, =0x2F7000 \n"
 298 "    LDR     R0, =0x1D3 \n"
 299 "    STR     R1, [SP] \n"
 300 "    STR     R0, [SP, #0x20] \n"
 301 "    MOV     R0, #0x96 \n"
 302 "    STR     R2, [SP, #0x10] \n"
 303 "    STR     R1, [SP, #0x14] \n"
 304 "    STR     R0, [SP, #0x24] \n"
 305 "    STR     R0, [SP, #0x28] \n"
 306 "    MOV     R0, #0x64 \n"
 307 "    STR     R0, [SP, #0x2C] \n"
 308 "    MOV     R0, #0 \n"
 309 "    STR     R0, [SP, #0x30] \n"
 310 "    STR     R0, [SP, #0x34] \n"
 311 "    STR     R0, [SP, #0x38] \n"
 312 "    MOV     R0, #0x10 \n"
 313 "    STR     R0, [SP, #0x5C] \n"
 314 "    MOV     R0, #0x1000 \n"
 315 "    STR     R0, [SP, #0x60] \n"
 316 "    MOV     R0, #0x100 \n"
 317 "    STR     R0, [SP, #0x64] \n"
 318 "    MOV     R0, #0x2000 \n"
 319 "    STR     R0, [SP, #0x68] \n"
 320 "    LDR     R1, =sub_FF8149AC_my \n"  // --> Patched. Old value = 0xFF8149AC.
 321 "    MOV     R2, #0 \n"
 322 "    MOV     R0, SP \n"
 323 "    BL      sub_003F1C50 \n"
 324 "    ADD     SP, SP, #0x74 \n"
 325 "    LDR     PC, [SP], #4 \n"
 326 );
 327 }
 328 
 329 /*************************************************************/
 330 //** sub_FF8149AC_my @ 0xFF8149AC - 0xFF814A44, length=39
 331 void __attribute__((naked,noinline)) sub_FF8149AC_my() {
 332 asm volatile (
 333 "    STMFD   SP!, {R4,LR} \n"
 334 "    LDR     R4, =0xFF814A68 /*'/_term'*/ \n"
 335 "    BL      sub_FF810858 \n"
 336 "    LDR     R1, =0x1A54 \n"
 337 "    LDR     R0, =0x19F0 \n"
 338 "    LDR     R1, [R1] \n"
 339 "    LDR     R0, [R0] \n"
 340 "    ADD     R1, R1, #0x10 \n"
 341 "    CMP     R0, R1 \n"
 342 "    LDRCC   R0, =0xFF814A78 /*'USER_MEM size checking'*/ \n"
 343 "    BLCC    _err_init_task \n"
 344 "    BL      sub_FF813774 \n"
 345 "    CMP     R0, #0 \n"
 346 "    LDRLT   R0, =0xFF814A90 /*'dmSetup'*/ \n"
 347 "    BLLT    _err_init_task \n"
 348 "    BL      sub_FF8124E8 \n"
 349 "    CMP     R0, #0 \n"
 350 "    LDRLT   R0, =0xFF814A98 /*'termDriverInit'*/ \n"
 351 "    BLLT    _err_init_task \n"
 352 "    MOV     R0, R4 \n"
 353 "    BL      sub_FF8125D0 \n"
 354 "    CMP     R0, #0 \n"
 355 "    LDRLT   R0, =0xFF814AA8 /*'termDeviceCreate'*/ \n"
 356 "    BLLT    _err_init_task \n"
 357 "    MOV     R0, R4 \n"
 358 "    BL      sub_FF812100 \n"
 359 "    CMP     R0, #0 \n"
 360 "    LDRLT   R0, =0xFF814ABC /*'stdioSetup'*/ \n"
 361 "    BLLT    _err_init_task \n"
 362 "    BL      sub_FF815014 \n"
 363 "    CMP     R0, #0 \n"
 364 "    LDRLT   R0, =0xFF814AC8 /*'stdlibSetup'*/ \n"
 365 "    BLLT    _err_init_task \n"
 366 "    BL      sub_FF8110A8 \n"
 367 "    CMP     R0, #0 \n"
 368 "    LDRLT   R0, =0xFF814AD4 /*'extlib_setup'*/ \n"
 369 "    BLLT    _err_init_task \n"
 370 "    LDMFD   SP!, {R4,LR} \n"
 371 "    B       sub_FF817CEC_my \n"  // --> Patched. Old value = 0xFF817CEC.
 372 );
 373 }
 374 
 375 /*************************************************************/
 376 //** sub_FF817CEC_my @ 0xFF817CEC - 0xFF817D5C, length=29
 377 void __attribute__((naked,noinline)) sub_FF817CEC_my() {
 378 asm volatile (
 379 "    STMFD   SP!, {R3,LR} \n"
 380 //"  BL      _sub_FF823044 \n"  // --> Nullsub call removed.
 381 "    BL      sub_FF826CC8 \n"
 382 "    CMP     R0, #0 \n"
 383 "    BNE     loc_FF817D10 \n"
 384 "    BL      sub_FF81C958 /*_IsNormalCameraMode_FW*/ \n"
 385 "    CMP     R0, #0 \n"
 386 "    MOVNE   R0, #1 \n"
 387 "    BNE     loc_FF817D14 \n"
 388 
 389 "loc_FF817D10:\n"
 390 "    MOV     R0, #0 \n"
 391 
 392 "loc_FF817D14:\n"
 393 "    BL      sub_FF81BB18_my \n"  // --> Patched. Old value = 0xFF81BB18.
 394 "    CMP     R0, #0 \n"
 395 "    BNE     loc_FF817D28 \n"
 396 "    BL      sub_FF81B404 \n"
 397 
 398 "loc_FF817D24:\n"
 399 "    B       loc_FF817D24 \n"
 400 
 401 "loc_FF817D28:\n"
 402 "    BL      sub_003F8A34 \n"
 403 "    LDR     R1, =0x34E000 \n"
 404 "    MOV     R0, #0 \n"
 405 "    BL      sub_FF827210 \n"
 406 "    BL      sub_003F8D78 \n"
 407 "    MOV     R3, #0 \n"
 408 "    STR     R3, [SP] \n"
 409 "    LDR     R3, =task_Startup_my \n"  // --> Patched. Old value = 0xFF817C84.
 410 "    MOV     R2, #0 \n"
 411 "    MOV     R1, #0x19 \n"
 412 "    LDR     R0, =0xFF817D68 /*'Startup'*/ \n"
 413 "    BL      _CreateTask \n"
 414 "    MOV     R0, #0 \n"
 415 "    LDMFD   SP!, {R3,PC} \n"
 416 );
 417 }
 418 
 419 /*************************************************************/
 420 //** sub_FF81BB18_my @ 0xFF81BB18 - 0xFF81BB7C, length=26
 421 void __attribute__((naked,noinline)) sub_FF81BB18_my() {
 422 asm volatile (
 423 "    STMFD   SP!, {R2-R8,LR} \n"
 424 "    MOV     R6, #0 \n"
 425 "    MOV     R8, R0 \n"
 426 "    MOV     R7, R6 \n"
 427 //"  BL      _sub_FF858618 \n"  // --> Nullsub call removed.
 428 "    LDR     R0, =0xC0220114 \n"
 429 "    BL      sub_FF8569F4 \n"
 430 "    MOV     R4, #1 \n"
 431 "    BIC     R5, R4, R0 \n"
 432 "    LDR     R0, =0xC022010C \n"
 433 "    BL      sub_FF8569F4 \n"
 434 "    CMP     R8, #0 \n"
 435 "    BIC     R4, R4, R0 \n"
 436 "    BEQ     loc_FF81BB58 \n"
 437 "    ORRS    R0, R5, R4 \n"
 438 "    BEQ     loc_FF81BB7C \n"
 439 
 440 "loc_FF81BB58:\n"
 441 "    BL      sub_FF826CC8 \n"
 442 "    MOV     R2, R0 \n"
 443 "    MOV     R3, #0 \n"
 444 "    MOV     R1, R4 \n"
 445 "    MOV     R0, R5 \n"
 446 "    STRD    R6, [SP] \n"
 447 //"  BL      _sub_FF858620 \n"  // Disable StartUpChecks
 448 //"  BL      _sub_FF85861C \n"  // --> Nullsub call removed.
 449 "    MOV     R0, #1 \n"
 450 
 451 "loc_FF81BB7C:\n"
 452 "    LDMFD   SP!, {R2-R8,PC} \n"
 453 );
 454 }
 455 
 456 /*************************************************************/
 457 //** task_Startup_my @ 0xFF817C84 - 0xFF817CE8, length=26
 458 void __attribute__((naked,noinline)) task_Startup_my() {
 459 asm volatile (
 460 "    STMFD   SP!, {R4,LR} \n"
 461 "    BL      sub_FF812EB8 \n"
 462 "    BL      sub_FF81BF74 \n"
 463 "    BL      sub_FF81B3B0 \n"
 464 //"  BL      _sub_FF858E4C \n"  // --> Nullsub call removed.
 465 "    BL      sub_FF826F28 \n"
 466 //"  BL      _sub_FF826DC4 \n"  // load DISKBOOT.BIN
 467 "    BL      sub_FF8270AC \n"
 468 "    BL      sub_FF8272E4 \n"
 469 "    BL      sub_FF827070 \n"
 470 "    BL      sub_FF826F60 \n"
 471 "    BL      sub_FF822F7C \n"
 472 "    BL      sub_FF8272EC \n"
 473 "    BL      CreateTask_spytask\n" // added
 474 "    BL      taskcreatePhySw_my \n"  // --> Patched. Old value = 0xFF81B9C0.
 475 "    BL      sub_FF820D44 \n"
 476 "    BL      sub_FF89FAE4 \n"
 477 "    BL      sub_FF8190C4 \n"
 478 "    BL      sub_FF81AD1C \n"
 479 "    BL      sub_FF826AF8 \n"
 480 "    BL      sub_FF81B364 \n"
 481 "    BL      sub_FF81ACB8 \n"
 482 "    BL      sub_FF8470B0 \n"
 483 "    BL      sub_FF819DC8 \n"
 484 "    BL      sub_FF81AC7C \n"
 485 "    LDMFD   SP!, {R4,LR} \n"
 486 "    B       sub_FF812FE0 \n"
 487 );
 488 }
 489 
 490 /*************************************************************/
 491 //** taskcreatePhySw_my @ 0xFF81B9C0 - 0xFF81BA08, length=19
 492 void __attribute__((naked,noinline)) taskcreatePhySw_my() {
 493 asm volatile (
 494 "    STMFD   SP!, {R3-R5,LR} \n"
 495 "    BL      sub_FF825D50 \n"
 496 "    BL      sub_FF81C8A8 /*_IsFactoryMode_FW*/ \n"
 497 "    CMP     R0, #0 \n"
 498 "    BLEQ    sub_FF825CB8 /*_OpLog.Start_FW*/ \n"
 499 "    LDR     R4, =0x1CF4 \n"
 500 "    LDR     R0, [R4, #4] \n"
 501 "    CMP     R0, #0 \n"
 502 "    BNE     loc_FF81BA04 \n"
 503 "    MOV     R3, #0 \n"
 504 "    STR     R3, [SP] \n"
 505 "    LDR     R3, =mykbd_task \n"  // --> Patched. Old value = 0xFF81B98C.
 506 "    MOV     R2, #0x2000 \n"  // --> Patched. Old value = 0x800. stack size for new task_PhySw so we don't have to do stack switch
 507 "    MOV     R1, #0x17 \n"
 508 "    LDR     R0, =0xFF81BC74 /*'PhySw'*/ \n"
 509 "    BL      sub_003F7C6C /*_CreateTaskStrictly*/ \n"
 510 "    STR     R0, [R4, #4] \n"
 511 
 512 "loc_FF81BA04:\n"
 513 "    LDMFD   SP!, {R3-R5,LR} \n"
 514 "    B       sub_FF8592D4 \n"
 515 );
 516 }
 517 
 518 /*************************************************************/
 519 //** init_file_modules_task @ 0xFF849E18 - 0xFF849E4C, length=14
 520 void __attribute__((naked,noinline)) init_file_modules_task() {
 521 asm volatile (
 522 "    STMFD   SP!, {R4-R6,LR} \n"
 523 "    BL      sub_FF88B780 \n"
 524 "    LDR     R5, =0x5006 \n"
 525 "    MOVS    R4, R0 \n"
 526 "    MOVNE   R1, #0 \n"
 527 "    MOVNE   R0, R5 \n"
 528 "    BLNE    _PostLogicalEventToUI \n"
 529 "    BL      sub_FF88B7B4 \n"
 530 "    BL      core_spytask_can_start\n"  // CHDK: Set "it's-safe-to-start" flag for spytask
 531 "    CMP     R4, #0 \n"
 532 "    LDMNEFD SP!, {R4-R6,PC} \n"
 533 "    MOV     R0, R5 \n"
 534 "    LDMFD   SP!, {R4-R6,LR} \n"
 535 "    MOV     R1, #0 \n"
 536 "    B       _PostLogicalEventToUI \n"
 537 );
 538 }
 539 
 540 /*************************************************************/
 541 //** JogDial_task_my @ 0xFF858F98 - 0xFF8592D0, length=207
 542 void __attribute__((naked,noinline)) JogDial_task_my() {
 543 asm volatile (
 544 "    STMFD   SP!, {R4-R11,LR} \n"
 545 "    SUB     SP, SP, #0x1C \n"
 546 "    BL      sub_FF859340 \n"
 547 "    LDR     R12, =0x2B30 \n"
 548 "    LDR     R6, =0xFFBACCE4 \n"
 549 "    MOV     R0, #0 \n"
 550 "    ADD     R10, SP, #8 \n"
 551 "    ADD     R9, SP, #0xC \n"
 552 
 553 // Save pointer for kbd.c routine
 554 "    LDR     R2, =jog_position \n"
 555 "    STR     R9, [R2] \n"
 556 
 557 
 558 "loc_FF858FB8:\n"
 559 "    ADD     R2, SP, #0x14 \n"
 560 "    MOV     R1, #0 \n"
 561 "    ADD     R4, R2, R0, LSL#1 \n"
 562 "    ADD     R3, SP, #0x10 \n"
 563 "    STRH    R1, [R4] \n"
 564 "    ADD     R4, R3, R0, LSL#1 \n"
 565 "    STRH    R1, [R4] \n"
 566 "    STR     R1, [R9, R0, LSL#2] \n"
 567 "    STR     R1, [R10, R0, LSL#2] \n"
 568 "    ADD     R0, R0, #1 \n"
 569 "    CMP     R0, #1 \n"
 570 "    BLT     loc_FF858FB8 \n"
 571 
 572 "loc_FF858FE8:\n"
 573 "    LDR     R0, =0x2B30 \n"
 574 "    MOV     R2, #0 \n"
 575 "    LDR     R0, [R0, #8] \n"
 576 "    MOV     R1, SP \n"
 577 "    BL      sub_003F84B8 /*_ReceiveMessageQueue*/ \n"
 578 "    CMP     R0, #0 \n"
 579 "    LDRNE   R2, =0x20B \n"
 580 "    LDRNE   R1, =0xFF859258 /*'RotaryEncoder.c'*/ \n"
 581 "    MOVNE   R0, #0 \n"
 582 "    BLNE    _DebugAssert \n"
 583 "    LDR     R0, [SP] \n"
 584 "    AND     R4, R0, #0xFF \n"
 585 "    AND     R0, R0, #0xFF00 \n"
 586 "    CMP     R0, #0x100 \n"
 587 "    BEQ     loc_FF859060 \n"
 588 "    CMP     R0, #0x200 \n"
 589 "    BEQ     loc_FF859098 \n"
 590 "    CMP     R0, #0x300 \n"
 591 "    BEQ     loc_FF8592A4 \n"
 592 "    CMP     R0, #0x400 \n"
 593 "    BNE     loc_FF858FE8 \n"
 594 "    CMP     R4, #0 \n"
 595 "    LDRNE   R2, =0x285 \n"
 596 "    LDRNE   R1, =0xFF859258 /*'RotaryEncoder.c'*/ \n"
 597 "    MOVNE   R0, #0 \n"
 598 "    BLNE    _DebugAssert \n"
 599 "    RSB     R0, R4, R4, LSL#3 \n"
 600 "    LDR     R0, [R6, R0, LSL#2] \n"
 601 
 602 "loc_FF859058:\n"
 603 "    BL      sub_FF859324 \n"
 604 "    B       loc_FF858FE8 \n"
 605 
 606 "loc_FF859060:\n"
 607 //------------------  added code ---------------------
 608 "labelA:\n"
 609 "    LDR     R0, =jogdial_stopped\n"
 610 "    LDR     R0, [R0]\n"
 611 "    CMP     R0, #1\n"
 612 "    BNE     labelB\n"
 613 "    MOV     R0, #40\n"
 614 "    BL      _SleepTask\n"
 615 "    B       labelA\n"
 616 "labelB:\n"
 617 //------------------  original code ------------------
 618 "    LDR     R0, =0x2B3C \n"
 619 "    LDR     R0, [R0, R4, LSL#2] \n"
 620 "    BL      sub_FF816298 /*_CancelTimer*/ \n"
 621 "    LDR     R2, =0xFF858EDC \n"
 622 "    ORR     R3, R4, #0x200 \n"
 623 "    MOV     R1, R2 \n"
 624 "    MOV     R0, #0x28 \n"
 625 "    BL      sub_FF8161C8 /*_SetTimerAfter*/ \n"
 626 "    TST     R0, #1 \n"
 627 "    CMPNE   R0, #0x15 \n"
 628 "    STR     R0, [R10, R4, LSL#2] \n"
 629 "    BEQ     loc_FF858FE8 \n"
 630 "    LDR     R2, =0x21D \n"
 631 "    B       loc_FF859240 \n"
 632 
 633 "loc_FF859098:\n"
 634 "    RSB     R5, R4, R4, LSL#3 \n"
 635 "    LDR     R0, [R6, R5, LSL#2] \n"
 636 "    LDR     R1, =0xC0240000 \n"
 637 "    ADD     R0, R1, R0, LSL#8 \n"
 638 "    LDR     R0, [R0, #0x104] \n"
 639 "    MOV     R1, R0, ASR#16 \n"
 640 "    ADD     R0, SP, #0x14 \n"
 641 "    ADD     R11, R0, R4, LSL#1 \n"
 642 "    ADD     R0, SP, #0x10 \n"
 643 "    ADD     R0, R0, R4, LSL#1 \n"
 644 "    STRH    R1, [R11] \n"
 645 "    STR     R0, [SP, #0x18] \n"
 646 "    LDRSH   R3, [R0] \n"
 647 "    SUB     R2, R1, R3 \n"
 648 "    CMP     R2, #0 \n"
 649 "    BNE     loc_FF85911C \n"
 650 "    LDR     R0, [R9, R4, LSL#2] \n"
 651 "    CMP     R0, #0 \n"
 652 "    BEQ     loc_FF8591FC \n"
 653 "    LDR     R7, =0x2B3C \n"
 654 "    LDR     R0, [R7, R4, LSL#2] \n"
 655 "    BL      sub_FF816298 /*_CancelTimer*/ \n"
 656 "    LDR     R2, =0xFF858EE8 \n"
 657 "    ORR     R3, R4, #0x300 \n"
 658 "    MOV     R1, R2 \n"
 659 "    MOV     R0, #0x1F4 \n"
 660 "    BL      sub_FF8161C8 /*_SetTimerAfter*/ \n"
 661 "    TST     R0, #1 \n"
 662 "    CMPNE   R0, #0x15 \n"
 663 "    STR     R0, [R7, R4, LSL#2] \n"
 664 "    BEQ     loc_FF8591FC \n"
 665 "    LDR     R2, =0x236 \n"
 666 "    B       loc_FF8591F0 \n"
 667 
 668 "loc_FF85911C:\n"
 669 "    MOV     R0, R2 \n"
 670 "    RSBLT   R0, R0, #0 \n"
 671 "    MOVLE   R7, #0 \n"
 672 "    MOVGT   R7, #1 \n"
 673 "    CMP     R0, #0xFF \n"
 674 "    BLS     loc_FF859158 \n"
 675 "    LDR     R0, =0x7FFF \n"
 676 "    CMP     R2, #0 \n"
 677 "    SUBLE   R0, R0, R3 \n"
 678 "    ADDLE   R0, R0, R1 \n"
 679 "    SUBGT   R0, R0, R1 \n"
 680 "    ADDGT   R0, R0, R3 \n"
 681 "    MVN     R1, #0x8000 \n"
 682 "    SUB     R0, R0, R1 \n"
 683 "    EOR     R7, R7, #1 \n"
 684 
 685 "loc_FF859158:\n"
 686 "    STR     R0, [SP, #4] \n"
 687 "    LDR     R0, [R9, R4, LSL#2] \n"
 688 "    CMP     R0, #0 \n"
 689 "    ADDEQ   R0, R6, R5, LSL#2 \n"
 690 "    LDREQ   R0, [R0, #8] \n"
 691 "    BEQ     loc_FF859190 \n"
 692 "    ADD     R8, R6, R5, LSL#2 \n"
 693 "    ADD     R1, R8, R7, LSL#2 \n"
 694 "    LDR     R1, [R1, #0x10] \n"
 695 "    CMP     R1, R0 \n"
 696 "    BEQ     loc_FF859194 \n"
 697 "    LDR     R0, [R8, #0xC] \n"
 698 "    BL      sub_FF81BA0C \n"
 699 "    LDR     R0, [R8, #8] \n"
 700 
 701 "loc_FF859190:\n"
 702 "    BL      sub_FF81BA0C \n"
 703 
 704 "loc_FF859194:\n"
 705 "    ADD     R0, R6, R5, LSL#2 \n"
 706 "    ADD     R7, R0, R7, LSL#2 \n"
 707 "    LDR     R0, [R7, #0x10] \n"
 708 "    LDR     R1, [SP, #4] \n"
 709 "    BL      sub_FF81BA1C \n"
 710 "    LDR     R0, [R7, #0x10] \n"
 711 "    LDR     R7, =0x2B3C \n"
 712 "    STR     R0, [R9, R4, LSL#2] \n"
 713 "    LDRH    R1, [R11] \n"
 714 "    LDR     R0, [SP, #0x18] \n"
 715 "    STRH    R1, [R0] \n"
 716 "    LDR     R0, [R7, R4, LSL#2] \n"
 717 "    BL      sub_FF816298 /*_CancelTimer*/ \n"
 718 "    LDR     R2, =0xFF858EE8 \n"
 719 "    ORR     R3, R4, #0x300 \n"
 720 "    MOV     R1, R2 \n"
 721 "    MOV     R0, #0x1F4 \n"
 722 "    BL      sub_FF8161C8 /*_SetTimerAfter*/ \n"
 723 "    TST     R0, #1 \n"
 724 "    CMPNE   R0, #0x15 \n"
 725 "    STR     R0, [R7, R4, LSL#2] \n"
 726 "    BEQ     loc_FF8591FC \n"
 727 "    LDR     R2, =0x267 \n"
 728 
 729 "loc_FF8591F0:\n"
 730 "    LDR     R1, =0xFF859258 /*'RotaryEncoder.c'*/ \n"
 731 "    MOV     R0, #0 \n"
 732 "    BL      _DebugAssert \n"
 733 
 734 "loc_FF8591FC:\n"
 735 "    ADD     R0, R6, R5, LSL#2 \n"
 736 "    LDR     R0, [R0, #0x18] \n"
 737 "    CMP     R0, #1 \n"
 738 "    BNE     loc_FF85929C \n"
 739 "    LDR     R0, =0x2B30 \n"
 740 "    LDR     R0, [R0, #0x10] \n"
 741 "    CMP     R0, #0 \n"
 742 "    BEQ     loc_FF85929C \n"
 743 "    LDR     R2, =0xFF858EDC \n"
 744 "    ORR     R3, R4, #0x400 \n"
 745 "    MOV     R1, R2 \n"
 746 "    BL      sub_FF8161C8 /*_SetTimerAfter*/ \n"
 747 "    TST     R0, #1 \n"
 748 "    CMPNE   R0, #0x15 \n"
 749 "    STR     R0, [R10, R4, LSL#2] \n"
 750 "    BEQ     loc_FF858FE8 \n"
 751 "    LDR     R2, =0x26E \n"
 752 
 753 "loc_FF859240:\n"
 754 "    LDR     R1, =0xFF859258 /*'RotaryEncoder.c'*/ \n"
 755 "    MOV     R0, #0 \n"
 756 "    BL      _DebugAssert \n"
 757 "    B       loc_FF858FE8 \n"
 758 
 759 "loc_FF85929C:\n"
 760 "    LDR     R0, [R6, R5, LSL#2] \n"
 761 "    B       loc_FF859058 \n"
 762 
 763 "loc_FF8592A4:\n"
 764 "    LDR     R0, [R9, R4, LSL#2] \n"
 765 "    CMP     R0, #0 \n"
 766 "    MOVEQ   R2, #0x278 \n"
 767 "    LDREQ   R1, =0xFF859258 /*'RotaryEncoder.c'*/ \n"
 768 "    BLEQ    _DebugAssert \n"
 769 "    RSB     R0, R4, R4, LSL#3 \n"
 770 "    ADD     R0, R6, R0, LSL#2 \n"
 771 "    LDR     R0, [R0, #0xC] \n"
 772 "    BL      sub_FF81BA0C \n"
 773 "    MOV     R0, #0 \n"
 774 "    STR     R0, [R9, R4, LSL#2] \n"
 775 "    B       loc_FF858FE8 \n"
 776 );
 777 }

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