root/loader/sx430is/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 extern long *blob_chdk_core;
   4 extern long blob_chdk_core_size;
   5 
   6 //#define LED_PR 0xc022d1fc
   7 //#define LED_AF 0xc022d200
   8 //#define DELAY 5000000
   9 
  10 void __attribute__((noreturn)) my_restart()
  11 {
  12   //  volatile long *p1 = (void*)LED_AF;
  13     //int counter;
  14     // DEBUG: blink led
  15     //counter = DELAY; *p1 = 0x93d800;  while (counter--) { asm("nop\n nop\n"); };
  16     //counter = DELAY; *p1 = 0x83dc00;  while (counter--) { asm("nop\n nop\n"); };
  17     {
  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     // restart function
  26     // from sub_FF038D8C via 0x23456789  sx430
  27     asm volatile (
  28                 "    MOV     R0, #0x78 \n" 
  29                 "    MCR     p15, 0, R0, c1, c0 \n" 
  30                 "    MOV     R0, #0 \n" 
  31                 "    MCR     p15, 0, R0, c7, c10, 4 \n" 
  32                 "    MCR     p15, 0, R0, c7, c5 \n" 
  33                 "    MCR     p15, 0, R0, c7, c6 \n" 
  34                 "    MOV     R0, #0x80000006 \n" 
  35                 "    MCR     p15, 0, R0, c9, c1 \n" 
  36                 "    MCR     p15, 0, R0, c9, c1, 1 \n" 
  37                 "    MRC     p15, 0, R0, c1, c0 \n" 
  38                 "    ORR     R0, R0, #0x50000 \n" 
  39                 "    MCR     p15, 0, R0, c1, c0 \n" 
  40                 "    LDR     R0, =0x23456789 \n" 
  41                 "    MOV     R1, #0x80000000 \n" 
  42                 //"    STR     R0, [R1, #0xFFC] \n" 
  43                 //"    LDR     R0, =sub_FF020000 \n" 
  44                 "    MOV     R0, %0\n"              // new jump-vector
  45                 "    BLX     R0 \n"
  46                 "    MOV     R0, #1 \n"         
  47                 //"    LDMFD   SP!, {R4,LR} \n"  
  48          : : "r"(MEMISOSTART) : "memory","r0","r1","r2","r3","r4"
  49         );
  50 
  51         while(1);
  52 }
  53 

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