root/loader/sx1/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     unsigned 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 #define LED_PR 0xC02200B4
  25 
  26 
  27 static void __attribute__((noreturn)) shutdown()
  28 {
  29     volatile long *p = (void*)LED_PR;       // turned off later, so assumed to be power
  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 *p=(void*)LED_PR;
  47         int i;
  48 
  49         for(;cnt>0;cnt--){
  50                 p[0]=0x46;
  51 
  52                 for(i=0;i<0x200000;i++){
  53                         asm ("nop\n");
  54                         asm ("nop\n");
  55                 }
  56                 p[0]=0x44;
  57                 for(i=0;i<0x200000;i++){
  58                         asm ("nop\n");
  59                         asm ("nop\n");
  60                 }
  61         }
  62         shutdown();
  63 }

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