root/loader/ixus60_sd600/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 // For DEBUG
   4 /*
   5 #define LED_AF   0xc0220080
   6 #define LED_PR   0xc0220084
   7 #define LED_RED  0xc0220088
   8 
   9 void port_on(int port)
  10 {
  11     volatile long *p=(void*)port;
  12     *p=0x46;
  13 }
  14 
  15 void port_off(int port)
  16 {
  17     volatile long *p=(void*)port;
  18     *p=0x44;
  19 }
  20 */
  21 
  22 // static void __attribute__((noreturn)) shutdown();
  23 // static void __attribute__((noreturn)) panic(int cnt);
  24 
  25 extern long *blob_chdk_core;
  26 // extern long *blob_copy_and_reset;
  27 extern long blob_chdk_core_size;
  28 // extern long blob_copy_and_reset_size;
  29 
  30 
  31 
  32 void __attribute__((noreturn)) my_restart() 
  33 {
  34 
  35   {
  36   // char *dst = dst_void;
  37   // const char *src = src_void;
  38   long *dst = (long*)MEMISOSTART;
  39   const long *src = blob_chdk_core;
  40   long length = (blob_chdk_core_size + 3) >> 2;
  41 
  42   core_copy(src, dst, length);
  43 
  44 }
  45 
  46     asm volatile(
  47         "MRS     R1, CPSR\n"
  48         "BIC     R1, R1, #0x3F\n"
  49         "ORR     R1, R1, #0xD3\n"
  50         "MSR     CPSR_cf, R1\n"
  51 
  52         "LDR     R2, =0xC0200000\n"
  53         "MOV     R1, #0xFFFFFFFF\n"
  54         "STR     R1, [R2,#0x10C]\n"
  55         "STR     R1, [R2,#0xC]\n"
  56         "STR     R1, [R2,#0x1C]\n"
  57         "STR     R1, [R2,#0x2C]\n"
  58         "STR     R1, [R2,#0x3C]\n"
  59         "STR     R1, [R2,#0x4C]\n"
  60         "STR     R1, [R2,#0x5C]\n"
  61         "STR     R1, [R2,#0x6C]\n"
  62         "STR     R1, [R2,#0x7C]\n"
  63         "STR     R1, [R2,#0x8C]\n"
  64         "STR     R1, [R2,#0x9C]\n"
  65         "STR     R1, [R2,#0xAC]\n"
  66         "STR     R1, [R2,#0xBC]\n"
  67         "STR     R1, [R2,#0xCC]\n"
  68         "STR     R1, [R2,#0xDC]\n"
  69         "STR     R1, [R2,#0xEC]\n"
  70         "STR     R1, [R2,#0xFC]\n"
  71 
  72         "MOV     R1, #0x78\n"
  73         "MCR     p15, 0, R1,c1,c0\n"
  74         "MOV     R1, #0\n"
  75         "MCR     p15, 0, R1,c7,c10, 4\n"
  76         "MCR     p15, 0, R1,c7,c5\n"
  77         "MCR     p15, 0, R1,c7,c6\n"
  78         "MOV     R2, #0x40000000\n"
  79         "ORR     R1, R2, #6\n"
  80         "MCR     p15, 0, R1,c9,c1\n"
  81         "ORR     R1, R1, #6\n"
  82         "MCR     p15, 0, R1,c9,c1, 1\n"
  83         "MRC     p15, 0, R1,c1,c0\n"
  84         "ORR     R1, R1, #0x50000\n"
  85         "MCR     p15, 0, R1,c1,c0\n"
  86 
  87         "MOV     R3, #0xFF0\n"
  88         "LDR     R1, =0x12345678\n"
  89         "ADD     R3, R3, #0x4000000C\n"
  90         "STR     R1, [R3]\n"
  91 
  92         "MOV     SP, #0x1900\n"
  93         "MOV     LR, PC\n"
  94         "MOV     PC, %0\n"
  95     : : "r"(MEMISOSTART) : "memory","r1","r2","r3");
  96 
  97     while(1);
  98 }
  99 
 100 // static void __attribute__((noreturn)) shutdown()
 101 // {
 102 //     volatile long *p = (void*)0xc02200a0;
 103 //         
 104 //     asm(
 105 //          "MRS     R1, CPSR\n"
 106 //          "AND     R0, R1, #0x80\n"
 107 //          "ORR     R1, R1, #0x80\n"
 108 //          "MSR     CPSR_cf, R1\n"
 109 //          :::"r1","r0");
 110 //         
 111 //     *p = 0x44;
 112 // 
 113 //     while(1);
 114 // }
 115 // 
 116 // 
 117 // static void __attribute__((noreturn)) panic(int cnt)
 118 // {
 119 //      int i;
 120 // 
 121 //      for(;cnt>0;cnt--){
 122 //              
 123 //              port_on(LED_PR);
 124 // 
 125 //              for(i=0;i<0x200000;i++){
 126 //                      asm ("nop\n");
 127 //                      asm ("nop\n");
 128 //              }
 129 //              
 130 //              port_off(LED_PR);
 131 // 
 132 //              for(i=0;i<0x200000;i++){
 133 //                      asm ("nop\n");
 134 //                      asm ("nop\n");
 135 //              }
 136 //      }
 137 //      shutdown();
 138 // }

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