console_mask
};
-/* Output for the system console (kprintf etc) */
-void kputchar(char c)
-{
- if (c == '\n')
- tty_putc(1, '\r');
- tty_putc(1, c);
-}
-
static volatile uint8_t *uart_base = (volatile uint8_t *)0xFFF000;
#define GETB(x) (uart_base[(x)])
#define PUTB(x,y) uart_base[(x)] = (y)
+/* Output for the system console (kprintf etc). Polled. */
+void kputchar(char c)
+{
+ if (c == '\n') {
+ while(!(GETB(UART_SRA) & 4));
+ PUTB(UART_THRA, '\r');
+ }
+ while(!(GETB(UART_SRA) & 4));
+ PUTB(UART_THRA, c);
+}
+
ttyready_t tty_writeready(uint8_t minor)
{
- uint8_t c = GETB(0x10 * minor + UART_SRA);
- return (c & 2) ? TTY_READY_NOW : TTY_READY_SOON; /* TX DATA empty */
+ uint8_t c = GETB(0x10 * (minor - 1) + UART_SRA);
+ return (c & 4) ? TTY_READY_NOW : TTY_READY_SOON; /* TX DATA empty */
}
void tty_putc(uint8_t minor, unsigned char c)
{
- PUTB(0x10 * minor + UART_THRA, c);
+ PUTB(0x10 * (minor - 1) + UART_THRA, c);
}
void tty_setup(uint8_t minor, uint8_t flags)
{
}
-/* Currently run off the timer */
static void tty_interrupt(uint8_t r)
{
- if (r & 0x01) {
+ if (r & 0x02) {
r = GETB(UART_RHRA);
tty_inproc(1,r);
}
- if (r & 0x02) {
+ if (r & 0x01) {
if (sleeping & 2)
tty_outproc(1);
}
if (r & 0x04) {
/* How to clear break int ? */
}
- if (r & 0x10) {
+ if (r & 0x20) {
r = GETB(UART_RHRB);
tty_inproc(2,r);
}
- if (r & 0x20) {
+ if (r & 0x10) {
if (sleeping & 4)
tty_outproc(2);
}
{
uint8_t r = GETB(UART_ISR);
tty_interrupt(r);
- if (r & 0x08)
+ if (r & 0x08) {
+ /* Ack the interrupt */
+ GETB(UART_STOPCTR);
timer_interrupt();
+ }
/* and 0x80 is the GPIO */
}