root/platform/s90/sub/101c/boot.c

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

DEFINITIONS

This source file includes following definitions.
  1. taskCreateHook
  2. taskCreateHook2
  3. boot
  4. sub_FF810354_my
  5. sub_FF811178_my
  6. sub_FF815E34_my
  7. taskcreate_Startup_my
  8. task_Startup_my
  9. spytask
  10. CreateTask_spytask
  11. CreateTask_PhySw
  12. init_file_modules_task
  13. sub_FF88D3AC_my
  14. sub_FF86DFAC_my
  15. sub_FF86DBE0_my
  16. sub_FF86D8DC_my
  17. JogDial_task_my

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "core.h"
   4 #include "stdlib.h"
   5 
   6 
   7 const char * const new_sa = &_end;
   8 
   9 
  10 // Forward declarations
  11 void CreateTask_PhySw();
  12 void CreateTask_spytask();
  13 extern volatile int jogdial_stopped;
  14 void JogDial_task_my(void);
  15 
  16 void taskCreateHook(int *p) { 
  17 p-=17;
  18 if (p[0]==0xFF87A258)  p[0]=(int)capt_seq_task;
  19 if (p[0]==0xFF96193C)  p[0]=(int)movie_record_task;
  20 if (p[0]==0xFF898364)  p[0]=(int)init_file_modules_task;
  21 if (p[0]==0xFF8C0ED0)  p[0]=(int)exp_drv_task;
  22 if (p[0]==0xFF85E508)  p[0]=(int)JogDial_task_my;
  23 if (p[0]==0xFFA791B0)  p[0]=(int)filewritetask;
  24 }
  25 
  26 void taskCreateHook2(int *p) { 
  27 p-=17;
  28 if (p[0]==0xFF898364)  p[0]=(int)init_file_modules_task;
  29 if (p[0]==0xFF8C0ED0)  p[0]=(int)exp_drv_task;
  30 if (p[0]==0xFFA791B0)  p[0]=(int)filewritetask;
  31 }
  32 
  33 void __attribute__((naked,noinline)) boot() {
  34     asm volatile (
  35         "LDR     R1, =0xC0410000\n"
  36         "MOV     R0, #0\n"
  37         "STR     R0, [R1]\n"
  38         "MOV     R1, #0x78\n"
  39         "MCR     p15, 0, R1,c1,c0\n"
  40         "MOV     R1, #0\n"
  41         "MCR     p15, 0, R1,c7,c10, 4\n"
  42         "MCR     p15, 0, R1,c7,c5\n"
  43         "MCR     p15, 0, R1,c7,c6\n"
  44         "MOV     R0, #0x3D\n"
  45         "MCR     p15, 0, R0,c6,c0\n"
  46         "MOV     R0, #0xC000002F\n"
  47         "MCR     p15, 0, R0,c6,c1\n"
  48         "MOV     R0, #0x33\n"
  49         "MCR     p15, 0, R0,c6,c2\n"
  50         "MOV     R0, #0x40000033\n"
  51         "MCR     p15, 0, R0,c6,c3\n"
  52         "MOV     R0, #0x80000017\n"
  53         "MCR     p15, 0, R0,c6,c4\n"
  54         "LDR     R0, =0xFF80002D\n"
  55         "MCR     p15, 0, R0,c6,c5\n"
  56         "MOV     R0, #0x34\n"
  57         "MCR     p15, 0, R0,c2,c0\n"
  58         "MOV     R0, #0x34\n"
  59         "MCR     p15, 0, R0,c2,c0, 1\n"
  60         "MOV     R0, #0x34\n"
  61         "MCR     p15, 0, R0,c3,c0\n"
  62         "LDR     R0, =0x3333330\n"
  63         "MCR     p15, 0, R0,c5,c0, 2\n"
  64         "LDR     R0, =0x3333330\n"
  65         "MCR     p15, 0, R0,c5,c0, 3\n"
  66         "MRC     p15, 0, R0,c1,c0\n"
  67         "ORR     R0, R0, #0x1000\n"
  68         "ORR     R0, R0, #4\n"
  69         "ORR     R0, R0, #1\n"
  70         "MCR     p15, 0, R0,c1,c0\n"
  71         "MOV     R1, #0x80000006\n"
  72         "MCR     p15, 0, R1,c9,c1\n"
  73         "MOV     R1, #6\n"
  74         "MCR     p15, 0, R1,c9,c1, 1\n"
  75         "MRC     p15, 0, R1,c1,c0\n"
  76         "ORR     R1, R1, #0x50000\n"
  77         "MCR     p15, 0, R1,c1,c0\n"
  78         "LDR     R2, =0xC0200000\n"
  79         "MOV     R1, #1\n"
  80         "STR     R1, [R2,#0x10C]\n"
  81         "MOV     R1, #0xFF\n"
  82         "STR     R1, [R2,#0xC]\n"
  83         "STR     R1, [R2,#0x1C]\n"
  84         "STR     R1, [R2,#0x2C]\n"
  85         "STR     R1, [R2,#0x3C]\n"
  86         "STR     R1, [R2,#0x4C]\n"
  87         "STR     R1, [R2,#0x5C]\n"
  88         "STR     R1, [R2,#0x6C]\n"
  89         "STR     R1, [R2,#0x7C]\n"
  90         "STR     R1, [R2,#0x8C]\n"
  91         "STR     R1, [R2,#0x9C]\n"
  92         "STR     R1, [R2,#0xAC]\n"
  93         "STR     R1, [R2,#0xBC]\n"
  94         "STR     R1, [R2,#0xCC]\n"
  95         "STR     R1, [R2,#0xDC]\n"
  96         "STR     R1, [R2,#0xEC]\n"
  97         "STR     R1, [R2,#0xFC]\n"
  98         "LDR     R1, =0xC0400008\n"
  99         "LDR     R2, =0x430005\n"
 100         "STR     R2, [R1]\n"
 101         "MOV     R1, #1\n"
 102         "LDR     R2, =0xC0243100\n"
 103         "STR     R2, [R1]\n"
 104         "LDR     R2, =0xC0242010\n"
 105         "LDR     R1, [R2]\n"
 106         "ORR     R1, R1, #1\n"
 107         "STR     R1, [R2]\n"
 108         "LDR     R0, =0xFFC14E98\n"
 109         "LDR     R1, =0x1900\n"
 110         "LDR     R3, =0xF470\n"
 111 "loc_FF81013C:\n"
 112         "CMP     R1, R3\n"
 113         "LDRCC   R2, [R0],#4\n"
 114         "STRCC   R2, [R1],#4\n"
 115         "BCC     loc_FF81013C\n"
 116         "LDR     R1, =0x141DBC\n"
 117         "MOV     R2, #0\n"
 118 "loc_FF810154:\n"
 119         "CMP     R3, R1\n"
 120         "STRCC   R2, [R3],#4\n"
 121         "BCC     loc_FF810154\n"
 122         //"B       loc_FF810354\n"
 123                 "B       sub_FF810354_my\n" // ---------------->
 124     );
 125 };
 126 
 127 void __attribute__((naked,noinline)) sub_FF810354_my() {
 128 
 129     *(int*)0x1930=(int)taskCreateHook; 
 130     *(int*)0x1934=(int)taskCreateHook2; 
 131     *(int*)0x1938=(int)taskCreateHook;          
 132     /* Power ON/OFF detection */
 133         *(int*)(0x254C)= (*(int*)0xC0220128)&1 ? 0x2000000 : 0x1000000; // replacement  for correct power-on.
 134                 asm volatile (
 135         "LDR     R0, =0xFF8103CC\n"
 136         "MOV     R1, #0\n"
 137         "LDR     R3, =0xFF810404\n"
 138 "loc_FF810360:\n"
 139         "CMP     R0, R3\n"
 140         "LDRCC   R2, [R0],#4\n"
 141         "STRCC   R2, [R1],#4\n"
 142         "BCC     loc_FF810360\n"
 143         "LDR     R0, =0xFF810404\n"
 144         "MOV     R1, #0x4B0\n"
 145         "LDR     R3, =0xFF810618\n"
 146 "loc_FF81037C:\n"
 147         "CMP     R0, R3\n"
 148         "LDRCC   R2, [R0],#4\n"
 149         "STRCC   R2, [R1],#4\n"
 150         "BCC     loc_FF81037C\n"
 151         "MOV     R0, #0xD2\n"
 152         "MSR     CPSR_cxsf, R0\n"
 153         "MOV     SP, #0x1000\n"
 154         "MOV     R0, #0xD3\n"
 155         "MSR     CPSR_cxsf, R0\n"
 156         "MOV     SP, #0x1000\n"
 157         "LDR     R0, =0x6C4\n"
 158         "LDR     R2, =0xEEEEEEEE\n"
 159         "MOV     R3, #0x1000\n"
 160 "loc_FF8103B0:\n"
 161         "CMP     R0, R3\n"
 162         "STRCC   R2, [R0],#4\n"
 163         "BCC     loc_FF8103B0\n"
 164         //"BL      sub_FF811178\n"
 165                 "BL      sub_FF811178_my\n" // ------------->
 166 "loc_FF8103C0:\n"
 167         "ANDEQ   R0, R0, R4,ASR#13\n"
 168 "loc_FF8103C4:\n"
 169         "ANDEQ   R0, R0, R0,ROR R6\n"
 170 "loc_FF8103C8:\n"
 171         "ANDEQ   R0, R0, R4,ROR R6\n"
 172         "NOP\n"
 173         "LDR     PC, =0xFF810618\n"
 174   );
 175 };
 176 
 177 void __attribute__((naked,noinline)) sub_FF811178_my() { 
 178         asm volatile (
 179         "STR     LR, [SP,#-4]!\n"
 180         "SUB     SP, SP, #0x74\n"
 181         "MOV     R0, SP\n"
 182         "MOV     R1, #0x74\n"
 183         "BL      sub_FFB35034\n"
 184         "MOV     R0, #0x53000\n"
 185         "STR     R0, [SP,#4]\n"
 186         //"LDR     R0, =0x141DBC\n"
 187                  "LDR     R0, =new_sa\n"        // +
 188                  "LDR     R0, [R0]\n"           // +    
 189         "LDR     R2, =0x379C00\n"
 190         "LDR     R1, =0x3724A8\n"
 191         "STR     R0, [SP,#8]\n"
 192         "SUB     R0, R1, R0\n"
 193         "ADD     R3, SP, #0xC\n"
 194         "STR     R2, [SP]\n"
 195         "STMIA   R3, {R0-R2}\n"
 196         "MOV     R0, #0x22\n"
 197         "STR     R0, [SP,#0x18]\n"
 198         "MOV     R0, #0x68\n"
 199         "STR     R0, [SP,#0x1C]\n"
 200         "LDR     R0, =0x19B\n"
 201         //"LDR     R1, =sub_FF815E34\n"
 202                 "LDR     R1, =sub_FF815E34_my\n" // ------------->
 203         "STR     R0, [SP,#0x20]\n"
 204         "MOV     R0, #0x96\n"
 205         "STR     R0, [SP,#0x24]\n"
 206         "MOV     R0, #0x78\n"
 207         "STR     R0, [SP,#0x28]\n"
 208         "MOV     R0, #0x64\n"
 209         "STR     R0, [SP,#0x2C]\n"
 210         "MOV     R0, #0\n"
 211         "STR     R0, [SP,#0x30]\n"
 212         "STR     R0, [SP,#0x34]\n"
 213         "MOV     R0, #0x10\n"
 214         "STR     R0, [SP,#0x5C]\n"
 215         "MOV     R0, #0x800\n"
 216         "STR     R0, [SP,#0x60]\n"
 217         "MOV     R0, #0xA0\n"
 218         "STR     R0, [SP,#0x64]\n"
 219         "MOV     R0, #0x280\n"
 220         "STR     R0, [SP,#0x68]\n"
 221         "MOV     R0, SP\n"
 222         "MOV     R2, #0\n"
 223         "BL      sub_FF8133E4\n"
 224         "ADD     SP, SP, #0x74\n"
 225         "LDR     PC, [SP],#4\n"
 226         );
 227 }; 
 228 
 229 void __attribute__((naked,noinline)) sub_FF815E34_my() {
 230         asm volatile (
 231 
 232         "STMFD   SP!, {R4,LR}\n"
 233         "BL      sub_FF810B08\n"
 234         "BL      sub_FF81A148\n"
 235         "CMP     R0, #0\n"
 236         "LDRLT   R0, =0xFF815F48\n"
 237         "BLLT    sub_FF815F28\n"
 238         "BL      sub_FF815A70\n"
 239         "CMP     R0, #0\n"
 240         "LDRLT   R0, =0xFF815F50\n"
 241         "BLLT    sub_FF815F28\n"
 242         "LDR     R0, =0xFF815F60\n"
 243         "BL      sub_FF815B58\n"
 244         "CMP     R0, #0\n"
 245         "LDRLT   R0, =0xFF815F68\n"
 246         "BLLT    sub_FF815F28\n"
 247         "LDR     R0, =0xFF815F60\n"
 248         "BL      sub_FF813BE0\n"
 249         "CMP     R0, #0\n"
 250         "LDRLT   R0, =0xFF815F7C\n"
 251         "BLLT    sub_FF815F28\n"
 252         "BL      sub_FF819B5C\n"
 253         "CMP     R0, #0\n"
 254         "LDRLT   R0, =0xFF815F88\n"
 255         "BLLT    sub_FF815F28\n"
 256         "BL      sub_FF81165C\n"
 257         "CMP     R0, #0\n"
 258         "LDRLT   R0, =0xFF815F94\n"
 259         "BLLT    sub_FF815F28\n"
 260         "LDMFD   SP!, {R4,LR}\n"
 261         //"B       sub_FF81F868\n"
 262                 "B       taskcreate_Startup_my\n" //---------->
 263         );
 264 }; 
 265 
 266 
 267 
 268 void __attribute__((naked,noinline)) taskcreate_Startup_my() { 
 269         asm volatile (  
 270         "STMFD   SP!, {R3-R5,LR}\n"
 271         "BL      sub_FF833350\n"
 272         "BL      sub_FF83A614\n"
 273         "CMP     R0, #0\n"
 274         "BNE     loc_FF81F8B0\n"
 275         "LDR     R4, =0xC0220000\n"
 276         "LDR     R0, [R4,#0x12C]\n"
 277         "TST     R0, #1\n"
 278         "MOVEQ   R0, #0x12C\n"
 279         "BLEQ    sub_FF838A50    \n"
 280         "BL      sub_FF83334C\n"
 281         "CMP     R0, #0\n"
 282         "BNE     loc_FF81F8B0\n"
 283         "BL      sub_FF8329F4\n"
 284         "MOV     R0, #0x44\n"
 285         "STR     R0, [R4,#0x1C]\n"
 286         "BL      sub_FF832BE8\n"
 287 "loc_FF81F8AC:\n"
 288         "B       loc_FF81F8AC\n"
 289 "loc_FF81F8B0:\n"
 290         //"BL      sub_FF833358\n"      // removed, see boot() function
 291         "BL      sub_FF833354\n"
 292         "BL      sub_FF8388C8\n"
 293         "LDR     R1, =0x3CE000\n"
 294         "MOV     R0, #0\n"
 295         "BL      sub_FF838D10\n"
 296         "BL      sub_FF838ABC    \n"
 297         "MOV     R3, #0\n"
 298         "STR     R3, [SP]\n"
 299         //"ADR     R3, sub_FF81F804\n"
 300                 "LDR     R3, =task_Startup_my\n" //+ ----------->
 301         "MOV     R2, #0\n"
 302         "MOV     R1, #0x19\n"
 303         "LDR     R0, =0xFF81F8F8\n"
 304         "BL      sub_FF81E5B4    \n"
 305         "MOV     R0, #0\n"
 306         "LDMFD   SP!, {R3-R5,PC}\n"
 307  );
 308 }; 
 309 
 310 
 311 void __attribute__((naked,noinline)) task_Startup_my() { 
 312 
 313         asm volatile (
 314 
 315         "STMFD   SP!, {R4,LR}\n"
 316         "BL      sub_FF816490\n"
 317         "BL      sub_FF83444C\n"
 318         "BL      sub_FF832670\n"
 319         "BL      sub_FF83A654\n"
 320         "BL      sub_FF83A838\n"
 321         //"BL      sub_FF83A6E8\n" // Skip starting diskboot.bin again
 322         "BL      sub_FF83A9D8\n"
 323         "BL      sub_FF83136C\n"
 324         "BL      sub_FF83A868\n"
 325         "BL      sub_FF83806C\n"
 326         "BL      sub_FF83A9DC\n"
 327         //"BL      sub_FF83323C\n" //; taskcreate_PhySw
 328 
 329         );      
 330         CreateTask_PhySw(); // +
 331         CreateTask_spytask();  // +
 332      
 333     asm volatile (              
 334         "BL      sub_FF836080\n"
 335         "BL      sub_FF83A9F4\n"
 336         "BL      sub_FF8306A4\n"
 337         "BL      sub_FF831FC8\n"
 338         "BL      sub_FF83A3F0\n"
 339         "BL      sub_FF832624\n"
 340         "BL      sub_FF831ED4    \n"
 341         "BL      sub_FF8313A0\n"
 342         "BL      sub_FF83B564\n"
 343         "BL      sub_FF831EAC\n"
 344         "LDMFD   SP!, {R4,LR}\n"
 345         "B       sub_FF8165B0    \n"
 346         );
 347 }; 
 348 
 349 void spytask(long ua, long ub, long uc, long ud, long ue, long uf)
 350 {
 351     core_spytask();
 352 }
 353 void CreateTask_spytask() { 
 354         _CreateTask("SpyTask", 0x19, 0x2000, spytask, 0);
 355 };
 356 
 357 void __attribute__((naked,noinline)) CreateTask_PhySw() {
 358         asm volatile (
 359                          "STMFD   SP!, {R3-R5,LR}\n"
 360         "LDR     R4, =0x1C38\n"
 361         "LDR     R0, [R4,#0x10]\n"
 362         "CMP     R0, #0\n"
 363         "BNE     loc_FF833270\n"
 364         "MOV     R3, #0\n"
 365         "STR     R3, [SP]\n"
 366         //"ADR     R3, task_PhySw\n"
 367         //"MOV     R2, #0x800\n"
 368                 "LDR     R3, =mykbd_task\n"  // task_phySw
 369                 "MOV     R2, #0x2000\n"         // greater Stacksize
 370         "MOV     R1, #0x17\n"
 371         "LDR     R0, =0xFF833444\n"
 372         "BL      sub_FF838B10    \n"
 373         "STR     R0, [R4,#0x10]\n"
 374 "loc_FF833270:\n"
 375         "BL      sub_FF85E8B0\n"
 376         "BL      sub_FF88AF7C\n"
 377         "BL      sub_FF861E20\n"
 378         "CMP     R0, #0\n"
 379         "LDREQ   R1, =0x330E4\n"
 380         "LDMEQFD SP!, {R3-R5,LR}\n"
 381         "BEQ     sub_FF88AF04\n"
 382         "LDMFD   SP!, {R3-R5,PC}\n"
 383         );
 384 };
 385 
 386 
 387 void __attribute__((naked,noinline)) init_file_modules_task() { 
 388   asm volatile (
 389         "STMFD   SP!, {R4-R6,LR}\n"
 390         "BL      sub_FF88D380\n"
 391         "LDR     R5, =0x5006\n"
 392         "MOVS    R4, R0\n"
 393         "MOVNE   R1, #0\n"
 394         "MOVNE   R0, R5\n"
 395         "BLNE    sub_FF892570\n"
 396         //"BL      sub_FF88D3AC\n"
 397                 "BL      sub_FF88D3AC_my\n" // ----------------->
 398                 "BL      core_spytask_can_start\n"      // +
 399         "CMP     R4, #0\n"
 400         "MOVEQ   R0, R5\n"
 401         "LDMEQFD SP!, {R4-R6,LR}\n"
 402         "MOVEQ   R1, #0\n"
 403         "BEQ     sub_FF892570\n"
 404         "LDMFD   SP!, {R4-R6,PC}\n"
 405  );
 406 }; 
 407 
 408 void __attribute__((naked,noinline)) sub_FF88D3AC_my() { 
 409  asm volatile (
 410 
 411         "STMFD   SP!, {R4,LR}\n"
 412         "MOV     R0, #3\n"
 413         //"BL      sub_FF86DFAC    \n"
 414                 "BL      sub_FF86DFAC_my\n" //---------------->
 415         "BL      sub_FF947678\n"
 416         "LDR     R4, =0x302C\n"
 417         "LDR     R0, [R4,#4]\n"
 418         "CMP     R0, #0\n"
 419         "BNE     loc_FF88D3E4\n"
 420         "BL      sub_FF86D2B8\n"
 421         "BL      sub_FF93B6B4\n"
 422         "BL      sub_FF86D2B8\n"
 423         "BL      sub_FF8695B4\n"
 424         "BL      sub_FF86D1B8\n"
 425         "BL      sub_FF93B77C\n"
 426 "loc_FF88D3E4:\n"
 427         "MOV     R0, #1\n"
 428         "STR     R0, [R4]\n"
 429         "LDMFD   SP!, {R4,PC}\n"
 430  );
 431 }; 
 432 
 433 
 434 void __attribute__((naked,noinline)) sub_FF86DFAC_my() {
 435  asm volatile (
 436 
 437         "STMFD   SP!, {R4-R8,LR}\n"
 438         "MOV     R8, R0\n"
 439         "BL      sub_FF86DF2C    \n"
 440         "LDR     R1, =0x37EA0\n"
 441         "MOV     R6, R0\n"
 442         "ADD     R4, R1, R0,LSL#7\n"
 443         "LDR     R0, [R4,#0x6C]\n"
 444         "CMP     R0, #4\n"
 445         "LDREQ   R1, =0x804\n"
 446         "LDREQ   R0, =0xFF86DA78\n"
 447         "BLEQ    sub_FF81E88C\n"
 448         "MOV     R1, R8\n"
 449         "MOV     R0, R6\n"
 450         "BL      sub_FF86D7CC    \n"
 451         "LDR     R0, [R4,#0x38]\n"
 452         "BL      sub_FF86E5C8\n"
 453         "CMP     R0, #0\n"
 454         "STREQ   R0, [R4,#0x6C]\n"
 455         "MOV     R0, R6\n"
 456         "BL      sub_FF86D85C\n"
 457         "MOV     R0, R6\n"
 458         //"BL      sub_FF86DBE0\n"
 459                 "BL      sub_FF86DBE0_my\n" // ------------>
 460         "MOV     R5, R0\n"
 461         "MOV     R0, R6\n"
 462         "BL      sub_FF86DE08    \n"
 463         "LDR     R6, [R4,#0x3C]\n"
 464         "AND     R7, R5, R0\n"
 465         "CMP     R6, #0\n"
 466         "LDR     R1, [R4,#0x38]\n"
 467         "MOVEQ   R0, #0x80000001\n"
 468         "MOV     R5, #0\n"
 469         "BEQ     loc_FF86E05C\n"
 470         "MOV     R0, R1\n"
 471         "BL      sub_FF86D420\n"
 472         "CMP     R0, #0\n"
 473         "MOVNE   R5, #4\n"
 474         "CMP     R6, #5\n"
 475         "ORRNE   R0, R5, #1\n"
 476         "BICEQ   R0, R5, #1\n"
 477         "CMP     R7, #0\n"
 478         "BICEQ   R0, R0, #2\n"
 479         "ORREQ   R0, R0, #0x80000000\n"
 480         "BICNE   R0, R0, #0x80000000\n"
 481         "ORRNE   R0, R0, #2\n"
 482 "loc_FF86E05C:\n"
 483         "CMP     R8, #7\n"
 484         "STR     R0, [R4,#0x40]\n"
 485         "LDMNEFD SP!, {R4-R8,PC}\n"
 486         "MOV     R0, R8\n"
 487         "BL      sub_FF86DF7C\n"
 488         "CMP     R0, #0\n"
 489         "LDMEQFD SP!, {R4-R8,LR}\n"
 490         "LDREQ   R0, =0xFF86E0A8\n"
 491         "BEQ     sub_FF81175C\n"
 492         "LDMFD   SP!, {R4-R8,PC}\n"
 493  );
 494 }; 
 495 
 496 void __attribute__((naked,noinline)) sub_FF86DBE0_my() {
 497 
 498  asm volatile (
 499         "STMFD   SP!, {R4-R6,LR}\n"
 500         "MOV     R5, R0\n"
 501         "LDR     R0, =0x37EA0\n"
 502         "ADD     R4, R0, R5,LSL#7\n"
 503         "LDR     R0, [R4,#0x6C]\n"
 504         "TST     R0, #2\n"
 505         "MOVNE   R0, #1\n"
 506         "LDMNEFD SP!, {R4-R6,PC}\n"
 507         "LDR     R0, [R4,#0x38]\n"
 508         "MOV     R1, R5\n"
 509         //"BL      sub_FF86D8DC    \n"
 510                 "BL      sub_FF86D8DC_my\n" // ------------------>
 511         "CMP     R0, #0\n"
 512         "LDRNE   R0, [R4,#0x38]\n"
 513         "MOVNE   R1, R5\n"
 514         "BLNE    sub_FF86DA9C    \n"
 515         "LDR     R2, =0x37F20\n"
 516         "ADD     R1, R5, R5,LSL#4\n"
 517         "LDR     R1, [R2,R1,LSL#2]\n"
 518         "CMP     R1, #4\n"
 519         "BEQ     loc_FF86DC40\n"
 520         "CMP     R0, #0\n"
 521         "LDMEQFD SP!, {R4-R6,PC}\n"
 522         "MOV     R0, R5\n"
 523         "BL      sub_FF86D4B0\n"
 524 "loc_FF86DC40:\n"
 525         "CMP     R0, #0\n"
 526         "LDRNE   R1, [R4,#0x6C]\n"
 527         "ORRNE   R1, R1, #2\n"
 528         "STRNE   R1, [R4,#0x6C]\n"
 529         "LDMFD   SP!, {R4-R6,PC}\n"
 530  );
 531 };
 532 
 533 
 534 void __attribute__((naked,noinline)) sub_FF86D8DC_my() {
 535  asm volatile ( 
 536         "STMFD   SP!, {R4-R10,LR}\n"
 537         "MOV     R9, R0\n"
 538         "LDR     R0, =0x37EA0\n"
 539         "MOV     R8, #0\n"
 540         "ADD     R5, R0, R1,LSL#7\n"
 541         "LDR     R0, [R5,#0x3C]\n"
 542         "MOV     R7, #0\n"
 543         "CMP     R0, #7\n"
 544         "MOV     R6, #0\n"
 545         "ADDLS   PC, PC, R0,LSL#2\n"
 546         "B       loc_FF86DA34\n"
 547 "loc_FF86D908:\n"
 548         "B       loc_FF86D940\n"
 549 "loc_FF86D90C:\n"
 550         "B       loc_FF86D928\n"
 551 "loc_FF86D910:\n"
 552         "B       loc_FF86D928\n"
 553 "loc_FF86D914:\n"
 554         "B       loc_FF86D928\n"
 555 "loc_FF86D918:\n"
 556         "B       loc_FF86D928\n"
 557 "loc_FF86D91C:\n"
 558         "B       loc_FF86DA2C\n"
 559 "loc_FF86D920:\n"
 560         "B       loc_FF86D928\n"
 561 "loc_FF86D924:\n"
 562         "B       loc_FF86D928\n"
 563 "loc_FF86D928:\n"
 564         "MOV     R2, #0\n"
 565         "MOV     R1, #0x200\n"
 566         "MOV     R0, #2\n"
 567         "BL      sub_FF887400\n"
 568         "MOVS    R4, R0\n"
 569         "BNE     loc_FF86D948\n"
 570 "loc_FF86D940:\n"
 571         "MOV     R0, #0\n"
 572         "LDMFD   SP!, {R4-R10,PC}\n"
 573 "loc_FF86D948:\n"
 574         "LDR     R12, [R5,#0x50]\n"
 575         "MOV     R3, R4\n"
 576         "MOV     R2, #1\n"
 577         "MOV     R1, #0\n"
 578         "MOV     R0, R9\n"
 579         "BLX     R12\n"
 580         "CMP     R0, #1\n"
 581         "BNE     loc_FF86D974\n"
 582         "MOV     R0, #2\n"
 583         "BL      sub_FF88754C    \n"
 584         "B       loc_FF86D940\n"
 585 "loc_FF86D974:\n"
 586         "LDR     R1, [R5,#0x64]\n"
 587         "MOV     R0, R9\n"
 588         "BLX     R1\n"
 589 
 590                "MOV   R1, R4\n"           //  pointer to MBR in R1
 591                                 "BL    mbr_read_dryos\n"   //  total sectors count in R0 before and after call
 592 
 593                 // Start of DataGhost's FAT32 autodetection code
 594                 // Policy: If there is a partition which has type W95 FAT32, use the first one of those for image storage
 595                 // According to the code below, we can use R1, R2, R3 and R12.
 596                 // LR wasn't really used anywhere but for storing a part of the partition signature. This is the only thing
 597                 // that won't work with an offset, but since we can load from LR+offset into LR, we can use this to do that :)
 598                 "MOV     R12, R4\n"                    // Copy the MBR start address so we have something to work with
 599                 "MOV     LR, R4\n"                     // Save old offset for MBR signature
 600                 "MOV     R1, #1\n"                     // Note the current partition number
 601                 "B       dg_sd_fat32_enter\n"          // We actually need to check the first partition as well, no increments yet!
 602            "dg_sd_fat32:\n"
 603                 "CMP     R1, #4\n"                     // Did we already see the 4th partition?
 604                 "BEQ     dg_sd_fat32_end\n"            // Yes, break. We didn't find anything, so don't change anything.
 605                 "ADD     R12, R12, #0x10\n"            // Second partition
 606                 "ADD     R1, R1, #1\n"                 // Second partition for the loop
 607            "dg_sd_fat32_enter:\n"
 608                 "LDRB    R2, [R12, #0x1BE]\n"          // Partition status
 609                 "LDRB    R3, [R12, #0x1C2]\n"          // Partition type (FAT32 = 0xB)
 610                 "CMP     R3, #0xB\n"                   // Is this a FAT32 partition?
 611                 "CMPNE   R3, #0xC\n"                   // Not 0xB, is it 0xC (FAT32 LBA) then?
 612                 "BNE     dg_sd_fat32\n"                // No, it isn't.
 613                 "CMP     R2, #0x00\n"                  // It is, check the validity of the partition type
 614                 "CMPNE   R2, #0x80\n"
 615                 "BNE     dg_sd_fat32\n"                // Invalid, go to next partition
 616                                                        // This partition is valid, it's the first one, bingo!
 617                 "MOV     R4, R12\n"                    // Move the new MBR offset for the partition detection.
 618                 
 619            "dg_sd_fat32_end:\n"
 620                 // End of DataGhost's FAT32 autodetection code    
 621 
 622         "LDRB    R1, [R4,#0x1C9]\n"
 623         "LDRB    R3, [R4,#0x1C8]\n"
 624         "LDRB    R12, [R4,#0x1CC]\n"
 625         "MOV     R1, R1,LSL#24\n"
 626         "ORR     R1, R1, R3,LSL#16\n"
 627         "LDRB    R3, [R4,#0x1C7]\n"
 628         "LDRB    R2, [R4,#0x1BE]\n"
 629                                         //"LDRB    LR, [R4,#0x1FF]\n"  // replaced, see below
 630         "ORR     R1, R1, R3,LSL#8\n"
 631         "LDRB    R3, [R4,#0x1C6]\n"
 632         "CMP     R2, #0\n"
 633         "CMPNE   R2, #0x80\n"
 634         "ORR     R1, R1, R3\n"
 635         "LDRB    R3, [R4,#0x1CD]\n"
 636         "MOV     R3, R3,LSL#24\n"
 637         "ORR     R3, R3, R12,LSL#16\n"
 638         "LDRB    R12, [R4,#0x1CB]\n"
 639         "ORR     R3, R3, R12,LSL#8\n"
 640         "LDRB    R12, [R4,#0x1CA]\n"
 641         "ORR     R3, R3, R12\n"
 642                                         //"LDRB    R12, [R4,#0x1FE]\n"
 643                 "LDRB    R12, [LR,#0x1FE]\n"        // New! First MBR signature byte (0x55)
 644         "LDRB    LR, [LR,#0x1FF]\n"         //      Last MBR signature byte (0xAA)      
 645 
 646         "BNE     loc_FF86DA00\n"
 647         "CMP     R0, R1\n"
 648         "BCC     loc_FF86DA00\n"
 649         "ADD     R2, R1, R3\n"
 650         "CMP     R2, R0\n"
 651         "CMPLS   R12, #0x55\n"
 652         "CMPEQ   LR, #0xAA\n"
 653         "MOVEQ   R7, R1\n"
 654         "MOVEQ   R6, R3\n"
 655         "MOVEQ   R4, #1\n"
 656         "BEQ     loc_FF86DA04\n"
 657 "loc_FF86DA00:\n"
 658         "MOV     R4, R8\n"
 659 "loc_FF86DA04:\n"
 660         "MOV     R0, #2\n"
 661         "BL      sub_FF88754C    \n"
 662         "CMP     R4, #0\n"
 663         "BNE     loc_FF86DA40\n"
 664         "LDR     R1, [R5,#0x64]\n"
 665         "MOV     R7, #0\n"
 666         "MOV     R0, R9\n"
 667         "BLX     R1\n"
 668         "MOV     R6, R0\n"
 669         "B       loc_FF86DA40\n"
 670 "loc_FF86DA2C:\n"
 671         "MOV     R6, #0x40\n"
 672         "B       loc_FF86DA40\n"
 673 "loc_FF86DA34:\n"
 674         "LDR     R1, =0x568\n"
 675         "LDR     R0, =0xFF86DA78\n"
 676         "BL      sub_FF81E88C\n"
 677 "loc_FF86DA40:\n"
 678         "STR     R7, [R5,#0x44]!\n"
 679         "STMIB   R5, {R6,R8}\n"
 680         "MOV     R0, #1\n"
 681         "LDMFD   SP!, {R4-R10,PC}\n"
 682  );
 683 }; 
 684 
 685 void __attribute__((naked,noinline)) JogDial_task_my() {
 686         asm volatile (  
 687         "STMFD   SP!, {R4-R11,LR}\n"
 688         "SUB     SP, SP, #0x34\n"
 689         "BL      sub_FF85E904    \n"
 690         "LDR     R1, =0x2560\n"
 691         "LDR     R9, =0xFFB3AD1C\n"
 692         "MOV     R0, #0\n"
 693         "ADD     R2, SP, #0x1C\n"
 694         "ADD     R3, SP, #0x20\n"
 695         "ADD     R10, SP, #0xC\n"
 696         "ADD     R8, SP, #0x14\n"
 697         "MOV     R7, #0\n"
 698 "loc_FF85E534:\n"
 699         "ADD     R3, SP, #0x20\n"
 700         "ADD     R12, R3, R0,LSL#1\n"
 701         "ADD     R2, SP, #0x1C\n"
 702         "STRH    R7, [R12]\n"
 703         "ADD     R12, R2, R0,LSL#1\n"
 704         "STRH    R7, [R12]\n"
 705         "STR     R7, [R8,R0,LSL#2]\n"
 706         "STR     R7, [R10,R0,LSL#2]\n"
 707         "ADD     R0, R0, #1\n"
 708         "CMP     R0, #2\n"
 709         "BLT     loc_FF85E534\n"
 710 "loc_FF85E560:\n"
 711         "LDR     R0, =0x2560\n"
 712         "MOV     R2, #0\n"
 713         "LDR     R0, [R0,#8]\n"
 714         "ADD     R1, SP, #4\n"
 715         "BL      sub_FF8382FC    \n"
 716         "TST     R0, #1\n"
 717         "LDRNE   R1, =0x229\n"
 718         "LDRNE   R0, =0xFF85E830\n"
 719         "BLNE    sub_FF81E88C\n"
 720 //------------------  added code ---------------------
 721 "labelA:\n"
 722                 "LDR     R0, =jogdial_stopped\n"
 723                 "LDR     R0, [R0]\n"
 724                 "CMP     R0, #1\n"
 725                 "BNE     labelB\n"
 726                 "MOV     R0, #40\n"
 727                 "BL      _SleepTask\n"
 728                 "B       labelA\n"
 729 "labelB:\n"
 730 //------------------  original code ------------------
 731         "LDR     R0, [SP,#4]\n"
 732         "AND     R4, R0, #0xFF\n"
 733         "AND     R0, R0, #0xFF00\n"
 734         "CMP     R0, #0x100\n"
 735         "BEQ     loc_FF85E5E4\n"
 736         "CMP     R0, #0x200\n"
 737         "BEQ     loc_FF85E61C\n"
 738         "CMP     R0, #0x300\n"
 739         "BEQ     loc_FF85E884\n"
 740         "CMP     R0, #0x400\n"
 741         "BNE     loc_FF85E560\n"
 742         "CMP     R4, #0\n"
 743         "LDRNE   R1, =0x2DB\n"
 744         "LDRNE   R0, =0xFF85E830\n"
 745         "BLNE    sub_FF81E88C\n"
 746         "LDR     R2, =0xFFB3ACF4\n"
 747         "ADD     R0, R4, R4,LSL#2\n"
 748         "LDR     R1, [R2,R0,LSL#2]\n"
 749         "STR     R7, [R1]\n"
 750         "MOV     R1, #1\n"
 751         "ADD     R0, R2, R0,LSL#2\n"
 752 "loc_FF85E5D8:\n"
 753         "LDR     R0, [R0,#8]\n"
 754         "STR     R1, [R0]\n"
 755         "B       loc_FF85E560\n"
 756 "loc_FF85E5E4:\n"
 757         "LDR     R5, =0x2570\n"
 758         "LDR     R0, [R5,R4,LSL#2]\n"
 759         "BL      sub_FF839294\n"
 760         "LDR     R2, =0xFF85E45C\n"
 761         "ADD     R1, R2, #0\n"
 762         "ORR     R3, R4, #0x200\n"
 763         "MOV     R0, #0x28\n"
 764         "BL      sub_FF8391B0\n"
 765         "TST     R0, #1\n"
 766         "CMPNE   R0, #0x15\n"
 767         "STR     R0, [R10,R4,LSL#2]\n"
 768         "BEQ     loc_FF85E560\n"
 769         "LDR     R1, =0x23E\n"
 770         "B       loc_FF85E81C\n"
 771 "loc_FF85E61C:\n"
 772         "LDR     R1, =0xFFB3ACF4\n"
 773         "ADD     R0, R4, R4,LSL#2\n"
 774         "STR     R0, [SP,#0x30]\n"
 775         "ADD     R0, R1, R0,LSL#2\n"
 776         "STR     R0, [SP,#0x2C]\n"
 777         "LDR     R0, [R0,#4]\n"
 778         "LDR     R0, [R0]\n"
 779         "MOV     R2, R0,ASR#16\n"
 780         "ADD     R0, SP, #0x20\n"
 781         "ADD     R0, R0, R4,LSL#1\n"
 782         "STR     R0, [SP,#0x28]\n"
 783         "STRH    R2, [R0]\n"
 784         "ADD     R0, SP, #0x1C\n"
 785         "ADD     R0, R0, R4,LSL#1\n"
 786         "STR     R0, [SP,#0x24]\n"
 787         "LDRSH   R3, [R0]\n"
 788         "SUB     R0, R2, R3\n"
 789         "CMP     R0, #0\n"
 790         "BNE     loc_FF85E6AC\n"
 791         "LDR     R0, [R8,R4,LSL#2]\n"
 792         "CMP     R0, #0\n"
 793         "BEQ     loc_FF85E7D4\n"
 794         "LDR     R5, =0x2570\n"
 795         "LDR     R0, [R5,R4,LSL#2]\n"
 796         "BL      sub_FF839294\n"
 797         "LDR     R2, =0xFF85E468 \n"
 798         "ADD     R1, R2, #0\n"
 799         "ORR     R3, R4, #0x300\n"
 800         "MOV     R0, #0x1F4\n"
 801         "BL      sub_FF8391B0\n"
 802         "TST     R0, #1\n"
 803         "CMPNE   R0, #0x15\n"
 804         "STR     R0, [R5,R4,LSL#2]\n"
 805         "BEQ     loc_FF85E7D4\n"
 806         "LDR     R1, =0x25B\n"
 807         "B       loc_FF85E7CC\n"
 808 "loc_FF85E6AC:\n"
 809         "MOV     R1, R0\n"
 810         "RSBLT   R0, R0, #0\n"
 811         "MOVLE   R5, #0\n"
 812         "MOVGT   R5, #1\n"
 813         "CMP     R0, #0xFF\n"
 814         "BLS     loc_FF85E6EC\n"
 815         "CMP     R1, #0\n"
 816         "RSBLE   R0, R3, #0xFF\n"
 817         "ADDLE   R0, R0, #0x7F00\n"
 818         "ADDLE   R0, R0, R2\n"
 819         "RSBGT   R0, R2, #0xFF\n"
 820         "ADDGT   R0, R0, #0x7F00\n"
 821         "ADDGT   R0, R0, R3\n"
 822         "ADD     R0, R0, #0x8000\n"
 823         "ADD     R0, R0, #1\n"
 824         "EOR     R5, R5, #1\n"
 825 "loc_FF85E6EC:\n"
 826         "STR     R0, [SP,#8]\n"
 827         "LDR     R0, [R8,R4,LSL#2]\n"
 828         "CMP     R0, #0\n"
 829         "BEQ     loc_FF85E73C\n"
 830         "LDR     R1, =0xFFB3AD34\n"
 831         "ADD     R1, R1, R4,LSL#3\n"
 832         "LDR     R1, [R1,R5,LSL#2]\n"
 833         "CMP     R1, R0\n"
 834         "BEQ     loc_FF85E758\n"
 835         "ADD     R11, R4, R4,LSL#1\n"
 836         "ADD     R6, R9, R11,LSL#2\n"
 837         "LDRB    R0, [R6,#9]\n"
 838         "CMP     R0, #1\n"
 839         "LDREQ   R0, [R6,#4]\n"
 840         "BLEQ    sub_FF8943D0\n"
 841         "LDRB    R0, [R6,#8]\n"
 842         "CMP     R0, #1\n"
 843         "BNE     loc_FF85E758\n"
 844         "LDR     R0, [R9,R11,LSL#2]\n"
 845         "B       loc_FF85E754\n"
 846 "loc_FF85E73C:\n"
 847         "ADD     R0, R4, R4,LSL#1\n"
 848         "ADD     R1, R9, R0,LSL#2\n"
 849         "LDRB    R1, [R1,#8]\n"
 850         "CMP     R1, #1\n"
 851         "BNE     loc_FF85E758\n"
 852         "LDR     R0, [R9,R0,LSL#2]\n"
 853 "loc_FF85E754:\n"
 854         "BL      sub_FF8943D0\n"
 855 "loc_FF85E758:\n"
 856         "LDR     R0, =0xFFB3AD34\n"
 857         "LDR     R1, [SP,#8]\n"
 858         "ADD     R6, R0, R4,LSL#3\n"
 859         "LDR     R0, [R6,R5,LSL#2]\n"
 860         "BL      sub_FF894300\n"
 861         "LDR     R0, [R6,R5,LSL#2]\n"
 862         "STR     R0, [R8,R4,LSL#2]\n"
 863         "LDR     R0, [SP,#0x28]\n"
 864         "LDR     R1, [SP,#0x24]\n"
 865         "LDRH    R0, [R0]\n"
 866         "STRH    R0, [R1]\n"
 867         "ADD     R0, R4, R4,LSL#1\n"
 868         "ADD     R0, R9, R0,LSL#2\n"
 869         "LDRB    R0, [R0,#9]\n"
 870         "CMP     R0, #1\n"
 871         "BNE     loc_FF85E7D4\n"
 872         "LDR     R5, =0x2570\n"
 873         "LDR     R0, [R5,R4,LSL#2]\n"
 874         "BL      sub_FF839294\n"
 875         "LDR     R2, =0xFF85E468 \n"
 876         "ADD     R1, R2, #0\n"
 877         "ORR     R3, R4, #0x300\n"
 878         "MOV     R0, #0x1F4\n"
 879         "BL      sub_FF8391B0\n"
 880         "TST     R0, #1\n"
 881         "CMPNE   R0, #0x15\n"
 882         "STR     R0, [R5,R4,LSL#2]\n"
 883         "BEQ     loc_FF85E7D4\n"
 884         "LDR     R1, =0x2B5\n"
 885 "loc_FF85E7CC:\n"
 886         "LDR     R0, =0xFF85E830\n"
 887         "BL      sub_FF81E88C\n"
 888 "loc_FF85E7D4:\n"
 889         "ADD     R0, R4, R4,LSL#1\n"
 890         "ADD     R0, R9, R0,LSL#2\n"
 891         "LDRB    R0, [R0,#0xA]\n"
 892         "CMP     R0, #1\n"
 893         "BNE     loc_FF85E868\n"
 894         "LDR     R0, =0x2560\n"
 895         "LDR     R0, [R0,#0xC]\n"
 896         "CMP     R0, #0\n"
 897         "BEQ     loc_FF85E868\n"
 898         "LDR     R2, =0xFF85E45C\n"
 899         "ADD     R1, R2, #0\n"
 900         "ORR     R3, R4, #0x400\n"
 901         "BL      sub_FF8391B0\n"
 902         "TST     R0, #1\n"
 903         "CMPNE   R0, #0x15\n"
 904         "STR     R0, [R10,R4,LSL#2]\n"
 905         "BEQ     loc_FF85E560\n"
 906         "MOV     R1, #0x2C0\n"
 907 "loc_FF85E81C:\n"
 908         "LDR     R0, =0xFF85E830\n"
 909         "BL      sub_FF81E88C\n"
 910         "B       loc_FF85E560\n"
 911                 "NOP\n"
 912 "loc_FF85E868:\n"
 913         "LDR     R1, =0xFFB3ACF4\n"
 914         "LDR     R0, [SP,#0x30]\n"
 915         "LDR     R0, [R1,R0,LSL#2]\n"
 916         "STR     R7, [R0]\n"
 917         "LDR     R0, [SP,#0x2C]\n"
 918         "MOV     R1, #1\n"
 919         "B       loc_FF85E5D8\n"
 920 "loc_FF85E884:\n"
 921         "LDR     R0, [R8,R4,LSL#2]\n"
 922         "CMP     R0, #0\n"
 923         "LDREQ   R1, =0x2CD\n"
 924         "LDREQ   R0, =0xFF85E830\n"
 925         "BLEQ    sub_FF81E88C\n"
 926         "ADD     R0, R4, R4,LSL#1\n"
 927         "ADD     R0, R9, R0,LSL#2\n"
 928         "LDR     R0, [R0,#4]\n"
 929         "BL      sub_FF8943D0\n"
 930         "STR     R7, [R8,R4,LSL#2]\n"
 931         "B       loc_FF85E560\n"
 932 
 933  );
 934 }; 

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