After this has been brought up many times before, rename src/arch/i386 to
[coreboot.git] / src / arch / x86 / llshell / console.inc
1
2 jmp     console0
3
4 #define __STR(X) #X
5 #define STR(X) __STR(X)
6
7
8 #undef STR
9         /* uses:        ax, dx */
10 #if defined(SERIAL_CONSOLE)
11 #define __CONSOLE_INLINE_TX_AL TTYS0_TX_AL
12 #else
13 #define __CONSOLE_INLINE_TX_AL
14 #endif
15
16         /* uses:        esp, ax, dx */
17 #define __CONSOLE_TX_CHAR(byte) \
18         mov     byte, %al       ; \
19         CALLSP(console_tx_al)
20
21         /* uses:         ax, dx */
22 #define __CONSOLE_INLINE_TX_CHAR(byte)  \
23         mov     byte, %al       ; \
24         __CONSOLE_INLINE_TX_AL
25
26         /* uses:        esp, ax, edx */
27 #define __CONSOLE_TX_HEX8(byte) \
28         mov     byte, %al       ; \
29         CALLSP(console_tx_hex8)
30
31         /* uses:         byte, ax, dx */
32 #define __CONSOLE_INLINE_TX_HEX8(byte)  \
33         movb    byte, %dl       ; \
34         shll    $16, %edx       ; \
35         shr     $4, %al         ; \
36         add     $'0', %al       ; \
37         cmp     $'9', %al       ; \
38         jle     9f              ; \
39         add     $39, %al        ; \
40 9:                              ; \
41         __CONSOLE_INLINE_TX_AL  ; \
42         shrl    $16, %edx       ; \
43         movb    %dl, %al        ; \
44         and     $0x0f, %al      ; \
45         add     $'0', %al       ; \
46         cmp     $'9', %al       ; \
47         jle     9f              ; \
48         add     $39, %al        ; \
49 9:                              ; \
50         __CONSOLE_INLINE_TX_AL
51
52         /* uses:        esp, eax, ebx, dx */
53 #define __CONSOLE_TX_HEX32(lword)       \
54         mov     lword, %eax     ; \
55         CALLSP(console_tx_hex32)
56
57         /* uses:        eax, lword, dx */
58 #define __CONSOLE_INLINE_TX_HEX32(lword)        \
59         mov     lword, %eax     ; \
60         shr     $28, %eax       ; \
61         add     $'0', %al       ; \
62         cmp     $'9', %al       ; \
63         jle     9f              ; \
64         add     $39, %al        ; \
65 9:                              ; \
66         __CONSOLE_INLINE_TX_AL          ; \
67                                 ; \
68         mov     lword, %eax     ; \
69         shr     $24, %eax       ; \
70         and     $0x0f, %al      ; \
71         add     $'0', %al       ; \
72         cmp     $'9', %al       ; \
73         jle     9f              ; \
74         add     $39, %al        ; \
75 9:                              ; \
76         __CONSOLE_INLINE_TX_AL          ; \
77                                 ; \
78         mov     lword, %eax     ; \
79         shr     $20, %eax       ; \
80         and     $0x0f, %al      ; \
81         add     $'0', %al       ; \
82         cmp     $'9', %al       ; \
83         jle     9f              ; \
84         add     $39, %al        ; \
85 9:                              ; \
86         __CONSOLE_INLINE_TX_AL          ; \
87                                 ; \
88         mov     lword, %eax     ; \
89         shr     $16, %eax       ; \
90         and     $0x0f, %al      ; \
91         add     $'0', %al       ; \
92         cmp     $'9', %al       ; \
93         jle     9f              ; \
94         add     $39, %al        ; \
95 9:                              ; \
96         __CONSOLE_INLINE_TX_AL          ; \
97                                 ; \
98         mov     lword, %eax     ; \
99         shr     $12, %eax       ; \
100         and     $0x0f, %al      ; \
101         add     $'0', %al       ; \
102         cmp     $'9', %al       ; \
103         jle     9f              ; \
104         add     $39, %al        ; \
105 9:                              ; \
106         __CONSOLE_INLINE_TX_AL          ; \
107                                 ; \
108         mov     lword, %eax     ; \
109         shr     $8, %eax        ; \
110         and     $0x0f, %al      ; \
111         add     $'0', %al       ; \
112         cmp     $'9', %al       ; \
113         jle     9f              ; \
114         add     $39, %al        ; \
115 9:                              ; \
116         __CONSOLE_INLINE_TX_AL          ; \
117                                 ; \
118         mov     lword, %eax     ; \
119         shr     $4, %eax        ; \
120         and     $0x0f, %al      ; \
121         add     $'0', %al       ; \
122         cmp     $'9', %al       ; \
123         jle     9f              ; \
124         add     $39, %al        ; \
125 9:                              ; \
126         __CONSOLE_INLINE_TX_AL          ; \
127                                 ; \
128         mov     lword, %eax     ; \
129         and     $0x0f, %al      ; \
130         add     $'0', %al       ; \
131         cmp     $'9', %al       ; \
132         jle     9f              ; \
133         add     $39, %al        ; \
134 9:                              ; \
135         __CONSOLE_INLINE_TX_AL
136
137
138         /* uses:         esp, ebx, ax, dx */
139 #define __CONSOLE_TX_STRING(string)     \
140         mov     string, %ebx    ; \
141         CALLSP(console_tx_string)
142
143         /* uses:         ebx, ax, dx */
144 #define __CONSOLE_INLINE_TX_STRING(string)      \
145         movl    string, %ebx    ; \
146 10:     movb    (%ebx), %al     ; \
147         incl    %ebx            ; \
148         testb   %al, %al        ; \
149         jz      11f             ; \
150         __CONSOLE_INLINE_TX_AL  ; \
151         jmp     10b             ; \
152 11:
153
154
155 #define CONSOLE_EMERG_TX_CHAR(byte)            __CONSOLE_TX_CHAR(byte)
156 #define CONSOLE_EMERG_INLINE_TX_CHAR(byte)     __CONSOLE_INLINE_TX_CHAR(byte)
157 #define CONSOLE_EMERG_TX_HEX8(byte)            __CONSOLE_TX_HEX8(byte)
158 #define CONSOLE_EMERG_INLINE_TX_HEX8(byte)     __CONSOLE_INLINE_TX_HEX8(byte)
159 #define CONSOLE_EMERG_TX_HEX32(lword)          __CONSOLE_TX_HEX32(lword)
160 #define CONSOLE_EMERG_INLINE_TX_HEX32(lword)   __CONSOLE_INLINE_TX_HEX32(lword)
161 #define CONSOLE_EMERG_TX_STRING(string)        __CONSOLE_TX_STRING(string)
162 #define CONSOLE_EMERG_INLINE_TX_STRING(string) __CONSOLE_INLINE_TX_STRING(string)
163
164 #define CONSOLE_ALERT_TX_CHAR(byte)            __CONSOLE_TX_CHAR(byte)
165 #define CONSOLE_ALERT_INLINE_TX_CHAR(byte)     __CONSOLE_INLINE_TX_CHAR(byte)
166 #define CONSOLE_ALERT_TX_HEX8(byte)            __CONSOLE_TX_HEX8(byte)
167 #define CONSOLE_ALERT_INLINE_TX_HEX8(byte)     __CONSOLE_INLINE_TX_HEX8(byte)
168 #define CONSOLE_ALERT_TX_HEX32(lword)          __CONSOLE_TX_HEX32(lword)
169 #define CONSOLE_ALERT_INLINE_TX_HEX32(lword)   __CONSOLE_INLINE_TX_HEX32(lword)
170 #define CONSOLE_ALERT_TX_STRING(string)        __CONSOLE_TX_STRING(string)
171 #define CONSOLE_ALERT_INLINE_TX_STRING(string) __CONSOLE_INLINE_TX_STRING(string)
172
173 #define CONSOLE_CRIT_TX_CHAR(byte)            __CONSOLE_TX_CHAR(byte)
174 #define CONSOLE_CRIT_INLINE_TX_CHAR(byte)     __CONSOLE_INLINE_TX_CHAR(byte)
175 #define CONSOLE_CRIT_TX_HEX8(byte)            __CONSOLE_TX_HEX8(byte)
176 #define CONSOLE_CRIT_INLINE_TX_HEX8(byte)     __CONSOLE_INLINE_TX_HEX8(byte)
177 #define CONSOLE_CRIT_TX_HEX32(lword)          __CONSOLE_TX_HEX32(lword)
178 #define CONSOLE_CRIT_INLINE_TX_HEX32(lword)   __CONSOLE_INLINE_TX_HEX32(lword)
179 #define CONSOLE_CRIT_TX_STRING(string)        __CONSOLE_TX_STRING(string)
180 #define CONSOLE_CRIT_INLINE_TX_STRING(string) __CONSOLE_INLINE_TX_STRING(string)
181
182 #define CONSOLE_ERR_TX_CHAR(byte)            __CONSOLE_TX_CHAR(byte)
183 #define CONSOLE_ERR_INLINE_TX_CHAR(byte)     __CONSOLE_INLINE_TX_CHAR(byte)
184 #define CONSOLE_ERR_TX_HEX8(byte)            __CONSOLE_TX_HEX8(byte)
185 #define CONSOLE_ERR_INLINE_TX_HEX8(byte)     __CONSOLE_INLINE_TX_HEX8(byte)
186 #define CONSOLE_ERR_TX_HEX32(lword)          __CONSOLE_TX_HEX32(lword)
187 #define CONSOLE_ERR_INLINE_TX_HEX32(lword)   __CONSOLE_INLINE_TX_HEX32(lword)
188 #define CONSOLE_ERR_TX_STRING(string)        __CONSOLE_TX_STRING(string)
189 #define CONSOLE_ERR_INLINE_TX_STRING(string) __CONSOLE_INLINE_TX_STRING(string)
190
191 #define CONSOLE_WARNING_TX_CHAR(byte)            __CONSOLE_TX_CHAR(byte)
192 #define CONSOLE_WARNING_INLINE_TX_CHAR(byte)     __CONSOLE_INLINE_TX_CHAR(byte)
193 #define CONSOLE_WARNING_TX_HEX8(byte)            __CONSOLE_TX_HEX8(byte)
194 #define CONSOLE_WARNING_INLINE_TX_HEX8(byte)     __CONSOLE_INLINE_TX_HEX8(byte)
195 #define CONSOLE_WARNING_TX_HEX32(lword)          __CONSOLE_TX_HEX32(lword)
196 #define CONSOLE_WARNING_INLINE_TX_HEX32(lword)   __CONSOLE_INLINE_TX_HEX32(lword)
197 #define CONSOLE_WARNING_TX_STRING(string)        __CONSOLE_TX_STRING(string)
198 #define CONSOLE_WARNING_INLINE_TX_STRING(string) __CONSOLE_INLINE_TX_STRING(string)
199
200 #define CONSOLE_NOTICE_TX_CHAR(byte)            __CONSOLE_TX_CHAR(byte)
201 #define CONSOLE_NOTICE_INLINE_TX_CHAR(byte)     __CONSOLE_INLINE_TX_CHAR(byte)
202 #define CONSOLE_NOTICE_TX_HEX8(byte)            __CONSOLE_TX_HEX8(byte)
203 #define CONSOLE_NOTICE_INLINE_TX_HEX8(byte)     __CONSOLE_INLINE_TX_HEX8(byte)
204 #define CONSOLE_NOTICE_TX_HEX32(lword)          __CONSOLE_TX_HEX32(lword)
205 #define CONSOLE_NOTICE_INLINE_TX_HEX32(lword)   __CONSOLE_INLINE_TX_HEX32(lword)
206 #define CONSOLE_NOTICE_TX_STRING(string)        __CONSOLE_TX_STRING(string)
207 #define CONSOLE_NOTICE_INLINE_TX_STRING(string) __CONSOLE_INLINE_TX_STRING(string)
208
209 #define CONSOLE_INFO_TX_CHAR(byte)            __CONSOLE_TX_CHAR(byte)
210 #define CONSOLE_INFO_INLINE_TX_CHAR(byte)     __CONSOLE_INLINE_TX_CHAR(byte)
211 #define CONSOLE_INFO_TX_HEX8(byte)            __CONSOLE_TX_HEX8(byte)
212 #define CONSOLE_INFO_INLINE_TX_HEX8(byte)     __CONSOLE_INLINE_TX_HEX8(byte)
213 #define CONSOLE_INFO_TX_HEX32(lword)          __CONSOLE_TX_HEX32(lword)
214 #define CONSOLE_INFO_INLINE_TX_HEX32(lword)   __CONSOLE_INLINE_TX_HEX32(lword)
215 #define CONSOLE_INFO_TX_STRING(string)        __CONSOLE_TX_STRING(string)
216 #define CONSOLE_INFO_INLINE_TX_STRING(string) __CONSOLE_INLINE_TX_STRING(string)
217
218 #define CONSOLE_DEBUG_TX_CHAR(byte)            __CONSOLE_TX_CHAR(byte)
219 #define CONSOLE_DEBUG_INLINE_TX_CHAR(byte)     __CONSOLE_INLINE_TX_CHAR(byte)
220 #define CONSOLE_DEBUG_TX_HEX8(byte)            __CONSOLE_TX_HEX8(byte)
221 #define CONSOLE_DEBUG_INLINE_TX_HEX8(byte)     __CONSOLE_INLINE_TX_HEX8(byte)
222 #define CONSOLE_DEBUG_TX_HEX32(lword)          __CONSOLE_TX_HEX32(lword)
223 #define CONSOLE_DEBUG_INLINE_TX_HEX32(lword)   __CONSOLE_INLINE_TX_HEX32(lword)
224 #define CONSOLE_DEBUG_TX_STRING(string)        __CONSOLE_TX_STRING(string)
225 #define CONSOLE_DEBUG_INLINE_TX_STRING(string) __CONSOLE_INLINE_TX_STRING(string)
226
227 #define CONSOLE_SPEW_TX_CHAR(byte)            __CONSOLE_TX_CHAR(byte)
228 #define CONSOLE_SPEW_INLINE_TX_CHAR(byte)     __CONSOLE_INLINE_TX_CHAR(byte)
229 #define CONSOLE_SPEW_TX_HEX8(byte)            __CONSOLE_TX_HEX8(byte)
230 #define CONSOLE_SPEW_INLINE_TX_HEX8(byte)     __CONSOLE_INLINE_TX_HEX8(byte)
231 #define CONSOLE_SPEW_TX_HEX32(lword)          __CONSOLE_TX_HEX32(lword)
232 #define CONSOLE_SPEW_INLINE_TX_HEX32(lword)   __CONSOLE_INLINE_TX_HEX32(lword)
233 #define CONSOLE_SPEW_TX_STRING(string)        __CONSOLE_TX_STRING(string)
234 #define CONSOLE_SPEW_INLINE_TX_STRING(string) __CONSOLE_INLINE_TX_STRING(string)
235
236         /* uses:        esp, ax, dx */
237 console_tx_al:
238         __CONSOLE_INLINE_TX_AL
239         RETSP
240
241         /* uses:         esp, ax, edx */
242 console_tx_hex8:
243         __CONSOLE_INLINE_TX_HEX8(%al)
244         RETSP
245
246
247         /* uses:         esp, ebx, eax, dx */
248 console_tx_hex32:
249         mov     %eax, %ebx
250         shr     $28, %eax
251         add     $'0', %al
252         cmp     $'9', %al
253         jle     9f
254         add     $39, %al
255 9:
256         __CONSOLE_INLINE_TX_AL
257
258         mov     %ebx, %eax
259         shr     $24, %eax
260         and     $0x0f, %al
261         add     $'0', %al
262         cmp     $'9', %al
263         jle     9f
264         add     $39, %al
265 9:
266         __CONSOLE_INLINE_TX_AL
267
268         mov     %ebx, %eax
269         shr     $20, %eax
270         and     $0x0f, %al
271         add     $'0', %al
272         cmp     $'9', %al
273         jle     9f
274         add     $39, %al
275 9:
276         __CONSOLE_INLINE_TX_AL
277
278         mov     %ebx, %eax
279         shr     $16, %eax
280         and     $0x0f, %al
281         add     $'0', %al
282         cmp     $'9', %al
283         jle     9f
284         add     $39, %al
285 9:
286         __CONSOLE_INLINE_TX_AL
287
288         mov     %ebx, %eax
289         shr     $12, %eax
290         and     $0x0f, %al
291         add     $'0', %al
292         cmp     $'9', %al
293         jle     9f
294         add     $39, %al
295 9:
296         __CONSOLE_INLINE_TX_AL
297
298         mov     %ebx, %eax
299         shr     $8, %eax
300         and     $0x0f, %al
301         add     $'0', %al
302         cmp     $'9', %al
303         jle     9f
304         add     $39, %al
305 9:
306         __CONSOLE_INLINE_TX_AL
307
308         mov     %ebx, %eax
309         shr     $4, %eax
310         and     $0x0f, %al
311         add     $'0', %al
312         cmp     $'9', %al
313         jle     9f
314         add     $39, %al
315 9:
316         __CONSOLE_INLINE_TX_AL
317
318         mov     %ebx, %eax
319         and     $0x0f, %al
320         add     $'0', %al
321         cmp     $'9', %al
322         jle     9f
323         add     $39, %al
324 9:
325         __CONSOLE_INLINE_TX_AL
326         RETSP
327
328         /* Uses esp, ebx, ax, dx  */
329
330 console_tx_string:
331         mov     (%ebx), %al
332         inc     %ebx
333         cmp     $0, %al
334         jne     9f
335         RETSP
336 9:
337         __CONSOLE_INLINE_TX_AL
338         jmp     console_tx_string
339
340 console0: