root/platform/sx220hs/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. task_Startup_my
  9. taskcreatePhySw_my
  10. init_file_modules_task
  11. 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, =0xFF4A9BBC \n"
 134 "    LDR     R1, =0x1900 \n"
 135 "    LDR     R3, =0x11B20 \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, =0x186AE4 \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 loc_FF055B3C for correct power-on.
 162     // (short press = playback mode, long press = record mode)
 163     *(int*)(0x25A0) = (*(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_FF3AB8C0 \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, =0x186AE4 \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 = 0xFF00FC78.
 294 );
 295 }
 296 
 297 /*************************************************************/
 298 //** taskcreate_Startup_my @ 0xFF00FC78 - 0xFF00FD50, length=55
 299 void __attribute__((naked,noinline)) taskcreate_Startup_my() {
 300 asm volatile (
 301 "    STMFD   SP!, {R3-R9,LR} \n"
 302 "    MOV     R5, #0 \n"
 303 //"  BL      _sub_FF055B34 \n"  // --> Nullsub call removed.
 304 "    BL      sub_FF02D148 \n"
 305 "    LDR     R7, =0xC0220000 \n"
 306 "    MOVS    R9, R0 \n"
 307 "    MOV     R8, #1 \n"
 308 "    BNE     loc_FF00FCF4 \n"
 309 "    BL      sub_FF025F8C /*_IsNormalCameraMode_FW*/ \n"
 310 "    CMP     R0, #0 \n"
 311 "    BEQ     loc_FF00FCF4 \n"
 312 "    LDR     R0, [R7, #0xD4] \n"
 313 "    BICS    R4, R8, R0 \n"
 314 "    BEQ     loc_FF00FCC0 \n"
 315 "    MOV     R0, #0x12C \n"
 316 "    BL      _SleepTask \n"
 317 "    LDR     R0, [R7, #0xD4] \n"
 318 "    BIC     R4, R8, R0 \n"
 319 
 320 "loc_FF00FCC0:\n"
 321 "    LDR     R0, [R7, #0x12C] \n"
 322 "    BIC     R6, R8, R0 \n"
 323 "    BL      sub_FF023888 \n"
 324 "    CMP     R0, #1 \n"
 325 "    MOVEQ   R5, #1 \n"
 326 "    ORR     R0, R6, R4 \n"
 327 "    ORRS    R0, R0, R5 \n"
 328 "    BNE     loc_FF00FD04 \n"
 329 "    BL      sub_FF023CB8 \n"
 330 "    MOV     R0, #0x44 \n"
 331 "    STR     R0, [R7, #0x1C] \n"
 332 "    BL      sub_FF023EAC \n"
 333 
 334 "loc_FF00FCF0:\n"
 335 "    B       loc_FF00FCF0 \n"
 336 
 337 "loc_FF00FCF4:\n"
 338 "    LDR     R0, [R7, #0x12C] \n"
 339 "    BIC     R6, R8, R0 \n"
 340 "    LDR     R0, [R7, #0xD4] \n"
 341 "    BIC     R4, R8, R0 \n"
 342 
 343 "loc_FF00FD04:\n"
 344 "    MOV     R3, R5 \n"
 345 "    MOV     R2, R9 \n"
 346 "    MOV     R1, R4 \n"
 347 "    MOV     R0, R6 \n"
 348 //"  BL      _sub_FF055B3C \n"  // See begin of sub_FF000358_my
 349 //"  BL      _sub_FF055B38 \n"  // --> Nullsub call removed.
 350 "    BL      sub_FF02B318 \n"
 351 "    LDR     R1, =0x3CE000 \n"
 352 "    MOV     R0, #0 \n"
 353 "    BL      sub_FF02B788 \n"
 354 "    BL      sub_FF02B530 \n"
 355 "    MOV     R3, #0 \n"
 356 "    STR     R3, [SP] \n"
 357 "    LDR     R3, =task_Startup_my \n"  // --> Patched. Old value = 0xFF00FBF4.
 358 "    MOV     R2, #0 \n"
 359 "    MOV     R1, #0x19 \n"
 360 "    LDR     R0, =0xFF00FD64 /*'Startup'*/ \n"
 361 "    BL      _CreateTask \n"
 362 "    MOV     R0, #0 \n"
 363 "    LDMFD   SP!, {R3-R9,PC} \n"
 364 );
 365 }
 366 
 367 /*************************************************************/
 368 //** task_Startup_my @ 0xFF00FBF4 - 0xFF00FC4C, length=23
 369 void __attribute__((naked,noinline)) task_Startup_my() {
 370 asm volatile (
 371 "    STMFD   SP!, {R4,LR} \n"
 372 "    BL      sub_FF006588 \n"
 373 "    BL      sub_FF0257FC \n"
 374 "    BL      sub_FF0238C4 \n"
 375 //"  BL      _sub_FF0565D8 \n"  // --> Nullsub call removed.
 376 "    BL      sub_FF02D37C \n"
 377 //"  BL      _sub_FF02D224 \n"  // start diskboot.bin
 378 "    BL      sub_FF091ACC \n"
 379 "    LDR     R1, =0x30101 \n"
 380 "    MOV     R0, #2 \n"
 381 "    BL      sub_FF02A844 \n"
 382 "    LDR     R1, =0xC0220000 \n"
 383 "    MOV     R0, #8 \n"
 384 "    STR     R0, [R1, #0x9C] \n"
 385 "    MOV     R0, #2 \n"
 386 "    BL      sub_FF02A574 \n"
 387 "    BL      sub_FF022240 \n"
 388 "    BL      sub_FF02D3AC \n"
 389 "    BL      sub_FF02AABC \n"
 390 "    BL      sub_FF02D52C \n"
 391 
 392 "    BL      CreateTask_spytask\n"  // added
 393 
 394 "    BL      taskcreatePhySw_my \n"  // --> Patched. Old value = 0xFF024524.
 395 
 396 #if defined(OPT_RUN_WITH_BATT_COVER_OPEN)
 397 "    LDR     R0, =0x100000\n"       // Pause for startup with battery door open
 398 "batt_delay:\n"
 399 "    NOP\n"
 400 "    SUBS    R0, R0, #1\n"
 401 "    BNE     batt_delay\n"
 402 #endif
 403 
 404 "    LDR     PC, =0xFF00FC48 \n"  // Continue in firmware
 405 );
 406 }
 407 
 408 /*************************************************************/
 409 //** taskcreatePhySw_my @ 0xFF024524 - 0xFF024544, length=9
 410 void __attribute__((naked,noinline)) taskcreatePhySw_my() {
 411 asm volatile (
 412 "    STMFD   SP!, {R3-R5,LR} \n"
 413 "    LDR     R4, =0x1C40 \n"
 414 "    LDR     R0, [R4, #4] \n"
 415 "    CMP     R0, #0 \n"
 416 "    BNE     sub_FF024558 \n"
 417 "    MOV     R3, #0 \n"
 418 "    STR     R3, [SP] \n"
 419 "    LDR     R3, =mykbd_task \n"  // --> Patched. Old value = 0xFF0244F0.
 420 "    MOV     R2, #0x2000 \n"  // --> Patched. Old value = 0x800. stack size for new task_PhySw
 421 "    LDR     PC, =0xFF024548 \n"  // Continue in firmware
 422 );
 423 }
 424 
 425 /*************************************************************/
 426 //** init_file_modules_task @ 0xFF095240 - 0xFF09525C, length=8
 427 void __attribute__((naked,noinline)) init_file_modules_task() {
 428 asm volatile (
 429 "    STMFD   SP!, {R4-R6,LR} \n"
 430 "    BL      sub_FF08B180 \n"
 431 "    LDR     R5, =0x5006 \n"
 432 "    MOVS    R4, R0 \n"
 433 "    MOVNE   R1, #0 \n"
 434 "    MOVNE   R0, R5 \n"
 435 "    BLNE    _PostLogicalEventToUI \n"
 436 "    BL      sub_FF08B1AC \n"
 437 "    BL      core_spytask_can_start\n"  // CHDK: Set "it's-safe-to-start" flag for spytask
 438 "    LDR     PC, =0xFF095260 \n"  // Continue in firmware
 439 );
 440 }
 441 
 442 /*************************************************************/
 443 //** JogDial_task_my @ 0xFF05671C - 0xFF056A4C, length=205
 444 void __attribute__((naked,noinline)) JogDial_task_my() {
 445 asm volatile (
 446 "    STMFD   SP!, {R4-R11,LR} \n"
 447 "    SUB     SP, SP, #0x1C \n"
 448 "    BL      sub_FF056ABC \n"
 449 "    LDR     R12, =0x25BC \n"
 450 "    LDR     R6, =0xFF3B19D4 \n"
 451 "    MOV     R0, #0 \n"
 452 "    ADD     R10, SP, #8 \n"
 453 "    ADD     R9, SP, #0xC \n"
 454 
 455 // Save pointer for kbd.c routine
 456 "    LDR     R2, =jog_position \n"
 457 "    STR     R9, [R2] \n"
 458 
 459 "loc_FF05673C:\n"
 460 "    ADD     R2, SP, #0x14 \n"
 461 "    MOV     R1, #0 \n"
 462 "    ADD     R4, R2, R0, LSL#1 \n"
 463 "    ADD     R3, SP, #0x10 \n"
 464 "    STRH    R1, [R4] \n"
 465 "    ADD     R4, R3, R0, LSL#1 \n"
 466 "    STRH    R1, [R4] \n"
 467 "    STR     R1, [R9, R0, LSL#2] \n"
 468 "    STR     R1, [R10, R0, LSL#2] \n"
 469 "    ADD     R0, R0, #1 \n"
 470 "    CMP     R0, #1 \n"
 471 "    BLT     loc_FF05673C \n"
 472 
 473 "loc_FF05676C:\n"
 474 "    LDR     R0, =0x25BC \n"
 475 "    MOV     R2, #0 \n"
 476 "    LDR     R0, [R0, #8] \n"
 477 "    MOV     R1, SP \n"
 478 "    BL      sub_FF02AD50 /*_ReceiveMessageQueue*/ \n"
 479 "    CMP     R0, #0 \n"
 480 "    LDRNE   R1, =0x236 \n"
 481 "    LDRNE   R0, =0xFF0569D4 /*'RotaryEncoder.c'*/ \n"
 482 "    BLNE    _DebugAssert \n"
 483 "    LDR     R0, [SP] \n"
 484 "    AND     R4, R0, #0xFF \n"
 485 "    AND     R0, R0, #0xFF00 \n"
 486 "    CMP     R0, #0x100 \n"
 487 "    BEQ     loc_FF0567DC \n"
 488 "    CMP     R0, #0x200 \n"
 489 "    BEQ     loc_FF056814 \n"
 490 "    CMP     R0, #0x300 \n"
 491 "    BEQ     loc_FF056A1C \n"
 492 "    CMP     R0, #0x400 \n"
 493 "    BNE     loc_FF05676C \n"
 494 "    CMP     R4, #0 \n"
 495 "    LDRNE   R1, =0x2C1 \n"
 496 "    LDRNE   R0, =0xFF0569D4 /*'RotaryEncoder.c'*/ \n"
 497 "    BLNE    _DebugAssert \n"
 498 "    RSB     R0, R4, R4, LSL#3 \n"
 499 "    LDR     R0, [R6, R0, LSL#2] \n"
 500 
 501 "loc_FF0567D4:\n"
 502 "    BL      sub_FF056AA0 \n"
 503 "    B       loc_FF05676C \n"
 504 
 505 "loc_FF0567DC:\n"
 506 //------------------  added code ---------------------
 507 "labelA:\n"
 508 "    LDR     R0, =jogdial_stopped\n"
 509 "    LDR     R0, [R0]\n"
 510 "    CMP     R0, #1\n"
 511 "    BNE     labelB\n"
 512 "    MOV     R0, #40\n"
 513 "    BL      _SleepTask\n"
 514 "    B       labelA\n"
 515 "labelB:\n"
 516 //------------------  original code ------------------
 517 "    LDR     R0, =0x25C8 \n"
 518 "    LDR     R0, [R0, R4, LSL#2] \n"
 519 "    BL      sub_FF02BCFC /*_CancelTimer*/ \n"
 520 "    LDR     R2, =0xFF056668 \n"
 521 "    ORR     R3, R4, #0x200 \n"
 522 "    MOV     R1, R2 \n"
 523 "    MOV     R0, #0x28 \n"
 524 "    BL      sub_FF02BC18 /*_SetTimerAfter*/ \n"
 525 "    TST     R0, #1 \n"
 526 "    CMPNE   R0, #0x15 \n"
 527 "    STR     R0, [R10, R4, LSL#2] \n"
 528 "    BEQ     loc_FF05676C \n"
 529 "    MOV     R1, #0x248 \n"
 530 "    B       loc_FF0569C0 \n"
 531 
 532 "loc_FF056814:\n"
 533 "    RSB     R5, R4, R4, LSL#3 \n"
 534 "    LDR     R0, [R6, R5, LSL#2] \n"
 535 "    LDR     R1, =0xC0240000 \n"
 536 "    ADD     R0, R1, R0, LSL#8 \n"
 537 "    LDR     R0, [R0, #0x104] \n"
 538 "    MOV     R1, R0, ASR#16 \n"
 539 "    ADD     R0, SP, #0x14 \n"
 540 "    ADD     R11, R0, R4, LSL#1 \n"
 541 "    ADD     R0, SP, #0x10 \n"
 542 "    ADD     R0, R0, R4, LSL#1 \n"
 543 "    STRH    R1, [R11] \n"
 544 "    STR     R0, [SP, #0x18] \n"
 545 "    LDRSH   R3, [R0] \n"
 546 "    SUB     R2, R1, R3 \n"
 547 "    CMP     R2, #0 \n"
 548 "    BNE     loc_FF056898 \n"
 549 "    LDR     R0, [R9, R4, LSL#2] \n"
 550 "    CMP     R0, #0 \n"
 551 "    BEQ     loc_FF05697C \n"
 552 "    LDR     R7, =0x25C8 \n"
 553 "    LDR     R0, [R7, R4, LSL#2] \n"
 554 "    BL      sub_FF02BCFC /*_CancelTimer*/ \n"
 555 "    LDR     R2, =0xFF056674 \n"
 556 "    ORR     R3, R4, #0x300 \n"
 557 "    MOV     R1, R2 \n"
 558 "    MOV     R0, #0x1F4 \n"
 559 "    BL      sub_FF02BC18 /*_SetTimerAfter*/ \n"
 560 "    TST     R0, #1 \n"
 561 "    CMPNE   R0, #0x15 \n"
 562 "    STR     R0, [R7, R4, LSL#2] \n"
 563 "    BEQ     loc_FF05697C \n"
 564 "    LDR     R1, =0x261 \n"
 565 "    B       loc_FF056974 \n"
 566 
 567 "loc_FF056898:\n"
 568 "    MOV     R0, R2 \n"
 569 "    RSBLT   R0, R0, #0 \n"
 570 "    MOVLE   R7, #0 \n"
 571 "    MOVGT   R7, #1 \n"
 572 "    CMP     R0, #0xFF \n"
 573 "    BLS     loc_FF0568D4 \n"
 574 "    LDR     R0, =0x7FFF \n"
 575 "    CMP     R2, #0 \n"
 576 "    SUBLE   R0, R0, R3 \n"
 577 "    ADDLE   R0, R0, R1 \n"
 578 "    SUBGT   R0, R0, R1 \n"
 579 "    ADDGT   R0, R0, R3 \n"
 580 "    MVN     R1, #0x8000 \n"
 581 "    SUB     R0, R0, R1 \n"
 582 "    EOR     R7, R7, #1 \n"
 583 
 584 "loc_FF0568D4:\n"
 585 "    STR     R0, [SP, #4] \n"
 586 "    LDR     R0, [R9, R4, LSL#2] \n"
 587 "    CMP     R0, #0 \n"
 588 "    ADDEQ   R0, R6, R5, LSL#2 \n"
 589 "    LDREQ   R0, [R0, #8] \n"
 590 "    BEQ     loc_FF056910 \n"
 591 "    ADD     R8, R6, R5, LSL#2 \n"
 592 "    ADD     R1, R8, R7, LSL#2 \n"
 593 "    LDR     R1, [R1, #0x10] \n"
 594 "    CMP     R1, R0 \n"
 595 "    BEQ     loc_FF056918 \n"
 596 "    LDR     R0, [R8, #0xC] \n"
 597 "    MOV     R1, #0 \n"
 598 "    BL      sub_FF0240E0 \n"
 599 "    LDR     R0, [R8, #8] \n"
 600 
 601 "loc_FF056910:\n"
 602 "    MOV     R1, #0 \n"
 603 "    BL      sub_FF0240E0 \n"
 604 
 605 "loc_FF056918:\n"
 606 "    ADD     R0, R6, R5, LSL#2 \n"
 607 "    ADD     R7, R0, R7, LSL#2 \n"
 608 "    LDR     R0, [R7, #0x10] \n"
 609 "    LDR     R1, [SP, #4] \n"
 610 "    BL      sub_FF0240E0 \n"
 611 "    LDR     R0, [R7, #0x10] \n"
 612 "    LDR     R7, =0x25C8 \n"
 613 "    STR     R0, [R9, R4, LSL#2] \n"
 614 "    LDRH    R1, [R11] \n"
 615 "    LDR     R0, [SP, #0x18] \n"
 616 "    STRH    R1, [R0] \n"
 617 "    LDR     R0, [R7, R4, LSL#2] \n"
 618 "    BL      sub_FF02BCFC /*_CancelTimer*/ \n"
 619 "    LDR     R2, =0xFF056674 \n"
 620 "    ORR     R3, R4, #0x300 \n"
 621 "    MOV     R1, R2 \n"
 622 "    MOV     R0, #0x1F4 \n"
 623 "    BL      sub_FF02BC18 /*_SetTimerAfter*/ \n"
 624 "    TST     R0, #1 \n"
 625 "    CMPNE   R0, #0x15 \n"
 626 "    STR     R0, [R7, R4, LSL#2] \n"
 627 "    BEQ     loc_FF05697C \n"
 628 "    LDR     R1, =0x2A3 \n"
 629 
 630 "loc_FF056974:\n"
 631 "    LDR     R0, =0xFF0569D4 /*'RotaryEncoder.c'*/ \n"
 632 "    BL      _DebugAssert \n"
 633 
 634 "loc_FF05697C:\n"
 635 "    ADD     R0, R6, R5, LSL#2 \n"
 636 "    LDR     R0, [R0, #0x18] \n"
 637 "    CMP     R0, #1 \n"
 638 "    BNE     loc_FF056A14 \n"
 639 "    LDR     R0, =0x25BC \n"
 640 "    LDR     R0, [R0, #0x10] \n"
 641 "    CMP     R0, #0 \n"
 642 "    BEQ     loc_FF056A14 \n"
 643 "    LDR     R2, =0xFF056668 \n"
 644 "    ORR     R3, R4, #0x400 \n"
 645 "    MOV     R1, R2 \n"
 646 "    BL      sub_FF02BC18 /*_SetTimerAfter*/ \n"
 647 "    TST     R0, #1 \n"
 648 "    CMPNE   R0, #0x15 \n"
 649 "    STR     R0, [R10, R4, LSL#2] \n"
 650 "    BEQ     loc_FF05676C \n"
 651 "    LDR     R1, =0x2AA \n"
 652 
 653 "loc_FF0569C0:\n"
 654 "    LDR     R0, =0xFF0569D4 /*'RotaryEncoder.c'*/ \n"
 655 "    BL      _DebugAssert \n"
 656 "    B       loc_FF05676C \n"
 657 
 658 "loc_FF056A14:\n"
 659 "    LDR     R0, [R6, R5, LSL#2] \n"
 660 "    B       loc_FF0567D4 \n"
 661 
 662 "loc_FF056A1C:\n"
 663 "    LDR     R0, [R9, R4, LSL#2] \n"
 664 "    CMP     R0, #0 \n"
 665 "    MOVEQ   R1, #0x2B4 \n"
 666 "    LDREQ   R0, =0xFF0569D4 /*'RotaryEncoder.c'*/ \n"
 667 "    BLEQ    _DebugAssert \n"
 668 "    RSB     R0, R4, R4, LSL#3 \n"
 669 "    ADD     R0, R6, R0, LSL#2 \n"
 670 "    LDR     R0, [R0, #0xC] \n"
 671 "    MOV     R1, #0 \n"
 672 "    BL      sub_FF0240E0 \n"
 673 "    MOV     R0, #0 \n"
 674 "    STR     R0, [R9, R4, LSL#2] \n"
 675 "    B       loc_FF05676C \n"
 676 );
 677 }

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