Korean Solaris System Administrator's Guide

Chapter 4 TTY Environment and Support

This chapter assumes you are familiar with how:

Refer to the termio(7) man pages for background information on STREAMS and TTY drivers.

TTY Streams

The data path between a user's shell and the terminal is called a stream. The data on a stream contain characters and control information that affect data handling, such as the control sequences that precede a change in code set or communication protocols. Data entering the stream from the terminal are raw or unprocessed. Data are sequentially processed by STREAMS modules for appropriate use by the shell or an application.

STREAMS provides a way to modularize the processing on a line, allowing processing instructions to be grouped in functional modules. These modules can be added or removed from the line so that different environments can be provided to a terminal according to the user's needs.

Traditional STREAMS

The traditional STREAMS TTY environment contains a raw device driver, a line discipline module, and a stream head. The raw device driver provides an I/O interface between the kernel and the hardware. Because it is closest to the physical hardware, it provides basic communication protocols, baud rate switching, and other low level services. The line discipline module is a set of instructions or disciplines that transforms the raw data to processed data. This includes handling the delete character, line kill character, and others. The stream head provides an interface between the user's process and the stream.

Korean Solaris STREAMS

The Korean Solaris operating environment uses the modular nature of STREAMS to support Korean. In addition to the traditional TTY modules, this product implements code conversion in STREAMS. Hangul-Hanja conversion is typically supplied by many existing Korean TTYs and is not available in the Korean Solaris TTY environment.

The Korean Solaris operating environment enhances the traditional modules. Its line discipline handles proper cursor movement for wide characters as well as normal protocols. The Korean Solaris software code conversion modules convert between two different character code formats such as between Packed (also called Combination code of KS C 5601-1987) and EUC (called Completion code).

Code conversion depends on the appropriate flags or parameters being set. For example, if a Packed code terminal is being used, the input from the terminal is converted to EUC and the output to the terminal is converted to Packed code.

The major modules that can be pushed onto the stream are ldterm, kpack and kjohap:

TTY Utilities

ioctl (input/output control) calls are low-level routines for handling device input and output.

The termcap and terminfo databases are used by applications to configure their terminal display appropriately.

EUC ioctl Features

The Korean Solaris operating environment uses ioctl(2) STREAMS commands for general EUC handling. The following is a summary of these ioctl calls and their effects:

Table 4-1 ioctl Requests and Descriptions

ioctl Request

Description 

EUC_WGET

Get cswidth values from TTY stream

EUC_WSET

Set cswidth values for TTY stream

EUC_OXLOFF

Set code conversion to OFF 

EUC_OXLON

Set code conversion to ON 

Character code conversion to and from the terminal is controlled by EUC_OXLON and EUC_OXLOFF.

termcap

termcap and terminfo are the databases used to tailor the terminal characteristics for an application. The following are extensions to the termcap database:

Table 4-2 termcap Variables and Descriptions

Variable 

Description  

dv

Device type: language and codeset  

ci

Init sequence for multiple codesets  

s0

Shift into codeset 0  

s1

Shift into codeset 1  

s2

Shift into codeset 2  

s3

Shift into codeset 3  

terminfo

The following are extensions to terminfo. The s0-s3 string values are used as data announcement mechanisms for the respective code sets during terminal I/O.

Table 4-3 terminfo Variables and Definitions

Variable 

Capname 

Tc 

Definition 

device_type

devt

dv

Device type: language and codeset  

code_set_init

csin

ci

Init sequence for multiple codesets  

set0_des_set

s0ds

s0

Shift into codeset 0  

set1_des_set

s1ds

s1

Shift into codeset 1  

set2_des_set

s2ds

s2

Shift into codeset 2  

set3_des_set

s3ds

s3

Shift into codeset 3  

TTY Commands

The two commands for configuring and using the TTY environment are setterm and /bin/stty. setterm is used primarily to build the TTY stream for a particular terminal type, pushing the necessary modules onto the stream. stty changes the behavior of the modules in the stream.

setterm Command

setterm is used to configure the TTY STREAMS environment. It can inquire about and manipulate STREAMS modules for a particular TTY port. setterm allows users to tailor their TTY STREAMS environment using system-provided or user-provided STREAMS modules.

setterm uses a terminal device name that reflects the devt (device type) field in the terminfo database for configuring STREAMS modules for a TTY port. This device name is matched with an entry of the same name in the setterm configuration file, /usr/share/lib/setterm/ko/conf.file or /usr/share/lib/setterm/ko.UTF-8/conf.file. This entry contains detailed instructions on which modules to pop and push in order to properly configure the STREAMS environment.

setterm can also take the device type as a direct argument. This device type is similarly matched with an entry in /usr/share/lib/setterm/ko/conf.file or /usr/share/lib/setterm/ko.UTF-8/conf.file.

The setterm configuration file uses a special language for instructions on what actions to take. This language allows users to determine the names of modules on the STREAMS stack, to push or pop modules on the stack, and to do other operations. setterm manipulates the STREAMS stack by making ioctl calls.

For more information, see the setterm(1) man page.

