Building Driver Stacks in the Linux Kernel

Figure 6.1 is a simplified diagram of the default TTY driver configuration after you load the bt.o module.You see how both the bt and serial TTY drivers use the N_TTY ¡disc as an adapter between themselves and the standard TTY I/O code? The N_TTY ¡disc is suitable for console TTY drivers. It does things like scan for control characters in the byte stream. But an application can change any TTY driver's line discipline by using a special ioctl call. For example, we could have an application change the serial driver's line discipline to be bt_ldisc instead of N_TTY.

Figure 6.1 Default TTY Driver Configuration

Figure 6.1 Default TTY Driver Configuration

Guess what? That's exactly how we make the Bluetooth driver talk to a Bluetooth card attached by a serial cable. Figure 6.2 shows a picture of this. The bt_ldisc in effect will route all data to and from the serial port through the Bluetooth driver.That's where all the parsing and packet assembly will take place.

Figure 6.2 Stacked TTY Driver Configuration

Figure 6.2 Stacked TTY Driver Configuration

In summary, line disciplines are important because they allow user-space applications to stack TTY drivers in the kernel. Note that this is exactly how PPP works over a TTY—and therefore RFCOMM devices must be TTY drivers.

Was this article helpful?

0 0

Post a comment