Change console code to emit SPEW with DEFAULT_CONSOLE_LOGLEVEL==8.
[coreboot.git] / src / arch / i386 / lib / console_print.c
1
2 static void __console_tx_nibble(unsigned nibble)
3 {
4         unsigned char digit;
5         digit = nibble + '0';
6         if (digit > '9') {
7                 digit += 39;
8         }
9         __console_tx_byte(digit);
10 }
11
12 static void __console_tx_char(int loglevel, unsigned char byte)
13 {
14         if (ASM_CONSOLE_LOGLEVEL >= loglevel) {
15                 uart_tx_byte(byte);
16         }
17 }
18
19 static void __console_tx_hex8(int loglevel, unsigned char value)
20 {
21         if (ASM_CONSOLE_LOGLEVEL >= loglevel) {
22                 __console_tx_nibble((value >>  4U) & 0x0fU);
23                 __console_tx_nibble(value & 0x0fU);
24         }
25 }
26
27 static void __console_tx_hex16(int loglevel, unsigned short value)
28 {
29         if (ASM_CONSOLE_LOGLEVEL >= loglevel) {
30                 __console_tx_nibble((value >> 12U) & 0x0fU);
31                 __console_tx_nibble((value >>  8U) & 0x0fU);
32                 __console_tx_nibble((value >>  4U) & 0x0fU);
33                 __console_tx_nibble(value & 0x0fU);
34         }
35 }
36
37 static void __console_tx_hex32(int loglevel, unsigned int value)
38 {
39         if (ASM_CONSOLE_LOGLEVEL >= loglevel) {
40                 __console_tx_nibble((value >> 28U) & 0x0fU);
41                 __console_tx_nibble((value >> 24U) & 0x0fU);
42                 __console_tx_nibble((value >> 20U) & 0x0fU);
43                 __console_tx_nibble((value >> 16U) & 0x0fU);
44                 __console_tx_nibble((value >> 12U) & 0x0fU);
45                 __console_tx_nibble((value >>  8U) & 0x0fU);
46                 __console_tx_nibble((value >>  4U) & 0x0fU);
47                 __console_tx_nibble(value & 0x0fU);
48         }
49 }
50
51 static void __console_tx_string(int loglevel, const char *str)
52 {
53         if (ASM_CONSOLE_LOGLEVEL >= loglevel) {
54                 unsigned char ch;
55                 while((ch = *str++) != '\0') {
56                         __console_tx_byte(ch);
57                 }
58         }
59 }
60
61 /* Actually this should say defined(__ROMCC__) but that define is explicitly
62  * set in some auto.c files to trigger the simple device_t version to be used.
63  * So __GNUCC__ does the right thing here.
64  */
65 #if defined (__GNUCC__)
66 #define STATIC
67 #else
68 #define STATIC static
69 #endif
70
71 STATIC void print_emerg_char(unsigned char byte) { __console_tx_char(BIOS_EMERG, byte); }
72 STATIC void print_emerg_hex8(unsigned char value){ __console_tx_hex8(BIOS_EMERG, value); }
73 STATIC void print_emerg_hex16(unsigned short value){ __console_tx_hex16(BIOS_EMERG, value); }
74 STATIC void print_emerg_hex32(unsigned int value) { __console_tx_hex32(BIOS_EMERG, value); }
75 STATIC void print_emerg(const char *str) { __console_tx_string(BIOS_EMERG, str); }
76
77 STATIC void print_alert_char(unsigned char byte) { __console_tx_char(BIOS_ALERT, byte); }
78 STATIC void print_alert_hex8(unsigned char value) { __console_tx_hex8(BIOS_ALERT, value); }
79 STATIC void print_alert_hex16(unsigned short value){ __console_tx_hex16(BIOS_ALERT, value); }
80 STATIC void print_alert_hex32(unsigned int value) { __console_tx_hex32(BIOS_ALERT, value); }
81 STATIC void print_alert(const char *str) { __console_tx_string(BIOS_ALERT, str); }
82
83 STATIC void print_crit_char(unsigned char byte) { __console_tx_char(BIOS_CRIT, byte); }
84 STATIC void print_crit_hex8(unsigned char value) { __console_tx_hex8(BIOS_CRIT, value); }
85 STATIC void print_crit_hex16(unsigned short value){ __console_tx_hex16(BIOS_CRIT, value); }
86 STATIC void print_crit_hex32(unsigned int value) { __console_tx_hex32(BIOS_CRIT, value); }
87 STATIC void print_crit(const char *str) { __console_tx_string(BIOS_CRIT, str); }
88
89 STATIC void print_err_char(unsigned char byte) { __console_tx_char(BIOS_ERR, byte); }
90 STATIC void print_err_hex8(unsigned char value) { __console_tx_hex8(BIOS_ERR, value); }
91 STATIC void print_err_hex16(unsigned short value){ __console_tx_hex16(BIOS_ERR, value); }
92 STATIC void print_err_hex32(unsigned int value) { __console_tx_hex32(BIOS_ERR, value); }
93 STATIC void print_err(const char *str) { __console_tx_string(BIOS_ERR, str); }
94
95 STATIC void print_warning_char(unsigned char byte) { __console_tx_char(BIOS_WARNING, byte); }
96 STATIC void print_warning_hex8(unsigned char value) { __console_tx_hex8(BIOS_WARNING, value); }
97 STATIC void print_warning_hex16(unsigned short value){ __console_tx_hex16(BIOS_WARNING, value); }
98 STATIC void print_warning_hex32(unsigned int value) { __console_tx_hex32(BIOS_WARNING, value); }
99 STATIC void print_warning(const char *str) { __console_tx_string(BIOS_WARNING, str); }
100
101 STATIC void print_notice_char(unsigned char byte) { __console_tx_char(BIOS_NOTICE, byte); }
102 STATIC void print_notice_hex8(unsigned char value) { __console_tx_hex8(BIOS_NOTICE, value); }
103 STATIC void print_notice_hex16(unsigned short value){ __console_tx_hex16(BIOS_NOTICE, value); }
104 STATIC void print_notice_hex32(unsigned int value) { __console_tx_hex32(BIOS_NOTICE, value); }
105 STATIC void print_notice(const char *str) { __console_tx_string(BIOS_NOTICE, str); }
106
107 STATIC void print_info_char(unsigned char byte) { __console_tx_char(BIOS_INFO, byte); }
108 STATIC void print_info_hex8(unsigned char value) { __console_tx_hex8(BIOS_INFO, value); }
109 STATIC void print_info_hex16(unsigned short value){ __console_tx_hex16(BIOS_INFO, value); }
110 STATIC void print_info_hex32(unsigned int value) { __console_tx_hex32(BIOS_INFO, value); }
111 STATIC void print_info(const char *str) { __console_tx_string(BIOS_INFO, str); }
112
113 STATIC void print_debug_char(unsigned char byte) { __console_tx_char(BIOS_DEBUG, byte); }
114 STATIC void print_debug_hex8(unsigned char value) { __console_tx_hex8(BIOS_DEBUG, value); }
115 STATIC void print_debug_hex16(unsigned short value){ __console_tx_hex16(BIOS_DEBUG, value); }
116 STATIC void print_debug_hex32(unsigned int value) { __console_tx_hex32(BIOS_DEBUG, value); }
117 STATIC void print_debug(const char *str) { __console_tx_string(BIOS_DEBUG, str); }
118
119 STATIC void print_spew_char(unsigned char byte) { __console_tx_char(BIOS_SPEW, byte); }
120 STATIC void print_spew_hex8(unsigned char value) { __console_tx_hex8(BIOS_SPEW, value); }
121 STATIC void print_spew_hex16(unsigned short value){ __console_tx_hex16(BIOS_SPEW, value); }
122 STATIC void print_spew_hex32(unsigned int value) { __console_tx_hex32(BIOS_SPEW, value); }
123 STATIC void print_spew(const char *str) { __console_tx_string(BIOS_SPEW, str); }
124