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

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