1 void outb(unsigned char value, unsigned short port)
3 __builtin_outb(value, port);
6 unsigned char inb(unsigned short port)
8 return __builtin_inb(port);
12 #ifndef CONFIG_TTYS0_BASE
13 #define CONFIG_TTYS0_BASE 0x3f8
16 #ifndef CONFIG_TTYS0_BAUD
17 #define CONFIG_TTYS0_BAUD 115200
20 #if ((115200%CONFIG_TTYS0_BAUD) != 0)
21 #error Bad ttys0 baud rate
24 #if CONFIG_TTYS0_BAUD == 115200
25 #define CONFIG_TTYS0_DIV (1)
27 #define CONFIG_TTYS0_DIV (115200/CONFIG_TTYS0_BAUD)
30 /* Line Control Settings */
31 #ifndef CONFIG_TTYS0_LCS
32 /* Set 8bit, 1 stop bit, no parity */
33 #define CONFIG_TTYS0_LCS 0x3
36 #define UART_LCS CONFIG_TTYS0_LCS
56 int uart_can_tx_byte(void)
58 return inb(CONFIG_TTYS0_BASE + UART_LSR) & 0x20;
61 void uart_wait_to_tx_byte(void)
63 while(!uart_can_tx_byte())
67 void uart_wait_until_sent(void)
69 while(!(inb(CONFIG_TTYS0_BASE + UART_LSR) & 0x40))
73 static void uart_tx_byte(unsigned char data)
75 uart_wait_to_tx_byte();
76 outb(data, CONFIG_TTYS0_BASE + UART_TBR);
77 /* Make certain the data clears the fifos */
78 uart_wait_until_sent();
84 /* disable interrupts */
85 outb(0x0, CONFIG_TTYS0_BASE + UART_IER);
87 outb(0x01, CONFIG_TTYS0_BASE + UART_FCR);
88 /* Set Baud Rate Divisor to 12 ==> 115200 Baud */
89 outb(0x80 | UART_LCS, CONFIG_TTYS0_BASE + UART_LCR);
90 outb(CONFIG_TTYS0_DIV & 0xFF, CONFIG_TTYS0_BASE + UART_DLL);
91 outb((CONFIG_TTYS0_DIV >> 8) & 0xFF, CONFIG_TTYS0_BASE + UART_DLM);
92 outb(UART_LCS, CONFIG_TTYS0_BASE + UART_LCR);
96 void __console_tx_char(unsigned char byte)
102 void __console_tx_string(char *str)
105 while((ch = *str++) != '\0') {
106 __console_tx_char(ch);
111 void print_debug_char(unsigned char byte) { __console_tx_char(byte); }
112 void print_debug(char *str) { __console_tx_string(str); }
116 static const char msg[] = "hello world\r\n";
122 print_debug("hello world\r\n");
123 print_debug("how are you today\r\n");