|
1 | 1 | #include "../generic/check_compat.c"
|
2 | 2 |
|
| 3 | +#define LED 0xD20801E0 |
| 4 | + |
3 | 5 | extern long *blob_chdk_core;
|
4 | 6 | extern long blob_chdk_core_size;
|
5 | 7 |
|
| 8 | +typedef struct { |
| 9 | + const char *str; |
| 10 | + const char *fw_str; |
| 11 | + void (*dcc_by_mva)(void *addr, long len); |
| 12 | + void (*ici_by_mva)(void *addr, long len); |
| 13 | + void (*core_unblock)(unsigned coreid); |
| 14 | +} ld_ver_t; |
| 15 | + |
| 16 | +ld_ver_t fw = { "GM1.01A", // |
| 17 | + (void*) 0xE03CFDF0, // |
| 18 | + (void*) 0xE036BA79, // dcache_clean_range |
| 19 | + (void*) 0xE036BB4D, // icache_flush_range |
| 20 | + (void*) 0xE0523D73 // |
| 21 | + }; |
| 22 | + |
| 23 | +int __attribute__((naked)) get_core_id() { |
| 24 | + asm volatile ( |
| 25 | + "mrc p15, #0, r0, c0, c0, #5\n" |
| 26 | + "ands r0, #0xf\n" |
| 27 | + "bx lr\n" |
| 28 | + ); |
| 29 | +} |
| 30 | + |
| 31 | +/** |
| 32 | + * @see loader entry |
| 33 | + */ |
6 | 34 | void __attribute__((noreturn)) my_restart() {
|
7 |
| - check_compat(); |
| 35 | + void (*cont)(int coreid) = (void*)(MEMISOSTART | 1); |
| 36 | + int coreid = get_core_id(); |
| 37 | + |
| 38 | + if (!coreid) { /* core 0 only */ |
| 39 | + check_compat(); |
| 40 | + |
| 41 | + long *dst = (long*)MEMISOSTART; |
| 42 | + const long *src = blob_chdk_core; |
| 43 | + long length = (blob_chdk_core_size + 3) >> 2; |
| 44 | + |
| 45 | + core_copy(src, dst, length); |
| 46 | + |
| 47 | + set_led(LED, 1, LEDCNTRL_NEW4); /* green LED on */ |
| 48 | + |
| 49 | + fw.dcc_by_mva(dst, length<<2); |
| 50 | + fw.ici_by_mva(dst, length<<2); |
| 51 | + fw.core_unblock(1); /* core 1 */ |
| 52 | + } |
8 | 53 |
|
9 |
| - while (1) |
10 |
| - ; |
| 54 | + cont(coreid); |
| 55 | + while(1); |
11 | 56 | }
|
0 commit comments