root/platform/s110/sub/102b/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_F800038C_my
  6. sub_F800116C_my
  7. sub_F8004264_my
  8. sub_F800CCB4_my
  9. sub_F80211F4_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 @ 0xF800000C - 0xF8000184, 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, =0xF0000037 \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, =0xF896E004 \n"
 130 "    LDR     R1, =0x685000 \n"
 131 "    LDR     R3, =0x6B3264 \n"
 132 
 133 "loc_F8000144:\n"
 134 "    CMP     R1, R3 \n"
 135 "    LDRCC   R2, [R0], #4 \n"
 136 "    STRCC   R2, [R1], #4 \n"
 137 "    BCC     loc_F8000144 \n"
 138 "    LDR     R0, =0xF8953558 \n"
 139 "    LDR     R1, =0x1900 \n"
 140 "    LDR     R3, =0x1C3AC \n"
 141 
 142 "loc_F8000160:\n"
 143 "    CMP     R1, R3 \n"
 144 "    LDRCC   R2, [R0], #4 \n"
 145 "    STRCC   R2, [R1], #4 \n"
 146 "    BCC     loc_F8000160 \n"
 147 "    LDR     R1, =0x28BC88 \n"
 148 "    MOV     R2, #0 \n"
 149 
 150 "loc_F8000178:\n"
 151 "    CMP     R3, R1 \n"
 152 "    STRCC   R2, [R3], #4 \n"
 153 "    BCC     loc_F8000178 \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_F800038C_my \n"  // --> Patched. Old value = 0xF800038C.
 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_F800038C_my @ 0xF800038C - 0xF80003F4, length=27
 224 void __attribute__((naked,noinline)) sub_F800038C_my() {
 225 
 226     if ( (*(int*)0xC022F48C & 0x4) )
 227         *(int*)(0x2FF0+0x4) = 0x200000;     // Playmode "PhySwConfig.c" @f807b174
 228     else
 229         *(int*)(0x2FF0+0x4) = 0x100000;     // Shootingmode
 230 
 231 asm volatile (
 232 "    LDR     R0, =0xF8000404 \n"
 233 "    MOV     R1, #0 \n"
 234 "    LDR     R3, =0xF800043C \n"
 235 
 236 "loc_F8000398:\n"
 237 "    CMP     R0, R3 \n"
 238 "    LDRCC   R2, [R0], #4 \n"
 239 "    STRCC   R2, [R1], #4 \n"
 240 "    BCC     loc_F8000398 \n"
 241 "    LDR     R0, =0xF800043C \n"
 242 "    MOV     R1, #0x4B0 \n"
 243 "    LDR     R3, =0xF8000624 \n"
 244 
 245 "loc_F80003B4:\n"
 246 "    CMP     R0, R3 \n"
 247 "    LDRCC   R2, [R0], #4 \n"
 248 "    STRCC   R2, [R1], #4 \n"
 249 "    BCC     loc_F80003B4 \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_F80003E8:\n"
 261 "    CMP     R0, R3 \n"
 262 "    STRCC   R2, [R0], #4 \n"
 263 "    BCC     loc_F80003E8 \n"
 264 "    BL      sub_F800116C_my \n"  // --> Patched. Old value = 0xF800116C.
 265 );
 266 }
 267 
 268 /*************************************************************/
 269 //** sub_F800116C_my @ 0xF800116C - 0xF8001220, length=46
 270 void __attribute__((naked,noinline)) sub_F800116C_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_006AB924 \n"
 277 "    MOV     R0, #0x83000 \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, =0x28BC88 \n"
 282 #else
 283 "    LDR     R0, =new_sa\n"   // otherwise use patched value
 284 "    LDR     R0, [R0]\n"      // 
 285 #endif
 286 
 287 "    LDR     R2, =0x53F15C \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, #0x98 \n"
 294 "    STR     R0, [SP, #0x1C] \n"
 295 "    LDR     R0, =0x1E2 \n"
 296 "    LDR     R1, =0x549C00 \n"
 297 "    STR     R2, [SP, #0x10] \n"
 298 "    STR     R0, [SP, #0x20] \n"
 299 "    MOV     R0, #0xF6 \n"
 300 "    STR     R1, [SP] \n"
 301 "    STR     R1, [SP, #0x14] \n"
 302 "    STR     R0, [SP, #0x24] \n"
 303 "    MOV     R0, #0xB6 \n"
 304 "    STR     R0, [SP, #0x28] \n"
 305 "    MOV     R0, #0x85 \n"
 306 "    STR     R0, [SP, #0x2C] \n"
 307 "    MOV     R0, #0x40 \n"
 308 "    STR     R0, [SP, #0x30] \n"
 309 "    MOV     R0, #4 \n"
 310 "    STR     R0, [SP, #0x34] \n"
 311 "    MOV     R0, #0x10 \n"
 312 "    STR     R0, [SP, #0x5C] \n"
 313 "    MOV     R0, #0x800 \n"
 314 "    STR     R0, [SP, #0x60] \n"
 315 "    MOV     R0, #0xA0 \n"
 316 "    STR     R0, [SP, #0x64] \n"
 317 "    MOV     R0, #0x280 \n"
 318 "    STR     R0, [SP, #0x68] \n"
 319 "    LDR     R1, =sub_F8004264_my \n"  // --> Patched. Old value = 0xF8004264.
 320 "    MOV     R2, #0 \n"
 321 "    MOV     R0, SP \n"
 322 "    BL      sub_006867E8 \n"
 323 "    ADD     SP, SP, #0x74 \n"
 324 "    LDR     PC, [SP], #4 \n"
 325 );
 326 }
 327 
 328 /*************************************************************/
 329 //** sub_F8004264_my @ 0xF8004264 - 0xF8004308, length=42
 330 void __attribute__((naked,noinline)) sub_F8004264_my() {
 331 asm volatile (
 332 "    STMFD   SP!, {R4,LR} \n"
 333 "    BL      sub_F8000AE8 \n"
 334 "    BL      sub_F8005450 \n"
 335 "    CMP     R0, #0 \n"
 336 "    LDRLT   R0, =0xF80043D4 /*'dmSetup'*/ \n"
 337 "    BLLT    _err_init_task \n"
 338 "    BL      sub_F8003E9C \n"
 339 "    CMP     R0, #0 \n"
 340 "    LDRLT   R0, =0xF80043DC /*'termDriverInit'*/ \n"
 341 "    BLLT    _err_init_task \n"
 342 "    LDR     R0, =0xF80043EC /*'/_term'*/ \n"
 343 "    BL      sub_F8003F84 \n"
 344 "    CMP     R0, #0 \n"
 345 "    LDRLT   R0, =0xF80043F4 /*'termDeviceCreate'*/ \n"
 346 "    BLLT    _err_init_task \n"
 347 "    LDR     R0, =0xF80043EC /*'/_term'*/ \n"
 348 "    BL      sub_F80029A4 \n"
 349 "    CMP     R0, #0 \n"
 350 "    LDRLT   R0, =0xF8004408 /*'stdioSetup'*/ \n"
 351 "    BLLT    _err_init_task \n"
 352 "    BL      sub_F8004DEC \n"
 353 "    CMP     R0, #0 \n"
 354 "    LDRLT   R0, =0xF8004414 /*'stdlibSetup'*/ \n"
 355 "    BLLT    _err_init_task \n"
 356 "    BL      sub_F8007A08 \n"
 357 "    CMP     R0, #0 \n"
 358 "    LDRLT   R0, =0xF8004420 /*'posixSetup'*/ \n"
 359 "    BLLT    _err_init_task \n"
 360 "    BL      sub_F8007AC8 \n"
 361 "    CMP     R0, #0 \n"
 362 "    LDRLT   R0, =0xF800442C /*'pthreadSetup'*/ \n"
 363 "    BLLT    _err_init_task \n"
 364 "    BL      sub_F8006938 \n"
 365 "    CMP     R0, #0 \n"
 366 "    LDRLT   R0, =0xF800443C /*'dhcpc_setup'*/ \n"
 367 "    BLLT    _err_init_task \n"
 368 "    BL      sub_F8001664 \n"
 369 "    CMP     R0, #0 \n"
 370 "    LDRLT   R0, =0xF8004448 /*'armlib_setup'*/ \n"
 371 "    BLLT    _err_init_task \n"
 372 "    LDMFD   SP!, {R4,LR} \n"
 373 "    B       sub_F800CCB4_my \n"  // --> Patched. Old value = 0xF800CCB4.
 374 );
 375 }
 376 
 377 /*************************************************************/
 378 //** sub_F800CCB4_my @ 0xF800CCB4 - 0xF800CD2C, length=31
 379 void __attribute__((naked,noinline)) sub_F800CCB4_my() {
 380 asm volatile (
 381 "    STMFD   SP!, {R3,LR} \n"
 382 "    BL      sub_F803B40C \n"
 383 "    CMP     R0, #0 \n"
 384 "    BNE     loc_F800CCD4 \n"
 385 "    BL      sub_F8023348 /*_IsNormalCameraMode_FW*/ \n"
 386 "    CMP     R0, #0 \n"
 387 "    MOVNE   R0, #1 \n"
 388 "    BNE     loc_F800CCD8 \n"
 389 
 390 "loc_F800CCD4:\n"
 391 "    MOV     R0, #0 \n"
 392 
 393 "loc_F800CCD8:\n"
 394 "    BL      sub_F80211F4_my \n"  // --> Patched. Old value = 0xF80211F4.
 395 "    CMP     R0, #0 \n"
 396 "    BNE     loc_F800CCF8 \n"
 397 "    BL      sub_F80205CC \n"
 398 "    LDR     R1, =0x83DC00 \n"
 399 "    MOV     R0, #0x54 \n"
 400 "    BL      sub_F80399A0 \n"
 401 
 402 "loc_F800CCF4:\n"
 403 "    B       loc_F800CCF4 \n"
 404 
 405 "loc_F800CCF8:\n"
 406 "    BL      sub_0068F698 \n"
 407 "    LDR     R1, =0x5CE000 \n"
 408 "    MOV     R0, #0 \n"
 409 "    BL      sub_F803979C \n"
 410 "    BL      sub_0068F8B0 \n"
 411 "    MOV     R3, #0 \n"
 412 "    STR     R3, [SP] \n"
 413 "    LDR     R3, =task_Startup_my \n"  // --> Patched. Old value = 0xF800CC4C.
 414 "    MOV     R2, #0 \n"
 415 "    MOV     R1, #0x19 \n"
 416 "    LDR     R0, =0xF800CD3C /*'Startup'*/ \n"
 417 "    BL      _CreateTask \n"
 418 "    MOV     R0, #0 \n"
 419 "    LDMFD   SP!, {R3,PC} \n"
 420 );
 421 }
 422 
 423 /*************************************************************/
 424 //** sub_F80211F4_my @ 0xF80211F4 - 0xF802124C, length=23
 425 void __attribute__((naked,noinline)) sub_F80211F4_my() {
 426 asm volatile (
 427 "    STMFD   SP!, {R4-R6,LR} \n"
 428 "    MOV     R6, R0 \n"
 429 //"  BL      _sub_F807B16C \n"  // --> Nullsub call removed.
 430 "    MOV     R0, #0x36 \n"
 431 "    BL      sub_F80399B0 \n"
 432 "    MOV     R4, #1 \n"
 433 "    BIC     R5, R4, R0 \n"
 434 "    MOV     R0, #0x37 \n"
 435 "    BL      sub_F80399B0 \n"
 436 "    CMP     R6, #0 \n"
 437 "    BIC     R4, R4, R0 \n"
 438 "    BEQ     loc_F802122C \n"
 439 "    ORRS    R0, R5, R4 \n"
 440 "    LDMEQFD SP!, {R4-R6,PC} \n"
 441 
 442 "loc_F802122C:\n"
 443 "    BL      sub_F803B40C \n"
 444 "    MOV     R2, R0 \n"
 445 "    MOV     R3, #0 \n"
 446 "    MOV     R1, R4 \n"
 447 "    MOV     R0, R5 \n"
 448 //"  BL      _sub_F807B174 \n"  // Disable StartUpChecks
 449 //"  BL      _sub_F807B170 \n"  // --> Nullsub call removed.
 450 "    MOV     R0, #1 \n"
 451 "    LDMFD   SP!, {R4-R6,PC} \n"
 452 );
 453 }
 454 
 455 /*************************************************************/
 456 //** task_Startup_my @ 0xF800CC4C - 0xF800CCB0, length=26
 457 void __attribute__((naked,noinline)) task_Startup_my() {
 458 asm volatile (
 459 "    STMFD   SP!, {R4,LR} \n"
 460 "    BL      sub_F8004954 \n"
 461 "    BL      sub_F8022408 \n"
 462 "    BL      sub_F8020434 \n"
 463 //"  BL      _sub_F807BC9C \n"  // --> Nullsub call removed.
 464 "    BL      sub_F803B644 \n"
 465 //"  BL      _sub_F803B4EC \n"  // load DISKBOOT.BIN
 466 "    BL      sub_F803B7BC \n"
 467 "    BL      sub_F803B988 \n"
 468 //"  BL      _sub_F803B7B0 \n"  // --> Nullsub call removed.
 469 "    BL      sub_F803B674 \n"
 470 "    BL      sub_F80396D0 \n"
 471 "    BL      sub_F803B990 \n"
 472 "    BL      CreateTask_spytask\n" // added
 473 "    BL      taskcreatePhySw_my \n"  // --> Patched. Old value = 0xF8021094.
 474 "    BL      sub_F8036DF8 \n"
 475 "    BL      sub_F80ED7F0 \n"
 476 "    BL      sub_F801DF88 \n"
 477 "    BL      sub_F801FDA4 \n"
 478 "    BL      sub_F803B198 \n"
 479 "    BL      sub_F80203E8 \n"
 480 "    BL      sub_F801FD40 \n"
 481 //"  BL      _sub_F803B7B4 \n"  // --> Nullsub call removed.
 482 "    BL      sub_F801ECA4 \n"
 483 "    BL      sub_F801FD04 \n"
 484 "    LDMFD   SP!, {R4,LR} \n"
 485 "    B       sub_F8004A90 \n"
 486 );
 487 }
 488 
 489 /*************************************************************/
 490 //** taskcreatePhySw_my @ 0xF8021094 - 0xF80210E8, length=22
 491 void __attribute__((naked,noinline)) taskcreatePhySw_my() {
 492 asm volatile (
 493 "    STMFD   SP!, {R3-R5,LR} \n"
 494 "    LDR     R4, =0x1E80 \n"
 495 "    LDR     R0, [R4, #4] \n"
 496 "    CMP     R0, #0 \n"
 497 "    BNE     loc_F80210C8 \n"
 498 "    MOV     R3, #0 \n"
 499 "    STR     R3, [SP] \n"
 500 "    LDR     R3, =mykbd_task \n"  // --> Patched. Old value = 0xF8021060.
 501 "    MOV     R2, #0x2000 \n"  // --> Patched. Old value = 0x800. stack size for new task_PhySw so we don't have to do stack switch
 502 "    MOV     R1, #0x17 \n"
 503 "    LDR     R0, =0xF8021344 /*'PhySw'*/ \n"
 504 "    BL      sub_0068AF04 /*_CreateTaskStrictly*/ \n"
 505 "    STR     R0, [R4, #4] \n"
 506 
 507 "loc_F80210C8:\n"
 508 "    BL      sub_F807C0E4 \n"
 509 "    BL      sub_F80D501C \n"
 510 "    BL      sub_F8023298 /*_IsFactoryMode_FW*/ \n"
 511 "    CMP     R0, #0 \n"
 512 "    BNE     loc_F80210E8 \n"
 513 "    LDR     R1, =0x41608 \n"
 514 "    MOV     R0, #0 \n"
 515 "    BL      sub_F80D4F88 /*_OpLog.Start_FW*/ \n"
 516 
 517 "loc_F80210E8:\n"
 518 "    LDMFD   SP!, {R3-R5,PC} \n"
 519 );
 520 }
 521 
 522 /*************************************************************/
 523 //** init_file_modules_task @ 0xF80675A8 - 0xF80675DC, length=14
 524 void __attribute__((naked,noinline)) init_file_modules_task() {
 525 asm volatile (
 526 "    STMFD   SP!, {R4-R6,LR} \n"
 527 "    BL      sub_F80D7584 \n"
 528 "    LDR     R5, =0x5006 \n"
 529 "    MOVS    R4, R0 \n"
 530 "    MOVNE   R1, #0 \n"
 531 "    MOVNE   R0, R5 \n"
 532 "    BLNE    _PostLogicalEventToUI \n"
 533 "    BL      sub_F80D75B0 \n"
 534 "    BL      core_spytask_can_start\n"  // CHDK: Set "it's-safe-to-start" flag for spytask
 535 "    CMP     R4, #0 \n"
 536 "    LDMNEFD SP!, {R4-R6,PC} \n"
 537 "    MOV     R0, R5 \n"
 538 "    LDMFD   SP!, {R4-R6,LR} \n"
 539 "    MOV     R1, #0 \n"
 540 "    B       _PostLogicalEventToUI \n"
 541 );
 542 }
 543 
 544 /*************************************************************/
 545 //** JogDial_task_my @ 0xF807BDB8 - 0xF807C0E0, length=203
 546 void __attribute__((naked,noinline)) JogDial_task_my() {
 547 asm volatile (
 548 "    STMFD   SP!, {R4-R11,LR} \n"
 549 "    SUB     SP, SP, #0x24 \n"
 550 "    BL      sub_F807C150 \n"
 551 "    LDR     R12, =0x3014 \n"
 552 "    LDR     R6, =0xF864B5D4 \n"
 553 "    MOV     R0, #0 \n"
 554 
 555 // Save pointer for kbd.c routine
 556 "    ADD     R10, SP, #0x18 \n"
 557 "    LDR     R9, =jog_position \n"
 558 "    STR     R10, [R9] \n"
 559 
 560 "    ADD     R10, SP, #8 \n"
 561 "    ADD     R9, SP, #0x10 \n"
 562 
 563 "loc_F807BDD8:\n"
 564 "    ADD     R2, SP, #0x1C \n"
 565 "    MOV     R1, #0 \n"
 566 "    ADD     R4, R2, R0, LSL#1 \n"
 567 "    ADD     R3, SP, #0x18 \n"
 568 "    STRH    R1, [R4] \n"
 569 "    ADD     R4, R3, R0, LSL#1 \n"
 570 "    STRH    R1, [R4] \n"
 571 "    STR     R1, [R9, R0, LSL#2] \n"
 572 "    STR     R1, [R10, R0, LSL#2] \n"
 573 "    ADD     R0, R0, #1 \n"
 574 "    CMP     R0, #2 \n"
 575 "    BLT     loc_F807BDD8 \n"
 576 
 577 "loc_F807BE08:\n"
 578 "    LDR     R0, =0x3014 \n"
 579 "    MOV     R2, #0 \n"
 580 "    LDR     R0, [R0, #8] \n"
 581 "    MOV     R1, SP \n"
 582 "    BL      sub_0068F164 /*_ReceiveMessageQueue*/ \n"
 583 "    CMP     R0, #0 \n"
 584 "    LDRNE   R1, =0x20B \n"
 585 "    LDRNE   R0, =0xF807C068 /*'RotaryEncoder.c'*/ \n"
 586 "    BLNE    _DebugAssert \n"
 587 "    LDR     R0, [SP] \n"
 588 "    AND     R4, R0, #0xFF \n"
 589 "    AND     R0, R0, #0xFF00 \n"
 590 "    CMP     R0, #0x100 \n"
 591 "    BEQ     loc_F807BE78 \n"
 592 "    CMP     R0, #0x200 \n"
 593 "    BEQ     loc_F807BEB0 \n"
 594 "    CMP     R0, #0x300 \n"
 595 "    BEQ     loc_F807C0B4 \n"
 596 "    CMP     R0, #0x400 \n"
 597 "    BNE     loc_F807BE08 \n"
 598 "    CMP     R4, #0 \n"
 599 "    LDRNE   R1, =0x285 \n"
 600 "    LDRNE   R0, =0xF807C068 /*'RotaryEncoder.c'*/ \n"
 601 "    BLNE    _DebugAssert \n"
 602 "    RSB     R0, R4, R4, LSL#3 \n"
 603 "    LDR     R0, [R6, R0, LSL#2] \n"
 604 
 605 "loc_F807BE70:\n"
 606 "    BL      sub_F807C134 \n"
 607 "    B       loc_F807BE08 \n"
 608 
 609 "loc_F807BE78:\n"
 610 //------------------  added code ---------------------
 611 "labelA:\n"
 612 "    LDR     R0, =jogdial_stopped\n"
 613 "    LDR     R0, [R0]\n"
 614 "    CMP     R0, #1\n"
 615 "    BNE     labelB\n"
 616 "    MOV     R0, #40\n"
 617 "    BL      _SleepTask\n"
 618 "    B       labelA\n"
 619 "labelB:\n"
 620 //------------------  original code ------------------
 621 "    LDR     R0, =0x3024 \n"
 622 "    LDR     R0, [R0, R4, LSL#2] \n"
 623 "    BL      sub_F8039F8C /*_CancelTimer*/ \n"
 624 "    LDR     R2, =0xF807BD04 \n"
 625 "    ORR     R3, R4, #0x200 \n"
 626 "    MOV     R1, R2 \n"
 627 "    MOV     R0, #0x28 \n"
 628 "    BL      sub_F8039EA8 /*_SetTimerAfter*/ \n"
 629 "    TST     R0, #1 \n"
 630 "    CMPNE   R0, #0x15 \n"
 631 "    STR     R0, [R10, R4, LSL#2] \n"
 632 "    BEQ     loc_F807BE08 \n"
 633 "    LDR     R1, =0x21D \n"
 634 "    B       loc_F807C054 \n"
 635 
 636 "loc_F807BEB0:\n"
 637 "    RSB     R5, R4, R4, LSL#3 \n"
 638 "    LDR     R0, [R6, R5, LSL#2] \n"
 639 "    LDR     R1, =0xC0240000 \n"
 640 "    ADD     R0, R1, R0, LSL#8 \n"
 641 "    LDR     R0, [R0, #0x104] \n"
 642 "    MOV     R1, R0, ASR#16 \n"
 643 "    ADD     R0, SP, #0x1C \n"
 644 "    ADD     R11, R0, R4, LSL#1 \n"
 645 "    ADD     R0, SP, #0x18 \n"
 646 "    ADD     R0, R0, R4, LSL#1 \n"
 647 "    STRH    R1, [R11] \n"
 648 "    STR     R0, [SP, #0x20] \n"
 649 "    LDRSH   R3, [R0] \n"
 650 "    SUB     R2, R1, R3 \n"
 651 "    CMP     R2, #0 \n"
 652 "    BNE     loc_F807BF34 \n"
 653 "    LDR     R0, [R9, R4, LSL#2] \n"
 654 "    CMP     R0, #0 \n"
 655 "    BEQ     loc_F807C010 \n"
 656 "    LDR     R7, =0x3024 \n"
 657 "    LDR     R0, [R7, R4, LSL#2] \n"
 658 "    BL      sub_F8039F8C /*_CancelTimer*/ \n"
 659 "    LDR     R2, =0xF807BD10 \n"
 660 "    ORR     R3, R4, #0x300 \n"
 661 "    MOV     R1, R2 \n"
 662 "    MOV     R0, #0x1F4 \n"
 663 "    BL      sub_F8039EA8 /*_SetTimerAfter*/ \n"
 664 "    TST     R0, #1 \n"
 665 "    CMPNE   R0, #0x15 \n"
 666 "    STR     R0, [R7, R4, LSL#2] \n"
 667 "    BEQ     loc_F807C010 \n"
 668 "    LDR     R1, =0x236 \n"
 669 "    B       loc_F807C008 \n"
 670 
 671 "loc_F807BF34:\n"
 672 "    MOV     R0, R2 \n"
 673 "    RSBLT   R0, R0, #0 \n"
 674 "    MOVLE   R7, #0 \n"
 675 "    MOVGT   R7, #1 \n"
 676 "    CMP     R0, #0xFF \n"
 677 "    BLS     loc_F807BF70 \n"
 678 "    LDR     R0, =0x7FFF \n"
 679 "    CMP     R2, #0 \n"
 680 "    SUBLE   R0, R0, R3 \n"
 681 "    ADDLE   R0, R0, R1 \n"
 682 "    SUBGT   R0, R0, R1 \n"
 683 "    ADDGT   R0, R0, R3 \n"
 684 "    MVN     R1, #0x8000 \n"
 685 "    SUB     R0, R0, R1 \n"
 686 "    EOR     R7, R7, #1 \n"
 687 
 688 "loc_F807BF70:\n"
 689 "    STR     R0, [SP, #4] \n"
 690 "    LDR     R0, [R9, R4, LSL#2] \n"
 691 "    CMP     R0, #0 \n"
 692 "    ADDEQ   R0, R6, R5, LSL#2 \n"
 693 "    LDREQ   R0, [R0, #8] \n"
 694 "    BEQ     loc_F807BFA8 \n"
 695 "    ADD     R8, R6, R5, LSL#2 \n"
 696 "    ADD     R1, R8, R7, LSL#2 \n"
 697 "    LDR     R1, [R1, #0x10] \n"
 698 "    CMP     R1, R0 \n"
 699 "    BEQ     loc_F807BFAC \n"
 700 "    LDR     R0, [R8, #0xC] \n"
 701 "    BL      sub_F80210EC \n"
 702 "    LDR     R0, [R8, #8] \n"
 703 
 704 "loc_F807BFA8:\n"
 705 "    BL      sub_F80210EC \n"
 706 
 707 "loc_F807BFAC:\n"
 708 "    ADD     R0, R6, R5, LSL#2 \n"
 709 "    ADD     R7, R0, R7, LSL#2 \n"
 710 "    LDR     R0, [R7, #0x10] \n"
 711 "    LDR     R1, [SP, #4] \n"
 712 "    BL      sub_F80210FC \n"
 713 "    LDR     R0, [R7, #0x10] \n"
 714 "    LDR     R7, =0x3024 \n"
 715 "    STR     R0, [R9, R4, LSL#2] \n"
 716 "    LDRH    R1, [R11] \n"
 717 "    LDR     R0, [SP, #0x20] \n"
 718 "    STRH    R1, [R0] \n"
 719 "    LDR     R0, [R7, R4, LSL#2] \n"
 720 "    BL      sub_F8039F8C /*_CancelTimer*/ \n"
 721 "    LDR     R2, =0xF807BD10 \n"
 722 "    ORR     R3, R4, #0x300 \n"
 723 "    MOV     R1, R2 \n"
 724 "    MOV     R0, #0x1F4 \n"
 725 "    BL      sub_F8039EA8 /*_SetTimerAfter*/ \n"
 726 "    TST     R0, #1 \n"
 727 "    CMPNE   R0, #0x15 \n"
 728 "    STR     R0, [R7, R4, LSL#2] \n"
 729 "    BEQ     loc_F807C010 \n"
 730 "    LDR     R1, =0x267 \n"
 731 
 732 "loc_F807C008:\n"
 733 "    LDR     R0, =0xF807C068 /*'RotaryEncoder.c'*/ \n"
 734 "    BL      _DebugAssert \n"
 735 
 736 "loc_F807C010:\n"
 737 "    ADD     R0, R6, R5, LSL#2 \n"
 738 "    LDR     R0, [R0, #0x18] \n"
 739 "    CMP     R0, #1 \n"
 740 "    BNE     loc_F807C0AC \n"
 741 "    LDR     R0, =0x3014 \n"
 742 "    LDR     R0, [R0, #0xC] \n"
 743 "    CMP     R0, #0 \n"
 744 "    BEQ     loc_F807C0AC \n"
 745 "    LDR     R2, =0xF807BD04 \n"
 746 "    ORR     R3, R4, #0x400 \n"
 747 "    MOV     R1, R2 \n"
 748 "    BL      sub_F8039EA8 /*_SetTimerAfter*/ \n"
 749 "    TST     R0, #1 \n"
 750 "    CMPNE   R0, #0x15 \n"
 751 "    STR     R0, [R10, R4, LSL#2] \n"
 752 "    BEQ     loc_F807BE08 \n"
 753 "    LDR     R1, =0x26E \n"
 754 
 755 "loc_F807C054:\n"
 756 "    LDR     R0, =0xF807C068 /*'RotaryEncoder.c'*/ \n"
 757 "    BL      _DebugAssert \n"
 758 "    B       loc_F807BE08 \n"
 759 
 760 "loc_F807C0AC:\n"
 761 "    LDR     R0, [R6, R5, LSL#2] \n"
 762 "    B       loc_F807BE70 \n"
 763 
 764 "loc_F807C0B4:\n"
 765 "    LDR     R0, [R9, R4, LSL#2] \n"
 766 "    CMP     R0, #0 \n"
 767 "    MOVEQ   R1, #0x278 \n"
 768 "    LDREQ   R0, =0xF807C068 /*'RotaryEncoder.c'*/ \n"
 769 "    BLEQ    _DebugAssert \n"
 770 "    RSB     R0, R4, R4, LSL#3 \n"
 771 "    ADD     R0, R6, R0, LSL#2 \n"
 772 "    LDR     R0, [R0, #0xC] \n"
 773 "    BL      sub_F80210EC \n"
 774 "    MOV     R0, #0 \n"
 775 "    STR     R0, [R9, R4, LSL#2] \n"
 776 "    B       loc_F807BE08 \n"
 777 );
 778 }

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