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

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