Previous Home Next


Serial Driver

The serial driver provides the console interface that's used to deliver debug messages and interact with the system. The driver is contained in the source file vx115_com.c, in the arch/arm/vx115 subdirectory. The driver provides several interfaces for use by various NetBSD subsystems: the standard autoconfig functions, a set of character device functions, and functions supporting console functionality.

Initialization

The serial driver provides the usual autoconfig match/attach functions:
as well as the usual autoconfig attachment declaration:
CFATTACH_DECL(vx115_com, sizeof(struct vx115_com_softc), vx115_com_match, vx115_com_attach, NULL, NULL);

tty functions

These functions are assigned to fields in the serial driver's softc structure's tty field. The tty structure is allocated during the attach routine, and then partially initialized by assigning these function pointers. The NetBSD tty subsystem handles further initialization (it obtains a pointer to the tty struct using the vx115_com_tty( ) method of the cdevsw struct). These functions handle the device-specific tty operations.

cdevsw functions

These are the basic interface functions for character drivers in NetBSD.

consdev functions

The consdev struct contains ponters to methods used for console input and output. These functions are used for low-level operations like kernel print statements. For example, the kernel printf function uses the following call sequence:

printf -> kprintf -> KPRINTF_PUTCHAR -> putchar -> v_putc -> cnputc -> cn_tab.cn_putc = vx115_com_cnputc

The functions are very low-level routines that just directly write to or read from the serial interface.

Interrupt routines

The interrupt routines handle the actual transfer of data between the driver's buffers and the serial interface FIFO. The hardware routines transfer between the hardware FIFO and the buffers, while the soft interrupt routines interpret the data and finish transmission as needed.

Transmit

Transmission is done primarily through the hardware interrupt routine, which is called whenever the transmit FIFO level falls below a threshold. The soft interrupt routine is scheduled only when the transmission is complete, and just synchronizes the tty buffer pointers to account for the transmitted data and checks to see if new data has become available for transmission, restarting transmission if so. 

vx115_tx_hard

vx115_com_txsoft

Receive

vx115_rx_hard

vx115_rx_soft

Early initialization

Because it's desirable to have serial output early in the boot process for debugging purposes during execution of the initarm( ) routine, there's an early initialization of the serial driver in the init_arm( ) function.



Previous Home Next


Comments/questions: jsevy@cs.drexel.edu