root/platform/ixus55_sd450/sub/100b/boot.c

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

DEFINITIONS

This source file includes following definitions.
  1. boot
  2. h_usrInit
  3. h_usrKernelInit
  4. h_usrRoot

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "core.h"
   4 
   5 const char * const new_sa = &_end;
   6 
   7 /* Ours stuff */
   8 extern long wrs_kernel_bss_start;
   9 extern long wrs_kernel_bss_end;
  10 extern void createHook (void *pNewTcb);
  11 extern void deleteHook (void *pTcb);
  12 
  13 
  14 void boot();
  15 
  16 /* "relocated" functions */
  17 void __attribute__((naked,noinline)) h_usrInit(); // Orig. starts at FF811A64
  18 void __attribute__((naked,noinline)) h_usrKernelInit(); // Orig. starts at FF81181C
  19 void __attribute__((naked,noinline)) h_usrRoot(); // Orig. starts at FF811B44
  20 
  21 
  22 
  23 void boot()
  24 {
  25     // offset of "start of data" string in primary.bin - 4
  26     // All the asm code below is from: 0xFF8100E0
  27 
  28     long *canon_data_src = (void*)0xFFAEB3F0;
  29     long *canon_data_dst = (void*)0x1900;
  30     // up to the end of flash
  31     long canon_data_len = 0xEA00;
  32     // just after ROM data
  33     long *canon_bss_start = (void*)(0x1900+0xEA00);
  34     // BSS end offset (from FF810154 disasm) minus BSS start
  35     long canon_bss_len = 0xA87D0 - (long)canon_bss_start;
  36     long i;
  37 
  38 
  39     asm volatile (
  40         "MRC     p15, 0, R0,c1,c0\n"
  41         "ORR     R0, R0, #0x1000\n"
  42         "ORR     R0, R0, #4\n"
  43         "ORR     R0, R0, #1\n"
  44         "MCR     p15, 0, R0,c1,c0\n"
  45     :::"r0");
  46 
  47     for(i=0;i<canon_data_len/4;i++)
  48         canon_data_dst[i]=canon_data_src[i];
  49 
  50     for(i=0;i<canon_bss_len/4;i++)
  51         canon_bss_start[i]=0;
  52 
  53     asm volatile (
  54         "MRC     p15, 0, R0,c1,c0\n"
  55         "ORR     R0, R0, #0x1000\n"
  56         "BIC     R0, R0, #4\n"
  57         "ORR     R0, R0, #1\n"
  58         "MCR     p15, 0, R0,c1,c0\n"
  59     :::"r0");
  60     
  61     h_usrInit();
  62 }
  63 
  64 
  65 void h_usrInit() // Orig. starts at FF811A64
  66 {
  67     asm volatile (
  68         "STR     LR, [SP,#-4]!\n"
  69         "BL      sub_FF811A40\n"
  70         "MOV     R0, #2\n"
  71         "MOV     R1, R0\n"
  72         "BL      sub_FFACF04C\n" // unknown_libname_838
  73         "BL      sub_FFABB724\n" // excVecInit
  74         "BL      sub_FF811298\n"
  75         "BL      sub_FF811800\n"
  76         "LDR     LR, [SP],#4\n"
  77         "B       h_usrKernelInit\n"
  78     );
  79 }
  80 
  81 void  h_usrKernelInit() // Orig. starts at FF81181C
  82 {
  83     asm volatile (
  84         "STMFD   SP!, {R4,LR}\n"
  85         "SUB     SP, SP, #8\n"
  86         "BL      sub_FFACF54C\n" // classLibInit
  87         "BL      sub_FFAE4838\n" // taskLibInit
  88         "LDR     R3, =0xF294\n"
  89         "LDR     R2, =0xA5400\n"
  90         "LDR     R1, [R3]\n"
  91         "LDR     R0, =0xA8190\n"
  92         "MOV     R3, #0x100\n"
  93         "BL      sub_FFADD688\n" // qInit
  94         "LDR     R3, =0xF254\n"
  95         "LDR     R0, =0xFB1C\n"
  96         "LDR     R1, [R3]\n"
  97         "BL      sub_FFADD688\n" // qInit
  98         "LDR     R3, =0xF310\n"
  99         "LDR     R0, =0xA8164\n"
 100         "LDR     R1, [R3]\n"
 101         "BL      sub_FFADD688\n" // qInit
 102         "BL      sub_FFAE93B8\n" // workQInit
 103         "BL      sub_FF811384\n"
 104         "MOV     R4, #0\n"
 105         "MOV     R3, R0\n"
 106         "MOV     R12, #0x800\n"
 107         "LDR     R0, =h_usrRoot\n"  // !!!
 108         "MOV     R1, #0x4000\n"
 109     );    
 110 //        "LDR     R2, =0xD87D0\n"      // !!! 0xA87D0 + 0x30000
 111     asm volatile (
 112         "LDR     R2, =new_sa\n"
 113         "LDR     R2, [R2]\n"
 114     );
 115     asm volatile (
 116         "STR     R12, [SP]\n"
 117         "STR     R4, [SP,#4]\n"
 118         "BL      sub_FFAE1A78\n" // kernelInit
 119         "ADD     SP, SP, #8\n"
 120         "LDMFD   SP!, {R4,PC}\n"
 121     );
 122 };
 123 
 124 
 125 
 126 void  h_usrRoot() // Orig. starts at FF811B44
 127 {
 128     asm volatile (
 129         "STMFD   SP!, {R4,R5,LR}\n"
 130         "MOV     R5, R0\n"
 131         "MOV     R4, R1\n"
 132         "BL      sub_FF811AA8\n"
 133         "MOV     R1, R4\n"
 134         "MOV     R0, R5\n"
 135         "BL      sub_FFAD56C8\n" // memInit
 136         "MOV     R1, R4\n"
 137         "MOV     R0, R5\n"
 138         "BL      sub_FFAD6140\n" // memPartLibInit
 139         "BL      sub_FF8117DC\n"
 140         "MOV     R0, #0x32\n"
 141         "BL      sub_FFAD80E4\n" // selectInit
 142         "BL      sub_FF811AEC\n"
 143         "BL      sub_FF811ACC\n"
 144         "BL      sub_FF811B18\n"
 145         "BL      sub_FFAD79A4\n" // selTaskDeleteHookAdd
 146         "BL      sub_FF811A9C\n"
 147     );
 148 
 149     _taskCreateHookAdd(createHook);
 150     _taskDeleteHookAdd(deleteHook);
 151 
 152     drv_self_hide();
 153 
 154     asm volatile (
 155         "LDMFD   SP!, {R4,R5,LR}\n"
 156         "B       sub_FF811444\n"
 157     );
 158 }
 159 

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