24.14 klopen (8023)

This procedure is called to “open” a terminal as a character special file. This call is usually made by the program “/etc/init” for each terminal which is to be active in the system. Since child processes inherit the open files of their parents, it is not usually necessary for other processes to “open” the device again. It will be noted that the there is no attempt to stop two unrelated processes having the terminal as an open file simultaneously.

8026:

Check the minor device number;

8030:

Locate the appropriate “tty” structure;

8031:

If the process opening the file has no associated controlling terminal designate the current terminal for this role. (Note that the reference stored is the address of a “tty” structure.):

8033:

Store the terminal device number in the “tty” structure

8039:

Calculate the address of the appropriate set of device registers for the terminal and store

8045:

If the terminal is not already “open”, do some initialisation of the “tty” structure ..

8046:

“t_state” is set to show the file is “open”, so that the next three lines will not be executed if the file is opened a second time, possibly undoing the effect of a “stty” system call:

“t_state” is also set to show “CARR_ON” (“carrier on”). This is a software flag which shows that the terminal is logically enabled, regardless of the true hardware status of the terminal. If “CARR_ON” is reset for a terminal, the system should ignore all input from the terminal.

(This does not seem to be entirely true, and this point will be taken up again later.);

8047:

The standard terminal is assumed to be unable to interpret horizontal tabs, to support only the 64 character ASCII subset, to run in full duplex mode and to require both “carriage return” and “line feed” characters to provide normal “new line” processing. (Could this be a Model 33 teletype?);

8048:

The “erase” and “kill” characters are set according to the UNIX convention;

8051:

The Receiver Control Status register is initialised with the pattern “0103” so that the terminal is made ready, reading is enabled and receiver interrupts are enabled;

8052:

The Transmitter Control Status register is initialised so that an interrupt will be generated whenever the interface is ready to receive another character.

Note that the “open” routine does not distinguish between the cases where the file is opened for reading only, or writing only, or for both reading and writing.