The upper half routines consist of ttyputc and ttywrite, which are the producers of data into the output buffer.
Ttyputc(devptr, ch)
The routine ttyputc(devptr, ch), used to input a single character, does the following:
If the input character is NEWLINE then it recursively calls itself to print a RETURN before the NEWLINE *.
Waits for osem (free space)
Deposits character in output buffer.
`Signals' lower-half output routine by enabling output interrupts
The routine ttywrite(devptr, buff, count), used to output count number of characters, does the following:
Copies as many characters as it can in the space available, making sure that the count of osem is adjusted appropriately.
Uses ttyputc to output the rest.