root/loader/g7x2/main.c

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

DEFINITIONS

This source file includes following definitions.
  1. get_core_id
  2. my_restart

   1 #include "../generic/check_compat.c"
   2 
   3 extern long *blob_chdk_core;
   4 extern long blob_chdk_core_size;
   5 
   6 int __attribute__((naked)) get_core_id() {
   7     asm volatile (
   8 "    mrc     p15, #0, r0, c0, c0, #5\n"
   9 "    ands    r0, #0xf\n"
  10 "    bx      lr\n"
  11     );
  12 }
  13 
  14 void __attribute__((noreturn)) my_restart()
  15 {
  16     int coreid = get_core_id();
  17 
  18     if (!coreid) {
  19         check_compat();
  20 
  21         long *dst = (long*)MEMISOSTART;
  22         const long *src = blob_chdk_core;
  23         long length = (blob_chdk_core_size + 3) >> 2;
  24 
  25         core_copy(src, dst, length);
  26 
  27         // GPIO base = 0xD2080000
  28         // 0xD20801E4   - SD led
  29 
  30         // light up green LED
  31         volatile int* p = (int*)0xD20801E4;
  32         *p = 0x24D0002;
  33     }
  34 
  35     asm volatile (
  36             "movs   r0, %2\n"
  37             "bne    cont1\n"
  38 
  39             "movs   r0, #1\n"
  40             "ldr    r1, =0xe051e07d\n"
  41             "blx    r1\n" // unblock core1
  42 
  43         "cont1:\n"
  44             "mov     r1, %1\n"
  45             "mov     r0, %0\n"
  46             "ldr     r2, =0xe042eb75\n" // address is OK for 101a
  47             "blx     r2\n"              // caching related routine called at fw startup
  48             "mov     r1, %1\n"
  49             "mov     r0, %0\n"
  50             "ldr     r2, =0xe042ec4d\n" // address is OK for 101a
  51             "blx     r2\n"              // caching related routine called at fw startup
  52             "mov     r0, %0\n"
  53             "add     r0, r0, #1\n"
  54             "bx      r0\n"
  55             : : "r"(MEMISOSTART), "r"(((blob_chdk_core_size+3)>>2)<<2), "r"(coreid) : "memory","r0","r1","r2","r3"
  56     );
  57     while(1);
  58 }

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