Since some people disapprove of white space cleanups mixed in regular commits
[coreboot.git] / util / mkelfImage / linux-ia64 / head.S
1 #define ASSEMBLY 1
2
3         .text
4
5 #include "convert.h"
6
7         .globl _start
8         .proc _start
9 _start:
10         alloc   loc0=ar.pfs,1,2,3,0 /* in, local, out, rotating */
11         mov     loc1=rp
12         mov     r14=ip  /* Get the address of _start, I'm in the first bundle */
13         movl    r15=@gprel(_start)
14         ;;
15         sub     gp=r14,r15      /* gp = _start - @gprel(_start), current value of gp */
16         ;;
17         mov     out0=in0
18         mov     out1=r28
19         add     out2=@gprel(params),gp
20         br.call.sptk.few rp=convert_params
21
22
23         mov     r28=r8
24         add     r15=@gprel(entry), gp
25         ;;
26         ld8     r16=[r15]
27         ;;
28         mov     b1=r16
29         mov     ar.pfs=loc0
30         mov     rp=loc1
31         ;;
32         br.cond.sptk.few b1
33
34         .size _start, . - _start
35         .endp _start
36
37
38 #if 0
39
40 /* Base Address */
41 #define UART_BASE       0x00000000f8030000
42 #define UART_BAUD       9600
43
44 /* Data */
45 #define UART_RBR        0x00
46 #define UART_TBR        0x00
47 /* Control */
48 #define UART_IER        0x01
49 #define UART_IIR        0x02
50 #define UART_FCR        0x02
51 #define UART_LCR        0x03
52 #define UART_MCR        0x04
53
54 #define UART_DLL        0x00
55 #define UART_DLM        0x01
56 /* Status */
57 #define UART_LSR        0x05
58 #define UART_MSR        0x06
59 #define UART_SCR        0x07
60
61 #define UART_PHYS_BASE  (0x8000000000000000|UART_BASE)
62 #define UART_DIV        (115200/UART_BAUD)
63 #define UART_DIV_LO     (UART_DIV&0xFF)
64 #define UART_DIV_HI     ((UART_DIV >> 8)&0xFF)
65
66 #if ((115200%UART_BAUD) != 0)
67 #error Bad uart baud rate
68 #endif
69
70 /* NOTE: As these are debugging functions, they do not consume any
71  * space on the register stack, and instead rely entirely on
72  * scratch registers for the registers they use.
73  */
74 uart_init:
75         /* set the UART_BASE */
76         movl    r31=UART_PHYS_BASE
77         ;;
78
79         /* disable interrupts */
80         add     r30=UART_IER,r31
81         mov     r29=0x00
82         ;;
83         st1     [r30]=r29
84
85         /* enable fifos */
86         add     r30=UART_FCR,r31
87         mov     r29=0x01
88         ;;
89         st1     [r30]=r29
90
91         /* Set Baud Rate Divisor to UART_BAUD */
92         add     r30=UART_LCR,r31
93         mov     r29=0x83
94         ;;
95         st1     [r30]=r29
96
97         add     r30=UART_DLL,r31
98         mov     r29=UART_DIV_LO
99         ;;
100         st1     [r30]=r29
101
102         add     r30=UART_DLM,r31
103         mov     r29=UART_DIV_HI
104         ;;
105         st1     [r30]=r29
106
107         add     r30=UART_LCR,r31
108         mov     r29=0x03
109         ;;
110         st1     [r30]=r29
111
112         br.ret.sptk.few rp
113
114         .proc   uart_tx_byte
115         .globl  uart_tx_byte
116 uart_tx_byte:
117         /* set the UART_PHYS_BASE */
118         movl    r31=UART_PHYS_BASE
119         ;;
120 __uart_tx_byte:
121         /* Wait until the UART can hold another byte */
122         add     r30=UART_LSR,r31
123         ;;
124 9:      ld1.acq.nta     r29=[r30]
125         ;;
126         and     r29=0x20,r29
127         ;;
128         cmp.eq  p63,p0=0,r29
129 (p63)   br.cond.sptk.few        9b
130
131         /* Transmit the byte */
132         add     r30=UART_TBR,r31
133         ;;
134         st1.rel.nta     [r30]=r32
135         ;;
136
137         /* Wait until the UART is empty to be certain the byte is flushed */
138         add     r30=UART_LSR,r31
139         ;;
140 9:      ld1.acq.nta     r29=[r30]
141         ;;
142         and     r29=0x40,r29
143         ;;
144         cmp.eq  p63,p0=0,r29
145 (p63)   br.cond.sptk.few        9b
146         ;;
147         br.ret.sptk.few rp
148         .endp uart_tx_byte
149
150 __uart_tx_hex_char:
151         cmp.ltu p62,p63=9,r32
152         ;;
153 (p63)   add     r32=48,r32      /* digits*/
154 (p62)   add     r32=55,r32      /* letters */
155         br.cond.sptk.few __uart_tx_byte
156
157 uart_tx_hex64:
158         /* set the UART_bASE */
159         movl    r31=UART_PHYS_BASE
160         /* skip r28 */
161         mov     r27=rp
162         mov     r26=ar.pfs
163         mov     r25=r32
164         ;;
165         extr.u  r32=r25,60,4
166         br.call.sptk.few rp=__uart_tx_hex_char
167         ;;
168         extr.u  r32=r25,56,4
169         br.call.sptk.few rp=__uart_tx_hex_char
170         ;;
171         extr.u  r32=r25,52,4
172         br.call.sptk.few rp=__uart_tx_hex_char
173         ;;
174         extr.u  r32=r25,48,4
175         br.call.sptk.few rp=__uart_tx_hex_char
176         ;;
177         extr.u  r32=r25,44,4
178         br.call.sptk.few rp=__uart_tx_hex_char
179         ;;
180         extr.u  r32=r25,40,4
181         br.call.sptk.few rp=__uart_tx_hex_char
182         ;;
183         extr.u  r32=r25,36,4
184         br.call.sptk.few rp=__uart_tx_hex_char
185         ;;
186         extr.u  r32=r25,32,4
187         br.call.sptk.few rp=__uart_tx_hex_char
188         ;;
189         extr.u  r32=r25,28,4
190         br.call.sptk.few rp=__uart_tx_hex_char
191         ;;
192         extr.u  r32=r25,24,4
193         br.call.sptk.few rp=__uart_tx_hex_char
194         ;;
195         extr.u  r32=r25,20,4
196         br.call.sptk.few rp=__uart_tx_hex_char
197         ;;
198         extr.u  r32=r25,16,4
199         br.call.sptk.few rp=__uart_tx_hex_char
200         ;;
201         extr.u  r32=r25,12,4
202         br.call.sptk.few rp=__uart_tx_hex_char
203         ;;
204         extr.u  r32=r25,8,4
205         br.call.sptk.few rp=__uart_tx_hex_char
206         ;;
207         extr.u  r32=r25,4,4
208         br.call.sptk.few rp=__uart_tx_hex_char
209         ;;
210         extr.u  r32=r25,0,4
211         br.call.sptk.few rp=__uart_tx_hex_char
212         ;;
213         mov     ar.pfs = r26
214         mov     rp = r27
215         ;;
216         br.ret.sptk.few rp
217 #endif
218
219         .section ".trailer", "a"
220         /* Constants set at build time, these are at the very end of my image */
221         .balign 16
222         .global params
223 params:
224 convert_magic:
225         .quad   CONVERT_MAGIC
226 entry:
227         .quad   0
228 initrd_start:
229         .quad   0
230 initrd_size:
231         .quad   0
232 cmdline:
233         .asciz "BOOT_IMAGE=head.S console=ttyS0 ip=dhcp root=/dev/nfs"
234         .org cmdline + 1024, 0
235 cmdline_end: