root/platform/ixus900_sd900/sub/100c/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 void boot();
  14 
  15 // "relocated" functions
  16 void __attribute__((naked,noinline)) h_usrInit();
  17 void __attribute__((naked,noinline)) h_usrKernelInit();
  18 void __attribute__((naked,noinline)) h_usrRoot();
  19 
  20 // setup .data and .bss
  21 void boot() {
  22     // http://chdk.setepontos.com/index.php/topic,774.msg6347/topicseen.html#msg6347
  23     long *canon_data_src = (void*)0xFFB6DA40;   // ROM:FF810104
  24     long *canon_data_dst = (void*)0x1900;   // ROM:FF810108
  25     long canon_data_len = 0xCC00;   // ROM:FF8100F8
  26     long *canon_bss_start = (void*)0xE500;   // ROM:FF810130 (canon_data_dst + canon_data_len)
  27     long canon_bss_len = 0xA4D10 - 0xE500;   // ROM:FF810134 (MEMISOSTART - canon_bss_start)
  28     //long canon_bss_len = 0xA4D10 - (long)canon_bss_start;
  29     long i;
  30 
  31     // ROM:FF8100E4 , same as SD800, SD750 and other VxWorks
  32     asm volatile(
  33         "MRC     p15, 0, R0,c1,c0\n"
  34         "ORR     R0, R0, #0x1000\n"
  35         "ORR     R0, R0, #4\n"
  36         "ORR     R0, R0, #1\n"
  37         "MCR     p15, 0, R0,c1,c0\n"
  38         :::"r0"
  39     );
  40 
  41     for(i=0; i<canon_data_len/4; i++)
  42         canon_data_dst[i]=canon_data_src[i];
  43 
  44     for(i=0; i<canon_bss_len/4; i++)
  45         canon_bss_start[i]=0;
  46 
  47     // ROM:FF81015C , same as SD800, SD750 and other VxWorks
  48     asm volatile(
  49         "MRC     p15, 0, R0,c1,c0\n"
  50         "ORR     R0, R0, #0x1000\n"
  51         "BIC     R0, R0, #4\n"
  52         "ORR     R0, R0, #1\n"
  53         "MCR     p15, 0, R0,c1,c0\n"
  54         :::"r0"
  55     );
  56 
  57     h_usrInit();
  58 }
  59 
  60 // ROM:FF81198C
  61 void h_usrInit() {
  62     asm volatile(
  63         "STR     LR, [SP,#-4]!\n"
  64         "BL      sub_FF811968\n"
  65         "MOV     R0, #2\n"
  66         "MOV     R1, R0\n"
  67         "BL      sub_FFB54584\n"
  68         "BL      sub_FFB46DF8\n"     // excVecInit()
  69         "BL      sub_FF8111C4\n"     // sysInitStack()
  70         "BL      sub_FF811728\n"
  71         "LDR     LR, [SP],#4\n"
  72         "B       h_usrKernelInit\n"
  73     );
  74 }
  75 
  76 // ROM:FF811744 #
  77 void  h_usrKernelInit() {
  78     asm volatile(
  79         "STMFD   SP!, {R4,LR}\n"
  80         "SUB     SP, SP, #8\n"
  81         "BL      sub_FFB54A84\n"     // classLibInit()
  82         "BL      sub_FFB6786C\n"     // taskLibInit()
  83         "LDR     R3, =0xD520\n"
  84         "LDR     R2, =0xA1960\n"
  85         "LDR     R1, [R3]\n"
  86         "LDR     R0, =0xA46D0\n"
  87         "MOV     R3, #0x100\n"
  88         "BL      sub_FFB6097C\n"     // qInit()
  89         "LDR     R3, =0xD4E0\n"
  90         "LDR     R0, =0xDD28\n"
  91         "LDR     R1, [R3]\n"
  92         "BL      sub_FFB6097C\n"     // qInit()
  93         "LDR     R3, =0xD59C\n"
  94         "LDR     R0, =0xA46A4\n"
  95         "LDR     R1, [R3]\n"
  96         "BL      sub_FFB6097C\n"     // qInit()
  97         "BL      sub_FFB6BC28\n"     // workQInit()
  98         "BL      sub_FF8112AC\n"
  99         "MOV     R4, #0\n"
 100         "MOV     R3, R0\n"
 101         "MOV     R12, #0x800\n"
 102         "LDR     R0, =h_usrRoot\n"   // important !!
 103         "MOV     R1, #0x4000\n"
 104         "LDR     R2, =new_sa\n"      // skip some memory for later use with CHDK
 105         "LDR     R2, [R2]\n"         // helps "LDR     R2, =new_sa\n"
 106         "STR     R12, [SP]\n"
 107         "STR     R4, [SP,#4]\n"
 108         "BL      sub_FFB64AAC\n"     // kernelInit()
 109         "ADD     SP, SP, #8\n"
 110         "LDMFD   SP!, {R4,PC}\n"
 111     );
 112 }
 113 
 114 void  h_usrRoot() {
 115     // ROM:FF811A60
 116     asm volatile(
 117         "STMFD   SP!, {R4,R5,LR}\n"
 118         "MOV     R5, R0\n"
 119         "MOV     R4, R1\n"
 120         "BL      sub_FF8119D0\n"   // lib_Init()
 121         "MOV     R1, R4\n"
 122         "MOV     R0, R5\n"
 123         "BL      sub_FFB59718\n"   // memInit()
 124         "MOV     R1, R4\n"
 125         "MOV     R0, R5\n"
 126         "BL      sub_FFB5A190\n"   // memPartLibInit()
 127         //"BL      sub_FF8117E8\n"   // nullsub_1()
 128         "BL      sub_FF811704\n"
 129         "BL      sub_FF811A0C\n"   // tty_Init() (console log)
 130         //"BL      sub_FF811A0C_my\n"   // tty_Init() (console log)
 131         "BL      sub_FF8119F0\n"   // env_Init()
 132         "BL      sub_FF811A38\n"   // stdlog_Init() (logInit)
 133         "BL      sub_FF8119C4\n"   // show_Init()
 134     );
 135 
 136     _taskCreateHookAdd(createHook);
 137     _taskDeleteHookAdd(deleteHook);
 138 
 139     drv_self_hide();
 140 
 141     // ROM:FF811AA0 , same as SD800, SD750
 142     asm volatile(
 143         "LDMFD   SP!, {R4,R5,LR}\n"
 144         "B       sub_FF81136C\n"   // startup_Init()
 145     );
 146 }
 147 
 148 /*
 149 // VxWorks console
 150 // tty_Init
 151 void __attribute__((naked,noinline)) sub_FF811A0C_my(long p) {
 152     asm volatile (
 153         "MOV     R0, #0x1000\n"
 154         "STR     LR, [SP]\n"
 155         "BL      sub_FF811474\n"   // tty_StartMsg
 156         "MOV     R1, #0x32\n"
 157         //"LDR     R2, =aNull\n"   // original
 158         "LDR     R2, ='/tyCo/0'\n"   // +
 159         "MOV     R0, #0x14\n"
 160         "BL      _iosInit\n"
 161         "BL      sub_FFB5DBB0\n"   // ttyDrv
 162         "LDR     LR, [SP]\n"
 163         "B       sub_FF811874\n\n"
 164     );
 165 */

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