Pull model-name into release branch
[deliverable/linux.git] / arch / cris / arch-v10 / boot / rescue / kimagerescue.S
1 /* $Id: kimagerescue.S,v 1.1 2001/12/17 13:59:27 bjornw Exp $
2 *
3 * Rescue code to be prepended on a kimage and copied to the
4 * rescue serial port.
5 * This is called from the rescue code, it will copy received data to
6 * 4004000 and after a timeout jump to it.
7 */
8
9 #define ASSEMBLER_MACROS_ONLY
10 #include <asm/sv_addr_ag.h>
11
12 #define CODE_START 0x40004000
13 #define CODE_LENGTH 784
14 #define TIMEOUT_VALUE 1000
15
16
17 #ifdef CONFIG_ETRAX_RESCUE_SER0
18 #define SERXOFF R_SERIAL0_XOFF
19 #define SERBAUD R_SERIAL0_BAUD
20 #define SERRECC R_SERIAL0_REC_CTRL
21 #define SERRDAT R_SERIAL0_REC_DATA
22 #define SERSTAT R_SERIAL0_STATUS
23 #endif
24 #ifdef CONFIG_ETRAX_RESCUE_SER1
25 #define SERXOFF R_SERIAL1_XOFF
26 #define SERBAUD R_SERIAL1_BAUD
27 #define SERRECC R_SERIAL1_REC_CTRL
28 #define SERRDAT R_SERIAL1_REC_DATA
29 #define SERSTAT R_SERIAL1_STATUS
30 #endif
31 #ifdef CONFIG_ETRAX_RESCUE_SER2
32 #define SERXOFF R_SERIAL2_XOFF
33 #define SERBAUD R_SERIAL2_BAUD
34 #define SERRECC R_SERIAL2_REC_CTRL
35 #define SERRDAT R_SERIAL2_REC_DATA
36 #define SERSTAT R_SERIAL2_STATUS
37 #endif
38 #ifdef CONFIG_ETRAX_RESCUE_SER3
39 #define SERXOFF R_SERIAL3_XOFF
40 #define SERBAUD R_SERIAL3_BAUD
41 #define SERRECC R_SERIAL3_REC_CTRL
42 #define SERRDAT R_SERIAL3_REC_DATA
43 #define SERSTAT R_SERIAL3_STATUS
44 #endif
45
46 .text
47 ;; This is the entry point of the rescue code
48 ;; 0x80000000 if loaded in flash (as it should be)
49 ;; since etrax actually starts at address 2 when booting from flash, we
50 ;; put a nop (2 bytes) here first so we dont accidentally skip the di
51
52 nop
53 di
54 #ifndef CONFIG_SVINTO_SIM
55 ;; setup port PA and PB default initial directions and data
56 ;; (so we can flash LEDs, and so that DTR and others are set)
57
58 move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0
59 move.b $r0, [R_PORT_PA_DIR]
60 move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0
61 move.b $r0, [R_PORT_PA_DATA]
62
63 move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0
64 move.b $r0, [R_PORT_PB_DIR]
65 move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0
66 move.b $r0, [R_PORT_PB_DATA]
67
68 ;; We need to setup the bus registers before we start using the DRAM
69 #include "../../lib/dram_init.S"
70
71 #endif
72 ;; Setup the stack to a suitably high address.
73 ;; We assume 8 MB is the minimum DRAM in an eLinux
74 ;; product and put the sp at the top for now.
75
76 move.d 0x40800000, $sp
77
78 ;; setup the serial port at 115200 baud
79
80 moveq 0, $r0
81 move.d $r0, [SERXOFF]
82
83 move.b 0x99, $r0
84 move.b $r0, [SERBAUD] ; 115.2kbaud for both transmit and receive
85
86 move.b 0x40, $r0 ; rec enable
87 move.b $r0, [SERRECC]
88
89
90 moveq 0, $r1 ; "timer" to clock out a LED red flash
91 move.d CODE_START, $r3 ; destination counter
92 move.d CODE_LENGTH, $r4 ; length
93 move.d TIMEOUT_VALUE, $r5 ; "timeout" until jump
94
95 wait_ser:
96 addq 1, $r1
97 subq 1, $r5 ; decrease timeout
98 beq jump_start ; timed out
99 nop
100 #ifndef CONFIG_ETRAX_NO_LEDS
101 #ifdef CONFIG_ETRAX_PA_LEDS
102 move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r2
103 #endif
104 #ifdef CONFIG_ETRAX_PB_LEDS
105 move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r2
106 #endif
107 move.d (1 << CONFIG_ETRAX_LED1R) | (1 << CONFIG_ETRAX_LED2R), $r0
108 btstq 16, $r1
109 bpl 1f
110 nop
111 or.d $r0, $r2 ; set bit
112 ba 2f
113 nop
114 1: not $r0 ; clear bit
115 and.d $r0, $r2
116 2:
117 #ifdef CONFIG_ETRAX_PA_LEDS
118 move.b $r2, [R_PORT_PA_DATA]
119 #endif
120 #ifdef CONFIG_ETRAX_PB_LEDS
121 move.b $r2, [R_PORT_PB_DATA]
122 #endif
123 #endif
124
125 ;; check if we got something on the serial port
126
127 move.b [SERSTAT], $r0
128 btstq 0, $r0 ; data_avail
129 bpl wait_ser
130 nop
131
132 ;; got something - copy the byte and loop
133
134 move.b [SERRDAT], $r0
135 move.b $r0, [$r3+]
136 move.d TIMEOUT_VALUE, $r5 ; reset "timeout"
137 subq 1, $r4 ; decrease length
138 bne wait_ser
139 nop
140 jump_start:
141 ;; jump into downloaded code
142
143 jump CODE_START
This page took 0.034581 seconds and 6 git commands to generate.