2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: 16450 serial UART serial console.
9 #include <hardware/uart.h>
11 #include <bootconsole.h>
16 #define SER_MAXBAUD 115200
18 /* These settings can be kept across warm reboots in kickstart */
19 unsigned short Serial_Base
= 0x03F8;
20 static unsigned int baudRate
= 115200;
29 /* Standard base addresses for four PC AT serial ports */
30 static unsigned short standard_ports
[] =
38 void serial_Init(char *opts
)
41 unsigned short uDivisor
;
46 /* Command line option format: debug=serial[:N][@baud] */
49 unsigned short port
= strtoul(++opts
, &opts
, 0);
51 /* N can be either port number (0 - 4) or direct base address specification */
53 Serial_Base
= standard_ports
[port
];
61 unsigned int baud
= strtoul(++opts
, NULL
, 10);
63 if (baud
<= SER_MAXBAUD
)
69 base
= IO_Base
+ Serial_Base
;
74 uDivisor
= SER_MAXBAUD
/ baudRate
;
75 tmp
= inb_p(base
+ UART_LCR
);
76 outb_p(tmp
| UART_LCR_DLAB
, base
+ UART_LCR
);
77 outb_p(uDivisor
& 0xFF, base
+ UART_DLL
);
78 outb_p(uDivisor
>> 8, base
+ UART_DLM
);
79 outb_p(tmp
, base
+ UART_LCR
);
81 outb_p(UART_LCR_WLEN8
, base
+ UART_LCR
);
82 inb_p(base
+ UART_RX
);
85 static void serial_RawPutc(char data
)
90 base
= IO_Base
+ Serial_Base
;
95 /* Wait until the transmitter is empty */
96 while (!(inb_p(base
+ UART_LSR
) & UART_LSR_TEMT
));
98 /* Send out the byte */
99 outb_p(data
, base
+ UART_TX
);
102 void serial_Putc(char chr
)
106 /* Ignore null bytes, they are output by formatting routines as terminators */
110 /* Prepend CR to LF */
112 serial_RawPutc('\r');