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

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