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