The source code for generic serial device drivers can be found in the drv/src/dbg subtree. There are two files per driver: Bsp.h and a file defining the interface to platform specific functions. This interface is device driver dependent.
The dbgBsp platform-specific source code can be found in the /src/dbg directory tree.
A serial line device driver is platform independent. It depends only on a chip used for serial I/O. A serial line device driver calls a small number of platform dependent functions in order to access device registers. If a generic driver already exists for your platform, you only need to modify these functions. If no generic device driver exists for a chip on your platform, create one using the generic serial line device driver interface described in drv/src/dbg/dbgUart.h.
This section describes a dbgBsp for the PowerPC Genesis-2 board. The source files for this example are in powerpc/genesis2/src/dbg. There are three files in this directory:
dbgBsp.c
ns16550Bsp.c
Imakefile
dbgBsp.c:
Declares and initializes a dbgBsp structure (as defined in bki/dbgBsp.h)
Implements the board reset function
Calls the serial driver initialization function and initializes the dbgBsp field in the BootConf structure
Contains dbgBsp_init, which is an entry point for dbgBsp
ns16550Bsp.c:
The ns16550_inb(), ns16550_outb() functions provide access to device registers.
The ns16550_divisor() function calculates the divisor corresponding to a given baud rate, which is then used to program the baud rate in the generic driver.
The ns16550_ioremap() function is called each time the I/O space mapping is changed.
Imakefile:
Builds dbgBsp binary file from dbgBsp.o and ns16550.o
Includes $(DRV_DIST_BIN)/dbg/ns16550.o (the generic driver) and $(DRV_DIST_BIN)/dbg/dbgUartConf.o (the serial line configuration) in the binary file
Declares dbgBsp_init as the entry point