root/loader/sx130is/main.c

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

DEFINITIONS

This source file includes following definitions.
  1. my_restart
  2. shutdown
  3. panic

   1 static void __attribute__((noreturn)) shutdown();
   2 static void __attribute__((noreturn)) panic(int cnt);
   3 
   4 extern long *blob_chdk_core;
   5 extern long *blob_copy_and_reset;
   6 extern long blob_chdk_core_size;
   7 extern long blob_copy_and_reset_size;
   8 
   9 
  10 
  11 void __attribute__((noreturn)) my_restart()
  12 {
  13     void __attribute__((noreturn)) (*copy_and_restart)(char *dst, char *src, long length);
  14     int i;
  15 
  16         for (i=0; i<(blob_copy_and_reset_size/sizeof(long)); i++){
  17         ((long*)(RESTARTSTART))[i] = blob_copy_and_reset[i];
  18     }
  19 
  20     copy_and_restart = (void*)RESTARTSTART;
  21     copy_and_restart((void*)MEMISOSTART, (char*)blob_chdk_core, blob_chdk_core_size);
  22 }
  23 
  24 
  25 //#define LED_PR 0xC022006C             // no power led on sx130
  26 
  27 static void __attribute__((noreturn)) shutdown()
  28 {
  29 //    volatile long *p = (void*) LED_PR;
  30 
  31     asm(
  32          "MRS     R1, CPSR\n"
  33          "AND     R0, R1, #0x80\n"
  34          "ORR     R1, R1, #0x80\n"
  35          "MSR     CPSR_cf, R1\n"
  36          :::"r1","r0");
  37 
  38 //    *p = 0x44;  // led off.
  39 
  40     while(1);
  41 }
  42 
  43 
  44 static void __attribute__((noreturn)) panic(int cnt)
  45 {
  46         volatile long *red=(void*) 0xC0220010;  // red(orange) led sx130
  47 
  48         int i;
  49 
  50         for(;cnt>0;cnt--){
  51                 *red = 0x46;
  52 
  53                 for(i=0;i<0x200000;i++){
  54                         asm ("nop\n");
  55                         asm ("nop\n");
  56                 }
  57 
  58                 *red = 0x44;
  59 
  60                 for(i=0;i<0x200000;i++){
  61                         asm ("nop\n");
  62                         asm ("nop\n");
  63                 }
  64         }
  65         shutdown();
  66 }

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