1 /* 2 * Ben NanoNote stage 2 payload test. 3 * 4 * Copyright (C) Wolfgang Spraul <wolfgang@sharism.cc> 5 * Copyright (C) 2015 Paul Boddie <paul@boddie.org.uk> 6 * 7 * This program is free software; you can redistribute it and/or modify it under 8 * the terms of the GNU General Public License as published by the Free Software 9 * Foundation; either version 3 of the License, or (at your option) any later 10 * version. 11 * 12 * This program is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 15 * details. 16 * 17 * You should have received a copy of the GNU General Public License along with 18 * this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #ifdef CONFIG_CPU_JZ4730_MINIPC 22 #include "board-minipc.h" 23 #else 24 #include "board-nanonote.h" 25 #endif 26 27 #include "lcd.h" 28 29 void c_main(void) 30 { 31 /* Relocate object locations. */ 32 33 volatile unsigned int start_addr, got_start, got_end, addr, offset; 34 volatile int started; 35 36 /* get absolute start address */ 37 __asm__ __volatile__( 38 "move %0, $20\n\t" 39 : "=r"(start_addr) 40 : 41 ); 42 43 /* get related GOT address */ 44 __asm__ __volatile__( 45 "la $4, _GLOBAL_OFFSET_TABLE_\n\t" 46 "move %0, $4\n\t" 47 "la $5, _got_end\n\t" 48 "move %1, $5\n\t" 49 : "=r"(got_start),"=r"(got_end) 50 : 51 ); 52 53 /* calculate offset and correct GOT*/ 54 offset = start_addr - 0x80000000; 55 got_start += offset; 56 got_end += offset; 57 58 for ( addr = got_start + 8; addr < got_end; addr += 4 ) 59 *((volatile unsigned int *)(addr)) += offset; // add offset to correct all GOT 60 61 /* The actual work. */ 62 63 started = is_started(); 64 if (!started) { 65 gpio_init2(); 66 cpm_init(); 67 rtc_init(); 68 timer_init(); 69 } 70 lcd_init(); 71 while (1); 72 }