summaryrefslogtreecommitdiff
path: root/util/romcc/tests/simple_test15.c
blob: d02eaefd3530e8cde9b00cf82ecbd523337ac648 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
static void outb(unsigned char value, unsigned short port)
{
        __builtin_outb(value, port);
}

static unsigned char inb(unsigned short port)
{
        return __builtin_inb(port);
}
static int uart_can_tx_byte(void)
{
        return inb(0x3f8 + 0x05) & 0x20;
}

static void uart_wait_to_tx_byte(void)
{
        while(!uart_can_tx_byte())
                ;
}

static void uart_wait_until_sent(void)
{
        while(!(inb(0x3f8 + 0x05) & 0x40))
                ;
}

static void uart_tx_byte(unsigned char data)
{
        uart_wait_to_tx_byte();
        outb(data, 0x3f8 + 0x00);

        uart_wait_until_sent();
}

static void print_debug(const char *str)
{
	unsigned char ch;
	while((ch = *str++) != '\0') {
		uart_tx_byte(ch);
	}
}

static void main(void)
{
	print_debug("one\r\n");
        print_debug("two\r\n");
}