root/platform/sx240hs/sub/100c/boot.c

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

DEFINITIONS

This source file includes following definitions.
  1. taskHook
  2. CreateTask_spytask
  3. boot
  4. sub_FF00038C_my
  5. sub_FF0011E4_my
  6. sub_FF004294_my
  7. taskcreate_Startup_my
  8. sub_FF00B19C_my
  9. sub_FF00B1F0_my
  10. task_Startup_my
  11. taskcreatePhySw_my
  12. init_file_modules_task
  13. JogDial_task_my

   1 /*
   2  * boot.c - auto-generated by CHDK code_gen.
   3  */
   4 #include "lolevel.h"
   5 #include "platform.h"
   6 #include "core.h"
   7 #include "dryos31.h"
   8 
   9 #define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
  10 
  11 const char * const new_sa = &_end;
  12 
  13 // Forward declarations
  14 extern volatile int jogdial_stopped;
  15 void JogDial_task_my(void);
  16 
  17 extern void task_CaptSeq();
  18 extern void task_InitFileModules();
  19 extern void task_RotaryEncoder();
  20 extern void task_MovieRecord();
  21 extern void task_ExpDrv();
  22 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 - 0xFF000184, length=95
  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, #0x37 \n"
  74 "    MCR     p15, 0, R0, c6, c2 \n"
  75 "    MOV     R0, #0x40000037 \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 "    LDR     R0, =0xD000002B \n"
  82 "    MCR     p15, 0, R0, c6, c7 \n"
  83 "    MOV     R0, #0x34 \n"
  84 "    MCR     p15, 0, R0, c2, c0 \n"
  85 "    MOV     R0, #0x34 \n"
  86 "    MCR     p15, 0, R0, c2, c0, 1 \n"
  87 "    MOV     R0, #0x34 \n"
  88 "    MCR     p15, 0, R0, c3, c0 \n"
  89 "    LDR     R0, =0x33333330 \n"
  90 "    MCR     p15, 0, R0, c5, c0, 2 \n"
  91 "    LDR     R0, =0x33333330 \n"
  92 "    MCR     p15, 0, R0, c5, c0, 3 \n"
  93 "    MRC     p15, 0, R0, c1, c0 \n"
  94 "    ORR     R0, R0, #0x1000 \n"
  95 "    ORR     R0, R0, #4 \n"
  96 "    ORR     R0, R0, #1 \n"
  97 "    MCR     p15, 0, R0, c1, c0 \n"
  98 "    MOV     R1, #0x80000006 \n"
  99 "    MCR     p15, 0, R1, c9, c1 \n"
 100 "    MOV     R1, #6 \n"
 101 "    MCR     p15, 0, R1, c9, c1, 1 \n"
 102 "    MRC     p15, 0, R1, c1, c0 \n"
 103 "    ORR     R1, R1, #0x50000 \n"
 104 "    MCR     p15, 0, R1, c1, c0 \n"
 105 "    LDR     R2, =0xC0200000 \n"
 106 "    MOV     R1, #1 \n"
 107 "    STR     R1, [R2, #0x10C] \n"
 108 "    MOV     R1, #0xFF \n"
 109 "    STR     R1, [R2, #0xC] \n"
 110 "    STR     R1, [R2, #0x1C] \n"
 111 "    STR     R1, [R2, #0x2C] \n"
 112 "    STR     R1, [R2, #0x3C] \n"
 113 "    STR     R1, [R2, #0x4C] \n"
 114 "    STR     R1, [R2, #0x5C] \n"
 115 "    STR     R1, [R2, #0x6C] \n"
 116 "    STR     R1, [R2, #0x7C] \n"
 117 "    STR     R1, [R2, #0x8C] \n"
 118 "    STR     R1, [R2, #0x9C] \n"
 119 "    STR     R1, [R2, #0xAC] \n"
 120 "    STR     R1, [R2, #0xBC] \n"
 121 "    STR     R1, [R2, #0xCC] \n"
 122 "    STR     R1, [R2, #0xDC] \n"
 123 "    STR     R1, [R2, #0xEC] \n"
 124 "    STR     R1, [R2, #0xFC] \n"
 125 "    LDR     R1, =0xC0400008 \n"
 126 "    LDR     R2, =0x430005 \n"
 127 "    STR     R2, [R1] \n"
 128 "    MOV     R1, #1 \n"
 129 "    LDR     R2, =0xC0243100 \n"
 130 "    STR     R2, [R1] \n"
 131 "    LDR     R2, =0xC0242010 \n"
 132 "    LDR     R1, [R2] \n"
 133 "    ORR     R1, R1, #1 \n"
 134 "    STR     R1, [R2] \n"
 135 "    LDR     R0, =0xFF680A14 \n"
 136 "    LDR     R1, =0x685000 \n"
 137 "    LDR     R3, =0x69544C \n"
 138 
 139 "loc_FF000144:\n"
 140 "    CMP     R1, R3 \n"
 141 "    LDRCC   R2, [R0], #4 \n"
 142 "    STRCC   R2, [R1], #4 \n"
 143 "    BCC     loc_FF000144 \n"
 144 "    LDR     R0, =0xFF66DB9C \n"
 145 "    LDR     R1, =0x1900 \n"
 146 "    LDR     R3, =0x14778 \n"
 147 
 148 "loc_FF000160:\n"
 149 "    CMP     R1, R3 \n"
 150 "    LDRCC   R2, [R0], #4 \n"
 151 "    STRCC   R2, [R1], #4 \n"
 152 "    BCC     loc_FF000160 \n"
 153 "    LDR     R1, =0x193A24 \n"
 154 "    MOV     R2, #0 \n"
 155 
 156 "loc_FF000178:\n"
 157 "    CMP     R3, R1 \n"
 158 "    STRCC   R2, [R3], #4 \n"
 159 "    BCC     loc_FF000178 \n"
 160 "    B       sub_FF00038C_my \n"  // --> Patched. Old value = 0xFF00038C.
 161 );
 162 }
 163 
 164 /*************************************************************/
 165 //** sub_FF00038C_my @ 0xFF00038C - 0xFF0003F4, length=27
 166 void __attribute__((naked,noinline)) sub_FF00038C_my() {
 167 
 168     //http://chdk.setepontos.com/index.php/topic,4194.0.html
 169     *(int*)0x1938=(int)taskHook;
 170     *(int*)0x193C=(int)taskHook;
 171 
 172     // From SX260: funnel testings for 100b sx260
 173     // Replacement of sub_FF04D3E8 for correct power-on.
 174     // (short press = playback mode, long press = record mode)
 175     *(int*)(0x2618+0x4) = (*(int*)0xC022F48C)&4 ? 0x200000 : 0x100000;
 176 
 177 asm volatile (
 178 "    LDR     R0, =0xFF000404 \n"
 179 "    MOV     R1, #0 \n"
 180 "    LDR     R3, =0xFF00043C \n"
 181 
 182 "loc_FF000398:\n"
 183 "    CMP     R0, R3 \n"
 184 "    LDRCC   R2, [R0], #4 \n"
 185 "    STRCC   R2, [R1], #4 \n"
 186 "    BCC     loc_FF000398 \n"
 187 "    LDR     R0, =0xFF00043C \n"
 188 "    MOV     R1, #0x4B0 \n"
 189 "    LDR     R3, =0xFF000650 \n"
 190 
 191 "loc_FF0003B4:\n"
 192 "    CMP     R0, R3 \n"
 193 "    LDRCC   R2, [R0], #4 \n"
 194 "    STRCC   R2, [R1], #4 \n"
 195 "    BCC     loc_FF0003B4 \n"
 196 "    MOV     R0, #0xD2 \n"
 197 "    MSR     CPSR_cxsf, R0 \n"
 198 "    MOV     SP, #0x1000 \n"
 199 "    MOV     R0, #0xD3 \n"
 200 "    MSR     CPSR_cxsf, R0 \n"
 201 "    MOV     SP, #0x1000 \n"
 202 "    LDR     R0, =0x6C4 \n"
 203 "    LDR     R2, =0xEEEEEEEE \n"
 204 "    MOV     R3, #0x1000 \n"
 205 
 206 "loc_FF0003E8:\n"
 207 "    CMP     R0, R3 \n"
 208 "    STRCC   R2, [R0], #4 \n"
 209 "    BCC     loc_FF0003E8 \n"
 210 "    BL      sub_FF0011E4_my \n"  // --> Patched. Old value = 0xFF0011E4.
 211 );
 212 }
 213 
 214 /*************************************************************/
 215 //** sub_FF0011E4_my @ 0xFF0011E4 - 0xFF001290, length=44
 216 void __attribute__((naked,noinline)) sub_FF0011E4_my() {
 217 asm volatile (
 218 "    STR     LR, [SP, #-4]! \n"
 219 "    SUB     SP, SP, #0x74 \n"
 220 "    MOV     R1, #0x74 \n"
 221 "    MOV     R0, SP \n"
 222 "    BL      sub_00690448 \n"
 223 "    MOV     R0, #0x67000 \n"
 224 "    STR     R0, [SP, #4] \n"
 225 
 226 #if defined(CHDK_NOT_IN_CANON_HEAP) // use original heap offset if CHDK is loaded in high memory
 227 "    LDR     R0, =0x193A24 \n"
 228 #else
 229 "    LDR     R0, =new_sa\n"   // otherwise use patched value
 230 "    LDR     R0, [R0]\n"      //
 231 #endif
 232 
 233 "    LDR     R2, =0x55D440 \n"
 234 "    STR     R0, [SP, #8] \n"
 235 "    SUB     R0, R2, R0 \n"
 236 "    STR     R0, [SP, #0xC] \n"
 237 "    MOV     R0, #0x22 \n"
 238 "    STR     R0, [SP, #0x18] \n"
 239 "    MOV     R0, #0x7C \n"
 240 "    STR     R0, [SP, #0x1C] \n"
 241 "    LDR     R1, =0x565C00 \n"
 242 "    LDR     R0, =0x1CD \n"
 243 "    STR     R1, [SP] \n"
 244 "    STR     R0, [SP, #0x20] \n"
 245 "    MOV     R0, #0x96 \n"
 246 "    STR     R2, [SP, #0x10] \n"
 247 "    STR     R1, [SP, #0x14] \n"
 248 "    STR     R0, [SP, #0x24] \n"
 249 "    STR     R0, [SP, #0x28] \n"
 250 "    MOV     R0, #0x64 \n"
 251 "    STR     R0, [SP, #0x2C] \n"
 252 "    MOV     R0, #0 \n"
 253 "    STR     R0, [SP, #0x30] \n"
 254 "    STR     R0, [SP, #0x34] \n"
 255 "    MOV     R0, #0x10 \n"
 256 "    STR     R0, [SP, #0x5C] \n"
 257 "    MOV     R0, #0x800 \n"
 258 "    STR     R0, [SP, #0x60] \n"
 259 "    MOV     R0, #0xA0 \n"
 260 "    STR     R0, [SP, #0x64] \n"
 261 "    MOV     R0, #0x280 \n"
 262 "    STR     R0, [SP, #0x68] \n"
 263 "    LDR     R1, =sub_FF004294_my \n"  // --> Patched. Old value = 0xFF004294.
 264 "    MOV     R2, #0 \n"
 265 "    MOV     R0, SP \n"
 266 "    BL      sub_00686778 \n"
 267 "    ADD     SP, SP, #0x74 \n"
 268 "    LDR     PC, [SP], #4 \n"
 269 );
 270 }
 271 
 272 /*************************************************************/
 273 //** sub_FF004294_my @ 0xFF004294 - 0xFF004308, length=30
 274 void __attribute__((naked,noinline)) sub_FF004294_my() {
 275 asm volatile (
 276 "    STMFD   SP!, {R4,LR} \n"
 277 "    BL      sub_FF000B5C \n"
 278 "    BL      sub_FF0053B8 \n"
 279 "    CMP     R0, #0 \n"
 280 "    LDRLT   R0, =0xFF0043A8 /*'dmSetup'*/ \n"
 281 "    BLLT    _err_init_task \n"
 282 "    BL      sub_FF003ECC \n"
 283 "    CMP     R0, #0 \n"
 284 "    LDRLT   R0, =0xFF0043B0 /*'termDriverInit'*/ \n"
 285 "    BLLT    _err_init_task \n"
 286 "    LDR     R0, =0xFF0043C0 /*'/_term'*/ \n"
 287 "    BL      sub_FF003FB4 \n"
 288 "    CMP     R0, #0 \n"
 289 "    LDRLT   R0, =0xFF0043C8 /*'termDeviceCreate'*/ \n"
 290 "    BLLT    _err_init_task \n"
 291 "    LDR     R0, =0xFF0043C0 /*'/_term'*/ \n"
 292 "    BL      sub_FF0029D4 \n"
 293 "    CMP     R0, #0 \n"
 294 "    LDRLT   R0, =0xFF0043DC /*'stdioSetup'*/ \n"
 295 "    BLLT    _err_init_task \n"
 296 "    BL      sub_FF004D54 \n"
 297 "    CMP     R0, #0 \n"
 298 "    LDRLT   R0, =0xFF0043E8 /*'stdlibSetup'*/ \n"
 299 "    BLLT    _err_init_task \n"
 300 "    BL      sub_FF0016D4 \n"
 301 "    CMP     R0, #0 \n"
 302 "    LDRLT   R0, =0xFF0043F4 /*'armlib_setup'*/ \n"
 303 "    BLLT    _err_init_task \n"
 304 "    LDMFD   SP!, {R4,LR} \n"
 305 "    B       taskcreate_Startup_my \n"  // --> Patched. Old value = 0xFF00B1C0.
 306 );
 307 }
 308 
 309 /*************************************************************/
 310 //** taskcreate_Startup_my @ 0xFF00B1C0 - 0xFF00B1EC, length=12
 311 void __attribute__((naked,noinline)) taskcreate_Startup_my() {
 312 asm volatile (
 313 "    STMFD   SP!, {R3,LR} \n"
 314 "    BL      sub_0068C118 \n"
 315 "    BL      sub_0068C330 \n"
 316 "    MOV     R3, #0 \n"
 317 "    STR     R3, [SP] \n"
 318 "    LDR     R3, =sub_FF00B19C_my \n"  // --> Patched. Old value = 0xFF00B19C.
 319 "    MOV     R2, #0x200 \n"
 320 "    MOV     R1, #0x19 \n"
 321 "    LDR     R0, =0xFF00B2C8 /*'Booting'*/ \n"
 322 "    BL      _CreateTask \n"
 323 "    MOV     R0, #0 \n"
 324 "    LDMFD   SP!, {R3,PC} \n"
 325 );
 326 }
 327 
 328 /*************************************************************/
 329 //** sub_FF00B19C_my @ 0xFF00B19C - 0xFF00B1BC, length=9
 330 void __attribute__((naked,noinline)) sub_FF00B19C_my() {
 331 asm volatile (
 332 "    STMFD   SP!, {R4,LR} \n"
 333 //"  BL      _sub_FF04D3E0 \n"  // --> Nullsub call removed.
 334 "    BL      sub_FF02040C \n"
 335 "    BL      sub_FF01E134 \n"
 336 "    BL      sub_FF0272DC \n"
 337 "    BL      sub_FF01E854 \n"
 338 "    BL      sub_FF01D8E8 \n"
 339 "    LDMFD   SP!, {R4,LR} \n"
 340 "    B       sub_FF00B1F0_my \n"  // --> Patched. Old value = 0xFF00B1F0.
 341 );
 342 }
 343 
 344 /*************************************************************/
 345 //** sub_FF00B1F0_my @ 0xFF00B1F0 - 0xFF00B2C0, length=53
 346 void __attribute__((naked,noinline)) sub_FF00B1F0_my() {
 347 asm volatile (
 348 "    STMFD   SP!, {R3-R7,LR} \n"
 349 "    BL      sub_FF027078 \n"
 350 "    MOVS    R6, R0 \n"
 351 "    BNE     loc_FF00B254 \n"
 352 "    BL      sub_FF020D40 /*_IsNormalCameraMode_FW*/ \n"
 353 "    CMP     R0, #0 \n"
 354 "    BEQ     loc_FF00B254 \n"
 355 "    MOV     R0, #0x37 \n"
 356 "    BL      sub_FF0255E8 \n"
 357 "    RSBS    R5, R0, #1 \n"
 358 "    MOVCC   R5, #0 \n"
 359 "    MOV     R0, #0x36 \n"
 360 "    BL      sub_FF0255E8 \n"
 361 "    RSBS    R4, R0, #1 \n"
 362 "    MOVCC   R4, #0 \n"
 363 "    ORRS    R0, R4, R5 \n"
 364 "    BNE     loc_FF00B274 \n"
 365 "    BL      sub_FF01E2C0 \n"
 366 "    BL      sub_0068A7F8 /*_GetSRAndDisableInterrupt*/ \n"
 367 "    LDR     R2, =0xC022C000 \n"
 368 "    LDR     R1, [R2, #0x30C] \n"
 369 "    BIC     R1, R1, #0x300 \n"
 370 "    STR     R1, [R2, #0x30C] \n"
 371 "    BL      sub_0068A7FC /*_SetSR*/ \n"
 372 
 373 "loc_FF00B250:\n"
 374 "    B       loc_FF00B250 \n"
 375 
 376 "loc_FF00B254:\n"
 377 "    MOV     R0, #0x36 \n"
 378 "    BL      sub_FF0255E8 \n"
 379 "    RSBS    R4, R0, #1 \n"
 380 "    MOVCC   R4, #0 \n"
 381 "    MOV     R0, #0x37 \n"
 382 "    BL      sub_FF0255E8 \n"
 383 "    RSBS    R5, R0, #1 \n"
 384 "    MOVCC   R5, #0 \n"
 385 
 386 "loc_FF00B274:\n"
 387 "    MOV     R3, #0 \n"
 388 "    MOV     R2, R6 \n"
 389 "    MOV     R1, R5 \n"
 390 "    MOV     R0, R4 \n"
 391 //"  BL      _sub_FF04D3E8 \n"  // See begin of sub_FF00038C_my
 392 //"  BL      _sub_FF04D3E4 \n"  // --> Nullsub call removed.
 393 "    BL      sub_0068C118 \n"
 394 "    LDR     R1, =0x5CE000 \n"
 395 "    MOV     R0, #0 \n"
 396 "    BL      sub_FF0253D4 \n"
 397 "    BL      sub_0068C330 \n"
 398 "    MOV     R3, #0 \n"
 399 "    STR     R3, [SP] \n"
 400 "    LDR     R3, =task_Startup_my \n"  // --> Patched. Old value = 0xFF00B140.
 401 "    MOV     R2, #0 \n"
 402 "    MOV     R1, #0x19 \n"
 403 "    LDR     R0, =0xFF00B2DC /*'Startup'*/ \n"
 404 "    BL      _CreateTask \n"
 405 "    MOV     R0, #0 \n"
 406 "    LDMFD   SP!, {R3-R7,PC} \n"
 407 );
 408 }
 409 
 410 /*************************************************************/
 411 //** task_Startup_my @ 0xFF00B140 - 0xFF00B198, length=23
 412 void __attribute__((naked,noinline)) task_Startup_my() {
 413 asm volatile (
 414 "    STMFD   SP!, {R4,LR} \n"
 415 "    BL      sub_FF0048D4 \n"
 416 //"  BL      _sub_FF04DD7C \n"  // --> Nullsub call removed.
 417 //"  BL      _sub_FF027184 \n"  // start diskboot.bin
 418 "    BL      sub_FF027444 \n"
 419 "    BL      sub_FF027610 \n"
 420 //"  BL      _sub_FF027438 \n"  // --> Nullsub call removed.
 421 "    BL      sub_FF02730C \n"
 422 "    BL      sub_FF025308 \n"
 423 "    BL      sub_FF027618 \n"
 424 
 425 "    BL      CreateTask_spytask\n"  // added
 426 
 427 "    BL      taskcreatePhySw_my \n"  // --> Patched. Old value = 0xFF01F188.
 428 "    LDR     PC, =0xFF00B16C \n"  // Continue in firmware
 429 );
 430 }
 431 
 432 /*************************************************************/
 433 //** taskcreatePhySw_my @ 0xFF01F188 - 0xFF01F1A8, length=9
 434 void __attribute__((naked,noinline)) taskcreatePhySw_my() {
 435 asm volatile (
 436 "    STMFD   SP!, {R3-R5,LR} \n"
 437 "    LDR     R4, =0x1C60 \n"
 438 "    LDR     R0, [R4, #4] \n"
 439 "    CMP     R0, #0 \n"
 440 "    BNE     sub_FF01F1BC \n"
 441 "    MOV     R3, #0 \n"
 442 "    STR     R3, [SP] \n"
 443 "    LDR     R3, =mykbd_task \n"  // --> Patched. Old value = 0xFF01F154.
 444 "    MOV     R2, #0x2000 \n"  // --> Patched. Old value = 0x800. stack size for new task_PhySw
 445 "    LDR     PC, =0xFF01F1AC \n"  // Continue in firmware
 446 );
 447 }
 448 
 449 /*************************************************************/
 450 //** init_file_modules_task @ 0xFF08BBC4 - 0xFF08BBE0, length=8
 451 void __attribute__((naked,noinline)) init_file_modules_task() {
 452 asm volatile (
 453 "    STMFD   SP!, {R4-R6,LR} \n"
 454 "    BL      sub_FF080D64 \n"
 455 "    LDR     R5, =0x5006 \n"
 456 "    MOVS    R4, R0 \n"
 457 "    MOVNE   R1, #0 \n"
 458 "    MOVNE   R0, R5 \n"
 459 "    BLNE    _PostLogicalEventToUI \n"
 460 "    BL      sub_FF080D98 \n"
 461 "    BL      core_spytask_can_start\n"  // CHDK: Set "it's-safe-to-start" flag for spytask
 462 "    LDR     PC, =0xFF08BBE4 \n"  // Continue in firmware
 463 );
 464 }
 465 
 466 /*************************************************************/
 467 //** JogDial_task_my @ 0xFF04DEB0 - 0xFF04E1CC, length=200
 468 void __attribute__((naked,noinline)) JogDial_task_my() {
 469 asm volatile (
 470 "    STMFD   SP!, {R4-R11,LR} \n"
 471 "    SUB     SP, SP, #0x1C \n"
 472 "    BL      sub_FF04E23C \n"
 473 "    LDR     R12, =0x262C \n"
 474 "    LDR     R6, =0xFF441820 \n"
 475 "    MOV     R0, #0 \n"
 476 "    ADD     R10, SP, #8 \n"
 477 "    ADD     R9, SP, #0xC \n"
 478 
 479 // Save pointer for kbd.c routine
 480 "    LDR     R2, =jog_position \n"
 481 "    STR     R9, [R2] \n"
 482 
 483 "loc_FF04DED0:\n"
 484 "    ADD     R2, SP, #0x14 \n"
 485 "    MOV     R1, #0 \n"
 486 "    ADD     R4, R2, R0, LSL#1 \n"
 487 "    ADD     R3, SP, #0x10 \n"
 488 "    STRH    R1, [R4] \n"
 489 "    ADD     R4, R3, R0, LSL#1 \n"
 490 "    STRH    R1, [R4] \n"
 491 "    STR     R1, [R9, R0, LSL#2] \n"
 492 "    STR     R1, [R10, R0, LSL#2] \n"
 493 "    ADD     R0, R0, #1 \n"
 494 "    CMP     R0, #1 \n"
 495 "    BLT     loc_FF04DED0 \n"
 496 
 497 "loc_FF04DF00:\n"
 498 "    LDR     R0, =0x262C \n"
 499 "    MOV     R2, #0 \n"
 500 "    LDR     R0, [R0, #8] \n"
 501 "    MOV     R1, SP \n"
 502 "    BL      sub_0068BBE4 /*_ReceiveMessageQueue*/ \n"
 503 "    CMP     R0, #0 \n"
 504 "    MOVNE   R1, #0x200 \n"
 505 "    LDRNE   R0, =0xFF04E15C /*'RotaryEncoder.c'*/ \n"
 506 "    BLNE    _DebugAssert \n"
 507 "    LDR     R0, [SP] \n"
 508 "    AND     R4, R0, #0xFF \n"
 509 "    AND     R0, R0, #0xFF00 \n"
 510 "    CMP     R0, #0x100 \n"
 511 "    BEQ     loc_FF04DF70 \n"
 512 "    CMP     R0, #0x200 \n"
 513 "    BEQ     loc_FF04DFA8 \n"
 514 "    CMP     R0, #0x300 \n"
 515 "    BEQ     loc_FF04E1A0 \n"
 516 "    CMP     R0, #0x400 \n"
 517 "    BNE     loc_FF04DF00 \n"
 518 "    CMP     R4, #0 \n"
 519 "    LDRNE   R1, =0x27A \n"
 520 "    LDRNE   R0, =0xFF04E15C /*'RotaryEncoder.c'*/ \n"
 521 "    BLNE    _DebugAssert \n"
 522 "    RSB     R0, R4, R4, LSL#3 \n"
 523 "    LDR     R0, [R6, R0, LSL#2] \n"
 524 
 525 "loc_FF04DF68:\n"
 526 "    BL      sub_FF04E220 \n"
 527 "    B       loc_FF04DF00 \n"
 528 
 529 "loc_FF04DF70:\n"
 530 //------------------  added code ---------------------
 531 "labelA:\n"
 532 "    LDR     R0, =jogdial_stopped\n"
 533 "    LDR     R0, [R0]\n"
 534 "    CMP     R0, #1\n"
 535 "    BNE     labelB\n"
 536 "    MOV     R0, #40\n"
 537 "    BL      _SleepTask\n"
 538 "    B       labelA\n"
 539 "labelB:\n"
 540 //------------------  original code ------------------
 541 "    LDR     R0, =0x2638 \n"
 542 "    LDR     R0, [R0, R4, LSL#2] \n"
 543 "    BL      sub_FF025BC4 /*_CancelTimer*/ \n"
 544 "    LDR     R2, =0xFF04DDFC \n"
 545 "    ORR     R3, R4, #0x200 \n"
 546 "    MOV     R1, R2 \n"
 547 "    MOV     R0, #0x28 \n"
 548 "    BL      sub_FF025AE0 /*_SetTimerAfter*/ \n"
 549 "    TST     R0, #1 \n"
 550 "    CMPNE   R0, #0x15 \n"
 551 "    STR     R0, [R10, R4, LSL#2] \n"
 552 "    BEQ     loc_FF04DF00 \n"
 553 "    LDR     R1, =0x212 \n"
 554 "    B       loc_FF04E14C \n"
 555 
 556 "loc_FF04DFA8:\n"
 557 "    RSB     R5, R4, R4, LSL#3 \n"
 558 "    LDR     R0, [R6, R5, LSL#2] \n"
 559 "    LDR     R1, =0xC0240000 \n"
 560 "    ADD     R0, R1, R0, LSL#8 \n"
 561 "    LDR     R0, [R0, #0x104] \n"
 562 "    MOV     R1, R0, ASR#16 \n"
 563 "    ADD     R0, SP, #0x14 \n"
 564 "    ADD     R11, R0, R4, LSL#1 \n"
 565 "    ADD     R0, SP, #0x10 \n"
 566 "    ADD     R0, R0, R4, LSL#1 \n"
 567 "    STRH    R1, [R11] \n"
 568 "    STR     R0, [SP, #0x18] \n"
 569 "    LDRSH   R3, [R0] \n"
 570 "    SUB     R2, R1, R3 \n"
 571 "    CMP     R2, #0 \n"
 572 "    BNE     loc_FF04E02C \n"
 573 "    LDR     R0, [R9, R4, LSL#2] \n"
 574 "    CMP     R0, #0 \n"
 575 "    BEQ     loc_FF04E108 \n"
 576 "    LDR     R7, =0x2638 \n"
 577 "    LDR     R0, [R7, R4, LSL#2] \n"
 578 "    BL      sub_FF025BC4 /*_CancelTimer*/ \n"
 579 "    LDR     R2, =0xFF04DE08 \n"
 580 "    ORR     R3, R4, #0x300 \n"
 581 "    MOV     R1, R2 \n"
 582 "    MOV     R0, #0x1F4 \n"
 583 "    BL      sub_FF025AE0 /*_SetTimerAfter*/ \n"
 584 "    TST     R0, #1 \n"
 585 "    CMPNE   R0, #0x15 \n"
 586 "    STR     R0, [R7, R4, LSL#2] \n"
 587 "    BEQ     loc_FF04E108 \n"
 588 "    LDR     R1, =0x22B \n"
 589 "    B       loc_FF04E100 \n"
 590 
 591 "loc_FF04E02C:\n"
 592 "    MOV     R0, R2 \n"
 593 "    RSBLT   R0, R0, #0 \n"
 594 "    MOVLE   R7, #0 \n"
 595 "    MOVGT   R7, #1 \n"
 596 "    CMP     R0, #0xFF \n"
 597 "    BLS     loc_FF04E068 \n"
 598 "    LDR     R0, =0x7FFF \n"
 599 "    CMP     R2, #0 \n"
 600 "    SUBLE   R0, R0, R3 \n"
 601 "    ADDLE   R0, R0, R1 \n"
 602 "    SUBGT   R0, R0, R1 \n"
 603 "    ADDGT   R0, R0, R3 \n"
 604 "    MVN     R1, #0x8000 \n"
 605 "    SUB     R0, R0, R1 \n"
 606 "    EOR     R7, R7, #1 \n"
 607 
 608 "loc_FF04E068:\n"
 609 "    STR     R0, [SP, #4] \n"
 610 "    LDR     R0, [R9, R4, LSL#2] \n"
 611 "    CMP     R0, #0 \n"
 612 "    ADDEQ   R0, R6, R5, LSL#2 \n"
 613 "    LDREQ   R0, [R0, #8] \n"
 614 "    BEQ     loc_FF04E0A0 \n"
 615 "    ADD     R8, R6, R5, LSL#2 \n"
 616 "    ADD     R1, R8, R7, LSL#2 \n"
 617 "    LDR     R1, [R1, #0x10] \n"
 618 "    CMP     R1, R0 \n"
 619 "    BEQ     loc_FF04E0A4 \n"
 620 "    LDR     R0, [R8, #0xC] \n"
 621 "    BL      sub_FF01F1E0 \n"
 622 "    LDR     R0, [R8, #8] \n"
 623 
 624 "loc_FF04E0A0:\n"
 625 "    BL      sub_FF01F1E0 \n"
 626 
 627 "loc_FF04E0A4:\n"
 628 "    ADD     R0, R6, R5, LSL#2 \n"
 629 "    ADD     R7, R0, R7, LSL#2 \n"
 630 "    LDR     R0, [R7, #0x10] \n"
 631 "    LDR     R1, [SP, #4] \n"
 632 "    BL      sub_FF01F1F0 \n"
 633 "    LDR     R0, [R7, #0x10] \n"
 634 "    LDR     R7, =0x2638 \n"
 635 "    STR     R0, [R9, R4, LSL#2] \n"
 636 "    LDRH    R1, [R11] \n"
 637 "    LDR     R0, [SP, #0x18] \n"
 638 "    STRH    R1, [R0] \n"
 639 "    LDR     R0, [R7, R4, LSL#2] \n"
 640 "    BL      sub_FF025BC4 /*_CancelTimer*/ \n"
 641 "    LDR     R2, =0xFF04DE08 \n"
 642 "    ORR     R3, R4, #0x300 \n"
 643 "    MOV     R1, R2 \n"
 644 "    MOV     R0, #0x1F4 \n"
 645 "    BL      sub_FF025AE0 /*_SetTimerAfter*/ \n"
 646 "    TST     R0, #1 \n"
 647 "    CMPNE   R0, #0x15 \n"
 648 "    STR     R0, [R7, R4, LSL#2] \n"
 649 "    BEQ     loc_FF04E108 \n"
 650 "    MOV     R1, #0x25C \n"
 651 
 652 "loc_FF04E100:\n"
 653 "    LDR     R0, =0xFF04E15C /*'RotaryEncoder.c'*/ \n"
 654 "    BL      _DebugAssert \n"
 655 
 656 "loc_FF04E108:\n"
 657 "    ADD     R0, R6, R5, LSL#2 \n"
 658 "    LDR     R0, [R0, #0x18] \n"
 659 "    CMP     R0, #1 \n"
 660 "    BNE     loc_FF04E198 \n"
 661 "    LDR     R0, =0x262C \n"
 662 "    LDR     R0, [R0, #0x10] \n"
 663 "    CMP     R0, #0 \n"
 664 "    BEQ     loc_FF04E198 \n"
 665 "    LDR     R2, =0xFF04DDFC \n"
 666 "    ORR     R3, R4, #0x400 \n"
 667 "    MOV     R1, R2 \n"
 668 "    BL      sub_FF025AE0 /*_SetTimerAfter*/ \n"
 669 "    TST     R0, #1 \n"
 670 "    CMPNE   R0, #0x15 \n"
 671 "    STR     R0, [R10, R4, LSL#2] \n"
 672 "    BEQ     loc_FF04DF00 \n"
 673 "    LDR     R1, =0x263 \n"
 674 
 675 "loc_FF04E14C:\n"
 676 "    LDR     R0, =0xFF04E15C /*'RotaryEncoder.c'*/ \n"
 677 "    BL      _DebugAssert \n"
 678 "    B       loc_FF04DF00 \n"
 679 
 680 "loc_FF04E198:\n"
 681 "    LDR     R0, [R6, R5, LSL#2] \n"
 682 "    B       loc_FF04DF68 \n"
 683 
 684 "loc_FF04E1A0:\n"
 685 "    LDR     R0, [R9, R4, LSL#2] \n"
 686 "    CMP     R0, #0 \n"
 687 "    LDREQ   R1, =0x26D \n"
 688 "    LDREQ   R0, =0xFF04E15C /*'RotaryEncoder.c'*/ \n"
 689 "    BLEQ    _DebugAssert \n"
 690 "    RSB     R0, R4, R4, LSL#3 \n"
 691 "    ADD     R0, R6, R0, LSL#2 \n"
 692 "    LDR     R0, [R0, #0xC] \n"
 693 "    BL      sub_FF01F1E0 \n"
 694 "    MOV     R0, #0 \n"
 695 "    STR     R0, [R9, R4, LSL#2] \n"
 696 "    B       loc_FF04DF00 \n"
 697 );
 698 }

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