root/loader/ixus90_sd790/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 __attribute__((noreturn)) my_restart() 
  14 {
  15   // DEBUG: blink led
  16   /*
  17   #define DP (void*)0xC02200d4  // direct-print (blue)
  18   #define GREEN (void*)0xC0220134
  19   #define DELAY 5000000
  20 
  21   volatile long *p = (void*)GREEN;       // turned off later, so assumed to be power
  22   int counter;
  23 
  24   counter = DELAY; *p = 0x46;  while (counter--) { asm("nop\n nop\n"); };
  25   counter = DELAY; *p = 0x44;  while (counter--) { asm("nop\n nop\n"); };
  26   */
  27   {
  28   // char *dst = dst_void;
  29   // const char *src = src_void;
  30   long *dst = (long*)MEMISOSTART;
  31   const long *src = blob_chdk_core;
  32   long length = (blob_chdk_core_size + 3) >> 2;
  33 
  34   core_copy(src, dst, length);
  35 
  36 }
  37 
  38         //DEBUG: blink again
  39         //counter = DELAY; *p = 0x46;  while (counter--) { asm("nop\n nop\n"); };
  40         //counter = DELAY; *p = 0x44;  while (counter--) { asm("nop\n nop\n"); };
  41 
  42         // resetcode here:
  43         asm volatile (
  44                 "MRS    R0, CPSR\n"
  45                 "BIC    R0, R0, #0x3F\n"
  46                 "ORR    R0, R0, #0xD3\n"
  47                 "MSR    CPSR, R0\n"
  48                 "LDR    R1, =0xC0200000\n"
  49                 "MOV    R0, #0xFFFFFFFF\n"
  50                 "STR    R0, [R1,#0x10C]\n"
  51                 "STR    R0, [R1,#0xC]\n"
  52                 "STR    R0, [R1,#0x1C]\n"
  53                 "STR    R0, [R1,#0x2C]\n"
  54                 "STR    R0, [R1,#0x3C]\n"
  55                 "STR    R0, [R1,#0x4C]\n"
  56                 "STR    R0, [R1,#0x5C]\n"
  57                 "STR    R0, [R1,#0x6C]\n"
  58                 "STR    R0, [R1,#0x7C]\n"
  59                 "STR    R0, [R1,#0x8C]\n"
  60                 "STR    R0, [R1,#0x9C]\n"
  61                 "STR    R0, [R1,#0xAC]\n"
  62                 "STR    R0, [R1,#0xBC]\n"
  63                 "STR    R0, [R1,#0xCC]\n"
  64                 "STR    R0, [R1,#0xDC]\n"
  65                 "STR    R0, [R1,#0xEC]\n"
  66                 "CMP    R4, #7\n"
  67                 "STR    R0, [R1,#0xFC]\n"
  68                 "LDMEQFD        SP!, {R4,PC}\n"
  69                 "MOV    R0, #0x78\n"
  70                 "MCR    p15, 0, R0,c1,c0\n"
  71                 "MOV    R0, #0\n"
  72                 "MCR    p15, 0, R0,c7,c10, 4\n"
  73                 "MCR    p15, 0, R0,c7,c5\n"
  74                 "MCR    p15, 0, R0,c7,c6\n"
  75                 "MOV    R0, #0x40000006\n"
  76                 "MCR    p15, 0, R0,c9,c1\n"
  77                 "MCR    p15, 0, R0,c9,c1, 1\n"
  78                 "MRC    p15, 0, R0,c1,c0\n"
  79                 "ORR    R0, R0, #0x50000\n"
  80                 "MCR    p15, 0, R0,c1,c0\n"
  81                 "LDR    R0, =0x12345678\n"
  82                 "MOV    R1, #0x40000000\n"
  83                 "STR    R0, [R1,#0xFFC]\n"
  84                 //"LDR  R0, =0xFF810000\n"      // original jump-vector
  85                 "MOV     R0, %0\n"              // new jump-vector
  86                 "LDMFD  SP!, {R4,LR}\n"
  87                 "BX     R0\n"
  88                  : : "r"(MEMISOSTART) : "memory","r0","r1","r2","r3","r4");
  89 
  90         while(1);
  91 }
  92 
  93 // #define LED_PR 0xC02200CC
  94 // #define LED_GREEN 0xc0220134
  95 // #define LED_ORANGE 0xc0220130
  96 // 
  97 // static void __attribute__((noreturn)) shutdown()
  98 // {
  99 //     volatile long *p = (void*)LED_PR;       // turned off later, so assumed to be power
 100 //         
 101 //     asm(
 102 //          "MRS     R1, CPSR\n"
 103 //          "AND     R0, R1, #0x80\n"
 104 //          "ORR     R1, R1, #0x80\n"
 105 //          "MSR     CPSR_cf, R1\n"
 106 //          :::"r1","r0");
 107 //         
 108 //     *p = 0x44;  // led off.
 109 // 
 110 //     while(1);
 111 // }
 112 // 
 113 // static void __attribute__((noreturn)) panic(int cnt)
 114 // {
 115 //      volatile long *p=(void*)LED_PR;
 116 //      int i;
 117 // 
 118 //      for(;cnt>0;cnt--){
 119 //              p[0]=0x46;
 120 // 
 121 //              for(i=0;i<0x200000;i++){
 122 //                      asm ("nop\n");
 123 //                      asm ("nop\n");
 124 //              }
 125 //              p[0]=0x44;
 126 //              for(i=0;i<0x200000;i++){
 127 //                      asm ("nop\n");
 128 //                      asm ("nop\n");
 129 //              }
 130 //      }
 131 //      shutdown();
 132 // }

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