/bin/stty Command

The defeucw option to the /bin/stty command is for modifying STREAMS modules to reflect changes in the user's environment. It does not work with the /usr/ucb version of stty, which has not been internationalized.

The following command queries the user's environment for information on EUC code-set width and sets that information in the line discipline:


system% /bin/stty defeucw 

For example, if the user has the environment variable LC_CTYPE set to locale, this option gets information on the number of bytes per character and the screen width per character for the codesets in the ko and ko.UTF-8 environments and then sends this information to relevant modules in the stream.

TTY Setup Examples

The system administrator can add setterm in the startup script in /etc/rcn.d directory (where n is the run level), to run at the system boot time. Also, users can run the setterm command at login to configure the stream for their terminal, including the appropriate modules for Korean input code conversion. The following examples using setterm work as commands typed at a system prompt or included in system files such as .cshrc, .login, and the startup script. Such commands can either explicitly set the device type or use the terminfo database.

Configuring STREAMS for Korean Solaris Software

To explicitly configure the STREAMS module for EUC (Completion code) terminal type:


system% setterm -x EUC

For some more examples, consider using a Packed (Combination) code terminal, which uses either the Packed or Johap module.

To explicitly initialize the Packed STREAMS module, which supports a Combination code of KS C 5601-1987:


system% setterm -x PACK

To explicitly initialize the Johap STREAMS module, which supports a Combination code of KS C 5601-1992:


system% setterm -x JOHAP

This usage is independent of terminfo.

Further consider using a FAST-15 Packed code terminal on a system with an entry like the following (which is appropriate for such a terminal) in the terminfo database:


fast-15 | fast-pack | korean terminal packed mode,
devt=PACK,
use=vt100-w,

A configuring command that references this entry would be:


system% setterm -t fast-15

For setterm to work properly in this application, /usr/share/lib/setterm/ko/conf.file must contain an entry that corresponds to the device type. This entry gives setterm instructions for placing appropriate conversion modules in the TTY stream; for example:


#
KoreanPACK|PACKthrow \
							popto zs|mcp|mti|ptem \
							push kpack \
							push ldterm \
							push ttcompat \
							run {stty defeucw} \
							catch
#
KoreanJOHAP|JOHAP	throw \
							popto zs|mcp|mti|ptem \
							push kjohap \
							push ldterm \
							push ttcompat \
							run {stty defeucw} \
							catch
#
GenericEUC|EUCthrow \
							popto zs|mcp|mti|ptem \
							push ldterm \
							push ttcompat \
							run {stty defeucw} \
							catch
#
ASCIIthrow \
							popto zs|mcp|mti|ptem \
							push ldterm \
							push ttcompat \
							catch
# 

For more information, refer to the setterm(1) man page.

Configuring STREAMS for the ko.UTF-8 Locale

To explicitly configure the STREAMS module for the ko.UTF-8 locale:


system% setterm -x u8

To explicitly initialize the STREAMS module for an EUC terminal to use the ko.UTF-8 locale:


system% setterm -x ku8euc

To explicitly initialize the Johap STREAMS module, which supports a Combination code of KS C 5601-1992 terminal, to use the ko.UTF-8 locale:


system% setterm -x ku8johap
system% stty defeucw cs8 -istrip

For setterm to work properly in this application, /usr/share/lib/setterm/ko.UTF-8/conf.file must contain an entry that corresponds to the device type. This entry gives setterm instructions for placing appropriate conversion modules in the TTY stream; for example


# Korean specific entries:
#
# Completion/Wansung/EUC code terminal support (KS C 5601-1992)
KoreanU8EUC|KU8EUCthrow			\
			popto zs|mcp|mti|ptem   \
			push ku8euc		\
			push eucu8		\
			push ldterm		\
			push ttcompat		\
			push u8euc		\
			run {stty defeucw}	\
			catch
#
# Combination code terminal support (KS C 5601-1992 Annex 3)
KoreanU8JOHAP|KU8JOHAPthrow			\
			popto zs|mcp|mti|ptem   \
			push ku8johap		\
			push eucu8		\
			push ldterm		\
			push ttcompat		\
			push u8euc		\
			run {stty defeucw}	\
			catch
#

For more information, refer to the setterm(1) man page.

Terminal Support

The Korean Solaris operating environment supports Completion-code terminals and Packed-code (also called Combination-code, both KS C 5601-1987 and KS C 5601-1992) terminals. The terminals should have built-in automata and Hangul/Hanja fonts and input methods.

Installing a Terminal

If you have not added a terminal to your system before, first try installing a terminal in ASCII mode only. For more information, see System Administration Guide.

Serial Port Interface for Adding Terminals

Serial Ports is available from the Admintool menu to configure serial ports for terminals. Serial Ports provides the easiest method of installing a terminal. Serial Ports is invoked by admintool. For more information on admintool, see System Administration Guide.

Accessing Serial Ports

