Path: blob/master/arch/cris/boot/rescue/kimagerescue.S
10819 views
/*1* Rescue code to be prepended on a kimage and copied to the2* rescue serial port.3* This is called from the rescue code, it will copy received data to4* 4004000 and after a timeout jump to it.5*/67#define ASSEMBLER_MACROS_ONLY8#include <arch/sv_addr_ag.h>910#define CODE_START 0x4000400011#define CODE_LENGTH 78412#define TIMEOUT_VALUE 1000131415#ifdef CONFIG_ETRAX_RESCUE_SER016#define SERXOFF R_SERIAL0_XOFF17#define SERBAUD R_SERIAL0_BAUD18#define SERRECC R_SERIAL0_REC_CTRL19#define SERRDAT R_SERIAL0_REC_DATA20#define SERSTAT R_SERIAL0_STATUS21#endif22#ifdef CONFIG_ETRAX_RESCUE_SER123#define SERXOFF R_SERIAL1_XOFF24#define SERBAUD R_SERIAL1_BAUD25#define SERRECC R_SERIAL1_REC_CTRL26#define SERRDAT R_SERIAL1_REC_DATA27#define SERSTAT R_SERIAL1_STATUS28#endif29#ifdef CONFIG_ETRAX_RESCUE_SER230#define SERXOFF R_SERIAL2_XOFF31#define SERBAUD R_SERIAL2_BAUD32#define SERRECC R_SERIAL2_REC_CTRL33#define SERRDAT R_SERIAL2_REC_DATA34#define SERSTAT R_SERIAL2_STATUS35#endif36#ifdef CONFIG_ETRAX_RESCUE_SER337#define SERXOFF R_SERIAL3_XOFF38#define SERBAUD R_SERIAL3_BAUD39#define SERRECC R_SERIAL3_REC_CTRL40#define SERRDAT R_SERIAL3_REC_DATA41#define SERSTAT R_SERIAL3_STATUS42#endif4344.text45;; This is the entry point of the rescue code46;; 0x80000000 if loaded in flash (as it should be)47;; since etrax actually starts at address 2 when booting from flash, we48;; put a nop (2 bytes) here first so we dont accidentally skip the di4950nop51di52#ifndef CONFIG_SVINTO_SIM53;; setup port PA and PB default initial directions and data54;; (so we can flash LEDs, and so that DTR and others are set)5556move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r057move.b $r0, [R_PORT_PA_DIR]58move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r059move.b $r0, [R_PORT_PA_DATA]6061move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r062move.b $r0, [R_PORT_PB_DIR]63move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r064move.b $r0, [R_PORT_PB_DATA]6566;; We need to setup the bus registers before we start using the DRAM67#include "../../lib/dram_init.S"6869#endif70;; Setup the stack to a suitably high address.71;; We assume 8 MB is the minimum DRAM in an eLinux72;; product and put the sp at the top for now.7374move.d 0x40800000, $sp7576;; setup the serial port at 115200 baud7778moveq 0, $r079move.d $r0, [SERXOFF]8081move.b 0x99, $r082move.b $r0, [SERBAUD] ; 115.2kbaud for both transmit83; and receive8485move.b 0x40, $r0 ; rec enable86move.b $r0, [SERRECC]878889moveq 0, $r1 ; "timer" to clock out a LED red flash90move.d CODE_START, $r3 ; destination counter91move.d CODE_LENGTH, $r4 ; length92move.d TIMEOUT_VALUE, $r5 ; "timeout" until jump9394wait_ser:95addq 1, $r196subq 1, $r5 ; decrease timeout97beq jump_start ; timed out98nop99#ifndef CONFIG_ETRAX_NO_LEDS100#ifdef CONFIG_ETRAX_PA_LEDS101move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r2102#endif103#ifdef CONFIG_ETRAX_PB_LEDS104move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r2105#endif106move.d (1 << CONFIG_ETRAX_LED1R) | (1 << CONFIG_ETRAX_LED2R), $r0107btstq 16, $r1108bpl 1f109nop110or.d $r0, $r2 ; set bit111ba 2f112nop1131: not $r0 ; clear bit114and.d $r0, $r21152:116#ifdef CONFIG_ETRAX_PA_LEDS117move.b $r2, [R_PORT_PA_DATA]118#endif119#ifdef CONFIG_ETRAX_PB_LEDS120move.b $r2, [R_PORT_PB_DATA]121#endif122#endif123124;; check if we got something on the serial port125126move.b [SERSTAT], $r0127btstq 0, $r0 ; data_avail128bpl wait_ser129nop130131;; got something - copy the byte and loop132133move.b [SERRDAT], $r0134move.b $r0, [$r3+]135move.d TIMEOUT_VALUE, $r5 ; reset "timeout"136subq 1, $r4 ; decrease length137bne wait_ser138nop139jump_start:140;; jump into downloaded code141142jump CODE_START143144145