Writing a Kernel Line Discipline
Look at the internals of a line discipline and implement a simple line discipline for a serial touch screen controller.
Tuesday, March 15th, 2005
From June 1999 to February 2001, Linux Magazine’ s “Gearheads” column presented a variety of articles about Linux kernel and device driver development. This month, “Gearheads” returns as a monthly column, reflecting an increasing interest in porting and adapting the Linux kernel to hardware of all kinds. If you’d like to suggest topics for “Gearheads,” please see the contact information at the end of the article.
Line disciplines are an elegant way to use the same serial device driver to run different technologies. Terminals and many other devices, including equipment based on Point-to-Point Protocol (PPP), Serial Line Internet Protocol (SLIP), Bluetooth, and Infrared Data (IrDa), make use of a serial transport.
Line disciplines reside one layer above the serial driver and shape its behavior. The serial drivers handle the transfer of data to and from the hardware, while the line disciplines are responsible for processing the data and transferring it between kernel space and user space.
Line disciplines are also used to implement network interfaces over serial transport protocols. For example, the PPP, SLIP, and Bluetooth line disciplines perform packet framing, allocate and populate corresponding networking data structures, and pass the data on to the corresponding protocol layers.
There are sixteen standard line disciplines supported by the Linux kernel. The default line discipline that gets attached when a serial port gets opened is the N_TTY line discipline, which implements terminal I/O processing.