root/platform/g1x/sub/100f/boot.c

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

DEFINITIONS

This source file includes following definitions.
  1. taskHook
  2. CreateTask_spytask
  3. boot
  4. sub_FF000364_my
  5. sub_FF0011BC_my
  6. sub_FF005F38_my
  7. taskcreate_Startup_my
  8. sub_FF00FDA4_my
  9. task_Startup_my
  10. taskcreatePhySw_my
  11. init_file_modules_task
  12. 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_DvlpSeqTask();
  19 extern void task_InitFileModules();
  20 extern void task_RotaryEncoder();
  21 extern void task_MovieRecord();
  22 extern void task_ExpDrv();
  23 extern void task_FileWrite();
  24 
  25 void __attribute__((naked,noinline)) taskHook(context_t **context)
  26 { 
  27     asm volatile("STMFD   SP!, {R0-R12,LR}\n");     // G1X crashes without this
  28     
  29         task_t *tcb=(task_t*)((char*)context-offsetof(task_t, context));
  30 
  31         // Replace firmware task addresses with ours
  32         if(tcb->entry == (void*)task_CaptSeq)                   tcb->entry = (void*)capt_seq_task; 
  33     if(tcb->entry == (void*)task_DvlpSeqTask)       tcb->entry = (void*)dvlp_seq_task;
  34         if(tcb->entry == (void*)task_InitFileModules)   tcb->entry = (void*)init_file_modules_task;
  35         if(tcb->entry == (void*)task_RotaryEncoder)             tcb->entry = (void*)JogDial_task_my;
  36         if(tcb->entry == (void*)task_MovieRecord)               tcb->entry = (void*)movie_record_task;
  37         if(tcb->entry == (void*)task_ExpDrv)                    tcb->entry = (void*)exp_drv_task;
  38     if(tcb->entry == (void*)task_FileWrite)         tcb->entry = (void*)filewritetask;
  39 
  40     asm volatile("LDMFD   SP!, {R0-R12,PC}\n");     // G1X crashes without this
  41 }
  42 
  43 /*----------------------------------------------------------------------
  44         CreateTask --> core_spytask
  45 -----------------------------------------------------------------------*/
  46 void CreateTask_spytask()
  47 {
  48         _CreateTask("SpyTask", 0x19, 0x2000, core_spytask, 0);
  49 }
  50 
  51 ///*----------------------------------------------------------------------
  52 // Pointer to stack location where jogdial task records previous and current
  53 // jogdial positions
  54 short *jog_position;
  55 
  56 /*----------------------------------------------------------------------
  57         boot()
  58 
  59         Main entry point for the CHDK code
  60 -----------------------------------------------------------------------*/
  61 
  62 /*************************************************************/
  63 //** boot @ 0xFF00000C - 0xFF000168, length=88
  64 void __attribute__((naked,noinline)) boot() {
  65 asm volatile (
  66 "    LDR     R1, =0xC0410000 \n"
  67 "    MOV     R0, #0 \n"
  68 "    STR     R0, [R1] \n"
  69 "    MOV     R1, #0x78 \n"
  70 "    MCR     p15, 0, R1, c1, c0 \n"
  71 "    MOV     R1, #0 \n"
  72 "    MCR     p15, 0, R1, c7, c10, 4 \n"
  73 "    MCR     p15, 0, R1, c7, c5 \n"
  74 "    MCR     p15, 0, R1, c7, c6 \n"
  75 "    MOV     R0, #0x3D \n"
  76 "    MCR     p15, 0, R0, c6, c0 \n"
  77 "    MOV     R0, #0xC000002F \n"
  78 "    MCR     p15, 0, R0, c6, c1 \n"
  79 "    MOV     R0, #0x37 \n"
  80 "    MCR     p15, 0, R0, c6, c2 \n"
  81 "    MOV     R0, #0x40000037 \n"
  82 "    MCR     p15, 0, R0, c6, c3 \n"
  83 "    MOV     R0, #0x80000017 \n"
  84 "    MCR     p15, 0, R0, c6, c4 \n"
  85 "    LDR     R0, =0xFF00002F \n"
  86 "    MCR     p15, 0, R0, c6, c5 \n"
  87 "    LDR     R0, =0xD000002B \n"
  88 "    MCR     p15, 0, R0, c6, c7 \n"
  89 "    MOV     R0, #0x34 \n"
  90 "    MCR     p15, 0, R0, c2, c0 \n"
  91 "    MOV     R0, #0x34 \n"
  92 "    MCR     p15, 0, R0, c2, c0, 1 \n"
  93 "    MOV     R0, #0x34 \n"
  94 "    MCR     p15, 0, R0, c3, c0 \n"
  95 "    LDR     R0, =0x33333330 \n"
  96 "    MCR     p15, 0, R0, c5, c0, 2 \n"
  97 "    LDR     R0, =0x33333330 \n"
  98 "    MCR     p15, 0, R0, c5, c0, 3 \n"
  99 "    MRC     p15, 0, R0, c1, c0 \n"
 100 "    ORR     R0, R0, #0x1000 \n"
 101 "    ORR     R0, R0, #4 \n"
 102 "    ORR     R0, R0, #1 \n"
 103 "    MCR     p15, 0, R0, c1, c0 \n"
 104 "    MOV     R1, #0x80000006 \n"
 105 "    MCR     p15, 0, R1, c9, c1 \n"
 106 "    MOV     R1, #6 \n"
 107 "    MCR     p15, 0, R1, c9, c1, 1 \n"
 108 "    MRC     p15, 0, R1, c1, c0 \n"
 109 "    ORR     R1, R1, #0x50000 \n"
 110 "    MCR     p15, 0, R1, c1, c0 \n"
 111 "    LDR     R2, =0xC0200000 \n"
 112 "    MOV     R1, #1 \n"
 113 "    STR     R1, [R2, #0x10C] \n"
 114 "    MOV     R1, #0xFF \n"
 115 "    STR     R1, [R2, #0xC] \n"
 116 "    STR     R1, [R2, #0x1C] \n"
 117 "    STR     R1, [R2, #0x2C] \n"
 118 "    STR     R1, [R2, #0x3C] \n"
 119 "    STR     R1, [R2, #0x4C] \n"
 120 "    STR     R1, [R2, #0x5C] \n"
 121 "    STR     R1, [R2, #0x6C] \n"
 122 "    STR     R1, [R2, #0x7C] \n"
 123 "    STR     R1, [R2, #0x8C] \n"
 124 "    STR     R1, [R2, #0x9C] \n"
 125 "    STR     R1, [R2, #0xAC] \n"
 126 "    STR     R1, [R2, #0xBC] \n"
 127 "    STR     R1, [R2, #0xCC] \n"
 128 "    STR     R1, [R2, #0xDC] \n"
 129 "    STR     R1, [R2, #0xEC] \n"
 130 "    STR     R1, [R2, #0xFC] \n"
 131 "    LDR     R1, =0xC0400008 \n"
 132 "    LDR     R2, =0x430005 \n"
 133 "    STR     R2, [R1] \n"
 134 "    MOV     R1, #1 \n"
 135 "    LDR     R2, =0xC0243100 \n"
 136 "    STR     R2, [R1] \n"
 137 "    LDR     R2, =0xC0242010 \n"
 138 "    LDR     R1, [R2] \n"
 139 "    ORR     R1, R1, #1 \n"
 140 "    STR     R1, [R2] \n"
 141 "    LDR     R0, =0xFF6632C0 \n"
 142 "    LDR     R1, =0x1900 \n"
 143 "    LDR     R3, =0x14E64 \n"
 144 
 145 "loc_FF000144:\n"
 146 "    CMP     R1, R3 \n"
 147 "    LDRCC   R2, [R0], #4 \n"
 148 "    STRCC   R2, [R1], #4 \n"
 149 "    BCC     loc_FF000144 \n"
 150 "    LDR     R1, =0x18C774 \n"
 151 "    MOV     R2, #0 \n"
 152 
 153 "loc_FF00015C:\n"
 154 "    CMP     R3, R1 \n"
 155 "    STRCC   R2, [R3], #4 \n"
 156 "    BCC     loc_FF00015C \n"
 157 "    B       sub_FF000364_my \n"  // --> Patched. Old value = 0xFF000364.
 158 );
 159 }
 160 
 161 /*************************************************************/
 162 //** sub_FF000364_my @ 0xFF000364 - 0xFF0003CC, length=27
 163 void __attribute__((naked,noinline)) sub_FF000364_my() {
 164 
 165         //http://chdk.setepontos.com/index.php/topic,4194.0.html
 166         *(int*)0x1938=(int)taskHook;
 167         *(int*)0x193C=(int)taskHook;    // need this for startup in Playback mode (otherwise init_file_modules_task doesn't hook properly)
 168     
 169         // replacement of sub_FF056804 for correct power-on.
 170         *(int*)(0x26C8) = (*(int*)0xC022F48C)&0x800000 ? 0x200000 : 0x100000; 
 171     
 172 asm volatile (
 173 "    LDR     R0, =0xFF0003DC \n"
 174 "    MOV     R1, #0 \n"
 175 "    LDR     R3, =0xFF000414 \n"
 176 
 177 "loc_FF000370:\n"
 178 "    CMP     R0, R3 \n"
 179 "    LDRCC   R2, [R0], #4 \n"
 180 "    STRCC   R2, [R1], #4 \n"
 181 "    BCC     loc_FF000370 \n"
 182 "    LDR     R0, =0xFF000414 \n"
 183 "    MOV     R1, #0x4B0 \n"
 184 "    LDR     R3, =0xFF000628 \n"
 185 
 186 "loc_FF00038C:\n"
 187 "    CMP     R0, R3 \n"
 188 "    LDRCC   R2, [R0], #4 \n"
 189 "    STRCC   R2, [R1], #4 \n"
 190 "    BCC     loc_FF00038C \n"
 191 "    MOV     R0, #0xD2 \n"
 192 "    MSR     CPSR_cxsf, R0 \n"
 193 "    MOV     SP, #0x1000 \n"
 194 "    MOV     R0, #0xD3 \n"
 195 "    MSR     CPSR_cxsf, R0 \n"
 196 "    MOV     SP, #0x1000 \n"
 197 "    LDR     R0, =0x6C4 \n"
 198 "    LDR     R2, =0xEEEEEEEE \n"
 199 "    MOV     R3, #0x1000 \n"
 200 
 201 "loc_FF0003C0:\n"
 202 "    CMP     R0, R3 \n"
 203 "    STRCC   R2, [R0], #4 \n"
 204 "    BCC     loc_FF0003C0 \n"
 205 "    BL      sub_FF0011BC_my \n"  // --> Patched. Old value = 0xFF0011BC.
 206 );
 207 }
 208 
 209 /*************************************************************/
 210 //** sub_FF0011BC_my @ 0xFF0011BC - 0xFF001254, length=39
 211 void __attribute__((naked,noinline)) sub_FF0011BC_my() {
 212 asm volatile (
 213 "    STR     LR, [SP, #-4]! \n"
 214 "    SUB     SP, SP, #0x74 \n"
 215 "    MOV     R1, #0x74 \n"
 216 "    MOV     R0, SP \n"
 217 "    BL      sub_FF45F2EC \n"
 218 "    MOV     R0, #0x67000 \n"
 219 "    STR     R0, [SP, #4] \n"
 220 
 221 #if defined(CHDK_NOT_IN_CANON_HEAP) // use original heap offset if CHDK is loaded in high memory
 222 "    LDR     R0, =0x18C774 \n"
 223 #else
 224 "    LDR     R0, =new_sa\n"   // otherwise use patched value
 225 "    LDR     R0, [R0]\n"      // 
 226 #endif
 227 
 228 "    LDR     R2, =0x55D788 \n"
 229 "    STR     R0, [SP, #8] \n"
 230 "    SUB     R0, R2, R0 \n"
 231 "    STR     R0, [SP, #0xC] \n"
 232 "    MOV     R0, #0x22 \n"
 233 "    STR     R0, [SP, #0x18] \n"
 234 "    MOV     R0, #0x72 \n"
 235 "    STR     R0, [SP, #0x1C] \n"
 236 "    LDR     R1, =0x565C00 \n"
 237 "    LDR     R0, =0x1CD \n"
 238 "    STR     R1, [SP] \n"
 239 "    STR     R0, [SP, #0x20] \n"
 240 "    MOV     R0, #0x96 \n"
 241 "    STR     R2, [SP, #0x10] \n"
 242 "    STR     R1, [SP, #0x14] \n"
 243 "    STR     R0, [SP, #0x24] \n"
 244 "    STR     R0, [SP, #0x28] \n"
 245 "    MOV     R0, #0x64 \n"
 246 "    STR     R0, [SP, #0x2C] \n"
 247 "    MOV     R0, #0 \n"
 248 "    STR     R0, [SP, #0x30] \n"
 249 "    STR     R0, [SP, #0x34] \n"
 250 "    MOV     R0, #0x10 \n"
 251 "    STR     R0, [SP, #0x5C] \n"
 252 "    MOV     R0, #0x800 \n"
 253 "    STR     R0, [SP, #0x60] \n"
 254 "    MOV     R0, #0xA0 \n"
 255 "    STR     R0, [SP, #0x64] \n"
 256 "    MOV     R0, #0x280 \n"
 257 "    STR     R0, [SP, #0x68] \n"
 258 "    LDR     R1, =sub_FF005F38_my \n"  // --> Patched. Old value = 0xFF005F38.
 259 "    LDR     PC, =0xFF001258 \n"  // Continue in firmware
 260 );
 261 }
 262 
 263 /*************************************************************/
 264 //** sub_FF005F38_my @ 0xFF005F38 - 0xFF005FAC, length=30
 265 void __attribute__((naked,noinline)) sub_FF005F38_my() {
 266 asm volatile (
 267 "    STMFD   SP!, {R4,LR} \n"
 268 "    BL      sub_FF000B34 \n"
 269 "    BL      sub_FF00A390 \n"
 270 "    CMP     R0, #0 \n"
 271 "    LDRLT   R0, =0xFF00604C /*'dmSetup'*/ \n"
 272 "    BLLT    _err_init_task \n"
 273 "    BL      sub_FF005B70 \n"
 274 "    CMP     R0, #0 \n"
 275 "    LDRLT   R0, =0xFF006054 /*'termDriverInit'*/ \n"
 276 "    BLLT    _err_init_task \n"
 277 "    LDR     R0, =0xFF006064 /*'/_term'*/ \n"
 278 "    BL      sub_FF005C58 \n"
 279 "    CMP     R0, #0 \n"
 280 "    LDRLT   R0, =0xFF00606C /*'termDeviceCreate'*/ \n"
 281 "    BLLT    _err_init_task \n"
 282 "    LDR     R0, =0xFF006064 /*'/_term'*/ \n"
 283 "    BL      sub_FF003CB4 \n"
 284 "    CMP     R0, #0 \n"
 285 "    LDRLT   R0, =0xFF006080 /*'stdioSetup'*/ \n"
 286 "    BLLT    _err_init_task \n"
 287 "    BL      sub_FF009CF8 \n"
 288 "    CMP     R0, #0 \n"
 289 "    LDRLT   R0, =0xFF00608C /*'stdlibSetup'*/ \n"
 290 "    BLLT    _err_init_task \n"
 291 "    BL      sub_FF00169C \n"
 292 "    CMP     R0, #0 \n"
 293 "    LDRLT   R0, =0xFF006098 /*'armlib_setup'*/ \n"
 294 "    BLLT    _err_init_task \n"
 295 "    LDMFD   SP!, {R4,LR} \n"
 296 "    B       taskcreate_Startup_my \n"  // --> Patched. Old value = 0xFF00FD90.
 297 );
 298 }
 299 
 300 /*************************************************************/
 301 //** taskcreate_Startup_my @ 0xFF00FD90 - 0xFF00FDA0, length=5
 302 void __attribute__((naked,noinline)) taskcreate_Startup_my() {
 303 asm volatile (
 304 "    STMFD   SP!, {R4,LR} \n"
 305 //"  BL      _sub_FF0567FC \n"  // --> Nullsub call removed.
 306 "    BL      sub_FF00FDA4_my \n"  // --> Patched. Old value = 0xFF00FDA4.
 307 "    MOV     R0, #0 \n"
 308 "    LDMFD   SP!, {R4,PC} \n"
 309 );
 310 }
 311 
 312 /*************************************************************/
 313 //** sub_FF00FDA4_my @ 0xFF00FDA4 - 0xFF00FE64, length=49
 314 void __attribute__((naked,noinline)) sub_FF00FDA4_my() {
 315 asm volatile (
 316 "    STMFD   SP!, {R3-R7,LR} \n"
 317 "    MOV     R6, #0 \n"
 318 "    BL      sub_FF02C534 \n"
 319 "    MOVS    R7, R0 \n"
 320 "    BNE     loc_FF00FE10 \n"
 321 "    BL      sub_FF025358 /*_IsNormalCameraMode_FW*/ \n"
 322 "    CMP     R0, #0 \n"
 323 "    BEQ     loc_FF00FE10 \n"
 324 "    MOV     R0, #0x4F \n"
 325 "    BL      sub_FF02AAF0 \n"
 326 "    RSBS    R5, R0, #1 \n"
 327 "    MOVCC   R5, #0 \n"
 328 "    MOV     R0, #0x4B \n"
 329 "    BL      sub_FF02AAF0 \n"
 330 "    RSBS    R4, R0, #1 \n"
 331 "    MOVCC   R4, #0 \n"
 332 "    BL      sub_FF022B70 \n"
 333 "    CMP     R0, #1 \n"
 334 "    MOVEQ   R6, #1 \n"
 335 "    ORR     R0, R4, R5 \n"
 336 "    ORRS    R0, R0, R6 \n"
 337 "    BNE     loc_FF00FE30 \n"
 338 "    BL      sub_FF022D08 \n"
 339 "    LDR     R1, =0x83DC00 \n"
 340 "    MOV     R0, #0x54 \n"
 341 "    BL      sub_FF02AAE0 \n"
 342 
 343 "loc_FF00FE0C:\n"
 344 "    B       loc_FF00FE0C \n"
 345 
 346 "loc_FF00FE10:\n"
 347 "    MOV     R0, #0x4B \n"
 348 "    BL      sub_FF02AAF0 \n"
 349 "    RSBS    R4, R0, #1 \n"
 350 "    MOVCC   R4, #0 \n"
 351 "    MOV     R0, #0x4F \n"
 352 "    BL      sub_FF02AAF0 \n"
 353 "    RSBS    R5, R0, #1 \n"
 354 "    MOVCC   R5, #0 \n"
 355 
 356 "loc_FF00FE30:\n"
 357 "    MOV     R3, R6 \n"
 358 "    MOV     R2, R7 \n"
 359 "    MOV     R1, R5 \n"
 360 "    MOV     R0, R4 \n"
 361 //"  BL      _sub_FF056804 \n"  // See begin of sub_FF000364_my()
 362 //"  BL      _sub_FF056800 \n"  // --> Nullsub call removed.
 363 "    BL      sub_FF02A470 \n"
 364 "    LDR     R1, =0x5CE000 \n"
 365 "    MOV     R0, #0 \n"
 366 "    BL      sub_FF02A8E0 \n"
 367 "    BL      sub_FF02A688 /*_EnableDispatch*/ \n"
 368 "    MOV     R3, #0 \n"
 369 "    STR     R3, [SP] \n"
 370 "    LDR     R3, =task_Startup_my \n"  // --> Patched. Old value = 0xFF00FD34.
 371 "    LDR     PC, =0xFF00FE68 \n"  // Continue in firmware
 372 );
 373 }
 374 
 375 /*************************************************************/
 376 //** task_Startup_my @ 0xFF00FD34 - 0xFF00FD60, length=12
 377 void __attribute__((naked,noinline)) task_Startup_my() {
 378 asm volatile (
 379 "    STMFD   SP!, {R4,LR} \n"
 380 "    BL      sub_FF0065E8 \n"
 381 "    BL      sub_FF024A9C \n"
 382 "    BL      sub_FF022B80 \n"
 383 //"  BL      _sub_FF0574AC \n"  // --> Nullsub call removed.
 384 "    BL      sub_FF02C768 \n"
 385 //"  BL      _sub_FF02C610 \n"  // start diskboot.bin
 386 "    BL      sub_FF096F68 \n"
 387 "    BL      sub_FF02C798 \n"
 388 "    BL      sub_FF029C14 \n"
 389 "    BL      sub_FF02C924 \n"
 390 
 391 "    BL      CreateTask_spytask\n"  // added
 392 
 393 "    BL      taskcreatePhySw_my \n"  // --> Patched. Old value = 0xFF02380C.
 394 
 395 #if defined(OPT_RUN_WITH_BATT_COVER_OPEN)
 396 "    LDR     R0, =0xE0000\n"    // Pause for startup with battery door open
 397 "batt_delay:\n"
 398 "    NOP\n"
 399 "    SUBS    R0,R0,#1\n"
 400 "    BNE     batt_delay\n"
 401 #endif
 402 
 403 "    LDR     PC, =0xFF00FD64 \n"  // Continue in firmware
 404 );
 405 }
 406 
 407 /*************************************************************/
 408 //** taskcreatePhySw_my @ 0xFF02380C - 0xFF02382C, length=9
 409 void __attribute__((naked,noinline)) taskcreatePhySw_my() {
 410 asm volatile (
 411 "    STMFD   SP!, {R3-R5,LR} \n"
 412 "    LDR     R4, =0x1BF4 \n"
 413 "    LDR     R0, [R4, #4] \n"
 414 "    CMP     R0, #0 \n"
 415 "    BNE     sub_FF023840 \n"
 416 "    MOV     R3, #0 \n"
 417 "    STR     R3, [SP] \n"
 418 "    LDR     R3, =mykbd_task \n"  // --> Patched. Old value = 0xFF0237D8.
 419 "    MOV     R2, #0x2000 \n"  // --> Patched. Old value = 0x800. stack size for new task_PhySw
 420 "    LDR     PC, =0xFF023830 \n"  // Continue in firmware
 421 );
 422 }
 423 
 424 /*************************************************************/
 425 //** init_file_modules_task @ 0xFF09A978 - 0xFF09A994, length=8
 426 void __attribute__((naked,noinline)) init_file_modules_task() {
 427 asm volatile (
 428 "    STMFD   SP!, {R4-R6,LR} \n"
 429 "    BL      sub_FF0902A4 \n"
 430 "    LDR     R5, =0x5006 \n"
 431 "    MOVS    R4, R0 \n"
 432 "    MOVNE   R1, #0 \n"
 433 "    MOVNE   R0, R5 \n"
 434 "    BLNE    _PostLogicalEventToUI \n"
 435 "    BL      sub_FF0902D0 \n"
 436 "    BL      core_spytask_can_start\n"  // CHDK: Set "it's-safe-to-start" flag for spytask
 437 "    LDR     PC, =0xFF09A998 \n"  // Continue in firmware
 438 );
 439 }
 440 
 441 /*************************************************************/
 442 //** JogDial_task_my @ 0xFF0575CC - 0xFF0578F0, length=202
 443 void __attribute__((naked,noinline)) JogDial_task_my() {
 444 asm volatile (
 445 "    STMFD   SP!, {R4-R11,LR} \n"
 446 "    SUB     SP, SP, #0x24 \n"
 447 "    BL      sub_FF057960 \n"
 448 "    LDR     R12, =0x26E8 \n"
 449 "    LDR     R6, =0xFF464EA4 \n"
 450 "    MOV     R0, #0 \n"
 451 
 452 // Save pointer for kbd.c routine
 453 "    ADD     R10, SP, #0x18 \n"
 454 "    LDR     R9, =jog_position \n"
 455 "    STR     R10, [R9] \n"
 456 
 457 "    ADD     R10, SP, #8 \n"
 458 "    ADD     R9, SP, #0x10 \n"
 459 
 460 "loc_FF0575EC:\n"
 461 "    ADD     R2, SP, #0x1C \n"
 462 "    MOV     R1, #0 \n"
 463 "    ADD     R4, R2, R0, LSL#1 \n"
 464 "    ADD     R3, SP, #0x18 \n"
 465 "    STRH    R1, [R4] \n"
 466 "    ADD     R4, R3, R0, LSL#1 \n"
 467 "    STRH    R1, [R4] \n"
 468 "    STR     R1, [R9, R0, LSL#2] \n"
 469 "    STR     R1, [R10, R0, LSL#2] \n"
 470 "    ADD     R0, R0, #1 \n"
 471 "    CMP     R0, #2 \n"
 472 "    BLT     loc_FF0575EC \n"
 473 
 474 "loc_FF05761C:\n"
 475 "    LDR     R0, =0x26E8 \n"
 476 "    MOV     R2, #0 \n"
 477 "    LDR     R0, [R0, #8] \n"
 478 "    MOV     R1, SP \n"
 479 "    BL      sub_FF029EA8 /*_ReceiveMessageQueue*/ \n"
 480 "    CMP     R0, #0 \n"
 481 "    LDRNE   R1, =0x256 \n"
 482 "    LDRNE   R0, =0xFF05787C /*'RotaryEncoder.c'*/ \n"
 483 "    BLNE    _DebugAssert \n"
 484 "    LDR     R0, [SP] \n"
 485 "    AND     R4, R0, #0xFF \n"
 486 "    AND     R0, R0, #0xFF00 \n"
 487 "    CMP     R0, #0x100 \n"
 488 "    BEQ     loc_FF05768C \n"
 489 "    CMP     R0, #0x200 \n"
 490 "    BEQ     loc_FF0576C4 \n"
 491 "    CMP     R0, #0x300 \n"
 492 "    BEQ     loc_FF0578C4 \n"
 493 "    CMP     R0, #0x400 \n"
 494 "    BNE     loc_FF05761C \n"
 495 "    CMP     R4, #0 \n"
 496 "    LDRNE   R1, =0x2E1 \n"
 497 "    LDRNE   R0, =0xFF05787C /*'RotaryEncoder.c'*/ \n"
 498 "    BLNE    _DebugAssert \n"
 499 "    RSB     R0, R4, R4, LSL#3 \n"
 500 "    LDR     R0, [R6, R0, LSL#2] \n"
 501 
 502 "loc_FF057684:\n"
 503 "    BL      sub_FF057944 \n"
 504 "    B       loc_FF05761C \n"
 505 
 506 "loc_FF05768C:\n"
 507 //------------------  added code ---------------------
 508 "labelA:\n"
 509 "    LDR     R0, =jogdial_stopped\n"
 510 "    LDR     R0, [R0]\n"
 511 "    CMP     R0, #1\n"
 512 "    BNE     labelB\n"
 513 "    MOV     R0, #40\n"
 514 "    BL      _SleepTask\n"
 515 "    B       labelA\n"
 516 "labelB:\n"
 517 //------------------  original code ------------------
 518 "    LDR     R0, =0x26F8 \n"
 519 "    LDR     R0, [R0, R4, LSL#2] \n"
 520 "    BL      sub_FF02B0E4 /*_CancelTimer*/ \n"
 521 "    LDR     R2, =0xFF057518 \n"
 522 "    ORR     R3, R4, #0x200 \n"
 523 "    MOV     R1, R2 \n"
 524 "    MOV     R0, #0x28 \n"
 525 "    BL      sub_FF02B000 /*_SetTimerAfter*/ \n"
 526 "    TST     R0, #1 \n"
 527 "    CMPNE   R0, #0x15 \n"
 528 "    STR     R0, [R10, R4, LSL#2] \n"
 529 "    BEQ     loc_FF05761C \n"
 530 "    MOV     R1, #0x268 \n"
 531 "    B       loc_FF057868 \n"
 532 
 533 "loc_FF0576C4:\n"
 534 "    RSB     R5, R4, R4, LSL#3 \n"
 535 "    LDR     R0, [R6, R5, LSL#2] \n"
 536 "    LDR     R1, =0xC0240000 \n"
 537 "    ADD     R0, R1, R0, LSL#8 \n"
 538 "    LDR     R0, [R0, #0x104] \n"
 539 "    MOV     R1, R0, ASR#16 \n"
 540 "    ADD     R0, SP, #0x1C \n"
 541 "    ADD     R11, R0, R4, LSL#1 \n"
 542 "    ADD     R0, SP, #0x18 \n"
 543 "    ADD     R0, R0, R4, LSL#1 \n"
 544 "    STRH    R1, [R11] \n"
 545 "    STR     R0, [SP, #0x20] \n"
 546 "    LDRSH   R3, [R0] \n"
 547 "    SUB     R2, R1, R3 \n"
 548 "    CMP     R2, #0 \n"
 549 "    BNE     loc_FF057748 \n"
 550 "    LDR     R0, [R9, R4, LSL#2] \n"
 551 "    CMP     R0, #0 \n"
 552 "    BEQ     loc_FF057824 \n"
 553 "    LDR     R7, =0x26F8 \n"
 554 "    LDR     R0, [R7, R4, LSL#2] \n"
 555 "    BL      sub_FF02B0E4 /*_CancelTimer*/ \n"
 556 "    LDR     R2, =0xFF057524 \n"
 557 "    ORR     R3, R4, #0x300 \n"
 558 "    MOV     R1, R2 \n"
 559 "    MOV     R0, #0x1F4 \n"
 560 "    BL      sub_FF02B000 /*_SetTimerAfter*/ \n"
 561 "    TST     R0, #1 \n"
 562 "    CMPNE   R0, #0x15 \n"
 563 "    STR     R0, [R7, R4, LSL#2] \n"
 564 "    BEQ     loc_FF057824 \n"
 565 "    LDR     R1, =0x281 \n"
 566 "    B       loc_FF05781C \n"
 567 
 568 "loc_FF057748:\n"
 569 "    MOV     R0, R2 \n"
 570 "    RSBLT   R0, R0, #0 \n"
 571 "    MOVLE   R7, #0 \n"
 572 "    MOVGT   R7, #1 \n"
 573 "    CMP     R0, #0xFF \n"
 574 "    BLS     loc_FF057784 \n"
 575 "    LDR     R0, =0x7FFF \n"
 576 "    CMP     R2, #0 \n"
 577 "    SUBLE   R0, R0, R3 \n"
 578 "    ADDLE   R0, R0, R1 \n"
 579 "    SUBGT   R0, R0, R1 \n"
 580 "    ADDGT   R0, R0, R3 \n"
 581 "    MVN     R1, #0x8000 \n"
 582 "    SUB     R0, R0, R1 \n"
 583 "    EOR     R7, R7, #1 \n"
 584 
 585 "loc_FF057784:\n"
 586 "    STR     R0, [SP, #4] \n"
 587 "    LDR     R0, [R9, R4, LSL#2] \n"
 588 "    CMP     R0, #0 \n"
 589 "    ADDEQ   R0, R6, R5, LSL#2 \n"
 590 "    LDREQ   R0, [R0, #8] \n"
 591 "    BEQ     loc_FF0577BC \n"
 592 "    ADD     R8, R6, R5, LSL#2 \n"
 593 "    ADD     R1, R8, R7, LSL#2 \n"
 594 "    LDR     R1, [R1, #0x10] \n"
 595 "    CMP     R1, R0 \n"
 596 "    BEQ     loc_FF0577C0 \n"
 597 "    LDR     R0, [R8, #0xC] \n"
 598 "    BL      sub_FF023864 \n"
 599 "    LDR     R0, [R8, #8] \n"
 600 
 601 "loc_FF0577BC:\n"
 602 "    BL      sub_FF023864 \n"
 603 
 604 "loc_FF0577C0:\n"
 605 "    ADD     R0, R6, R5, LSL#2 \n"
 606 "    ADD     R7, R0, R7, LSL#2 \n"
 607 "    LDR     R0, [R7, #0x10] \n"
 608 "    LDR     R1, [SP, #4] \n"
 609 "    BL      sub_FF023874 \n"
 610 "    LDR     R0, [R7, #0x10] \n"
 611 "    LDR     R7, =0x26F8 \n"
 612 "    STR     R0, [R9, R4, LSL#2] \n"
 613 "    LDRH    R1, [R11] \n"
 614 "    LDR     R0, [SP, #0x20] \n"
 615 "    STRH    R1, [R0] \n"
 616 "    LDR     R0, [R7, R4, LSL#2] \n"
 617 "    BL      sub_FF02B0E4 /*_CancelTimer*/ \n"
 618 "    LDR     R2, =0xFF057524 \n"
 619 "    ORR     R3, R4, #0x300 \n"
 620 "    MOV     R1, R2 \n"
 621 "    MOV     R0, #0x1F4 \n"
 622 "    BL      sub_FF02B000 /*_SetTimerAfter*/ \n"
 623 "    TST     R0, #1 \n"
 624 "    CMPNE   R0, #0x15 \n"
 625 "    STR     R0, [R7, R4, LSL#2] \n"
 626 "    BEQ     loc_FF057824 \n"
 627 "    LDR     R1, =0x2C3 \n"
 628 
 629 "loc_FF05781C:\n"
 630 "    LDR     R0, =0xFF05787C /*'RotaryEncoder.c'*/ \n"
 631 "    BL      _DebugAssert \n"
 632 
 633 "loc_FF057824:\n"
 634 "    ADD     R0, R6, R5, LSL#2 \n"
 635 "    LDR     R0, [R0, #0x18] \n"
 636 "    CMP     R0, #1 \n"
 637 "    BNE     loc_FF0578BC \n"
 638 "    LDR     R0, =0x26E8 \n"
 639 "    LDR     R0, [R0, #0xC] \n"
 640 "    CMP     R0, #0 \n"
 641 "    BEQ     loc_FF0578BC \n"
 642 "    LDR     R2, =0xFF057518 \n"
 643 "    ORR     R3, R4, #0x400 \n"
 644 "    MOV     R1, R2 \n"
 645 "    BL      sub_FF02B000 /*_SetTimerAfter*/ \n"
 646 "    TST     R0, #1 \n"
 647 "    CMPNE   R0, #0x15 \n"
 648 "    STR     R0, [R10, R4, LSL#2] \n"
 649 "    BEQ     loc_FF05761C \n"
 650 "    LDR     R1, =0x2CA \n"
 651 
 652 "loc_FF057868:\n"
 653 "    LDR     R0, =0xFF05787C /*'RotaryEncoder.c'*/ \n"
 654 "    BL      _DebugAssert \n"
 655 "    B       loc_FF05761C \n"
 656 
 657 "loc_FF0578BC:\n"
 658 "    LDR     R0, [R6, R5, LSL#2] \n"
 659 "    B       loc_FF057684 \n"
 660 
 661 "loc_FF0578C4:\n"
 662 "    LDR     R0, [R9, R4, LSL#2] \n"
 663 "    CMP     R0, #0 \n"
 664 "    MOVEQ   R1, #0x2D4 \n"
 665 "    LDREQ   R0, =0xFF05787C /*'RotaryEncoder.c'*/ \n"
 666 "    BLEQ    _DebugAssert \n"
 667 "    RSB     R0, R4, R4, LSL#3 \n"
 668 "    ADD     R0, R6, R0, LSL#2 \n"
 669 "    LDR     R0, [R0, #0xC] \n"
 670 "    BL      sub_FF023864 \n"
 671 "    MOV     R0, #0 \n"
 672 "    STR     R0, [R9, R4, LSL#2] \n"
 673 "    B       loc_FF05761C \n"
 674 );
 675 }

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