root/loader/ixus130_sd1400/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   {
  16   // char *dst = dst_void;
  17   // const char *src = src_void;
  18   long *dst = (long*)MEMISOSTART;
  19   const long *src = blob_chdk_core;
  20   long length = (blob_chdk_core_size + 3) >> 2;
  21 
  22   core_copy(src, dst, length);
  23 
  24 }
  25 
  26   // found at address 0xff83b9c0
  27   asm volatile (
  28         "mrs    r0, CPSR\n"
  29         "bic    r0, r0, #63\n"  // 0x3f
  30         "orr    r0, r0, #211\n" // 0xd3
  31         "msr    CPSR, r0\n"
  32         "ldr    r1, =0xc0200000\n" // was: "[pc, #164]  ; ff83ba7c" 
  33         "mvn    r0, #0\n"       // 0x0
  34         "str    r0, [r1, #268]\n"
  35         "str    r0, [r1, #12]\n"
  36         "str    r0, [r1, #28]\n"
  37         "str    r0, [r1, #44]\n"
  38         "str    r0, [r1, #60]\n"
  39         "str    r0, [r1, #76]\n"
  40         "str    r0, [r1, #92]\n"
  41         "str    r0, [r1, #108]\n"
  42         "str    r0, [r1, #124]\n"
  43         "str    r0, [r1, #140]\n"
  44         "str    r0, [r1, #156]\n"
  45         "str    r0, [r1, #172]\n"
  46         "str    r0, [r1, #188]\n"
  47         "str    r0, [r1, #204]\n"
  48         "str    r0, [r1, #220]\n"
  49         "str    r0, [r1, #236]\n"
  50         "cmp    r4, #7\n"       // 0x7
  51         "str    r0, [r1, #252]\n"
  52         "popeq  {r4, pc}\n"
  53         "ldr    r0, =0x78\n" // was: "mov ..., #120"
  54         "mcr    15, 0, r0, cr1, cr0, 0\n"
  55         "ldr    r0, =0x0\n" // was: "mov ..., #0"
  56         "mcr    15, 0, r0, cr7, cr10, 4\n"
  57         "mcr    15, 0, r0, cr7, cr5, 0\n"
  58         "mcr    15, 0, r0, cr7, cr6, 0\n"
  59         "ldr    r0, =0x80000006\n" // was: "mov ..., #-2147483642"
  60         "mcr    15, 0, r0, cr9, cr1, 0\n"
  61         "mcr    15, 0, r0, cr9, cr1, 1\n"
  62         "mrc    15, 0, r0, cr1, cr0, 0\n"
  63         "orr    r0, r0, #327680\n"      // 0x50000
  64         "mcr    15, 0, r0, cr1, cr0, 0\n"
  65         "ldr    r0, =0x12345678\n" // was: "[pc, #36]   ; ff83ba80" 
  66         "ldr    r1, =0x80000000\n" // was: "mov ..., #-2147483648"
  67         "str    r0, [r1, #4092]\n"
  68         //"ldr    r0, =0xff810000\n" // changed to:
  69         "mov    r0, %0\n"
  70         "pop    {r4, lr}\n"
  71         "bx     r0\n"
  72         : : "r"(MEMISOSTART) : "memory","r0","r1","r2","r3","r4");
  73 
  74   while(1);
  75 }
  76 
  77 
  78 // static void __attribute__((noreturn)) shutdown()
  79 // {
  80 //     volatile long *p = (void*)0xC022001C;       // from task_Bye (not really complete)
  81 //         
  82 //     asm(
  83 //          "MRS     R1, CPSR\n"
  84 //          "AND     R0, R1, #0x80\n"
  85 //          "ORR     R1, R1, #0x80\n"
  86 //          "MSR     CPSR_cf, R1\n"
  87 //          :::"r1","r0");
  88 //         
  89 //     *p = 0x44;
  90 // 
  91 //     while(1);
  92 // }
  93 // 
  94 // #define LED_PR 0xC0220134
  95 // static void __attribute__((noreturn)) panic(int cnt)
  96 // {
  97 //      volatile long *p=(void*)LED_PR;
  98 //      int i;
  99 // 
 100 //      for(;cnt>0;cnt--){
 101 //              p[0]=0x46;
 102 // 
 103 //              for(i=0;i<0x200000;i++){
 104 //                      asm ("nop\n");
 105 //                      asm ("nop\n");
 106 //              }
 107 //              p[0]=0x44;
 108 //              for(i=0;i<0x200000;i++){
 109 //                      asm ("nop\n");
 110 //                      asm ("nop\n");
 111 //              }
 112 //      }
 113 //      shutdown();
 114 // }

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