root/loader/sx210is/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 
  14     void __attribute__((noreturn)) (*copy_and_restart)(char *dst, char *src, long length);
  15     int i;
  16 
  17     for (i=0; i<(blob_copy_and_reset_size/sizeof(long)); i++){
  18         ((long*)(RESTARTSTART))[i] = blob_copy_and_reset[i];
  19     }
  20 
  21     copy_and_restart = (void*)RESTARTSTART;
  22     copy_and_restart((void*)MEMISOSTART, (char*)blob_chdk_core, blob_chdk_core_size);
  23 
  24 }
  25 
  26 #define LED_PR 0xC0220130   // -> ASM1989 08.24.2010 found at  FF91E080  in sx200 was FF8E73D0
  27 
  28 
  29 static void __attribute__((noreturn)) shutdown()
  30 {
  31     volatile long *p = (void*)LED_PR;       // turned off later, so assumed to be power
  32 
  33     asm(
  34          "MRS     R1, CPSR\n"
  35          "AND     R0, R1, #0x80\n"
  36          "ORR     R1, R1, #0x80\n"
  37          "MSR     CPSR_cf, R1\n"
  38          :::"r1","r0");
  39 
  40     *p = 0x44;  // led off.
  41 
  42     while(1);
  43 }
  44 
  45 
  46 static void __attribute__((noreturn)) panic(int cnt)
  47 {
  48         volatile long *p=(void*)LED_PR;
  49         int i;
  50 
  51         for(;cnt>0;cnt--){
  52                 p[0]=0x46;
  53 
  54                 for(i=0;i<0x200000;i++){
  55                         asm ("nop\n");
  56                         asm ("nop\n");
  57                 }
  58                 p[0]=0x44;
  59                 for(i=0;i<0x200000;i++){
  60                         asm ("nop\n");
  61                         asm ("nop\n");
  62                 }
  63         }
  64         shutdown();
  65 }

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