Feature #13975


support for higher baud rates

Added by Joshua M. Clulow 3 months ago. Updated about 1 month ago.

Start date:
Due date:
% Done:


Estimated time:
Gerrit CR:


Baud rate selection on UNIX systems is a somewhat dusty corner of history. At some point in the distant past, the lower four bits of c_cflag in the termios structure were set aside to select the baud rate, using the constant CBAUD as a mask. This worked right up until serial lines exceeded 38400 baud, with the following speeds:

#define B0      0
#define B50     1
#define B75     2
#define B110    3
#define B134    4
#define B150    5
#define B200    6
#define B300    7
#define B600    8
#define B1200   9
#define B1800   10
#define B2400   11
#define B4800   12
#define B9600   13
#define B19200  14
#define B38400  15

There are, of course, faster speeds, with higher numbers:

#define B57600  16
#define B76800  17
#define B115200 18
#define B153600 19
#define B230400 20
#define B307200 21
#define B460800 22
#define B921600 23

But where, dear reader, do we put the extra bits? CS6 with a value of 16 consumes the next bit over in c_cflag. As it turns out, we have set aside another higher bit, CBAUDEXT, to signal that we are using the extended range. Baud rates faster than 38k4 are first reduced by 16 so that they can fit in the four bit space, and CBAUDEXT is set so that the kernel knows we did it. This means B921600 is effectively a CBAUD value of 7, leaving 8 slots in the range 8-15 free for our use here.

Though one might be forgiven for imagining the wallpaper peeling away at 921600 baud, there have since been new developments in the field of asynchronous serial communications. Some UARTs now run into the megabaud range, and indeed Linux systems have a set of extra higher speeds with which we could be source compatible:

#define  B1000000  0010010
#define  B1152000  0010011
#define  B1500000  0010012
#define  B2000000  0010013
#define  B2500000  0010014
#define  B3000000  0010015
#define  B3500000  0010016
#define  B4000000  0010017

As luck would have it, adding these extra definitions would take us right up to 31, which would represent the top of the CBAUDEXT space.

See Control Modes in termio(7I) for more background.

Once we add this, at least one driver can be immediately modified to support some of the higher speeds: usbftdi, which appears ready to support some existing 3Mbaud UART parts.

Files (1.38 KB) Joshua M. Clulow, 2021-08-25 11:17 PM

Related issues

Related to illumos gate - Bug #13979: support FTDI FT232H serial interfaceClosedJoshua M. Clulow


Also available in: Atom PDF