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

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

DEFINITIONS

This source file includes following definitions.
  1. CreateTask_spytask
  2. boot
  3. CreateTask_my
  4. sub_FF000380_my
  5. sub_FF001160_my
  6. sub_FF004210_my
  7. sub_FF00A21C_my
  8. sub_FF0191E8_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 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     CreateTask_spytask
  26 -----------------------------------------------------------------------*/
  27 void CreateTask_spytask()
  28 {
  29     _CreateTask("SpyTask", 0x19, 0x2000, core_spytask, 0);
  30 }
  31 
  32 ///*----------------------------------------------------------------------
  33 // Pointer to stack location where jogdial task records previous and current
  34 // jogdial positions
  35 short *jog_position;
  36 
  37 /*----------------------------------------------------------------------
  38     boot()
  39 
  40     Main entry point for the CHDK code
  41 -----------------------------------------------------------------------*/
  42 
  43 /*************************************************************/
  44 //** boot @ 0xFF00000C - 0xFF00017C, length=93
  45 void __attribute__((naked,noinline)) boot() {
  46 asm volatile (
  47 "    LDR     R1, =0xC0410000 \n"
  48 "    MOV     R0, #0 \n"
  49 "    STR     R0, [R1] \n"
  50 "    MOV     R1, #0x78 \n"
  51 "    MCR     p15, 0, R1, c1, c0 \n"
  52 "    MOV     R1, #0 \n"
  53 "    MCR     p15, 0, R1, c7, c10, 4 \n"
  54 "    MCR     p15, 0, R1, c7, c5 \n"
  55 "    MCR     p15, 0, R1, c7, c6 \n"
  56 "    MOV     R0, #0x3D \n"
  57 "    MCR     p15, 0, R0, c6, c0 \n"
  58 "    MOV     R0, #0xC000002F \n"
  59 "    MCR     p15, 0, R0, c6, c1 \n"
  60 "    MOV     R0, #0x33 \n"
  61 "    MCR     p15, 0, R0, c6, c2 \n"
  62 "    MOV     R0, #0x40000033 \n"
  63 "    MCR     p15, 0, R0, c6, c3 \n"
  64 "    MOV     R0, #0x80000017 \n"
  65 "    MCR     p15, 0, R0, c6, c4 \n"
  66 "    LDR     R0, =0xFF00002F \n"
  67 "    MCR     p15, 0, R0, c6, c5 \n"
  68 "    MOV     R0, #0x34 \n"
  69 "    MCR     p15, 0, R0, c2, c0 \n"
  70 "    MOV     R0, #0x34 \n"
  71 "    MCR     p15, 0, R0, c2, c0, 1 \n"
  72 "    MOV     R0, #0x34 \n"
  73 "    MCR     p15, 0, R0, c3, c0 \n"
  74 "    LDR     R0, =0x3333330 \n"
  75 "    MCR     p15, 0, R0, c5, c0, 2 \n"
  76 "    LDR     R0, =0x3333330 \n"
  77 "    MCR     p15, 0, R0, c5, c0, 3 \n"
  78 "    MRC     p15, 0, R0, c1, c0 \n"
  79 "    ORR     R0, R0, #0x1000 \n"
  80 "    ORR     R0, R0, #4 \n"
  81 "    ORR     R0, R0, #1 \n"
  82 "    MCR     p15, 0, R0, c1, c0 \n"
  83 "    MOV     R1, #0x80000006 \n"
  84 "    MCR     p15, 0, R1, c9, c1 \n"
  85 "    MOV     R1, #6 \n"
  86 "    MCR     p15, 0, R1, c9, c1, 1 \n"
  87 "    MRC     p15, 0, R1, c1, c0 \n"
  88 "    ORR     R1, R1, #0x50000 \n"
  89 "    MCR     p15, 0, R1, c1, c0 \n"
  90 "    LDR     R2, =0xC0200000 \n"
  91 "    MOV     R1, #1 \n"
  92 "    STR     R1, [R2, #0x10C] \n"
  93 "    MOV     R1, #0xFF \n"
  94 "    STR     R1, [R2, #0xC] \n"
  95 "    STR     R1, [R2, #0x1C] \n"
  96 "    STR     R1, [R2, #0x2C] \n"
  97 "    STR     R1, [R2, #0x3C] \n"
  98 "    STR     R1, [R2, #0x4C] \n"
  99 "    STR     R1, [R2, #0x5C] \n"
 100 "    STR     R1, [R2, #0x6C] \n"
 101 "    STR     R1, [R2, #0x7C] \n"
 102 "    STR     R1, [R2, #0x8C] \n"
 103 "    STR     R1, [R2, #0x9C] \n"
 104 "    STR     R1, [R2, #0xAC] \n"
 105 "    STR     R1, [R2, #0xBC] \n"
 106 "    STR     R1, [R2, #0xCC] \n"
 107 "    STR     R1, [R2, #0xDC] \n"
 108 "    STR     R1, [R2, #0xEC] \n"
 109 "    STR     R1, [R2, #0xFC] \n"
 110 "    LDR     R1, =0xC0400008 \n"
 111 "    LDR     R2, =0x430005 \n"
 112 "    STR     R2, [R1] \n"
 113 "    MOV     R1, #1 \n"
 114 "    LDR     R2, =0xC0243100 \n"
 115 "    STR     R2, [R1] \n"
 116 "    LDR     R2, =0xC0242010 \n"
 117 "    LDR     R1, [R2] \n"
 118 "    ORR     R1, R1, #1 \n"
 119 "    STR     R1, [R2] \n"
 120 "    LDR     R0, =0xFF4E1414 \n"
 121 "    LDR     R1, =0x431000 \n"
 122 "    LDR     R3, =0x44059C \n"
 123 
 124 "loc_FF00013C:\n"
 125 "    CMP     R1, R3 \n"
 126 "    LDRCC   R2, [R0], #4 \n"
 127 "    STRCC   R2, [R1], #4 \n"
 128 "    BCC     loc_FF00013C \n"
 129 "    LDR     R0, =0xFF4D317C \n"
 130 "    LDR     R1, =0x1900 \n"
 131 "    LDR     R3, =0xFB98 \n"
 132 
 133 "loc_FF000158:\n"
 134 "    CMP     R1, R3 \n"
 135 "    LDRCC   R2, [R0], #4 \n"
 136 "    STRCC   R2, [R1], #4 \n"
 137 "    BCC     loc_FF000158 \n"
 138 "    LDR     R1, =0x1791C0 \n"
 139 "    MOV     R2, #0 \n"
 140 
 141 "loc_FF000170:\n"
 142 "    CMP     R3, R1 \n"
 143 "    STRCC   R2, [R3], #4 \n"
 144 "    BCC     loc_FF000170 \n"
 145 /* Install task hooks via 0x193x is not possible with this new dryos version
 146    So the below code patches the CreateTask function in RAM to install our
 147    hook -- ERR99
 148 */
 149 // Install CreateTask patch
 150 "    LDR     R0, =patch_CreateTask\n"   // Patch data
 151 "    LDM     R0, {R1,R2}\n"             // Get two patch instructions
 152 "    LDR     R0, =hook_CreateTask\n"    // Address to patch
 153 "    STM     R0, {R1,R2}\n"             // Store patch instructions
 154 
 155 "    B       sub_FF000380_my \n"  // --> Patched. Old value = 0xFF000380.
 156 
 157 "patch_CreateTask:\n"
 158 "    LDR     PC, [PC,#-0x4]\n"          // Do jump to absolute address CreateTask_my
 159 "    .long   CreateTask_my\n"
 160 );
 161 }
 162 
 163 /*************************************************************/
 164 //** CreateTask_my @ 0x004368B0 - 0x004368B4, length=2
 165 void __attribute__((naked,noinline)) CreateTask_my() {
 166 asm volatile (
 167 "    STMFD   SP!, {R0}\n"
 168 //R3 = Pointer to task function to create
 169 
 170 /*** INSTALL capt_seq_task() hook ***/
 171 "    LDR     R0, =task_CaptSeq\n"       // DryOS original code function ptr.
 172 "    CMP     R0, R3\n"                  // is the given taskptr equal to our searched function?
 173 "    LDREQ   R3, =capt_seq_task\n"      // if so replace with our task function base ptr.
 174 "    BEQ     exitHook\n"                // below compares not necessary if this check has found something.
 175 
 176 /*** INSTALL exp_drv_task() hook ***/
 177 "    LDR     R0, =task_ExpDrv\n"
 178 "    CMP     R0, R3\n"
 179 "    LDREQ   R3, =exp_drv_task\n"
 180 "    BEQ     exitHook\n"
 181 
 182 /*** INSTALL filewrite() hook ***/
 183 "    LDR     R0, =task_FileWrite\n"
 184 "    CMP     R0, R3\n"
 185 "    LDREQ   R3, =filewritetask\n"
 186 "    BEQ     exitHook\n"
 187 
 188 /*** INSTALL JogDial() hook ***/
 189 "    LDR     R0, =task_RotaryEncoder\n"
 190 "    CMP     R0, R3\n"
 191 "    LDREQ   R3, =JogDial_task_my\n"
 192 "    BEQ     exitHook\n"
 193 
 194 /*** INSTALL movie_record_task() hook ***/
 195 "    LDR     R0, =task_MovieRecord\n"
 196 "    CMP     R0, R3\n"
 197 "    LDREQ   R3, =movie_record_task\n"
 198 "    BEQ     exitHook\n"
 199 
 200 /*** INSTALL init_file_modules_task() hook ***/
 201 "    LDR     R0, =task_InitFileModules\n"
 202 "    CMP     R0, R3\n"
 203 "    LDREQ   R3, =init_file_modules_task\n"
 204 
 205 "exitHook:\n"
 206 // restore overwritten registers
 207 "    LDMFD   SP!, {R0}\n"
 208 // Execute overwritten instructions from original code, then jump to firmware
 209 "    STMFD   SP!, {R1-R9,LR} \n"
 210 "    MOV     R4, R0 \n"
 211 "    LDR     PC, =0x004368B8 \n"  // Continue in firmware
 212 );
 213 }
 214 
 215 /*************************************************************/
 216 //** sub_FF000380_my @ 0xFF000380 - 0xFF0003E8, length=27
 217 void __attribute__((naked,noinline)) sub_FF000380_my() {
 218 
 219     //Replacement of sub_FF055F04 for correct power-on.
 220     //(short press = playback mode, long press = record mode)
 221     //look at power-on switch sub_FF0191E8
 222     *(int*)(0x2B14+0x4) = (*(int*)0xC0220104&1 ? 0x100000 : 0x200000);
 223 
 224 asm volatile (
 225 "    LDR     R0, =0xFF0003F8 \n"
 226 "    MOV     R1, #0 \n"
 227 "    LDR     R3, =0xFF000430 \n"
 228 
 229 "loc_FF00038C:\n"
 230 "    CMP     R0, R3 \n"
 231 "    LDRCC   R2, [R0], #4 \n"
 232 "    STRCC   R2, [R1], #4 \n"
 233 "    BCC     loc_FF00038C \n"
 234 "    LDR     R0, =0xFF000430 \n"
 235 "    MOV     R1, #0x4B0 \n"
 236 "    LDR     R3, =0xFF000618 \n"
 237 
 238 "loc_FF0003A8:\n"
 239 "    CMP     R0, R3 \n"
 240 "    LDRCC   R2, [R0], #4 \n"
 241 "    STRCC   R2, [R1], #4 \n"
 242 "    BCC     loc_FF0003A8 \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, =0x698 \n"
 250 "    LDR     R2, =0xEEEEEEEE \n"
 251 "    MOV     R3, #0x1000 \n"
 252 
 253 "loc_FF0003DC:\n"
 254 "    CMP     R0, R3 \n"
 255 "    STRCC   R2, [R0], #4 \n"
 256 "    BCC     loc_FF0003DC \n"
 257 "    BL      sub_FF001160_my \n"  // --> Patched. Old value = 0xFF001160.
 258 );
 259 }
 260 
 261 /*************************************************************/
 262 //** sub_FF001160_my @ 0xFF001160 - 0xFF00120C, length=44
 263 void __attribute__((naked,noinline)) sub_FF001160_my() {
 264 asm volatile (
 265 "    STR     LR, [SP, #-4]! \n"
 266 "    SUB     SP, SP, #0x74 \n"
 267 "    MOV     R1, #0x74 \n"
 268 "    MOV     R0, SP \n"
 269 "    BL      sub_0043C3A0 \n"
 270 "    MOV     R0, #0x57000 \n"
 271 "    STR     R0, [SP, #4] \n"
 272 
 273 #if defined(CHDK_NOT_IN_CANON_HEAP) // use original heap offset if CHDK is loaded in high memory
 274 "    LDR     R0, =0x1791C0 \n"
 275 #else
 276 "    LDR     R0, =new_sa\n"   // otherwise use patched value
 277 "    LDR     R0, [R0]\n"      //
 278 #endif
 279 
 280 "    LDR     R2, =0x32D440 \n"
 281 "    STR     R0, [SP, #8] \n"
 282 "    SUB     R0, R2, R0 \n"
 283 "    STR     R0, [SP, #0xC] \n"
 284 "    MOV     R0, #0x22 \n"
 285 "    STR     R0, [SP, #0x18] \n"
 286 "    MOV     R0, #0x7C \n"
 287 "    STR     R0, [SP, #0x1C] \n"
 288 "    LDR     R1, =0x335C00 \n"
 289 "    LDR     R0, =0x1CD \n"
 290 "    STR     R1, [SP] \n"
 291 "    STR     R0, [SP, #0x20] \n"
 292 "    MOV     R0, #0x96 \n"
 293 "    STR     R2, [SP, #0x10] \n"
 294 "    STR     R1, [SP, #0x14] \n"
 295 "    STR     R0, [SP, #0x24] \n"
 296 "    STR     R0, [SP, #0x28] \n"
 297 "    MOV     R0, #0x64 \n"
 298 "    STR     R0, [SP, #0x2C] \n"
 299 "    MOV     R0, #0 \n"
 300 "    STR     R0, [SP, #0x30] \n"
 301 "    STR     R0, [SP, #0x34] \n"
 302 "    MOV     R0, #0x10 \n"
 303 "    STR     R0, [SP, #0x5C] \n"
 304 "    MOV     R0, #0x800 \n"
 305 "    STR     R0, [SP, #0x60] \n"
 306 "    MOV     R0, #0xA0 \n"
 307 "    STR     R0, [SP, #0x64] \n"
 308 "    MOV     R0, #0x280 \n"
 309 "    STR     R0, [SP, #0x68] \n"
 310 "    LDR     R1, =sub_FF004210_my \n"  // --> Patched. Old value = 0xFF004210.
 311 "    MOV     R2, #0 \n"
 312 "    MOV     R0, SP \n"
 313 "    BL      sub_004327E8 \n"
 314 "    ADD     SP, SP, #0x74 \n"
 315 "    LDR     PC, [SP], #4 \n"
 316 );
 317 }
 318 
 319 /*************************************************************/
 320 //** sub_FF004210_my @ 0xFF004210 - 0xFF004284, length=30
 321 void __attribute__((naked,noinline)) sub_FF004210_my() {
 322 asm volatile (
 323 "    STMFD   SP!, {R4,LR} \n"
 324 "    BL      sub_FF000ADC \n"
 325 "    BL      sub_FF0050FC \n"
 326 "    CMP     R0, #0 \n"
 327 "    LDRLT   R0, =0xFF004324 /*'dmSetup'*/ \n"
 328 "    BLLT    _err_init_task \n"
 329 "    BL      sub_FF003E48 \n"
 330 "    CMP     R0, #0 \n"
 331 "    LDRLT   R0, =0xFF00432C /*'termDriverInit'*/ \n"
 332 "    BLLT    _err_init_task \n"
 333 "    LDR     R0, =0xFF00433C /*'/_term'*/ \n"
 334 "    BL      sub_FF003F30 \n"
 335 "    CMP     R0, #0 \n"
 336 "    LDRLT   R0, =0xFF004344 /*'termDeviceCreate'*/ \n"
 337 "    BLLT    _err_init_task \n"
 338 "    LDR     R0, =0xFF00433C /*'/_term'*/ \n"
 339 "    BL      sub_FF002950 \n"
 340 "    CMP     R0, #0 \n"
 341 "    LDRLT   R0, =0xFF004358 /*'stdioSetup'*/ \n"
 342 "    BLLT    _err_init_task \n"
 343 "    BL      sub_FF004A98 \n"
 344 "    CMP     R0, #0 \n"
 345 "    LDRLT   R0, =0xFF004364 /*'stdlibSetup'*/ \n"
 346 "    BLLT    _err_init_task \n"
 347 "    BL      sub_FF001650 \n"
 348 "    CMP     R0, #0 \n"
 349 "    LDRLT   R0, =0xFF004370 /*'armlib_setup'*/ \n"
 350 "    BLLT    _err_init_task \n"
 351 "    LDMFD   SP!, {R4,LR} \n"
 352 "    B       sub_FF00A21C_my \n"  // --> Patched. Old value = 0xFF00A21C.
 353 );
 354 }
 355 
 356 /*************************************************************/
 357 //** sub_FF00A21C_my @ 0xFF00A21C - 0xFF00A298, length=32
 358 void __attribute__((naked,noinline)) sub_FF00A21C_my() {
 359 asm volatile (
 360 "    STMFD   SP!, {R3,LR} \n"
 361 "    BL      sub_FF0209AC \n"
 362 "    CMP     R0, #0 \n"
 363 "    BNE     loc_FF00A23C \n"
 364 "    BL      sub_FF01AD48 /*_IsNormalCameraMode_FW*/ \n"
 365 "    CMP     R0, #0 \n"
 366 "    MOVNE   R0, #1 \n"
 367 "    BNE     loc_FF00A240 \n"
 368 
 369 "loc_FF00A23C:\n"
 370 "    MOV     R0, #0 \n"
 371 
 372 "loc_FF00A240:\n"
 373 "    BL      sub_FF0191E8_my \n"  // --> Patched. Old value = 0xFF0191E8.
 374 "    CMP     R0, #0 \n"
 375 "    BNE     loc_FF00A264 \n"
 376 "    BL      sub_FF01883C \n"
 377 "    LDR     R1, =0xC0220000 \n"
 378 "    MOV     R0, #0x44 \n"
 379 "    STR     R0, [R1, #0x12C] \n"
 380 "    BL      sub_FF0189B0 \n"
 381 
 382 "loc_FF00A260:\n"
 383 "    B       loc_FF00A260 \n"
 384 
 385 "loc_FF00A264:\n"
 386 "    BL      sub_0043786C \n"
 387 "    LDR     R1, =0x38E000 \n"
 388 "    MOV     R0, #0 \n"
 389 "    BL      sub_FF01EFEC \n"
 390 "    BL      sub_00437A84 /*_EnableDispatch*/ \n"
 391 "    MOV     R3, #0 \n"
 392 "    STR     R3, [SP] \n"
 393 "    LDR     R3, =task_Startup_my \n"  // --> Patched. Old value = 0xFF00A1B4.
 394 "    MOV     R2, #0 \n"
 395 "    MOV     R1, #0x19 \n"
 396 "    LDR     R0, =0xFF00A2A8 /*'Startup'*/ \n"
 397 "    BL      _CreateTask \n"
 398 "    MOV     R0, #0 \n"
 399 "    LDMFD   SP!, {R3,PC} \n"
 400 );
 401 }
 402 
 403 /*************************************************************/
 404 //** sub_FF0191E8_my @ 0xFF0191E8 - 0xFF019240, length=23
 405 void __attribute__((naked,noinline)) sub_FF0191E8_my() {
 406 asm volatile (
 407 "    STMFD   SP!, {R4-R6,LR} \n"
 408 "    MOV     R6, R0 \n"
 409 //"  BL      _sub_FF055EFC \n"  // --> Nullsub call removed.
 410 "    LDR     R0, =0xC0220104 \n"
 411 "    BL      sub_FF0569E4 \n"
 412 "    MOV     R4, #1 \n"
 413 "    BIC     R5, R4, R0 \n"
 414 "    LDR     R0, =0xC022010C \n"
 415 "    BL      sub_FF0569E4 \n"
 416 "    CMP     R6, #0 \n"
 417 "    BIC     R4, R4, R0 \n"
 418 "    BEQ     loc_FF019220 \n"
 419 "    ORRS    R0, R5, R4 \n"
 420 "    LDMEQFD SP!, {R4-R6,PC} \n"
 421 
 422 "loc_FF019220:\n"
 423 "    BL      sub_FF0209AC \n"
 424 "    MOV     R2, R0 \n"
 425 "    MOV     R3, #0 \n"
 426 "    MOV     R1, R4 \n"
 427 "    MOV     R0, R5 \n"
 428 //"  BL      _sub_FF055F04 \n"  // Disable StartUpChecks
 429 //"  BL      _sub_FF055F00 \n"  // --> Nullsub call removed.
 430 "    MOV     R0, #1 \n"
 431 "    LDMFD   SP!, {R4-R6,PC} \n"
 432 );
 433 }
 434 
 435 /*************************************************************/
 436 //** task_Startup_my @ 0xFF00A1B4 - 0xFF00A218, length=26
 437 void __attribute__((naked,noinline)) task_Startup_my() {
 438 asm volatile (
 439 "    STMFD   SP!, {R4,LR} \n"
 440 "    BL      sub_FF004850 \n"
 441 "    BL      sub_FF01A36C \n"
 442 "    BL      sub_FF01846C \n"
 443 //"  BL      _sub_FF0569F8 \n"  // --> Nullsub call removed.
 444 "    BL      sub_FF020BE0 \n"
 445 //"  BL      _sub_FF020A88 \n"  // load DISKBOOT.BIN
 446 "    BL      sub_FF020D70 \n"
 447 "    BL      sub_FF020F3C \n"
 448 "    BL      sub_FF020D34 \n"
 449 "    BL      sub_FF020C28 \n"
 450 "    BL      sub_FF01EF20 \n"
 451 "    BL      sub_FF020F44 \n"
 452 "    BL      CreateTask_spytask\n" // added
 453 "    BL      taskcreatePhySw_my \n"  // --> Patched. Old value = 0xFF019088.
 454 "    BL      sub_FF01CB60 \n"
 455 "    BL      sub_FF09A7E8 \n"
 456 "    BL      sub_FF016214 \n"
 457 "    BL      sub_FF017DB8 \n"
 458 "    BL      sub_FF02076C \n"
 459 "    BL      sub_FF018420 \n"
 460 "    BL      sub_FF017D54 \n"
 461 "    BL      sub_FF044334 \n"
 462 "    BL      sub_FF016EAC \n"
 463 "    BL      sub_FF017D18 \n"
 464 "    LDMFD   SP!, {R4,LR} \n"
 465 "    B       sub_FF004970 \n"
 466 );
 467 }
 468 
 469 /*************************************************************/
 470 //** taskcreatePhySw_my @ 0xFF019088 - 0xFF0190DC, length=22
 471 void __attribute__((naked,noinline)) taskcreatePhySw_my() {
 472 asm volatile (
 473 "    STMFD   SP!, {R3-R5,LR} \n"
 474 "    LDR     R4, =0x1D30 \n"
 475 "    LDR     R0, [R4, #4] \n"
 476 "    CMP     R0, #0 \n"
 477 "    BNE     loc_FF0190BC \n"
 478 "    MOV     R3, #0 \n"
 479 "    STR     R3, [SP] \n"
 480 "    LDR     R3, =mykbd_task \n"  // --> Patched. Old value = 0xFF019054.
 481 "    MOV     R2, #0x2000 \n"  // --> Patched. Old value = 0x800. stack size for new task_PhySw so we don't have to do stack switch
 482 "    MOV     R1, #0x17 \n"
 483 "    LDR     R0, =0xFF019338 /*'PhySw'*/ \n"
 484 "    BL      sub_00437ADC /*_CreateTaskStrictly*/ \n"
 485 "    STR     R0, [R4, #4] \n"
 486 
 487 "loc_FF0190BC:\n"
 488 "    BL      sub_FF056E68 \n"
 489 "    BL      sub_FF086644 \n"
 490 "    BL      sub_FF01AC98 /*_IsFactoryMode_FW*/ \n"
 491 "    CMP     R0, #0 \n"
 492 "    BNE     loc_FF0190DC \n"
 493 "    LDR     R1, =0x33BC4 \n"
 494 "    MOV     R0, #0 \n"
 495 "    BL      sub_FF0865B0 /*_OpLog.Start_FW*/ \n"
 496 
 497 "loc_FF0190DC:\n"
 498 "    LDMFD   SP!, {R3-R5,PC} \n"
 499 );
 500 }
 501 
 502 /*************************************************************/
 503 //** init_file_modules_task @ 0xFF046F88 - 0xFF046FBC, length=14
 504 void __attribute__((naked,noinline)) init_file_modules_task() {
 505 asm volatile (
 506 "    STMFD   SP!, {R4-R6,LR} \n"
 507 "    BL      sub_FF088B84 \n"
 508 "    LDR     R5, =0x5006 \n"
 509 "    MOVS    R4, R0 \n"
 510 "    MOVNE   R1, #0 \n"
 511 "    MOVNE   R0, R5 \n"
 512 "    BLNE    _PostLogicalEventToUI \n"
 513 "    BL      sub_FF088BB0 \n"
 514 "    BL      core_spytask_can_start\n"  // CHDK: Set "it's-safe-to-start" flag for spytask
 515 "    CMP     R4, #0 \n"
 516 "    LDMNEFD SP!, {R4-R6,PC} \n"
 517 "    MOV     R0, R5 \n"
 518 "    LDMFD   SP!, {R4-R6,LR} \n"
 519 "    MOV     R1, #0 \n"
 520 "    B       _PostLogicalEventToUI \n"
 521 );
 522 }
 523 
 524 /*************************************************************/
 525 //** JogDial_task_my @ 0xFF056B3C - 0xFF056E64, length=203
 526 void __attribute__((naked,noinline)) JogDial_task_my() {
 527 asm volatile (
 528 "    STMFD   SP!, {R4-R11,LR} \n"
 529 "    SUB     SP, SP, #0x1C \n"
 530 "    BL      sub_FF056ED4 \n"
 531 "    LDR     R12, =0x2B34 \n"
 532 "    LDR     R6, =0xFF39E4E8 \n"
 533 "    MOV     R0, #0 \n"
 534 "    ADD     R10, SP, #8 \n"
 535 "    ADD     R9, SP, #0xC \n"
 536 //Check this!!!
 537 // Save pointer for kbd.c routine
 538 "    LDR     R2, =jog_position \n"
 539 "    STR     R9, [R2] \n"
 540 
 541 
 542 "loc_FF056B5C:\n"
 543 "    ADD     R2, SP, #0x14 \n"
 544 "    MOV     R1, #0 \n"
 545 "    ADD     R4, R2, R0, LSL#1 \n"
 546 "    ADD     R3, SP, #0x10 \n"
 547 "    STRH    R1, [R4] \n"
 548 "    ADD     R4, R3, R0, LSL#1 \n"
 549 "    STRH    R1, [R4] \n"
 550 "    STR     R1, [R9, R0, LSL#2] \n"
 551 "    STR     R1, [R10, R0, LSL#2] \n"
 552 "    ADD     R0, R0, #1 \n"
 553 "    CMP     R0, #1 \n"
 554 "    BLT     loc_FF056B5C \n"
 555 
 556 "loc_FF056B8C:\n"
 557 "    LDR     R0, =0x2B34 \n"
 558 "    MOV     R2, #0 \n"
 559 "    LDR     R0, [R0, #8] \n"
 560 "    MOV     R1, SP \n"
 561 "    BL      sub_004372A4 /*_ReceiveMessageQueue*/ \n"
 562 "    CMP     R0, #0 \n"
 563 "    LDRNE   R1, =0x20B \n"
 564 "    LDRNE   R0, =0xFF056DEC /*'RotaryEncoder.c'*/ \n"
 565 "    BLNE    _DebugAssert \n"
 566 "    LDR     R0, [SP] \n"
 567 "    AND     R4, R0, #0xFF \n"
 568 "    AND     R0, R0, #0xFF00 \n"
 569 "    CMP     R0, #0x100 \n"
 570 "    BEQ     loc_FF056BFC \n"
 571 "    CMP     R0, #0x200 \n"
 572 "    BEQ     loc_FF056C34 \n"
 573 "    CMP     R0, #0x300 \n"
 574 "    BEQ     loc_FF056E38 \n"
 575 "    CMP     R0, #0x400 \n"
 576 "    BNE     loc_FF056B8C \n"
 577 "    CMP     R4, #0 \n"
 578 "    LDRNE   R1, =0x285 \n"
 579 "    LDRNE   R0, =0xFF056DEC /*'RotaryEncoder.c'*/ \n"
 580 "    BLNE    _DebugAssert \n"
 581 "    RSB     R0, R4, R4, LSL#3 \n"
 582 "    LDR     R0, [R6, R0, LSL#2] \n"
 583 
 584 "loc_FF056BF4:\n"
 585 "    BL      sub_FF056EB8 \n"
 586 "    B       loc_FF056B8C \n"
 587 
 588 "loc_FF056BFC:\n"
 589 //------------------  added code ---------------------
 590 "labelA:\n"
 591 "    LDR     R0, =jogdial_stopped\n"
 592 "    LDR     R0, [R0]\n"
 593 "    CMP     R0, #1\n"
 594 "    BNE     labelB\n"
 595 "    MOV     R0, #40\n"
 596 "    BL      _SleepTask\n"
 597 "    B       labelA\n"
 598 "labelB:\n"
 599 //------------------  original code ------------------
 600 "    LDR     R0, =0x2B40 \n"
 601 "    LDR     R0, [R0, R4, LSL#2] \n"
 602 "    BL      sub_FF01F564 /*_CancelTimer*/ \n"
 603 "    LDR     R2, =0xFF056A88 \n"
 604 "    ORR     R3, R4, #0x200 \n"
 605 "    MOV     R1, R2 \n"
 606 "    MOV     R0, #0x28 \n"
 607 "    BL      sub_FF01F480 /*_SetTimerAfter*/ \n"
 608 "    TST     R0, #1 \n"
 609 "    CMPNE   R0, #0x15 \n"
 610 "    STR     R0, [R10, R4, LSL#2] \n"
 611 "    BEQ     loc_FF056B8C \n"
 612 "    LDR     R1, =0x21D \n"
 613 "    B       loc_FF056DD8 \n"
 614 
 615 "loc_FF056C34:\n"
 616 "    RSB     R5, R4, R4, LSL#3 \n"
 617 "    LDR     R0, [R6, R5, LSL#2] \n"
 618 "    LDR     R1, =0xC0240000 \n"
 619 "    ADD     R0, R1, R0, LSL#8 \n"
 620 "    LDR     R0, [R0, #0x104] \n"
 621 "    MOV     R1, R0, ASR#16 \n"
 622 "    ADD     R0, SP, #0x14 \n"
 623 "    ADD     R11, R0, R4, LSL#1 \n"
 624 "    ADD     R0, SP, #0x10 \n"
 625 "    ADD     R0, R0, R4, LSL#1 \n"
 626 "    STRH    R1, [R11] \n"
 627 "    STR     R0, [SP, #0x18] \n"
 628 "    LDRSH   R3, [R0] \n"
 629 "    SUB     R2, R1, R3 \n"
 630 "    CMP     R2, #0 \n"
 631 "    BNE     loc_FF056CB8 \n"
 632 "    LDR     R0, [R9, R4, LSL#2] \n"
 633 "    CMP     R0, #0 \n"
 634 "    BEQ     loc_FF056D94 \n"
 635 "    LDR     R7, =0x2B40 \n"
 636 "    LDR     R0, [R7, R4, LSL#2] \n"
 637 "    BL      sub_FF01F564 /*_CancelTimer*/ \n"
 638 "    LDR     R2, =0xFF056A94 \n"
 639 "    ORR     R3, R4, #0x300 \n"
 640 "    MOV     R1, R2 \n"
 641 "    MOV     R0, #0x1F4 \n"
 642 "    BL      sub_FF01F480 /*_SetTimerAfter*/ \n"
 643 "    TST     R0, #1 \n"
 644 "    CMPNE   R0, #0x15 \n"
 645 "    STR     R0, [R7, R4, LSL#2] \n"
 646 "    BEQ     loc_FF056D94 \n"
 647 "    LDR     R1, =0x236 \n"
 648 "    B       loc_FF056D8C \n"
 649 
 650 "loc_FF056CB8:\n"
 651 "    MOV     R0, R2 \n"
 652 "    RSBLT   R0, R0, #0 \n"
 653 "    MOVLE   R7, #0 \n"
 654 "    MOVGT   R7, #1 \n"
 655 "    CMP     R0, #0xFF \n"
 656 "    BLS     loc_FF056CF4 \n"
 657 "    LDR     R0, =0x7FFF \n"
 658 "    CMP     R2, #0 \n"
 659 "    SUBLE   R0, R0, R3 \n"
 660 "    ADDLE   R0, R0, R1 \n"
 661 "    SUBGT   R0, R0, R1 \n"
 662 "    ADDGT   R0, R0, R3 \n"
 663 "    MVN     R1, #0x8000 \n"
 664 "    SUB     R0, R0, R1 \n"
 665 "    EOR     R7, R7, #1 \n"
 666 
 667 "loc_FF056CF4:\n"
 668 "    STR     R0, [SP, #4] \n"
 669 "    LDR     R0, [R9, R4, LSL#2] \n"
 670 "    CMP     R0, #0 \n"
 671 "    ADDEQ   R0, R6, R5, LSL#2 \n"
 672 "    LDREQ   R0, [R0, #8] \n"
 673 "    BEQ     loc_FF056D2C \n"
 674 "    ADD     R8, R6, R5, LSL#2 \n"
 675 "    ADD     R1, R8, R7, LSL#2 \n"
 676 "    LDR     R1, [R1, #0x10] \n"
 677 "    CMP     R1, R0 \n"
 678 "    BEQ     loc_FF056D30 \n"
 679 "    LDR     R0, [R8, #0xC] \n"
 680 "    BL      sub_FF0190E0 \n"
 681 "    LDR     R0, [R8, #8] \n"
 682 
 683 "loc_FF056D2C:\n"
 684 "    BL      sub_FF0190E0 \n"
 685 
 686 "loc_FF056D30:\n"
 687 "    ADD     R0, R6, R5, LSL#2 \n"
 688 "    ADD     R7, R0, R7, LSL#2 \n"
 689 "    LDR     R0, [R7, #0x10] \n"
 690 "    LDR     R1, [SP, #4] \n"
 691 "    BL      sub_FF0190F0 \n"
 692 "    LDR     R0, [R7, #0x10] \n"
 693 "    LDR     R7, =0x2B40 \n"
 694 "    STR     R0, [R9, R4, LSL#2] \n"
 695 "    LDRH    R1, [R11] \n"
 696 "    LDR     R0, [SP, #0x18] \n"
 697 "    STRH    R1, [R0] \n"
 698 "    LDR     R0, [R7, R4, LSL#2] \n"
 699 "    BL      sub_FF01F564 /*_CancelTimer*/ \n"
 700 "    LDR     R2, =0xFF056A94 \n"
 701 "    ORR     R3, R4, #0x300 \n"
 702 "    MOV     R1, R2 \n"
 703 "    MOV     R0, #0x1F4 \n"
 704 "    BL      sub_FF01F480 /*_SetTimerAfter*/ \n"
 705 "    TST     R0, #1 \n"
 706 "    CMPNE   R0, #0x15 \n"
 707 "    STR     R0, [R7, R4, LSL#2] \n"
 708 "    BEQ     loc_FF056D94 \n"
 709 "    LDR     R1, =0x267 \n"
 710 
 711 "loc_FF056D8C:\n"
 712 "    LDR     R0, =0xFF056DEC /*'RotaryEncoder.c'*/ \n"
 713 "    BL      _DebugAssert \n"
 714 
 715 "loc_FF056D94:\n"
 716 "    ADD     R0, R6, R5, LSL#2 \n"
 717 "    LDR     R0, [R0, #0x18] \n"
 718 "    CMP     R0, #1 \n"
 719 "    BNE     loc_FF056E30 \n"
 720 "    LDR     R0, =0x2B34 \n"
 721 "    LDR     R0, [R0, #0x10] \n"
 722 "    CMP     R0, #0 \n"
 723 "    BEQ     loc_FF056E30 \n"
 724 "    LDR     R2, =0xFF056A88 \n"
 725 "    ORR     R3, R4, #0x400 \n"
 726 "    MOV     R1, R2 \n"
 727 "    BL      sub_FF01F480 /*_SetTimerAfter*/ \n"
 728 "    TST     R0, #1 \n"
 729 "    CMPNE   R0, #0x15 \n"
 730 "    STR     R0, [R10, R4, LSL#2] \n"
 731 "    BEQ     loc_FF056B8C \n"
 732 "    LDR     R1, =0x26E \n"
 733 
 734 "loc_FF056DD8:\n"
 735 "    LDR     R0, =0xFF056DEC /*'RotaryEncoder.c'*/ \n"
 736 "    BL      _DebugAssert \n"
 737 "    B       loc_FF056B8C \n"
 738 
 739 "loc_FF056E30:\n"
 740 "    LDR     R0, [R6, R5, LSL#2] \n"
 741 "    B       loc_FF056BF4 \n"
 742 
 743 "loc_FF056E38:\n"
 744 "    LDR     R0, [R9, R4, LSL#2] \n"
 745 "    CMP     R0, #0 \n"
 746 "    MOVEQ   R1, #0x278 \n"
 747 "    LDREQ   R0, =0xFF056DEC /*'RotaryEncoder.c'*/ \n"
 748 "    BLEQ    _DebugAssert \n"
 749 "    RSB     R0, R4, R4, LSL#3 \n"
 750 "    ADD     R0, R6, R0, LSL#2 \n"
 751 "    LDR     R0, [R0, #0xC] \n"
 752 "    BL      sub_FF0190E0 \n"
 753 "    MOV     R0, #0 \n"
 754 "    STR     R0, [R9, R4, LSL#2] \n"
 755 "    B       loc_FF056B8C \n"
 756 );
 757 }

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