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

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

DEFINITIONS

This source file includes following definitions.
  1. taskHook
  2. CreateTask_spytask
  3. boot
  4. sub_FF000358_my
  5. sub_FF0011B0_my
  6. sub_FF005EE0_my
  7. taskcreate_Startup_my
  8. sub_FF00FC6C_my
  9. task_Startup_my
  10. sub_FF02DAB8_my
  11. sub_FF0941FC_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 // 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 void taskHook(context_t **context)
  25 {
  26     task_t *tcb=(task_t*)((char*)context-offsetof(task_t, context));
  27 
  28     // Replace firmware task addresses with ours
  29     if(tcb->entry == (void*)task_CaptSeq)          tcb->entry = (void*)capt_seq_task;
  30     if(tcb->entry == (void*)task_InitFileModules)  tcb->entry = (void*)init_file_modules_task;
  31     if(tcb->entry == (void*)task_RotaryEncoder)    tcb->entry = (void*)JogDial_task_my;
  32     if(tcb->entry == (void*)task_MovieRecord)      tcb->entry = (void*)movie_record_task;
  33     if(tcb->entry == (void*)task_ExpDrv)           tcb->entry = (void*)exp_drv_task;
  34     if(tcb->entry == (void*)task_FileWrite)        tcb->entry = (void*)filewritetask;
  35 }
  36 
  37 /*----------------------------------------------------------------------
  38     CreateTask_spytask
  39 -----------------------------------------------------------------------*/
  40 void CreateTask_spytask() {
  41     _CreateTask("SpyTask", 0x19, 0x2000, core_spytask, 0);
  42 }
  43 
  44 /*----------------------------------------------------------------------
  45    Pointer to stack location where jogdial task records previous and
  46    current jogdial positions
  47 -----------------------------------------------------------------------*/
  48 short *jog_position;
  49 
  50 /*----------------------------------------------------------------------
  51     boot()
  52 
  53     Main entry point for the CHDK code
  54 -----------------------------------------------------------------------*/
  55 
  56 /*************************************************************/
  57 //** boot @ 0xFF00000C - 0xFF000160, length=86
  58 void __attribute__((naked,noinline)) boot() {
  59 asm volatile (
  60 "    LDR     R1, =0xC0410000 \n"
  61 "    MOV     R0, #0 \n"
  62 "    STR     R0, [R1] \n"
  63 "    MOV     R1, #0x78 \n"
  64 "    MCR     p15, 0, R1, c1, c0 \n"
  65 "    MOV     R1, #0 \n"
  66 "    MCR     p15, 0, R1, c7, c10, 4 \n"
  67 "    MCR     p15, 0, R1, c7, c5 \n"
  68 "    MCR     p15, 0, R1, c7, c6 \n"
  69 "    MOV     R0, #0x3D \n"
  70 "    MCR     p15, 0, R0, c6, c0 \n"
  71 "    MOV     R0, #0xC000002F \n"
  72 "    MCR     p15, 0, R0, c6, c1 \n"
  73 "    MOV     R0, #0x35 \n"
  74 "    MCR     p15, 0, R0, c6, c2 \n"
  75 "    MOV     R0, #0x40000035 \n"
  76 "    MCR     p15, 0, R0, c6, c3 \n"
  77 "    MOV     R0, #0x80000017 \n"
  78 "    MCR     p15, 0, R0, c6, c4 \n"
  79 "    LDR     R0, =0xFF00002F \n"
  80 "    MCR     p15, 0, R0, c6, c5 \n"
  81 "    MOV     R0, #0x34 \n"
  82 "    MCR     p15, 0, R0, c2, c0 \n"
  83 "    MOV     R0, #0x34 \n"
  84 "    MCR     p15, 0, R0, c2, c0, 1 \n"
  85 "    MOV     R0, #0x34 \n"
  86 "    MCR     p15, 0, R0, c3, c0 \n"
  87 "    LDR     R0, =0x3333330 \n"
  88 "    MCR     p15, 0, R0, c5, c0, 2 \n"
  89 "    LDR     R0, =0x3333330 \n"
  90 "    MCR     p15, 0, R0, c5, c0, 3 \n"
  91 "    MRC     p15, 0, R0, c1, c0 \n"
  92 "    ORR     R0, R0, #0x1000 \n"
  93 "    ORR     R0, R0, #4 \n"
  94 "    ORR     R0, R0, #1 \n"
  95 "    MCR     p15, 0, R0, c1, c0 \n"
  96 "    MOV     R1, #0x80000006 \n"
  97 "    MCR     p15, 0, R1, c9, c1 \n"
  98 "    MOV     R1, #6 \n"
  99 "    MCR     p15, 0, R1, c9, c1, 1 \n"
 100 "    MRC     p15, 0, R1, c1, c0 \n"
 101 "    ORR     R1, R1, #0x50000 \n"
 102 "    MCR     p15, 0, R1, c1, c0 \n"
 103 "    LDR     R2, =0xC0200000 \n"
 104 "    MOV     R1, #1 \n"
 105 "    STR     R1, [R2, #0x10C] \n"
 106 "    MOV     R1, #0xFF \n"
 107 "    STR     R1, [R2, #0xC] \n"
 108 "    STR     R1, [R2, #0x1C] \n"
 109 "    STR     R1, [R2, #0x2C] \n"
 110 "    STR     R1, [R2, #0x3C] \n"
 111 "    STR     R1, [R2, #0x4C] \n"
 112 "    STR     R1, [R2, #0x5C] \n"
 113 "    STR     R1, [R2, #0x6C] \n"
 114 "    STR     R1, [R2, #0x7C] \n"
 115 "    STR     R1, [R2, #0x8C] \n"
 116 "    STR     R1, [R2, #0x9C] \n"
 117 "    STR     R1, [R2, #0xAC] \n"
 118 "    STR     R1, [R2, #0xBC] \n"
 119 "    STR     R1, [R2, #0xCC] \n"
 120 "    STR     R1, [R2, #0xDC] \n"
 121 "    STR     R1, [R2, #0xEC] \n"
 122 "    STR     R1, [R2, #0xFC] \n"
 123 "    LDR     R1, =0xC0400008 \n"
 124 "    LDR     R2, =0x430005 \n"
 125 "    STR     R2, [R1] \n"
 126 "    MOV     R1, #1 \n"
 127 "    LDR     R2, =0xC0243100 \n"
 128 "    STR     R2, [R1] \n"
 129 "    LDR     R2, =0xC0242010 \n"
 130 "    LDR     R1, [R2] \n"
 131 "    ORR     R1, R1, #1 \n"
 132 "    STR     R1, [R2] \n"
 133 "    LDR     R0, =0xFF4B5064 \n"
 134 "    LDR     R1, =0x1900 \n"
 135 "    LDR     R3, =0x11C18 \n"
 136 
 137 "loc_FF00013C:\n"
 138 "    CMP     R1, R3 \n"
 139 "    LDRCC   R2, [R0], #4 \n"
 140 "    STRCC   R2, [R1], #4 \n"
 141 "    BCC     loc_FF00013C \n"
 142 "    LDR     R1, =0x18A7FC \n"
 143 "    MOV     R2, #0 \n"
 144 
 145 "loc_FF000154:\n"
 146 "    CMP     R3, R1 \n"
 147 "    STRCC   R2, [R3], #4 \n"
 148 "    BCC     loc_FF000154 \n"
 149 "    B       sub_FF000358_my \n"  // --> Patched. Old value = 0xFF000358.
 150 );
 151 }
 152 
 153 /*************************************************************/
 154 //** sub_FF000358_my @ 0xFF000358 - 0xFF0003C0, length=27
 155 void __attribute__((naked,noinline)) sub_FF000358_my() {
 156 
 157     //http://chdk.setepontos.com/index.php/topic,4194.0.html
 158     *(int*)0x1938=(int)taskHook;
 159     *(int*)0x193C=(int)taskHook;
 160 
 161     // Replacement of sub_FF85FC4C (sub_FF834388) for correct power-on.
 162     // (short press = playback mode, long press = record mode)
 163     *(int*)(0x25E4) = (*(int*)0xC022012C)&1 ? 0x200000 : 0x100000;
 164 
 165 asm volatile (
 166 "    LDR     R0, =0xFF0003D0 \n"
 167 "    MOV     R1, #0 \n"
 168 "    LDR     R3, =0xFF000408 \n"
 169 
 170 "loc_FF000364:\n"
 171 "    CMP     R0, R3 \n"
 172 "    LDRCC   R2, [R0], #4 \n"
 173 "    STRCC   R2, [R1], #4 \n"
 174 "    BCC     loc_FF000364 \n"
 175 "    LDR     R0, =0xFF000408 \n"
 176 "    MOV     R1, #0x4B0 \n"
 177 "    LDR     R3, =0xFF00061C \n"
 178 
 179 "loc_FF000380:\n"
 180 "    CMP     R0, R3 \n"
 181 "    LDRCC   R2, [R0], #4 \n"
 182 "    STRCC   R2, [R1], #4 \n"
 183 "    BCC     loc_FF000380 \n"
 184 "    MOV     R0, #0xD2 \n"
 185 "    MSR     CPSR_cxsf, R0 \n"
 186 "    MOV     SP, #0x1000 \n"
 187 "    MOV     R0, #0xD3 \n"
 188 "    MSR     CPSR_cxsf, R0 \n"
 189 "    MOV     SP, #0x1000 \n"
 190 "    LDR     R0, =0x6C4 \n"
 191 "    LDR     R2, =0xEEEEEEEE \n"
 192 "    MOV     R3, #0x1000 \n"
 193 
 194 "loc_FF0003B4:\n"
 195 "    CMP     R0, R3 \n"
 196 "    STRCC   R2, [R0], #4 \n"
 197 "    BCC     loc_FF0003B4 \n"
 198 "    BL      sub_FF0011B0_my \n"  // --> Patched. Old value = 0xFF0011B0.
 199 );
 200 }
 201 
 202 /*************************************************************/
 203 //** sub_FF0011B0_my @ 0xFF0011B0 - 0xFF00125C, length=44
 204 void __attribute__((naked,noinline)) sub_FF0011B0_my() {
 205 asm volatile (
 206 "    STR     LR, [SP, #-4]! \n"
 207 "    SUB     SP, SP, #0x74 \n"
 208 "    MOV     R1, #0x74 \n"
 209 "    MOV     R0, SP \n"
 210 "    BL      sub_FF3B60A8 \n"
 211 "    MOV     R0, #0x53000 \n"
 212 "    STR     R0, [SP, #4] \n"
 213 
 214 #if defined(CHDK_NOT_IN_CANON_HEAP) // use original heap offset if CHDK is loaded in high memory
 215 "    LDR     R0, =0x18A7FC \n"
 216 #else
 217 "    LDR     R0, =new_sa\n"   // otherwise use patched value
 218 "    LDR     R0, [R0]\n"      //
 219 #endif
 220 
 221 "    LDR     R2, =0x371F80 \n"
 222 "    STR     R0, [SP, #8] \n"
 223 "    SUB     R0, R2, R0 \n"
 224 "    STR     R0, [SP, #0xC] \n"
 225 "    MOV     R0, #0x22 \n"
 226 "    STR     R0, [SP, #0x18] \n"
 227 "    MOV     R0, #0x68 \n"
 228 "    STR     R0, [SP, #0x1C] \n"
 229 "    LDR     R1, =0x379C00 \n"
 230 "    LDR     R0, =0x19B \n"
 231 "    STR     R1, [SP] \n"
 232 "    STR     R0, [SP, #0x20] \n"
 233 "    MOV     R0, #0x96 \n"
 234 "    STR     R2, [SP, #0x10] \n"
 235 "    STR     R1, [SP, #0x14] \n"
 236 "    STR     R0, [SP, #0x24] \n"
 237 "    STR     R0, [SP, #0x28] \n"
 238 "    MOV     R0, #0x64 \n"
 239 "    STR     R0, [SP, #0x2C] \n"
 240 "    MOV     R0, #0 \n"
 241 "    STR     R0, [SP, #0x30] \n"
 242 "    STR     R0, [SP, #0x34] \n"
 243 "    MOV     R0, #0x10 \n"
 244 "    STR     R0, [SP, #0x5C] \n"
 245 "    MOV     R0, #0x800 \n"
 246 "    STR     R0, [SP, #0x60] \n"
 247 "    MOV     R0, #0xA0 \n"
 248 "    STR     R0, [SP, #0x64] \n"
 249 "    MOV     R0, #0x280 \n"
 250 "    STR     R0, [SP, #0x68] \n"
 251 "    LDR     R1, =sub_FF005EE0_my \n"  // --> Patched. Old value = 0xFF005EE0.
 252 "    MOV     R2, #0 \n"
 253 "    MOV     R0, SP \n"
 254 "    BL      sub_FF0034C4 \n"
 255 "    ADD     SP, SP, #0x74 \n"
 256 "    LDR     PC, [SP], #4 \n"
 257 );
 258 }
 259 
 260 /*************************************************************/
 261 //** sub_FF005EE0_my @ 0xFF005EE0 - 0xFF005F54, length=30
 262 void __attribute__((naked,noinline)) sub_FF005EE0_my() {
 263 asm volatile (
 264 "    STMFD   SP!, {R4,LR} \n"
 265 "    BL      sub_FF000B28 \n"
 266 "    BL      sub_FF00A374 \n"
 267 "    CMP     R0, #0 \n"
 268 "    LDRLT   R0, =0xFF005FF4 /*'dmSetup'*/ \n"
 269 "    BLLT    _err_init_task \n"
 270 "    BL      sub_FF005B18 \n"
 271 "    CMP     R0, #0 \n"
 272 "    LDRLT   R0, =0xFF005FFC /*'termDriverInit'*/ \n"
 273 "    BLLT    _err_init_task \n"
 274 "    LDR     R0, =0xFF00600C /*'/_term'*/ \n"
 275 "    BL      sub_FF005C00 \n"
 276 "    CMP     R0, #0 \n"
 277 "    LDRLT   R0, =0xFF006014 /*'termDeviceCreate'*/ \n"
 278 "    BLLT    _err_init_task \n"
 279 "    LDR     R0, =0xFF00600C /*'/_term'*/ \n"
 280 "    BL      sub_FF003CA8 \n"
 281 "    CMP     R0, #0 \n"
 282 "    LDRLT   R0, =0xFF006028 /*'stdioSetup'*/ \n"
 283 "    BLLT    _err_init_task \n"
 284 "    BL      sub_FF009D00 \n"
 285 "    CMP     R0, #0 \n"
 286 "    LDRLT   R0, =0xFF006034 /*'stdlibSetup'*/ \n"
 287 "    BLLT    _err_init_task \n"
 288 "    BL      sub_FF001690 \n"
 289 "    CMP     R0, #0 \n"
 290 "    LDRLT   R0, =0xFF006040 /*'armlib_setup'*/ \n"
 291 "    BLLT    _err_init_task \n"
 292 "    LDMFD   SP!, {R4,LR} \n"
 293 "    B       taskcreate_Startup_my \n"  // --> Patched. Old value = 0xFF00FD54.
 294 );
 295 }
 296 
 297 /*************************************************************/
 298 //** taskcreate_Startup_my @ 0xFF00FD54 - 0xFF00FD80, length=12
 299 void __attribute__((naked,noinline)) taskcreate_Startup_my() {
 300 asm volatile (
 301 "    STMFD   SP!, {R3,LR} \n"
 302 "    BL      sub_FF02B74C \n"
 303 "    BL      sub_FF02B964 /*_EnableDispatch*/ \n"
 304 "    MOV     R3, #0 \n"
 305 "    STR     R3, [SP] \n"
 306 "    LDR     R3, =sub_FF00FC6C_my \n"  // --> Patched. Old value = 0xFF00FC6C.
 307 "    MOV     R2, #0x200 \n"
 308 "    MOV     R1, #0x19 \n"
 309 "    LDR     R0, =0xFF00FDA0 /*'Booting'*/ \n"
 310 "    BL      _CreateTask \n"
 311 "    MOV     R0, #0 \n"
 312 "    LDMFD   SP!, {R3,PC} \n"
 313 );
 314 }
 315 
 316 /*************************************************************/
 317 //** sub_FF00FC6C_my @ 0xFF00FC6C - 0xFF00FD50, length=58
 318 void __attribute__((naked,noinline)) sub_FF00FC6C_my() {
 319 asm volatile (
 320 "    STMFD   SP!, {R3-R9,LR} \n"
 321 "    MOV     R5, #0 \n"
 322 //"  BL      _sub_FF056DAC \n"  // --> Nullsub call removed.
 323 "    BL      sub_FF025C30 \n"
 324 "    BL      sub_FF023C70 \n"
 325 "    BL      sub_FF02D904 \n"
 326 "    BL      sub_FF024E90 \n"
 327 "    BL      sub_FF02389C \n"
 328 "    BL      sub_FF023C0C \n"
 329 "    BL      sub_FF02D674 \n"
 330 "    LDR     R7, =0xC0220000 \n"
 331 "    MOVS    R9, R0 \n"
 332 "    MOV     R8, #1 \n"
 333 "    BNE     loc_FF00FD00 \n"
 334 "    BL      sub_FF0263C0 /*_IsNormalCameraMode_FW*/ \n"
 335 "    CMP     R0, #0 \n"
 336 "    BEQ     loc_FF00FD00 \n"
 337 "    LDR     R0, [R7, #0xD4] \n"
 338 "    BICS    R4, R8, R0 \n"
 339 "    BEQ     loc_FF00FCCC \n"
 340 "    MOV     R0, #0x12C \n"
 341 "    BL      _SleepTask \n"
 342 "    LDR     R0, [R7, #0xD4] \n"
 343 "    BIC     R4, R8, R0 \n"
 344 
 345 "loc_FF00FCCC:\n"
 346 "    LDR     R0, [R7, #0x12C] \n"
 347 "    BIC     R6, R8, R0 \n"
 348 "    BL      sub_FF023C34 \n"
 349 "    CMP     R0, #1 \n"
 350 "    MOVEQ   R5, #1 \n"
 351 "    ORR     R0, R6, R4 \n"
 352 "    ORRS    R0, R0, R5 \n"
 353 "    BNE     loc_FF00FD10 \n"
 354 "    BL      sub_FF024064 \n"
 355 "    MOV     R0, #0x44 \n"
 356 "    STR     R0, [R7, #0x1C] \n"
 357 "    BL      sub_FF024258 \n"
 358 
 359 "loc_FF00FCFC:\n"
 360 "    B       loc_FF00FCFC \n"
 361 
 362 "loc_FF00FD00:\n"
 363 "    LDR     R0, [R7, #0x12C] \n"
 364 "    BIC     R6, R8, R0 \n"
 365 "    LDR     R0, [R7, #0xD4] \n"
 366 "    BIC     R4, R8, R0 \n"
 367 
 368 "loc_FF00FD10:\n"
 369 "    MOV     R3, R5 \n"
 370 "    MOV     R2, R9 \n"
 371 "    MOV     R1, R4 \n"
 372 "    MOV     R0, R6 \n"
 373 //"  BL      _sub_FF056DB4 \n"  // See begin of sub_FF00038C_my
 374 //"  BL      _sub_FF056DB0 \n"  // --> Nullsub call removed.
 375 "    LDR     R1, =0x3CE000 \n"
 376 "    MOV     R0, #0 \n"
 377 "    BL      sub_FF02BBBC \n"
 378 "    MOV     R3, #0 \n"
 379 "    STR     R3, [SP] \n"
 380 "    LDR     R3, =task_Startup_my \n"  // --> Patched. Old value = 0xFF00FBF4.
 381 "    MOV     R2, #0 \n"
 382 "    MOV     R1, #0x19 \n"
 383 "    LDR     R0, =0xFF00FD94 /*'Startup'*/ \n"
 384 "    BL      _CreateTask \n"
 385 "    LDMFD   SP!, {R3-R9,PC} \n"
 386 );
 387 }
 388 
 389 /*************************************************************/
 390 //** task_Startup_my @ 0xFF00FBF4 - 0xFF00FC4C, length=23
 391 void __attribute__((naked,noinline)) task_Startup_my() {
 392 asm volatile (
 393 "    STMFD   SP!, {R4,LR} \n"
 394 "    BL      sub_FF006588 \n"
 395 //"  BL      _sub_FF057868 \n"  // --> Nullsub call removed.
 396 //"  BL      _sub_FF02D7AC \n"  // SD1stInit, Diskboot
 397 "    BL      sub_FF0933B8 \n"
 398 "    LDR     R1, =0x30101 \n"
 399 "    MOV     R0, #2 \n"
 400 "    BL      sub_FF02AC78 \n"
 401 "    LDR     R1, =0xC0220000 \n"
 402 "    MOV     R0, #8 \n"
 403 "    STR     R0, [R1, #0x9C] \n"
 404 "    MOV     R0, #2 \n"
 405 "    BL      sub_FF02A9A8 \n"
 406 "    BL      sub_FF02227C \n"
 407 "    BL      sub_FF02D934 \n"
 408 "    BL      sub_FF02AEF0 \n"
 409 "    BL      sub_FF02DAB8_my \n"  // --> Patched. Old value = 0xFF02DAB8.
 410 
 411 "    BL      CreateTask_spytask\n"  // added
 412 
 413 "    BL      taskcreatePhySw_my \n"  // --> Patched. Old value = 0xFF0248DC.
 414 "    LDR     PC, =0xFF00FC3C \n"  // Continue in firmware
 415 );
 416 }
 417 
 418 /*************************************************************/
 419 //** sub_FF02DAB8_my @ 0xFF02DAB8 - 0xFF02DACC, length=6
 420 void __attribute__((naked,noinline)) sub_FF02DAB8_my() {
 421 asm volatile (
 422 "    STMFD   SP!, {R4,LR} \n"
 423 "    BL      sub_FF0941FC_my \n"  // --> Patched. Old value = 0xFF0941FC.
 424 "    BL      sub_FF08FAC4 \n"
 425 "    BL      sub_FF090384 \n"
 426 "    LDMFD   SP!, {R4,LR} \n"
 427 "    B       sub_FF09302C \n"
 428 );
 429 }
 430 
 431 /*************************************************************/
 432 //** sub_FF0941FC_my @ 0xFF0941FC - 0xFF094258, length=24
 433 void __attribute__((naked,noinline)) sub_FF0941FC_my() {
 434 asm volatile (
 435 "    STMFD   SP!, {R4-R6,LR} \n"
 436 "    BL      sub_FF026310 /*_IsFactoryMode_FW*/ \n"
 437 "    CMP     R0, #0 \n"
 438 "    LDR     R4, =0x48D8 \n"
 439 "    LDRNE   R0, =0xFF02BBC4 \n"
 440 "    STRNE   R0, [R4, #4] \n"
 441 "    LDRNE   R0, =0xFF02BBC8 \n"
 442 "    STRNE   R0, [R4, #8] \n"
 443 "    LDMNEFD SP!, {R4-R6,PC} \n"
 444 "    LDR     R0, [R4] \n"
 445 "    CMP     R0, #0 \n"
 446 "    LDMNEFD SP!, {R4-R6,PC} \n"
 447 "    LDR     R5, =0x727C0 \n"  // --> Patched. Old value = 0x927C0. (steal 128kB from UI memory)
 448 "    MOV     R0, R5 \n"
 449 "    BL      sub_FF02BBCC /*_malloc_strictly*/ \n"
 450 "    MOV     R1, R5 \n"
 451 "    BL      sub_FF001274 \n"
 452 "    TST     R0, #1 \n"
 453 "    STR     R0, [R4] \n"
 454 "    LDMEQFD SP!, {R4-R6,PC} \n"
 455 "    LDMFD   SP!, {R4-R6,LR} \n"
 456 "    MOV     R1, #0x4D \n"
 457 "    LDR     R0, =0xFF094278 /*'UiMemory.c'*/ \n"
 458 "    B       _DebugAssert \n"
 459 );
 460 }
 461 
 462 /*************************************************************/
 463 //** taskcreatePhySw_my @ 0xFF0248DC - 0xFF0248FC, length=9
 464 void __attribute__((naked,noinline)) taskcreatePhySw_my() {
 465 asm volatile (
 466 "    STMFD   SP!, {R3-R5,LR} \n"
 467 "    LDR     R4, =0x1C44 \n"
 468 "    LDR     R0, [R4, #4] \n"
 469 "    CMP     R0, #0 \n"
 470 "    BNE     sub_FF024910 \n"
 471 "    MOV     R3, #0 \n"
 472 "    STR     R3, [SP] \n"
 473 "    LDR     R3, =mykbd_task \n"  // --> Patched. Old value = 0xFF0248A8.
 474 "    MOV     R2, #0x2000 \n"  // --> Patched. Old value = 0x800. stack size for new task_PhySw
 475 "    LDR     PC, =0xFF024900 \n"  // Continue in firmware
 476 );
 477 }
 478 
 479 /*************************************************************/
 480 //** init_file_modules_task @ 0xFF096FCC - 0xFF096FE8, length=8
 481 void __attribute__((naked,noinline)) init_file_modules_task() {
 482 asm volatile (
 483 "    STMFD   SP!, {R4-R6,LR} \n"
 484 "    BL      sub_FF08C78C \n"
 485 "    LDR     R5, =0x5006 \n"
 486 "    MOVS    R4, R0 \n"
 487 "    MOVNE   R1, #0 \n"
 488 "    MOVNE   R0, R5 \n"
 489 "    BLNE    _PostLogicalEventToUI \n"
 490 "    BL      sub_FF08C7B8 \n"
 491 "    BL      core_spytask_can_start\n"  // CHDK: Set "it's-safe-to-start" flag for spytask
 492 "    LDR     PC, =0xFF096FEC \n"  // Continue in firmware
 493 );
 494 }
 495 
 496 /*************************************************************/
 497 //** JogDial_task_my @ 0xFF0579AC - 0xFF057CDC, length=205
 498 void __attribute__((naked,noinline)) JogDial_task_my() {
 499 asm volatile (
 500 "    STMFD   SP!, {R4-R11,LR} \n"
 501 "    SUB     SP, SP, #0x1C \n"
 502 "    BL      sub_FF057D4C \n"
 503 "    LDR     R12, =0x2600 \n"
 504 "    LDR     R6, =0xFF3BD370 \n"
 505 "    MOV     R0, #0 \n"
 506 "    ADD     R10, SP, #8 \n"
 507 "    ADD     R9, SP, #0xC \n"
 508 
 509 // Save pointer for kbd.c routine
 510 "    LDR     R2, =jog_position \n"
 511 "    STR     R9, [R2] \n"
 512 
 513 "loc_FF0579CC:\n"
 514 "    ADD     R2, SP, #0x14 \n"
 515 "    MOV     R1, #0 \n"
 516 "    ADD     R4, R2, R0, LSL#1 \n"
 517 "    ADD     R3, SP, #0x10 \n"
 518 "    STRH    R1, [R4] \n"
 519 "    ADD     R4, R3, R0, LSL#1 \n"
 520 "    STRH    R1, [R4] \n"
 521 "    STR     R1, [R9, R0, LSL#2] \n"
 522 "    STR     R1, [R10, R0, LSL#2] \n"
 523 "    ADD     R0, R0, #1 \n"
 524 "    CMP     R0, #1 \n"
 525 "    BLT     loc_FF0579CC \n"
 526 
 527 "loc_FF0579FC:\n"
 528 "    LDR     R0, =0x2600 \n"
 529 "    MOV     R2, #0 \n"
 530 "    LDR     R0, [R0, #8] \n"
 531 "    MOV     R1, SP \n"
 532 "    BL      sub_FF02B184 /*_ReceiveMessageQueue*/ \n"
 533 "    CMP     R0, #0 \n"
 534 "    LDRNE   R1, =0x236 \n"
 535 "    LDRNE   R0, =0xFF057C64 /*'RotaryEncoder.c'*/ \n"
 536 "    BLNE    _DebugAssert \n"
 537 "    LDR     R0, [SP] \n"
 538 "    AND     R4, R0, #0xFF \n"
 539 "    AND     R0, R0, #0xFF00 \n"
 540 "    CMP     R0, #0x100 \n"
 541 "    BEQ     loc_FF057A6C \n"
 542 "    CMP     R0, #0x200 \n"
 543 "    BEQ     loc_FF057AA4 \n"
 544 "    CMP     R0, #0x300 \n"
 545 "    BEQ     loc_FF057CAC \n"
 546 "    CMP     R0, #0x400 \n"
 547 "    BNE     loc_FF0579FC \n"
 548 "    CMP     R4, #0 \n"
 549 "    LDRNE   R1, =0x2C1 \n"
 550 "    LDRNE   R0, =0xFF057C64 /*'RotaryEncoder.c'*/ \n"
 551 "    BLNE    _DebugAssert \n"
 552 "    RSB     R0, R4, R4, LSL#3 \n"
 553 "    LDR     R0, [R6, R0, LSL#2] \n"
 554 
 555 "loc_FF057A64:\n"
 556 "    BL      sub_FF057D30 \n"
 557 "    B       loc_FF0579FC \n"
 558 
 559 "loc_FF057A6C:\n"
 560 //------------------  added code ---------------------
 561 "labelA:\n"
 562 "    LDR     R0, =jogdial_stopped\n"
 563 "    LDR     R0, [R0]\n"
 564 "    CMP     R0, #1\n"
 565 "    BNE     labelB\n"
 566 "    MOV     R0, #40\n"
 567 "    BL      _SleepTask\n"
 568 "    B       labelA\n"
 569 "labelB:\n"
 570 //------------------  original code ------------------
 571 "    LDR     R0, =0x260C \n"
 572 "    LDR     R0, [R0, R4, LSL#2] \n"
 573 "    BL      sub_FF02C130 /*_CancelTimer*/ \n"
 574 "    LDR     R2, =0xFF0578F8 \n"
 575 "    ORR     R3, R4, #0x200 \n"
 576 "    MOV     R1, R2 \n"
 577 "    MOV     R0, #0x28 \n"
 578 "    BL      sub_FF02C04C /*_SetTimerAfter*/ \n"
 579 "    TST     R0, #1 \n"
 580 "    CMPNE   R0, #0x15 \n"
 581 "    STR     R0, [R10, R4, LSL#2] \n"
 582 "    BEQ     loc_FF0579FC \n"
 583 "    MOV     R1, #0x248 \n"
 584 "    B       loc_FF057C50 \n"
 585 
 586 "loc_FF057AA4:\n"
 587 "    RSB     R5, R4, R4, LSL#3 \n"
 588 "    LDR     R0, [R6, R5, LSL#2] \n"
 589 "    LDR     R1, =0xC0240000 \n"
 590 "    ADD     R0, R1, R0, LSL#8 \n"
 591 "    LDR     R0, [R0, #0x104] \n"
 592 "    MOV     R1, R0, ASR#16 \n"
 593 "    ADD     R0, SP, #0x14 \n"
 594 "    ADD     R11, R0, R4, LSL#1 \n"
 595 "    ADD     R0, SP, #0x10 \n"
 596 "    ADD     R0, R0, R4, LSL#1 \n"
 597 "    STRH    R1, [R11] \n"
 598 "    STR     R0, [SP, #0x18] \n"
 599 "    LDRSH   R3, [R0] \n"
 600 "    SUB     R2, R1, R3 \n"
 601 "    CMP     R2, #0 \n"
 602 "    BNE     loc_FF057B28 \n"
 603 "    LDR     R0, [R9, R4, LSL#2] \n"
 604 "    CMP     R0, #0 \n"
 605 "    BEQ     loc_FF057C0C \n"
 606 "    LDR     R7, =0x260C \n"
 607 "    LDR     R0, [R7, R4, LSL#2] \n"
 608 "    BL      sub_FF02C130 /*_CancelTimer*/ \n"
 609 "    LDR     R2, =0xFF057904 \n"
 610 "    ORR     R3, R4, #0x300 \n"
 611 "    MOV     R1, R2 \n"
 612 "    MOV     R0, #0x1F4 \n"
 613 "    BL      sub_FF02C04C /*_SetTimerAfter*/ \n"
 614 "    TST     R0, #1 \n"
 615 "    CMPNE   R0, #0x15 \n"
 616 "    STR     R0, [R7, R4, LSL#2] \n"
 617 "    BEQ     loc_FF057C0C \n"
 618 "    LDR     R1, =0x261 \n"
 619 "    B       loc_FF057C04 \n"
 620 
 621 "loc_FF057B28:\n"
 622 "    MOV     R0, R2 \n"
 623 "    RSBLT   R0, R0, #0 \n"
 624 "    MOVLE   R7, #0 \n"
 625 "    MOVGT   R7, #1 \n"
 626 "    CMP     R0, #0xFF \n"
 627 "    BLS     loc_FF057B64 \n"
 628 "    LDR     R0, =0x7FFF \n"
 629 "    CMP     R2, #0 \n"
 630 "    SUBLE   R0, R0, R3 \n"
 631 "    ADDLE   R0, R0, R1 \n"
 632 "    SUBGT   R0, R0, R1 \n"
 633 "    ADDGT   R0, R0, R3 \n"
 634 "    MVN     R1, #0x8000 \n"
 635 "    SUB     R0, R0, R1 \n"
 636 "    EOR     R7, R7, #1 \n"
 637 
 638 "loc_FF057B64:\n"
 639 "    STR     R0, [SP, #4] \n"
 640 "    LDR     R0, [R9, R4, LSL#2] \n"
 641 "    CMP     R0, #0 \n"
 642 "    ADDEQ   R0, R6, R5, LSL#2 \n"
 643 "    LDREQ   R0, [R0, #8] \n"
 644 "    BEQ     loc_FF057BA0 \n"
 645 "    ADD     R8, R6, R5, LSL#2 \n"
 646 "    ADD     R1, R8, R7, LSL#2 \n"
 647 "    LDR     R1, [R1, #0x10] \n"
 648 "    CMP     R1, R0 \n"
 649 "    BEQ     loc_FF057BA8 \n"
 650 "    LDR     R0, [R8, #0xC] \n"
 651 "    MOV     R1, #0 \n"
 652 "    BL      sub_FF024498 \n"
 653 "    LDR     R0, [R8, #8] \n"
 654 
 655 "loc_FF057BA0:\n"
 656 "    MOV     R1, #0 \n"
 657 "    BL      sub_FF024498 \n"
 658 
 659 "loc_FF057BA8:\n"
 660 "    ADD     R0, R6, R5, LSL#2 \n"
 661 "    ADD     R7, R0, R7, LSL#2 \n"
 662 "    LDR     R0, [R7, #0x10] \n"
 663 "    LDR     R1, [SP, #4] \n"
 664 "    BL      sub_FF024498 \n"
 665 "    LDR     R0, [R7, #0x10] \n"
 666 "    LDR     R7, =0x260C \n"
 667 "    STR     R0, [R9, R4, LSL#2] \n"
 668 "    LDRH    R1, [R11] \n"
 669 "    LDR     R0, [SP, #0x18] \n"
 670 "    STRH    R1, [R0] \n"
 671 "    LDR     R0, [R7, R4, LSL#2] \n"
 672 "    BL      sub_FF02C130 /*_CancelTimer*/ \n"
 673 "    LDR     R2, =0xFF057904 \n"
 674 "    ORR     R3, R4, #0x300 \n"
 675 "    MOV     R1, R2 \n"
 676 "    MOV     R0, #0x1F4 \n"
 677 "    BL      sub_FF02C04C /*_SetTimerAfter*/ \n"
 678 "    TST     R0, #1 \n"
 679 "    CMPNE   R0, #0x15 \n"
 680 "    STR     R0, [R7, R4, LSL#2] \n"
 681 "    BEQ     loc_FF057C0C \n"
 682 "    LDR     R1, =0x2A3 \n"
 683 
 684 "loc_FF057C04:\n"
 685 "    LDR     R0, =0xFF057C64 /*'RotaryEncoder.c'*/ \n"
 686 "    BL      _DebugAssert \n"
 687 
 688 "loc_FF057C0C:\n"
 689 "    ADD     R0, R6, R5, LSL#2 \n"
 690 "    LDR     R0, [R0, #0x18] \n"
 691 "    CMP     R0, #1 \n"
 692 "    BNE     loc_FF057CA4 \n"
 693 "    LDR     R0, =0x2600 \n"
 694 "    LDR     R0, [R0, #0x10] \n"
 695 "    CMP     R0, #0 \n"
 696 "    BEQ     loc_FF057CA4 \n"
 697 "    LDR     R2, =0xFF0578F8 \n"
 698 "    ORR     R3, R4, #0x400 \n"
 699 "    MOV     R1, R2 \n"
 700 "    BL      sub_FF02C04C /*_SetTimerAfter*/ \n"
 701 "    TST     R0, #1 \n"
 702 "    CMPNE   R0, #0x15 \n"
 703 "    STR     R0, [R10, R4, LSL#2] \n"
 704 "    BEQ     loc_FF0579FC \n"
 705 "    LDR     R1, =0x2AA \n"
 706 
 707 "loc_FF057C50:\n"
 708 "    LDR     R0, =0xFF057C64 /*'RotaryEncoder.c'*/ \n"
 709 "    BL      _DebugAssert \n"
 710 "    B       loc_FF0579FC \n"
 711 
 712 "loc_FF057CA4:\n"
 713 "    LDR     R0, [R6, R5, LSL#2] \n"
 714 "    B       loc_FF057A64 \n"
 715 
 716 "loc_FF057CAC:\n"
 717 "    LDR     R0, [R9, R4, LSL#2] \n"
 718 "    CMP     R0, #0 \n"
 719 "    MOVEQ   R1, #0x2B4 \n"
 720 "    LDREQ   R0, =0xFF057C64 /*'RotaryEncoder.c'*/ \n"
 721 "    BLEQ    _DebugAssert \n"
 722 "    RSB     R0, R4, R4, LSL#3 \n"
 723 "    ADD     R0, R6, R0, LSL#2 \n"
 724 "    LDR     R0, [R0, #0xC] \n"
 725 "    MOV     R1, #0 \n"
 726 "    BL      sub_FF024498 \n"
 727 "    MOV     R0, #0 \n"
 728 "    STR     R0, [R9, R4, LSL#2] \n"
 729 "    B       loc_FF0579FC \n"
 730 );
 731 }

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