A Korean terminal that supports KS C 5601 is installed as you would install an ASCII terminal.

  1. Become superuser.


    system% su
    
  2. Type admintool.

    The admintool menu will appear.


    system# admintool
    
  3. Select the Serial Ports icon.

  1. Select Edit on the Serial Ports menu.

    Serial Ports: Modify Service submenu appears.

  2. On Admintool: Modify Service submenu select Enabled, Baud Rate 9600, and enter the terminal type.

    Graphic
  3. Under Expert Options, select "Create utemp entry" and enter the appropriate module in the Streams Modules field:

    To install a terminal that supports the KS C 5601-1987 version of Combination code for the Korean Solaris operating environment, add kpack to the Streams Modules field.

    To install a terminal that supports the KS C 5601-1992 version of Combination code for the Korean Solaris operating environment, add kjohap to the Streams Modules field.

    Graphic

Command Line Interface for Adding Terminals

The following procedure is required to set up a terminal on ttya port via the command line:

  1. Determine the port monitor version number.

    The port monitor version number will display.


    # ttyadm -V 
    
  2. Enter the following commands, substituting the port monitor version number for ver.

    (For more information on sacadm (1M) and pmadm (1M) see their man pages.)


    # pmadm -r -p zsmon -s ttya
    # sacadm -a -p zsmon -t ttymon -c /usr/lib/saf/ttymon -v ver
    
  3. Use the pmadm command that matches your terminal type to add a login service:

    For EUC terminals, use the following command:


    # pmadm -a -p zsmon -s ttya -i root -fu -v ver -m " `ttyadm -S y \
      -T terminal_type -d /dev/ttya -l 9600 -m ldterm,ttcompat -s \
      /usr/bin/login`"
    

    For Korean Packed code terminals, which use the KS C 5601-1987 version of Combination code, type the STREAMS module kpack in the ttyadm command:


    # pmadm -a -p zsmon -s ttya -i root -fu -v ver -m "`ttyadm -S y \
      -T  terminal_type -d /dev/ttya -l 9600 -m kpack,ldterm,ttcompat -s \
      /usr/bin/login`"
    

    For Korean Combination code terminals, which use the KS C 5601-1992 version of Combination code, type the STREAMS module kjohap in the ttyadm command:


    # pmadm -a -p zsmon -s ttya -i root -fu -v ver -m "`ttyadm -S y \
      -T terminal_type -d /dev/ttya -l 9600 -m kjohap,ldterm,ttcompat -s \
      /usr/bin/login`"
    
  4. Turn on the terminal.

    Follow the documentation that accompanies the terminal.

  5. Log in the terminal.

  6. Check the correctness of the installation:


    # setenv LANG ko
    # /bin/stty cs8 -istrip  defeucw 
    

    Note -

    These values show that the operating system is set to communicate with the terminal in "8-bit no-parity" mode. Make sure the terminal is set up in "8-bit no-parity" mode. Refer to the terminal's setup manual for the proper way to set terminal options.


Setting a User's TTY

To verify that your TTY is properly set up:

  1. Type the /bin/stty command with the -a option:


    system% /bin/stty -a 
    
  2. If the values from above (cs8, -istrip) are not listed, then use the following command to set them:


    system% /bin/stty cs8 -istrip defeucw
    

This is the last step in setting up a terminal. The default setting of a Korean terminal is the Completion-code mode. For installing a Packed-code TTY, continue to the next section.

Using Packed Code and Johap TTY in the ko Locale

If you are using a Packed code type terminal, you must load the STREAMS module into the kernel.

  1. If you are using a Packed code terminal (KS C 5601-1987), you should load kpack by typing the following command as superuser:


    system% su
    Password: (Type superuser password here if required.)
    # modload /kernel/strmod/kpack
    
  2. Type the following command:


    system% setterm -x PACK
    

Using Combination Code and Johap TTY in the ko Locale

  1. If you are using a Combination code terminal (KS C 5601-1992), load kjohap by typing the following command as superuser:


    system% su
    Password: (Type superuser password here if required.)
    # modload /usr/kernel/strmod/kjohap
    
  2. Type the following command:


    system% setterm -x JOHAP
    

Using EUC TTY in the ko.UTF-8 Locale

  1. If you are using an EUC terminal (KS C 5601-1987-0), load the ku8euc module by typing the following command as superuser:


    system% su
    Password: (Type superuser password here if required.)
    # modload /kernel/strmod/ku8euc
    
  2. To enable the stream module:


    system% setterm -x KU8EUC
    
  3. To enable 8-bit I/O:


    system% stty defeucw cs8 -istrip
    
  4. If you want to use dtterm, type the following command:


    system% setterm -x u8
    

Using Johap TTY in the ko.UTF-8 Locale

  1. If you are using a Johap code terminal (KS C 5601-1992-3), load the ku8johap module by typing the following command as superuser:


    system% su
    Password: (Type superuser password here if required.)
    # modload /kernel/strmod/ku8johap
    
  2. To enable the stream module:


    system% setterm -x KU8JOHAP
    
  3. To enable 8-bit I/O:


    system% stty defeucw cs8 -istrip
    
  4. If you want to use dtterm, type the following command:


    system% setterm -x u8