root/loader/ixus170_elph170/main.c

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

DEFINITIONS

This source file includes following definitions.
  1. my_restart

   1 // TODO: copied from ixus160 port
   2 extern long *blob_chdk_core;
   3 extern long blob_chdk_core_size;
   4 
   5 void __attribute__((noreturn)) my_restart()
   6 {
   7     {
   8         long *dst = (long*)MEMISOSTART;
   9         const long *src = blob_chdk_core;
  10         long length = (blob_chdk_core_size + 3) >> 2;
  11 
  12         if (src < dst && dst < src + length)
  13         {
  14              /* Have to copy backwards */
  15              src += length;
  16              dst += length;
  17              while (length--) *--dst = *--src;
  18         }
  19         else
  20             while (length--)  *dst++ = *src++;
  21     }
  22 
  23     // restart function
  24     // from sub_FF83846C via 0x12345678
  25     asm volatile (
  26                 "    MOV     R0, #0x78 \n" 
  27                 "    MCR     p15, 0, R0, c1, c0 \n" 
  28                 "    MOV     R0, #0 \n" 
  29                 "    MCR     p15, 0, R0, c7, c10, 4 \n" 
  30                 "    MCR     p15, 0, R0, c7, c5 \n" 
  31                 "    MCR     p15, 0, R0, c7, c6 \n" 
  32                 "    MOV     R0, #0x80000006 \n" 
  33                 "    MCR     p15, 0, R0, c9, c1 \n" 
  34                 "    MCR     p15, 0, R0, c9, c1, 1 \n" 
  35                 "    MRC     p15, 0, R0, c1, c0 \n" 
  36                 "    ORR     R0, R0, #0x50000 \n" 
  37                 "    MCR     p15, 0, R0, c1, c0 \n" 
  38                 "    LDR     R0, =0x12345678 \n" 
  39                 "    MOV     R1, #0x80000000 \n" 
  40                 "    STR     R0, [R1, #0xFFC] \n" 
  41                 //"    BL      sub_ff899c38 \n"  // nullsub
  42                 //"    LDR     R0, =0xFF820000 \n" 
  43                 "MOV     R0, %0\n"              // new jump-vector                              
  44                 //"    LDMFD   SP!, {R4,LR} \n" 
  45                 "    BX      R0 \n" 
  46          : : "r"(MEMISOSTART) : "memory","r0","r1","r2","r3","r4"
  47         );
  48 
  49         while(1);
  50 }
  51 

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