root/loader/s90/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
  26 
  27 static void __attribute__((noreturn)) shutdown()
  28 {
  29     //volatile long *p = (void*)0xc02200a0;       // what does this LED? Power?
  30     volatile long *p = (void*)LED_PR;       // turned off later, so assumed to be power
  31         
  32     asm(
  33          "MRS     R1, CPSR\n"
  34          "AND     R0, R1, #0x80\n"
  35          "ORR     R1, R1, #0x80\n"
  36          "MSR     CPSR_cf, R1\n"
  37          :::"r1","r0");
  38         
  39     *p = 0x44;  // led off.
  40 
  41     while(1);
  42 }
  43 
  44 
  45 static void __attribute__((noreturn)) panic(int cnt)
  46 {
  47         volatile long *p=(void*)LED_PR;
  48         int i;
  49 
  50         for(;cnt>0;cnt--){
  51                 p[0]=0x46;
  52 
  53                 for(i=0;i<0x200000;i++){
  54                         asm ("nop\n");
  55                         asm ("nop\n");
  56                 }
  57                 p[0]=0x44;
  58                 for(i=0;i<0x200000;i++){
  59                         asm ("nop\n");
  60                         asm ("nop\n");
  61                 }
  62         }
  63         shutdown();
  64 }

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