root/platform/ixusizoom_sd30/sub/100h/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 /*
   2  * boot.c - auto-generated by CHDK code_gen.
   3  */
   4 #include "lolevel.h"
   5 #include "platform.h"
   6 #include "core.h"
   7 
   8 /* Ours stuff */
   9 extern void createHook (void *pNewTcb);
  10 extern void deleteHook (void *pTcb);
  11 const char * const new_sa = &_end;
  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 void boot()
  21 {
  22     long *canon_data_src = (void*)0xffae8270; // This is the address of the "Startofdata"-4 string on the firmware
  23     long *canon_data_dst = (void*)MEMBASEADDR; // This is where the boot data is copiedduring firmware update
  24     long canon_data_len = 0xE7D0; // This is the length of data from "Startofdata" to the end of the firmware dump
  25     long *canon_bss_start = (void*) (canon_data_len + MEMBASEADDR); //  = 0xEB60 + 0x1900,  just after data
  26     long canon_bss_len = MEMISOSTART - (long) canon_bss_start; // The original address of h_usrKernelInit - bss start
  27     long i;
  28 
  29     asm volatile (
  30     "MRC     p15, 0, R0,c1,c0\n"
  31     "ORR     R0, R0, #0x1000\n"
  32     "ORR     R0, R0, #4\n"
  33     "ORR     R0, R0, #1\n"
  34     "MCR     p15, 0, R0,c1,c0\n"
  35     :::"r0");
  36 
  37 
  38     for(i=0;i<canon_data_len/4;i++)
  39     canon_data_dst[i]=canon_data_src[i];
  40 
  41     for(i=0;i<canon_bss_len/4;i++)
  42     canon_bss_start[i]=0;
  43 
  44     asm volatile (
  45     "MRC     p15, 0, R0,c1,c0\n"
  46     "ORR     R0, R0, #0x1000\n"
  47     "BIC     R0, R0, #4\n"
  48     "ORR     R0, R0, #1\n"
  49     "MCR     p15, 0, R0,c1,c0\n"
  50     :::"r0");
  51     
  52     h_usrInit();
  53 }
  54 
  55 
  56 /*************************************************************/
  57 //** h_usrInit @ 0xFF811A64 - 0xFF811A88, length=10
  58 void __attribute__((naked,noinline)) h_usrInit() {
  59 asm volatile (
  60 "    STR     LR, [SP, #-4]! \n"
  61 "    BL      sub_FF811A40 \n"
  62 "    MOV     R0, #2 \n"
  63 "    MOV     R1, R0 \n"
  64 "    BL      sub_FFACBEC8 \n"
  65 "    BL      sub_FFAB85A0 \n"
  66 "    BL      sub_FF811298 \n"
  67 "    BL      sub_FF811800 \n"
  68 "    LDR     LR, [SP], #4 \n"
  69 "    B       h_usrKernelInit \n"  // --> Patched. Old value = 0xFF81181C.
  70 );
  71 }
  72 
  73 /*************************************************************/
  74 //** h_usrKernelInit @ 0xFF81181C - 0xFF811894, length=31
  75 void __attribute__((naked,noinline)) h_usrKernelInit() {
  76 asm volatile (
  77 "    STMFD   SP!, {R4,LR} \n"
  78 "    SUB     SP, SP, #8 \n"
  79 "    BL      sub_FFACC3C8 \n"
  80 "    BL      sub_FFAE16B4 \n"
  81 "    LDR     R3, =0xF05C \n"
  82 "    LDR     R2, =0xA4740 \n"
  83 "    LDR     R1, [R3] \n"
  84 "    LDR     R0, =0xA7FB0 \n"
  85 "    MOV     R3, #0x100 \n"
  86 "    BL      sub_FFADA504 \n"
  87 "    LDR     R3, =0xF01C \n"
  88 "    LDR     R0, =0xF8E4 \n"
  89 "    LDR     R1, [R3] \n"
  90 "    BL      sub_FFADA504 \n"
  91 "    LDR     R3, =0xF0D8 \n"
  92 "    LDR     R0, =0xA7F84 \n"
  93 "    LDR     R1, [R3] \n"
  94 "    BL      sub_FFADA504 \n"
  95 "    BL      sub_FFAE6234 \n"
  96 "    BL      sub_FF811384 \n"
  97 "    MOV     R4, #0 \n"
  98 "    MOV     R3, R0 \n"
  99 "    MOV     R12, #0x800 \n"
 100 //"  LDR     R0, =0xFF811B44 \n"  // -
 101 
 102     "LDR     R0, =h_usrRoot\n" // +
 103 
 104 "    MOV     R1, #0x4000 \n"
 105 //"  LDR     R2, =0xA85F0 \n"  // -
 106 
 107     "LDR     R2, =new_sa\n"    // +
 108     "LDR     R2, [R2]\n"       // +
 109 
 110 "    STR     R12, [SP] \n"
 111 "    STR     R4, [SP, #4] \n"
 112 "    BL      sub_FFADE8F4 \n"
 113 "    ADD     SP, SP, #8 \n"
 114 "    LDMFD   SP!, {R4,PC} \n"
 115 );
 116 }
 117 
 118 /*************************************************************/
 119 //** h_usrRoot @ 0xFF811B44 - 0xFF811B94, length=21
 120 void __attribute__((naked,noinline)) h_usrRoot() {
 121 asm volatile (
 122 "    STMFD   SP!, {R4,R5,LR} \n"
 123 "    MOV     R5, R0 \n"
 124 "    MOV     R4, R1 \n"
 125 "    BL      sub_FF811AA8 \n"
 126 "    MOV     R1, R4 \n"
 127 "    MOV     R0, R5 \n"
 128 "    BL      sub_FFAD2544 \n"
 129 "    MOV     R1, R4 \n"
 130 "    MOV     R0, R5 \n"
 131 "    BL      sub_FFAD2FBC \n"
 132 "    BL      sub_FF8118C0 \n"
 133 "    BL      sub_FF8117DC \n"
 134 "    MOV     R0, #0x32 \n"
 135 "    BL      sub_FFAD4F60 \n"
 136 "    BL      sub_FF811AEC \n"
 137 "    BL      sub_FF811ACC \n"
 138 "    BL      sub_FF811B18 \n"
 139 "    BL      sub_FFAD4820 \n"
 140 "    BL      sub_FF811A9C \n"
 141 );
 142 
 143     _taskCreateHookAdd(createHook);
 144     _taskDeleteHookAdd(deleteHook);
 145 
 146     drv_self_hide();
 147 
 148 asm volatile (
 149 "    LDMFD   SP!, {R4,R5,LR} \n"
 150 "    B       sub_FF811444 \n"
 151 );
 152 }

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