root/platform/sx510hs/sub/100d/boot.c

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

DEFINITIONS

This source file includes following definitions.
  1. CreateTask_spytask
  2. debug_blink
  3. my_blinker
  4. boot
  5. CreateTask_my
  6. sub_FF0003C4_my
  7. sub_FF00291C_my
  8. sub_FF0049F4_my
  9. sub_FF007D34_my
  10. sub_FF00BD98_my
  11. task_Startup_my
  12. taskcreatePhySw_my
  13. init_file_modules_task
  14. 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 /*----------------------------------------------------------------------
  14     CreateTask_spytask
  15 -----------------------------------------------------------------------*/
  16 void CreateTask_spytask()
  17 {
  18     _CreateTask("SpyTask", 0x19, 0x2000, core_spytask, 0);
  19 }
  20 
  21 ///*----------------------------------------------------------------------
  22 // Pointer to stack location where jogdial task records previous and current
  23 // jogdial positions
  24 short *jog_position;
  25 
  26 
  27 #define GREEN_LED       0xC0220120
  28 #define AF_LED          0xC0223030
  29 //debug use only
  30 
  31 int debug_blink(int save_R0) {
  32         int i;
  33         *((volatile int *) AF_LED) = 0x46; // Turn on LED
  34         for (i=0; i<800000; i++) // Wait a while
  35                 {
  36                 asm volatile ( "nop\n" );
  37                 }
  38 
  39         *((volatile int *) AF_LED) = 0x44; // Turn off LED
  40         for (i=0; i<800000; i++) // Wait a while
  41                 {
  42                 asm volatile ( "nop\n" );
  43                 }
  44         return save_R0;
  45 };
  46 
  47 void __attribute__((naked,noinline)) my_blinker(int n) {
  48         asm volatile (
  49       "            STMFD   SP!, {R0-R9,LR}\n"
  50 );
  51         int i, j;
  52         for (j=0; j<n; j++)
  53         {
  54                 *((volatile int *) GREEN_LED) = 0x46; // Turn on LED
  55                 for (i=0; i<0x200000; i++) { asm volatile ( "nop \n" ); }
  56 
  57                 *((volatile int *) GREEN_LED) = 0x44; // Turn off LED
  58                 for (i=0; i<0x400000; i++) { asm volatile ( "nop \n" ); }
  59         }
  60         for (i=0; i<0x900000; i++) { asm volatile ( "nop \n" ); }
  61         asm volatile (
  62       "            LDMFD   SP!, {R0-R9,PC}\n"
  63         );
  64 }
  65 
  66 /*----------------------------------------------------------------------
  67     boot()
  68 
  69     Main entry point for the CHDK code
  70 -----------------------------------------------------------------------*/
  71 
  72 /*************************************************************/
  73 //** boot @ 0xFF00000C - 0xFF00017C, length=93
  74 void __attribute__((naked,noinline)) boot() {
  75 asm volatile (
  76 "    LDR     R1, =0xC0410000 \n"
  77 "    MOV     R0, #0 \n"
  78 "    STR     R0, [R1] \n"
  79 "    MOV     R1, #0x78 \n"
  80 "    MCR     p15, 0, R1, c1, c0 \n"
  81 "    MOV     R1, #0 \n"
  82 "    MCR     p15, 0, R1, c7, c10, 4 \n"
  83 "    MCR     p15, 0, R1, c7, c5 \n"
  84 "    MCR     p15, 0, R1, c7, c6 \n"
  85 "    MOV     R0, #0x3D \n"
  86 "    MCR     p15, 0, R0, c6, c0 \n"
  87 "    MOV     R0, #0xC000002F \n"
  88 "    MCR     p15, 0, R0, c6, c1 \n"
  89 "    MOV     R0, #0x35 \n"
  90 "    MCR     p15, 0, R0, c6, c2 \n"
  91 "    MOV     R0, #0x40000035 \n"
  92 "    MCR     p15, 0, R0, c6, c3 \n"
  93 "    MOV     R0, #0x80000017 \n"
  94 "    MCR     p15, 0, R0, c6, c4 \n"
  95 "    LDR     R0, =0xFF00002F \n"
  96 "    MCR     p15, 0, R0, c6, c5 \n"
  97 "    MOV     R0, #0x34 \n"
  98 "    MCR     p15, 0, R0, c2, c0 \n"
  99 "    MOV     R0, #0x34 \n"
 100 "    MCR     p15, 0, R0, c2, c0, 1 \n"
 101 "    MOV     R0, #0x34 \n"
 102 "    MCR     p15, 0, R0, c3, c0 \n"
 103 "    LDR     R0, =0x3333330 \n"
 104 "    MCR     p15, 0, R0, c5, c0, 2 \n"
 105 "    LDR     R0, =0x3333330 \n"
 106 "    MCR     p15, 0, R0, c5, c0, 3 \n"
 107 "    MRC     p15, 0, R0, c1, c0 \n"
 108 "    ORR     R0, R0, #0x1000 \n"
 109 "    ORR     R0, R0, #4 \n"
 110 "    ORR     R0, R0, #1 \n"
 111 "    MCR     p15, 0, R0, c1, c0 \n"
 112 "    MOV     R1, #0x80000006 \n"
 113 "    MCR     p15, 0, R1, c9, c1 \n"
 114 "    MOV     R1, #6 \n"
 115 "    MCR     p15, 0, R1, c9, c1, 1 \n"
 116 "    MRC     p15, 0, R1, c1, c0 \n"
 117 "    ORR     R1, R1, #0x50000 \n"
 118 "    MCR     p15, 0, R1, c1, c0 \n"
 119 "    LDR     R2, =0xC0200000 \n"
 120 "    MOV     R1, #1 \n"
 121 "    STR     R1, [R2, #0x10C] \n"
 122 "    MOV     R1, #0xFF \n"
 123 "    STR     R1, [R2, #0xC] \n"
 124 "    STR     R1, [R2, #0x1C] \n"
 125 "    STR     R1, [R2, #0x2C] \n"
 126 "    STR     R1, [R2, #0x3C] \n"
 127 "    STR     R1, [R2, #0x4C] \n"
 128 "    STR     R1, [R2, #0x5C] \n"
 129 "    STR     R1, [R2, #0x6C] \n"
 130 "    STR     R1, [R2, #0x7C] \n"
 131 "    STR     R1, [R2, #0x8C] \n"
 132 "    STR     R1, [R2, #0x9C] \n"
 133 "    STR     R1, [R2, #0xAC] \n"
 134 "    STR     R1, [R2, #0xBC] \n"
 135 "    STR     R1, [R2, #0xCC] \n"
 136 "    STR     R1, [R2, #0xDC] \n"
 137 "    STR     R1, [R2, #0xEC] \n"
 138 "    STR     R1, [R2, #0xFC] \n"
 139 "    LDR     R1, =0xC0400008 \n"
 140 "    LDR     R2, =0x430005 \n"
 141 "    STR     R2, [R1] \n"
 142 "    MOV     R1, #1 \n"
 143 "    LDR     R2, =0xC0243100 \n"
 144 "    STR     R2, [R1] \n"
 145 "    LDR     R2, =0xC0242010 \n"
 146 "    LDR     R1, [R2] \n"
 147 "    ORR     R1, R1, #1 \n"
 148 "    STR     R1, [R2] \n"
 149 "    LDR     R0, =0xFF719234 \n"
 150 "    LDR     R1, =0x6B1000 \n"
 151 "    LDR     R3, =0x6DB5D0 \n"
 152 
 153 "loc_FF00013C:\n"
 154 "    CMP     R1, R3 \n"
 155 "    LDRCC   R2, [R0], #4 \n"
 156 "    STRCC   R2, [R1], #4 \n"
 157 "    BCC     loc_FF00013C \n"
 158 "    LDR     R0, =0xFF702F8C \n"
 159 "    LDR     R1, =0x1900 \n"
 160 "    LDR     R3, =0x17BA8 \n"
 161 
 162 "loc_FF000158:\n"
 163 "    CMP     R1, R3 \n"
 164 "    LDRCC   R2, [R0], #4 \n"
 165 "    STRCC   R2, [R1], #4 \n"
 166 "    BCC     loc_FF000158 \n"
 167 "    LDR     R1, =0x265A28 \n"
 168 "    MOV     R2, #0 \n"
 169 
 170 "loc_FF000170:\n"
 171 "    CMP     R3, R1 \n"
 172 "    STRCC   R2, [R3], #4 \n"
 173 "    BCC     loc_FF000170 \n"
 174 /* Install task hooks via 0x193x is not possible with this new dryos version
 175    So the below code patches the CreateTask function in RAM to install our
 176    hook -- ERR99
 177 */
 178 // Install CreateTask patch
 179 "    LDR     R0, =patch_CreateTask\n"   // Patch data
 180 "    LDM     R0, {R1,R2}\n"             // Get two patch instructions
 181 "    LDR     R0, =hook_CreateTask\n"    // Address to patch
 182 "    STM     R0, {R1,R2}\n"             // Store patch instructions
 183 
 184 "    B       sub_FF0003C4_my \n"  // --> Patched. Old value = 0xFF0003C4.
 185 
 186 "patch_CreateTask:\n"
 187 "    LDR     PC, [PC,#-0x4]\n"          // Do jump to absolute address CreateTask_my
 188 "    .long   CreateTask_my\n"
 189 );
 190 }
 191 
 192 /*************************************************************/
 193 //** CreateTask_my @ 0x006B5778 - 0x006B577C, length=2
 194 void __attribute__((naked,noinline)) CreateTask_my() {
 195 asm volatile (
 196 "    STMFD   SP!, {R0}\n"
 197 //R3 = Pointer to task function to create
 198 
 199 /*** INSTALL capt_seq_task() hook ***/
 200 "    LDR     R0, =task_CaptSeq\n"       // DryOS original code function ptr.
 201 "    CMP     R0, R3\n"                  // is the given taskptr equal to our searched function?
 202 "    LDREQ   R3, =capt_seq_task\n"      // if so replace with our task function base ptr.
 203 "    BEQ     exitHook\n"                // below compares not necessary if this check has found something.
 204 
 205 /*** INSTALL task_developseq() hook ***/
 206 "    LDR     R0, =task_DvlpSeqTask\n"
 207 "    CMP     R0, R3\n"
 208 "    LDREQ   R3, =task_developseq_my\n"
 209 "    BEQ     exitHook\n"
 210 
 211 /*** INSTALL exp_drv_task() hook ***/
 212 "    LDR     R0, =task_ExpDrv\n"
 213 "    CMP     R0, R3\n"
 214 "    LDREQ   R3, =exp_drv_task\n"
 215 "    BEQ     exitHook\n"
 216 
 217 /*** INSTALL filewrite() hook ***/
 218 "    LDR     R0, =task_FileWrite\n"
 219 "    CMP     R0, R3\n"
 220 "    LDREQ   R3, =filewritetask\n"
 221 "    BEQ     exitHook\n"
 222 
 223 /*** INSTALL JogDial() hook ***/
 224 "    LDR     R0, =task_RotaryEncoder\n"
 225 "    CMP     R0, R3\n"
 226 "    LDREQ   R3, =JogDial_task_my\n"
 227 "    BEQ     exitHook\n"
 228 
 229 /*** INSTALL movie_record_task() hook ***/
 230 //"    LDR     R0, =task_MovieRecord\n"
 231 //"    CMP     R0, R3\n"
 232 //"    LDREQ   R3, =movie_record_task\n"
 233 //"    BEQ     exitHook\n"
 234 
 235 /*** INSTALL init_file_modules_task() hook ***/
 236 "    LDR     R0, =task_InitFileModules\n"
 237 "    CMP     R0, R3\n"
 238 "    LDREQ   R3, =init_file_modules_task\n"
 239 
 240 "exitHook:\n" 
 241 // restore overwritten registers
 242 "    LDMFD   SP!, {R0}\n"
 243 // Execute overwritten instructions from original code, then jump to firmware
 244 "    STMFD   SP!, {R1-R9,LR} \n"
 245 "    MOV     R4, R0 \n"
 246 "    LDR     PC, =0x006B5780 \n"  // Continue in firmware
 247 );
 248 }
 249 
 250 /*************************************************************/
 251 //** sub_FF0003C4_my @ 0xFF0003C4 - 0xFF00042C, length=27
 252 void __attribute__((naked,noinline)) sub_FF0003C4_my() {
 253 
 254     //Replacement of sub_ for correct power-on.
 255     //(short press = playback mode, long press = record mode)
 256 
 257     // look at power-on switch sub_FF00BD98
 258     // value and pointer from sub_FF04EAFC
 259     *(int*)(0x2b8c+0x4) = (*(int*)0xC0220104)&1 ? 0x200000 : 0x100000;
 260 
 261 asm volatile (
 262 "    LDR     R0, =0xFF00043C \n"
 263 "    MOV     R1, #0 \n"
 264 "    LDR     R3, =0xFF000474 \n"
 265 
 266 "loc_FF0003D0:\n"
 267 "    CMP     R0, R3 \n"
 268 "    LDRCC   R2, [R0], #4 \n"
 269 "    STRCC   R2, [R1], #4 \n"
 270 "    BCC     loc_FF0003D0 \n"
 271 "    LDR     R0, =0xFF000474 \n"
 272 "    MOV     R1, #0x1B0 \n"
 273 "    LDR     R3, =0xFF00065C \n"
 274 
 275 "loc_FF0003EC:\n"
 276 "    CMP     R0, R3 \n"
 277 "    LDRCC   R2, [R0], #4 \n"
 278 "    STRCC   R2, [R1], #4 \n"
 279 "    BCC     loc_FF0003EC \n"
 280 "    MOV     R0, #0xD2 \n"
 281 "    MSR     CPSR_cxsf, R0 \n"
 282 "    MOV     SP, #0x1000 \n"
 283 "    MOV     R0, #0xD3 \n"
 284 "    MSR     CPSR_cxsf, R0 \n"
 285 "    MOV     SP, #0x1000 \n"
 286 "    LDR     R0, =0x398 \n"
 287 "    LDR     R2, =0xEEEEEEEE \n"
 288 "    MOV     R3, #0x1000 \n"
 289 
 290 "loc_FF000420:\n"
 291 "    CMP     R0, R3 \n"
 292 "    STRCC   R2, [R0], #4 \n"
 293 "    BCC     loc_FF000420 \n"
 294 "    B       sub_FF00291C_my \n"  // --> Patched. Old value = 0xFF00291C.
 295 );
 296 }
 297 
 298 /*************************************************************/
 299 //** sub_FF00291C_my @ 0xFF00291C - 0xFF002A9C, length=97
 300 void __attribute__((naked,noinline)) sub_FF00291C_my() {
 301 asm volatile (
 302 "    LDR     R1, =0x1A54 \n"
 303 "    STR     LR, [SP, #-4]! \n"
 304 "    SUB     SP, SP, #0x74 \n"
 305 "    MOV     R0, #0x80000 \n"
 306 "    STR     R0, [R1] \n"
 307 "    LDR     R0, =0x40BCE980 \n"
 308 "    LDR     R1, =0x1A58 \n"
 309 "    STR     R0, [R1] \n"
 310 "    LDR     R1, =0x1A5C \n"
 311 "    ADD     R0, R0, #0x2000 \n"
 312 "    STR     R0, [R1] \n"
 313 "    MOV     R1, #0x74 \n"
 314 "    MOV     R0, SP \n"
 315 "    BL      sub_006D4CD4 \n"
 316 "    MOV     R0, #0x73000 \n"
 317 "    STR     R0, [SP, #4] \n"
 318 
 319 #if defined(CHDK_NOT_IN_CANON_HEAP) // use original heap offset if CHDK is loaded in high memory
 320 "    LDR     R0, =0x265A28 \n"
 321 #else
 322 "    LDR     R0, =new_sa\n"   // otherwise use patched value
 323 "    LDR     R0, [R0]\n"      //
 324 #endif
 325 
 326 "    LDR     R2, =0x5903AC \n"
 327 "    STR     R0, [SP, #8] \n"
 328 "    SUB     R0, R2, R0 \n"
 329 "    STR     R0, [SP, #0xC] \n"
 330 "    MOV     R0, #0x22 \n"
 331 "    STR     R0, [SP, #0x18] \n"
 332 "    MOV     R0, #0x98 \n"
 333 "    STR     R0, [SP, #0x1C] \n"
 334 "    MOV     R0, #0x1E8 \n"
 335 "    STR     R2, [SP, #0x10] \n"
 336 "    STR     R0, [SP, #0x20] \n"
 337 "    LDR     R1, =0x59B000 \n"
 338 "    SUB     R0, R0, #0xE6 \n"
 339 "    STR     R0, [SP, #0x24] \n"
 340 "    MOV     R0, #0xB6 \n"
 341 "    STR     R1, [SP] \n"
 342 "    STR     R0, [SP, #0x28] \n"
 343 "    MOV     R0, #0x85 \n"
 344 "    STR     R0, [SP, #0x2C] \n"
 345 "    MOV     R0, #0x40 \n"
 346 "    STR     R0, [SP, #0x30] \n"
 347 "    MOV     R0, #4 \n"
 348 "    STR     R0, [SP, #0x34] \n"
 349 "    MOV     R0, #0 \n"
 350 "    STR     R0, [SP, #0x38] \n"
 351 "    MOV     R0, #0x10 \n"
 352 "    STR     R0, [SP, #0x5C] \n"
 353 "    MOV     R0, #0x1000 \n"
 354 "    STR     R0, [SP, #0x60] \n"
 355 "    MOV     R0, #0x100 \n"
 356 "    STR     R0, [SP, #0x64] \n"
 357 "    MOV     R0, #0x2000 \n"
 358 "    STR     R1, [SP, #0x14] \n"
 359 "    STR     R0, [SP, #0x68] \n"
 360 "    LDR     R1, =sub_FF0049F4_my \n"  // --> Patched. Old value = 0xFF0049F4.
 361 "    MOV     R2, #0 \n"
 362 "    MOV     R0, SP \n"
 363 "    BL      sub_006B1C50 \n"
 364 "    ADD     SP, SP, #0x74 \n"
 365 "    LDR     PC, [SP], #4 \n"
 366 );
 367 }
 368 
 369 /*************************************************************/
 370 //** sub_FF0049F4_my @ 0xFF0049F4 - 0xFF004A8C, length=39
 371 void __attribute__((naked,noinline)) sub_FF0049F4_my() {
 372 asm volatile (
 373 "    STMFD   SP!, {R4,LR} \n"
 374 "    LDR     R4, =0xFF004AB0 /*'/_term'*/ \n"
 375 "    BL      sub_FF000858 \n"
 376 "    LDR     R1, =0x1A54 \n"
 377 "    LDR     R0, =0x19F0 \n"
 378 "    LDR     R1, [R1] \n"
 379 "    LDR     R0, [R0] \n"
 380 "    ADD     R1, R1, #0x10 \n"
 381 "    CMP     R0, R1 \n"
 382 "    LDRCC   R0, =0xFF004AC0 /*'USER_MEM size checking'*/ \n"
 383 "    BLCC    _err_init_task \n"
 384 "    BL      sub_FF0037BC \n"
 385 "    CMP     R0, #0 \n"
 386 "    LDRLT   R0, =0xFF004AD8 /*'dmSetup'*/ \n"
 387 "    BLLT    _err_init_task \n"
 388 "    BL      sub_FF002528 \n"
 389 "    CMP     R0, #0 \n"
 390 "    LDRLT   R0, =0xFF004AE0 /*'termDriverInit'*/ \n"
 391 "    BLLT    _err_init_task \n"
 392 "    MOV     R0, R4 \n"
 393 "    BL      sub_FF002610 \n"
 394 "    CMP     R0, #0 \n"
 395 "    LDRLT   R0, =0xFF004AF0 /*'termDeviceCreate'*/ \n"
 396 "    BLLT    _err_init_task \n"
 397 "    MOV     R0, R4 \n"
 398 "    BL      sub_FF002140 \n"
 399 "    CMP     R0, #0 \n"
 400 "    LDRLT   R0, =0xFF004B04 /*'stdioSetup'*/ \n"
 401 "    BLLT    _err_init_task \n"
 402 "    BL      sub_FF00505C \n"
 403 "    CMP     R0, #0 \n"
 404 "    LDRLT   R0, =0xFF004B10 /*'stdlibSetup'*/ \n"
 405 "    BLLT    _err_init_task \n"
 406 "    BL      sub_FF0010E8 \n"
 407 "    CMP     R0, #0 \n"
 408 "    LDRLT   R0, =0xFF004B1C /*'extlib_setup'*/ \n"
 409 "    BLLT    _err_init_task \n"
 410 "    LDMFD   SP!, {R4,LR} \n"
 411 "    B       sub_FF007D34_my \n"  // --> Patched. Old value = 0xFF007D34.
 412 );
 413 }
 414 
 415 /*************************************************************/
 416 //** sub_FF007D34_my @ 0xFF007D34 - 0xFF007DA4, length=29
 417 void __attribute__((naked,noinline)) sub_FF007D34_my() {
 418 asm volatile (
 419 "    STMFD   SP!, {R3,LR} \n"
 420 "    BL      sub_FF013B78 \n"
 421 "    BL      sub_FF0178F8 \n"
 422 "    CMP     R0, #0 \n"
 423 "    BNE     loc_FF007D58 \n"
 424 "    BL      sub_FF00D16C /*_IsNormalCameraMode_FW*/ \n"
 425 "    CMP     R0, #0 \n"
 426 "    MOVNE   R0, #1 \n"
 427 "    BNE     loc_FF007D5C \n"
 428 
 429 "loc_FF007D58:\n"
 430 "    MOV     R0, #0 \n"
 431 
 432 "loc_FF007D5C:\n"
 433 "    BL      sub_FF00BD98_my \n"  // --> Patched. Old value = 0xFF00BD98.
 434 "    CMP     R0, #0 \n"
 435 "    BNE     loc_FF007D70 \n"
 436 "    BL      sub_FF00B684 \n"
 437 
 438 "loc_FF007D6C:\n"
 439 "    B       loc_FF007D6C \n"
 440 
 441 "loc_FF007D70:\n"
 442 "    BL      sub_006B8A34 \n"
 443 "    LDR     R1, =0x60E000 \n"
 444 "    MOV     R0, #0 \n"
 445 "    BL      sub_FF017E48 \n"
 446 "    BL      sub_006B8D78 \n"
 447 "    MOV     R3, #0 \n"
 448 "    STR     R3, [SP] \n"
 449 "    LDR     R3, =task_Startup_my \n"  // --> Patched. Old value = 0xFF007CCC.
 450 "    MOV     R2, #0 \n"
 451 "    MOV     R1, #0x19 \n"
 452 "    LDR     R0, =0xFF007DB0 /*'Startup'*/ \n"
 453 "    BL      _CreateTask \n"
 454 "    MOV     R0, #0 \n"
 455 "    LDMFD   SP!, {R3,PC} \n"
 456 );
 457 }
 458 
 459 /*************************************************************/
 460 //** sub_FF00BD98_my @ 0xFF00BD98 - 0xFF00BDFC, length=26
 461 void __attribute__((naked,noinline)) sub_FF00BD98_my() {
 462 asm volatile (
 463 "    STMFD   SP!, {R2-R8,LR} \n"
 464 "    MOV     R6, #0 \n"
 465 "    MOV     R8, R0 \n"
 466 "    MOV     R7, R6 \n"
 467 //"  BL      _sub_FF04EAF4 \n"  // --> Nullsub call removed.
 468 "    LDR     R0, =0xC0220104 \n"
 469 "    BL      sub_FF04BDE8 \n"
 470 "    MOV     R4, #1 \n"
 471 "    BIC     R5, R4, R0 \n"
 472 "    LDR     R0, =0xC022010C \n"
 473 "    BL      sub_FF04BDE8 \n"
 474 "    CMP     R8, #0 \n"
 475 "    BIC     R4, R4, R0 \n"
 476 "    BEQ     loc_FF00BDD8 \n"
 477 "    ORRS    R0, R5, R4 \n"
 478 "    BEQ     loc_FF00BDFC \n"
 479 
 480 "loc_FF00BDD8:\n"
 481 "    BL      sub_FF0178F8 \n"
 482 "    MOV     R2, R0 \n"
 483 "    MOV     R3, #0 \n"
 484 "    MOV     R1, R4 \n"
 485 "    MOV     R0, R5 \n"
 486 "    STRD    R6, [SP] \n"
 487 //"  BL      _sub_FF04EAFC \n"  // Disable StartUpChecks
 488 //"  BL      _sub_FF04EAF8 \n"  // --> Nullsub call removed.
 489 "    MOV     R0, #1 \n"
 490 
 491 "loc_FF00BDFC:\n"
 492 "    LDMFD   SP!, {R2-R8,PC} \n"
 493 );
 494 }
 495 
 496 /*************************************************************/
 497 //** task_Startup_my @ 0xFF007CCC - 0xFF007D30, length=26
 498 void __attribute__((naked,noinline)) task_Startup_my() {
 499 asm volatile (
 500 "    STMFD   SP!, {R4,LR} \n"
 501 "    BL      sub_FF002F00 \n"
 502 "    BL      sub_FF00C1F4 \n"
 503 "    BL      sub_FF00B630 \n"
 504 //"  BL      _sub_FF04F600 \n"  // --> Nullsub call removed.
 505 "    BL      sub_FF017B54 \n"
 506 //"  BL      _sub_FF0179F0 \n"  // load DISKBOOT.BIN
 507 "    BL      sub_FF017CE4 \n"
 508 "    BL      sub_FF017F1C \n"
 509 "    BL      sub_FF017CA8 \n"
 510 "    BL      sub_FF017B94 \n"
 511 "    BL      sub_FF013AB0 \n"
 512 "    BL      sub_FF017F24 \n"
 513 "    BL      CreateTask_spytask\n" // added
 514 "    BL      taskcreatePhySw_my \n"  // --> Patched. Old value = 0xFF00BC40.
 515 "    BL      sub_FF011598 \n"
 516 "    BL      sub_FF09B6C0 \n"
 517 "    BL      sub_FF00910C \n"
 518 "    BL      sub_FF00AF94 \n"
 519 "    BL      sub_FF017728 \n"
 520 "    BL      sub_FF00B5E4 \n"
 521 "    BL      sub_FF00AF30 \n"
 522 "    BL      sub_FF039774 \n"
 523 "    BL      sub_FF009E78 \n"
 524 "    BL      sub_FF00AEF4 \n"
 525 "    LDMFD   SP!, {R4,LR} \n"
 526 "    B       sub_FF003028 \n"
 527 );
 528 }
 529 
 530 /*************************************************************/
 531 //** taskcreatePhySw_my @ 0xFF00BC40 - 0xFF00BC88, length=19
 532 void __attribute__((naked,noinline)) taskcreatePhySw_my() {
 533 asm volatile (
 534 "    STMFD   SP!, {R3-R5,LR} \n"
 535 "    BL      sub_FF016980 \n"
 536 "    BL      sub_FF00D0BC /*_IsFactoryMode_FW*/ \n"
 537 "    CMP     R0, #0 \n"
 538 "    BLEQ    sub_FF0168E8 /*_OpLog.Start_FW*/ \n"
 539 "    LDR     R4, =0x1CFC \n"
 540 "    LDR     R0, [R4, #4] \n"
 541 "    CMP     R0, #0 \n"
 542 "    BNE     loc_FF00BC84 \n"
 543 "    MOV     R3, #0 \n"
 544 "    STR     R3, [SP] \n"
 545 "    LDR     R3, =mykbd_task \n"  // --> Patched. Old value = 0xFF00BC0C.
 546 "    MOV     R2, #0x2000 \n"  // --> Patched. Old value = 0x800. stack size for new task_PhySw so we don't have to do stack switch
 547 "    MOV     R1, #0x17 \n"
 548 "    LDR     R0, =0xFF00BEF4 /*'PhySw'*/ \n"
 549 "    BL      sub_006B7C6C /*_CreateTaskStrictly*/ \n"
 550 "    STR     R0, [R4, #4] \n"
 551 
 552 "loc_FF00BC84:\n"
 553 "    LDMFD   SP!, {R3-R5,LR} \n"
 554 "    B       sub_FF04FAB0 \n"
 555 );
 556 }
 557 
 558 /*************************************************************/
 559 //** init_file_modules_task @ 0xFF03E99C - 0xFF03E9D0, length=14
 560 void __attribute__((naked,noinline)) init_file_modules_task() {
 561 asm volatile (
 562 "    STMFD   SP!, {R4-R6,LR} \n"
 563 "    BL      sub_FF0865CC \n"
 564 "    LDR     R5, =0x5006 \n"
 565 "    MOVS    R4, R0 \n"
 566 "    MOVNE   R1, #0 \n"
 567 "    MOVNE   R0, R5 \n"
 568 "    BLNE    _PostLogicalEventToUI \n"
 569 "    BL      sub_FF086600 \n"
 570 "    BL      core_spytask_can_start\n"  // CHDK: Set "it's-safe-to-start" flag for spytask
 571 "    CMP     R4, #0 \n"
 572 "    LDMNEFD SP!, {R4-R6,PC} \n"
 573 "    MOV     R0, R5 \n"
 574 "    LDMFD   SP!, {R4-R6,LR} \n"
 575 "    MOV     R1, #0 \n"
 576 "    B       _PostLogicalEventToUI \n"
 577 );
 578 }
 579 
 580 /*************************************************************/
 581 //** JogDial_task_my @ 0xFF04F774 - 0xFF04FAAC, length=207
 582 void __attribute__((naked,noinline)) JogDial_task_my() {
 583 asm volatile (
 584 "    STMFD   SP!, {R4-R11,LR} \n"
 585 "    SUB     SP, SP, #0x1C \n"
 586 "    BL      sub_FF04FB1C \n"
 587 "    LDR     R12, =0x2BAC \n"
 588 "    LDR     R6, =0xFF5687FC \n"
 589 "    MOV     R0, #0 \n"
 590 "    ADD     R10, SP, #8 \n"
 591 "    ADD     R9, SP, #0xC \n"
 592 
 593 // Save pointer for kbd.c routine
 594 "    LDR     R2, =jog_position \n"
 595 "    STR     R9, [R2] \n"
 596 
 597 
 598 "loc_FF04F794:\n"
 599 "    ADD     R2, SP, #0x14 \n"
 600 "    MOV     R1, #0 \n"
 601 "    ADD     R4, R2, R0, LSL#1 \n"
 602 "    ADD     R3, SP, #0x10 \n"
 603 "    STRH    R1, [R4] \n"
 604 "    ADD     R4, R3, R0, LSL#1 \n"
 605 "    STRH    R1, [R4] \n"
 606 "    STR     R1, [R9, R0, LSL#2] \n"
 607 "    STR     R1, [R10, R0, LSL#2] \n"
 608 "    ADD     R0, R0, #1 \n"
 609 "    CMP     R0, #1 \n"
 610 "    BLT     loc_FF04F794 \n"
 611 
 612 "loc_FF04F7C4:\n"
 613 "    LDR     R0, =0x2BAC \n"
 614 "    MOV     R2, #0 \n"
 615 "    LDR     R0, [R0, #8] \n"
 616 "    MOV     R1, SP \n"
 617 "    BL      sub_006B84B8 /*_ReceiveMessageQueue*/ \n"
 618 "    CMP     R0, #0 \n"
 619 "    LDRNE   R2, =0x20B \n"
 620 "    LDRNE   R1, =0xFF04FA34 /*'RotaryEncoder.c'*/ \n"
 621 "    MOVNE   R0, #0 \n"
 622 "    BLNE    _DebugAssert \n"
 623 "    LDR     R0, [SP] \n"
 624 "    AND     R4, R0, #0xFF \n"
 625 "    AND     R0, R0, #0xFF00 \n"
 626 "    CMP     R0, #0x100 \n"
 627 "    BEQ     loc_FF04F83C \n"
 628 "    CMP     R0, #0x200 \n"
 629 "    BEQ     loc_FF04F874 \n"
 630 "    CMP     R0, #0x300 \n"
 631 "    BEQ     loc_FF04FA80 \n"
 632 "    CMP     R0, #0x400 \n"
 633 "    BNE     loc_FF04F7C4 \n"
 634 "    CMP     R4, #0 \n"
 635 "    LDRNE   R2, =0x285 \n"
 636 "    LDRNE   R1, =0xFF04FA34 /*'RotaryEncoder.c'*/ \n"
 637 "    MOVNE   R0, #0 \n"
 638 "    BLNE    _DebugAssert \n"
 639 "    RSB     R0, R4, R4, LSL#3 \n"
 640 "    LDR     R0, [R6, R0, LSL#2] \n"
 641 
 642 "loc_FF04F834:\n"
 643 "    BL      sub_FF04FB00 \n"
 644 "    B       loc_FF04F7C4 \n"
 645 
 646 "loc_FF04F83C:\n"
 647 //------------------  added code ---------------------
 648 "labelA:\n"
 649 "    LDR     R0, =jogdial_stopped\n"
 650 "    LDR     R0, [R0]\n"
 651 "    CMP     R0, #1\n"
 652 "    BNE     labelB\n"
 653 "    MOV     R0, #40\n"
 654 "    BL      _SleepTask\n"
 655 "    B       labelA\n"
 656 "labelB:\n"
 657 //------------------  original code ------------------
 658 "    LDR     R0, =0x2BB8 \n"
 659 "    LDR     R0, [R0, R4, LSL#2] \n"
 660 "    BL      sub_FF0062E0 /*_CancelTimer*/ \n"
 661 "    LDR     R2, =0xFF04F6B8 \n"
 662 "    ORR     R3, R4, #0x200 \n"
 663 "    MOV     R1, R2 \n"
 664 "    MOV     R0, #0x28 \n"
 665 "    BL      sub_FF006210 /*_SetTimerAfter*/ \n"
 666 "    TST     R0, #1 \n"
 667 "    CMPNE   R0, #0x15 \n"
 668 "    STR     R0, [R10, R4, LSL#2] \n"
 669 "    BEQ     loc_FF04F7C4 \n"
 670 "    LDR     R2, =0x21D \n"
 671 "    B       loc_FF04FA1C \n"
 672 
 673 "loc_FF04F874:\n"
 674 "    RSB     R5, R4, R4, LSL#3 \n"
 675 "    LDR     R0, [R6, R5, LSL#2] \n"
 676 "    LDR     R1, =0xC0240000 \n"
 677 "    ADD     R0, R1, R0, LSL#8 \n"
 678 "    LDR     R0, [R0, #0x104] \n"
 679 "    MOV     R1, R0, ASR#16 \n"
 680 "    ADD     R0, SP, #0x14 \n"
 681 "    ADD     R11, R0, R4, LSL#1 \n"
 682 "    ADD     R0, SP, #0x10 \n"
 683 "    ADD     R0, R0, R4, LSL#1 \n"
 684 "    STRH    R1, [R11] \n"
 685 "    STR     R0, [SP, #0x18] \n"
 686 "    LDRSH   R3, [R0] \n"
 687 "    SUB     R2, R1, R3 \n"
 688 "    CMP     R2, #0 \n"
 689 "    BNE     loc_FF04F8F8 \n"
 690 "    LDR     R0, [R9, R4, LSL#2] \n"
 691 "    CMP     R0, #0 \n"
 692 "    BEQ     loc_FF04F9D8 \n"
 693 "    LDR     R7, =0x2BB8 \n"
 694 "    LDR     R0, [R7, R4, LSL#2] \n"
 695 "    BL      sub_FF0062E0 /*_CancelTimer*/ \n"
 696 "    LDR     R2, =0xFF04F6C4 \n"
 697 "    ORR     R3, R4, #0x300 \n"
 698 "    MOV     R1, R2 \n"
 699 "    MOV     R0, #0x1F4 \n"
 700 "    BL      sub_FF006210 /*_SetTimerAfter*/ \n"
 701 "    TST     R0, #1 \n"
 702 "    CMPNE   R0, #0x15 \n"
 703 "    STR     R0, [R7, R4, LSL#2] \n"
 704 "    BEQ     loc_FF04F9D8 \n"
 705 "    LDR     R2, =0x236 \n"
 706 "    B       loc_FF04F9CC \n"
 707 
 708 "loc_FF04F8F8:\n"
 709 "    MOV     R0, R2 \n"
 710 "    RSBLT   R0, R0, #0 \n"
 711 "    MOVLE   R7, #0 \n"
 712 "    MOVGT   R7, #1 \n"
 713 "    CMP     R0, #0xFF \n"
 714 "    BLS     loc_FF04F934 \n"
 715 "    LDR     R0, =0x7FFF \n"
 716 "    CMP     R2, #0 \n"
 717 "    SUBLE   R0, R0, R3 \n"
 718 "    ADDLE   R0, R0, R1 \n"
 719 "    SUBGT   R0, R0, R1 \n"
 720 "    ADDGT   R0, R0, R3 \n"
 721 "    MVN     R1, #0x8000 \n"
 722 "    SUB     R0, R0, R1 \n"
 723 "    EOR     R7, R7, #1 \n"
 724 
 725 "loc_FF04F934:\n"
 726 "    STR     R0, [SP, #4] \n"
 727 "    LDR     R0, [R9, R4, LSL#2] \n"
 728 "    CMP     R0, #0 \n"
 729 "    ADDEQ   R0, R6, R5, LSL#2 \n"
 730 "    LDREQ   R0, [R0, #8] \n"
 731 "    BEQ     loc_FF04F96C \n"
 732 "    ADD     R8, R6, R5, LSL#2 \n"
 733 "    ADD     R1, R8, R7, LSL#2 \n"
 734 "    LDR     R1, [R1, #0x10] \n"
 735 "    CMP     R1, R0 \n"
 736 "    BEQ     loc_FF04F970 \n"
 737 "    LDR     R0, [R8, #0xC] \n"
 738 "    BL      sub_FF00BC8C \n"
 739 "    LDR     R0, [R8, #8] \n"
 740 
 741 "loc_FF04F96C:\n"
 742 "    BL      sub_FF00BC8C \n"
 743 
 744 "loc_FF04F970:\n"
 745 "    ADD     R0, R6, R5, LSL#2 \n"
 746 "    ADD     R7, R0, R7, LSL#2 \n"
 747 "    LDR     R0, [R7, #0x10] \n"
 748 "    LDR     R1, [SP, #4] \n"
 749 "    BL      sub_FF00BC9C \n"
 750 "    LDR     R0, [R7, #0x10] \n"
 751 "    LDR     R7, =0x2BB8 \n"
 752 "    STR     R0, [R9, R4, LSL#2] \n"
 753 "    LDRH    R1, [R11] \n"
 754 "    LDR     R0, [SP, #0x18] \n"
 755 "    STRH    R1, [R0] \n"
 756 "    LDR     R0, [R7, R4, LSL#2] \n"
 757 "    BL      sub_FF0062E0 /*_CancelTimer*/ \n"
 758 "    LDR     R2, =0xFF04F6C4 \n"
 759 "    ORR     R3, R4, #0x300 \n"
 760 "    MOV     R1, R2 \n"
 761 "    MOV     R0, #0x1F4 \n"
 762 "    BL      sub_FF006210 /*_SetTimerAfter*/ \n"
 763 "    TST     R0, #1 \n"
 764 "    CMPNE   R0, #0x15 \n"
 765 "    STR     R0, [R7, R4, LSL#2] \n"
 766 "    BEQ     loc_FF04F9D8 \n"
 767 "    LDR     R2, =0x267 \n"
 768 
 769 "loc_FF04F9CC:\n"
 770 "    LDR     R1, =0xFF04FA34 /*'RotaryEncoder.c'*/ \n"
 771 "    MOV     R0, #0 \n"
 772 "    BL      _DebugAssert \n"
 773 
 774 "loc_FF04F9D8:\n"
 775 "    ADD     R0, R6, R5, LSL#2 \n"
 776 "    LDR     R0, [R0, #0x18] \n"
 777 "    CMP     R0, #1 \n"
 778 "    BNE     loc_FF04FA78 \n"
 779 "    LDR     R0, =0x2BAC \n"
 780 "    LDR     R0, [R0, #0x10] \n"
 781 "    CMP     R0, #0 \n"
 782 "    BEQ     loc_FF04FA78 \n"
 783 "    LDR     R2, =0xFF04F6B8 \n"
 784 "    ORR     R3, R4, #0x400 \n"
 785 "    MOV     R1, R2 \n"
 786 "    BL      sub_FF006210 /*_SetTimerAfter*/ \n"
 787 "    TST     R0, #1 \n"
 788 "    CMPNE   R0, #0x15 \n"
 789 "    STR     R0, [R10, R4, LSL#2] \n"
 790 "    BEQ     loc_FF04F7C4 \n"
 791 "    LDR     R2, =0x26E \n"
 792 
 793 "loc_FF04FA1C:\n"
 794 "    LDR     R1, =0xFF04FA34 /*'RotaryEncoder.c'*/ \n"
 795 "    MOV     R0, #0 \n"
 796 "    BL      _DebugAssert \n"
 797 "    B       loc_FF04F7C4 \n"
 798 
 799 "loc_FF04FA78:\n"
 800 "    LDR     R0, [R6, R5, LSL#2] \n"
 801 "    B       loc_FF04F834 \n"
 802 
 803 "loc_FF04FA80:\n"
 804 "    LDR     R0, [R9, R4, LSL#2] \n"
 805 "    CMP     R0, #0 \n"
 806 "    MOVEQ   R2, #0x278 \n"
 807 "    LDREQ   R1, =0xFF04FA34 /*'RotaryEncoder.c'*/ \n"
 808 "    BLEQ    _DebugAssert \n"
 809 "    RSB     R0, R4, R4, LSL#3 \n"
 810 "    ADD     R0, R6, R0, LSL#2 \n"
 811 "    LDR     R0, [R0, #0xC] \n"
 812 "    BL      sub_FF00BC8C \n"
 813 "    MOV     R0, #0 \n"
 814 "    STR     R0, [R9, R4, LSL#2] \n"
 815 "    B       loc_FF04F7C4 \n"
 816 );
 817 }

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