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

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