root/loader/ixus115_elph100hs/main.c

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

DEFINITIONS

This source file includes following definitions.
  1. my_restart

   1 #include "../generic/check_compat.c"
   2 
   3 // static void __attribute__((noreturn)) shutdown();
   4 // static void __attribute__((noreturn)) panic(int cnt);
   5 
   6 extern long *blob_chdk_core;
   7 // extern long *blob_copy_and_reset;
   8 extern long blob_chdk_core_size;
   9 // extern long blob_copy_and_reset_size;
  10 
  11 
  12 /*
  13 void LED_AF_on_short ()
  14 {int i=1, N=10000000;
  15 *((volatile int *) 0xC022000A) = 0x46;  //Turn on LED
  16 for (i=0; i<N; i++)                                             //Wait a while
  17         {
  18         asm volatile ("nop\n");
  19         }
  20 }
  21 
  22 void LED_AF_on_inf ()
  23 {
  24 *((volatile int *) 0xC022000A) = 0x46;  //Turn on LED
  25 while (1)                               //Wait an infium
  26         {
  27         asm volatile ("nop\n");
  28         }
  29 }
  30 
  31 void LED_AF_off ()
  32 {
  33 int i=1, N=10000000;
  34 *((volatile int *) 0xC022000A) = 0x44;  //Turn on LED
  35 for (i=0; i<N; i++)                                             //Wait a while
  36         {
  37         asm volatile ("nop\n");
  38         }
  39 }
  40 
  41 void LED_power_on_short ()
  42 {int i=1, N=10000000;
  43 for (i=0; i<N/2; i++)                                           //Wait a while
  44         {
  45         asm volatile ("nop\n");
  46         }
  47 *((volatile int *) 0xC0220010) = 0x46;  //Turn on LED
  48 for (i=0; i<N/2; i++)                                           //Wait a while
  49         {
  50         asm volatile ("nop\n");
  51         }
  52 }
  53 void LED_power_on_inf ()
  54 {
  55 *((volatile int *) 0xC0220010) = 0x46;  //Turn on LED
  56 while (1)                               //Wait an infium
  57         {
  58         asm volatile ("nop\n");
  59         }
  60 }
  61 void LED_power_off ()
  62 {
  63 int i=1, N=10000000;
  64 for (i=0; i<N; i++)                                             //Wait a while
  65         {
  66         asm volatile ("nop\n");
  67         }
  68         *((volatile int *) 0xC0220010) = 0x44; //Turn off LED
  69 }
  70 */
  71 void __attribute__((noreturn)) my_restart()
  72 {
  73 
  74         {
  75         // char *dst = dst_void;
  76         // const char *src = src_void;
  77         long *dst = (long*)MEMISOSTART;
  78         const long *src = blob_chdk_core;
  79         long length = (blob_chdk_core_size + 3) >> 2;
  80 
  81   core_copy(src, dst, length);
  82 
  83         }
  84         
  85 //elph100 found at FF83D370
  86         asm volatile (
  87                  "LDR     R1, =0xC0200000\n"
  88                  "MVN     R0, #0\n"
  89                  "STR     R0, [R1,#0x10C]\n"
  90                  "STR     R0, [R1,#0xC]\n"
  91                  "STR     R0, [R1,#0x1C]\n"
  92                  "STR     R0, [R1,#0x2C]\n"
  93                  "STR     R0, [R1,#0x3C]\n"
  94                  "STR     R0, [R1,#0x4C]\n"
  95                  "STR     R0, [R1,#0x5C]\n"
  96                  "STR     R0, [R1,#0x6C]\n"
  97                  "STR     R0, [R1,#0x7C]\n"
  98                  "STR     R0, [R1,#0x8C]\n"
  99                  "STR     R0, [R1,#0x9C]\n"
 100                  "STR     R0, [R1,#0xAC]\n"
 101                  "STR     R0, [R1,#0xBC]\n"
 102                  "STR     R0, [R1,#0xCC]\n"
 103                  "STR     R0, [R1,#0xDC]\n"
 104                  "STR     R0, [R1,#0xEC]\n"
 105                  "CMP     R4, #7\n"
 106                  "STR     R0, [R1,#0xFC]\n"
 107                  "LDMEQFD SP!, {R4,PC}\n"
 108                  "MOV     R0, #0x78\n"
 109                  "MCR     p15, 0, R0,c1,c0\n"
 110                  "MOV     R0, #0\n"
 111                  "MCR     p15, 0, R0,c7,c10, 4\n"
 112                  "MCR     p15, 0, R0,c7,c5\n"
 113                  "MCR     p15, 0, R0,c7,c6\n"
 114                  "MOV     R0, #0x80000006\n"
 115                  "MCR     p15, 0, R0,c9,c1\n"
 116                  "MCR     p15, 0, R0,c9,c1, 1\n"
 117                  "MRC     p15, 0, R0,c1,c0\n"
 118                  "ORR     R0, R0, #0x50000\n"
 119                  "MCR     p15, 0, R0,c1,c0\n"
 120                  "LDR     R0, =0x12345678\n"
 121                  "MOV     R1, #0x80000000\n"
 122                  "STR     R0, [R1,#0xFFC]\n"
 123                  "LDMFD   SP!, {R4,LR}\n"
 124                                  "MOV     R0, %0\n"  //new jump-vector
 125                  "BX      R0\n"
 126                                  : : "r"(MEMISOSTART) : "memory","r0","r1","r2","r3","r4"
 127                 
 128                                  );
 129         
 130         while(1);
 131 
 132 }
 133 
 134 // #define LED_PR 0xC0220010   // -> Just.J 24.08.2011 found at
 135 // 
 136 // 
 137 // static void __attribute__((noreturn)) shutdown()
 138 // {
 139 //     volatile long *p = (void*)LED_PR;       // turned off later, so assumed to be power
 140 // 
 141 //     asm(
 142 //          "MRS     R1, CPSR\n"
 143 //          "AND     R0, R1, #0x80\n"
 144 //          "ORR     R1, R1, #0x80\n"
 145 //          "MSR     CPSR_cf, R1\n"
 146 //          :::"r1","r0");
 147 // 
 148 //     *p = 0x44;  // led off.
 149 // 
 150 //     while(1);
 151 // }
 152 // 
 153 // 
 154 // static void __attribute__((noreturn)) panic(int cnt)
 155 // {
 156 //      volatile long *p=(void*)LED_PR;
 157 //      int i;
 158 // 
 159 //      for(;cnt>0;cnt--){
 160 //              p[0]=0x46;
 161 // 
 162 //              for(i=0;i<0x200000;i++){
 163 //                      asm ("nop\n");
 164 //                      asm ("nop\n");
 165 //              }
 166 //              p[0]=0x44;
 167 //              for(i=0;i<0x200000;i++){
 168 //                      asm ("nop\n");
 169 //                      asm ("nop\n");
 170 //              }
 171 //      }
 172 //      shutdown();
 173 // }

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