Eric Biederman | b138ac8 | 2003-04-22 18:44:01 +0000 | [diff] [blame^] | 1 | static void outb(unsigned char value, unsigned short port) |
| 2 | { |
| 3 | __builtin_outb(value, port); |
| 4 | } |
| 5 | |
| 6 | static unsigned char inb(unsigned short port) |
| 7 | { |
| 8 | return __builtin_inb(port); |
| 9 | } |
| 10 | static int uart_can_tx_byte(void) |
| 11 | { |
| 12 | return inb(0x3f8 + 0x05) & 0x20; |
| 13 | } |
| 14 | |
| 15 | static void uart_wait_to_tx_byte(void) |
| 16 | { |
| 17 | while(!uart_can_tx_byte()) |
| 18 | ; |
| 19 | } |
| 20 | |
| 21 | static void uart_wait_until_sent(void) |
| 22 | { |
| 23 | while(!(inb(0x3f8 + 0x05) & 0x40)) |
| 24 | ; |
| 25 | } |
| 26 | |
| 27 | static void uart_tx_byte(unsigned char data) |
| 28 | { |
| 29 | uart_wait_to_tx_byte(); |
| 30 | outb(data, 0x3f8 + 0x00); |
| 31 | |
| 32 | uart_wait_until_sent(); |
| 33 | } |
| 34 | |
| 35 | static void print_debug(const char *str) |
| 36 | { |
| 37 | unsigned char ch; |
| 38 | while((ch = *str++) != '\0') { |
| 39 | uart_tx_byte(ch); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | static void main(void) |
| 44 | { |
| 45 | print_debug("one\r\n"); |
| 46 | print_debug("two\r\n"); |
| 47 | } |