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