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

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

DEFINITIONS

This source file includes following definitions.
  1. blink_blue
  2. blink_orange
  3. blink
  4. boot
  5. h_usrInit
  6. h_usrKernelInit
  7. 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();
  18 void __attribute__((naked,noinline)) h_usrKernelInit();
  19 void __attribute__((naked,noinline)) h_usrRoot();
  20 
  21 
  22 #if 0
  23 void blink_blue(int duration)
  24 {
  25   int i;
  26 
  27   *((volatile long *) 0xc0220084) = 0x46; // Turn on LED   
  28   for (i=0; i<duration; i++) // Wait a while   
  29   {   
  30     asm volatile ( "nop\n" );   
  31   }   
  32    
  33   *((volatile long *) 0xc0220084) = 0x44; // Turn off LED   
  34   for (i=0; i<duration; i++) // Wait a while   
  35   {   
  36     asm volatile ( "nop\n" );   
  37   }
  38 }
  39 
  40 void blink_orange(int duration)
  41 {
  42   int i;
  43 
  44   *((volatile long *) 0xc0220080) = 0x46; // Turn on LED   
  45   for (i=0; i<duration; i++) // Wait a while   
  46   {   
  47     asm volatile ( "nop\n" );   
  48   }   
  49    
  50   *((volatile long *) 0xc0220080) = 0x44; // Turn off LED   
  51   for (i=0; i<duration; i++) // Wait a while   
  52   {   
  53     asm volatile ( "nop\n" );   
  54   }
  55 }
  56 
  57 void blink()
  58 {
  59     blink_blue(10000000);
  60     blink_orange(10000000);
  61     blink_blue(10000000);
  62 }
  63 #endif
  64 
  65 void boot()
  66 {
  67     long *canon_data_src = (void*)0xFFEC54F0;
  68     long *canon_data_dst = (void*)0x1900;
  69     long canon_data_len = 0xEBC0 - 0x1900;
  70     long *canon_bss_start = (void*)0xEBC0; // just after data
  71     long canon_bss_len = 0x9F7D0 - 0xEBC0;
  72     long i;
  73 
  74     asm volatile (
  75         "MRC     p15, 0, R0,c1,c0\n"
  76         "ORR     R0, R0, #0x1000\n"
  77         "ORR     R0, R0, #4\n"
  78         "ORR     R0, R0, #1\n"
  79         "MCR     p15, 0, R0,c1,c0\n"
  80     :::"r0");
  81 
  82     for(i=0;i<canon_data_len/4;i++)
  83         canon_data_dst[i]=canon_data_src[i];
  84 
  85     for(i=0;i<canon_bss_len/4;i++)
  86         canon_bss_start[i]=0;
  87 
  88     asm volatile (
  89         "MRC     p15, 0, R0,c1,c0\n"
  90         "ORR     R0, R0, #0x1000\n"
  91         "BIC     R0, R0, #4\n"
  92         "ORR     R0, R0, #1\n"
  93         "MCR     p15, 0, R0,c1,c0\n"
  94     :::"r0");
  95 
  96     h_usrInit();
  97 }
  98 
  99 
 100 void h_usrInit()
 101 {
 102     asm volatile (
 103         "STR     LR, [SP,#-4]!\n"
 104         "BL      sub_FFC01968\n"
 105         "MOV     R0, #2\n"
 106         "MOV     R1, R0\n"
 107         "BL      sub_FFEAB86C\n"     //unknown_libname_773 ; "Canon A-Series Firmware"
 108         "BL      sub_FFE9CEDC\n"     //excVecInit
 109         "BL      sub_FFC011C4\n"
 110         "BL      sub_FFC01728\n"
 111         "LDR     LR, [SP],#4\n"
 112         "B       h_usrKernelInit\n"
 113     );
 114 }
 115 
 116 void  h_usrKernelInit()
 117 {
 118 //    blink();
 119     asm volatile (
 120         "STMFD   SP!, {R4,LR}\n"
 121         "SUB     SP, SP, #8\n"
 122         "BL      sub_FFEABD6C\n"    //classLibInit
 123         "BL      sub_FFEBEB54\n"    //taskLibInit
 124         "LDR     R3, =0xDBD8\n"
 125         "LDR     R2, =0x9C460\n"
 126         "LDR     R1, [R3]\n"
 127         "LDR     R0, =0x9F190\n"
 128         "MOV     R3, #0x100\n"
 129         "BL      sub_FFEB7C64\n"   //qInit
 130         "LDR     R3, =0xDB98\n"
 131         "LDR     R0, =0xE3E0\n"
 132         "LDR     R1, [R3]\n"
 133         "BL      sub_FFEB7C64\n"   //qInit
 134         "LDR     R3, =0xDC54\n"
 135         "LDR     R0, =0x9F164\n"
 136         "LDR     R1, [R3]\n"
 137         "BL      sub_FFEB7C64\n"   //qInit
 138         "BL      sub_FFEC36D4\n"   //workQInit
 139         "BL      sub_FFC012B0\n"
 140         "MOV     R4, #0\n"
 141         "MOV     R3, R0\n"
 142         "MOV     R12, #0x800\n"
 143         "LDR     R0, =h_usrRoot\n"
 144         "MOV     R1, #0x4000\n"
 145     );
 146     asm volatile (
 147         "LDR     R2, =new_sa\n"
 148         "LDR     R2, [R2]\n"
 149     );
 150     asm volatile (
 151         "STR     R12, [SP]\n"
 152         "STR     R4, [SP,#4]\n"
 153         "BL      sub_FFEBBD94\n"  //kernelInit
 154         "ADD     SP, SP, #8\n"
 155         "LDMFD   SP!, {R4,PC}\n"
 156     );
 157 }
 158 
 159 
 160 void  h_usrRoot()
 161 {
 162     asm volatile (
 163         "STMFD   SP!, {R4,R5,LR}\n"
 164         "MOV     R5, R0\n"
 165         "MOV     R4, R1\n"
 166         "BL      sub_FFC019D0\n"
 167         "MOV     R1, R4\n"
 168         "MOV     R0, R5\n"
 169         "BL      sub_FFEB0A00\n"     //memInit
 170         "MOV     R1, R4\n"
 171         "MOV     R0, R5\n"
 172         "BL      sub_FFEB1478\n"     //memPartLibInit
 173         "BL      sub_FFC017E8\n"     //SetZoomActuatorSpeedPercent
 174         "BL      sub_FFC01704\n"
 175         "BL      sub_FFC01A10\n"
 176         "BL      sub_FFC019F4\n"
 177         "BL      sub_FFC01A3C\n"
 178         "BL      sub_FFC019C4\n"
 179     );
 180 
 181     _taskCreateHookAdd(createHook);
 182     _taskDeleteHookAdd(deleteHook);
 183 
 184     drv_self_hide();
 185 //    blink(); //    "BL      blink\n"
 186 
 187     asm volatile (
 188         "LDMFD   SP!, {R4,R5,LR}\n"
 189         "B       sub_FFC0136C\n"
 190     );
 191 }

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