[BACK]Return to cons_ns16550.c CVS log [TXT][DIR] Up to [local] / prex-old / sys / arch / arm / cats

File: [local] / prex-old / sys / arch / arm / cats / cons_ns16550.c (download)

Revision 1.1, Fri Jul 18 20:21:48 2008 UTC (15 years, 10 months ago) by nbrk
Branch: MAIN
CVS Tags: HEAD

first steps to let Prex kernel compile and run on arm-cats platform.
clocks and interrupts subsystems are stubs, but kernel diagnostics messages
work (using serial port 0).
kernel boots and panics in thread_init, but at least it boots and prints something!
it's far more easy and fun to hack code which compiles (:
still more work on the road.

/*
 * $Id: cons_ns16550.c,v 1.1 2008/07/18 20:21:48 nbrk Exp $
 */
/*
 * ns16550 USARTs.
 */
#include <sys/types.h>
#include <platform.h>

#define IO_BASE	0x7c000000

#define USART0_BASE	(IO_BASE + 0x3f8)
#define USART1_BASE	(IO_BASE + 0x2f8)

#define UART_DR	0	/* TX/RX data register */
#define UART_LSR	5	/* line status register */
#define  LST_DR		0x01	/* receiver data ready */
#define  LSR_TEMT	0x40	/* transmitter empty */

#define DIAG_USART	USART0_BASE


void
put_char(char c)
{
	/* poll TEMT */
	while ((*(volatile uint32_t *)(DIAG_USART + UART_LSR * 4)) & LSR_TEMT != 1)
		;

	/* write tx fifo */
	*(volatile uint32_t *)(DIAG_USART + UART_DR * 4) = c;
}