SCREEN(HW) UNIX System V
Name
screen - tty[01-n], color, monochrome, ega, vga display
adapter and video monitor
Description
The tty[01-n] device files provide character I/O between the
system and the video display monitor and keyboard. Each
file corresponds to a separate teletype device. Although
there is a maximum of 12 screens, the exact number available
(n) depends upon the amount of memory in the computer. The
screens are modeled after a 25 line, 80 column ASCII
terminal, unless specified otherwise.
System error messages from the kernel are written to
/dev/console, which is normally the current multiscreen. If
the /dev/console is the default output device for system
error messages, and the display being used is switched to
graphics mode, console messages are not displayed. When the
video device returns to text mode, a notice message is
displayed and the text of the kernel error can be recovered
from usr/adm/messages.
Although all tty[01-n] devices may be open concurrently,
only one of the corresponding devices can be active at any
given time. The active device displays its own screen and
takes sole possession of the keyboard. It is an error to
attempt to access the color, monochrome, or ega file when no
corresponding adapter exists or no multiscreens are
associated with it.
To get to the next consecutive screen, enter Ctrl-PrtSc
using the Ctrl key, and the PrtSc key. Any active screen
may be selected by entering alt-Fn, where Fn is one of the
function keys. For example, F1 refers to the tty01 device.
Control Modes
Multiscreens can be reassigned to different adapters (in
multi-adapter systems) with these ioctls :
SWAPMONO Selects the monochrome display as
the output device for the
multiscreen.
SWAPCGA Selects the regular color display
as the output device for the
multiscreen.
SWAPEGA Selects the enhanced color display
as the output device for the
multiscreen.
SWAPVGA Selects the video graphics array
color display as the output device
for the multiscreen.
To find out which display adapter type is currently attached
to the multiscreen, you can use ioctl(S) with the following
request:
CONS_CURRENT Returns the display adapter type
currently associated with the
multiscreen. The return value can
be one of: MONO, CGA, EGA, or VGA.
Display Modes
The following ioctls can be used to change the video display
mode:
SW_B80x25 Selects 80x25 black and white text
display mode. (MONO, CGA, EGA,
VGA)
SW_C80x25 Selects 80x25 color text display
mode. (CGA, EGA, VGA)
SW_BG320 Selects 320x200 black and white
graphics display mode. (CGA, EGA,
VGA)
SW_CG320 Selects 320x200 color graphics
display mode. (CGA, EGA, VGA)
SW_BG640 Selects 640x200 black and white
graphics display mode. (CGA, EGA,
VGA)
SW_EGAMONO80x25 Selects EGA (Enhanced Graphics
Adapter) mode 7 - emulates support
provided by the monochrome display.
(EGA, VGA)
SW_EGAMONOAPA Selects EGA support for 640x350
graphics display mode (EGA mode F).
(EGA with mono monitor)
SW_ENHMONOAPA2 Selects EGA mode F*. (EGA with
mono monitor)
SW_ENHB40x25 Selects enhanced EGA support for
40x25 black and white text display
mode. (EGA, VGA)
SW_ENHC40x25 Selects enhanced EGA support for
the 40x25 color text display mode.
(EGA, VGA)
SW_ENHB80x25 Selects enhanced EGA support for
80x25 black and white text display
mode. (EGA, VGA)
SW_ENHC80x25 Selects enhanced EGA support for
80x25 color text display mode.
(EGA, VGA)
SW_CG320_D Selects EGA support for 320x200
graphics display mode. (EGA mode
D.) (EGA, VGA)
SW_CG640_E Selects EGA support for 640x200
graphics display mode (EGA mode E).
(EGA, VGA)
SW_CG640x350 Selects EGA support for 640x350
graphics display mode (EGA mode
10). (EGA, VGA)
SW_ENH_CG640 Selects EGA mode 10*. (EGA, VGA)
SW_MCAMODE Reinitializes the monochrome
adapter. (MONO)
SW_VGA40x25 Selects VGA support for the 40x25
color text display mode (VGA mode
1+). (VGA)
SW_VGA80x25 Selects VGA support for the 80x25
black and white text display mode
(VGA mode 2+). (VGA)
SW_VGAM80x25 Selects VGA mode 7+ - emulates
support provided by the monochrome
display. (VGA with mono monitor)
SW_VGA11 Selects VGA support for the 640x480
graphics display mode (VGA mode
11). (VGA)
SW_VGA12 Selects VGA support for the 640x480
graphics display mode (VGA mode
12). (VGA)
SW_VGA13 Selects VGA support for the 320x200
graphics display mode (VGA mode
13). (VGA)
Switching to an invalid display mode for a display device
will result in an error.
Getting Display Modes
The following ioctl() requests are provided to obtain
information about the current display modes:
CONS_GET Returns the current display mode
setting for current display
adapter. (All)
CGA_GET Returns the current display mode
setting of the color graphics
adapter. (CGA only)
EGA_GET Returns the current display mode
setting of the enhanced graphics
adapter. (EGA only)
MCA_GET Returns the current display mode
setting of the monochrome adapter.
(MONO only)
VGA_GET Returns the current display mode of
the video graphics adapters. (VGA
only)
Memory Mapping Modes
The ioctl(S) routine is used to map the display memory of
the various devices into the user's data space. Refer to
your hardware manual for details on various displays,
adapters, and controllers.
These ioctl() requests can be used to map the display
memory:
MAPCONS Maps the display memory of the
adaptor currently being used into
the user's data space. (All)
MAPMONO Maps the monochrome adapter's
display memory into the user's data
space. (MONO only)
MAPCGA Maps the color adapter's display
memory into the user's data space.
(CGA only)
MAPEGA Maps the enhanced graphics
adapter's display memory into the
user's data space. (EGA only)
MAPVGA Maps the video graphics adapter's
display memory into the user's data
space. (VGA only)
For example, the following code can be used to acquire a
pointer to the start of the user data space associated with
the color graphics adapter display memory:
char *dp;
int retval;
.
.
.
/* fd is a file descriptor for a
multiscreen device */
retval = ioctl (fd, MAPCONS,0L);
dp = (char *) retval;
.
.
.
Note that when the display memory is mapped into the user
space, the adapter's m6845 start address registers are not
set. The start address can be reset in two ways, so that
the start address of the display memory corresponds to the
upper left hand corner of the screen:
1. Switch modes with an ioctl() (the ``switch'' can be to
the present mode). See the ``Display Modes'' section
of this manual page.
2. Change the start address high and low address with the
in-on-port/out-on-port ioctl().
The in-on-port/out-on-port ioctl()'s can also be used to
determine the current value in the start address register,
and then set up a pointer to point to the offset in the
mapped-in data space.
KDDISPTYPE
This call returns display information to the user. The
argument expected is the buffer address of a structure
of type kd_disparam into which display information is
returned to the user. The kd_disparam structure is
defined as follows:
struct kd_disparam {
long type; /*display type*/
char *addr; /*display memory address*/
ushort ioaddr[MKDIOADDR]; /*valid I/O addresses*/
}
Possible values for the type field include:
KD_MONO (0x01), for the IBM monochrome display adapter.
KD_HERCULES (0x02), for the Hercules monochrome
graphics adapter.
KD_CGA (0x03), for the IBM color graphics adapter.
KD_EGA (0x04), for the IBM enhanced graphics adapter.
KIOCSOUND
Start sound generation. Turn on sound. The "arg" is
the frequency desired. A frequency of 0 turns off the
sound. This is useful for generating tones while in
graphics mode.
KDGETLED
Get keyboard LED status. The argument is a pointer to
a character. The character will be filled with a
boolean combination of the following values:
CAP_LED 0x01 ( flag bit for scroll lock )
NUM_LED 0x02 ( flag bit for caps lock )
SCROLL_LED 0x04 ( flag bit for num lock )
KDSETLED
Set keyboard LED status. The argument is a character
whose value is the boolean combination of the values
listed under ``KDGETLED''.
KDADDIO
Add I/O port address to list of valid video adaptor
addresses. Argument is an unsigned short type which
should contain a valid port address for the installed
video adaptor.
KDDELIO
Delete I/O port address from list of valid video
adaptor addresses. Argument is an unsigned short type
which should contain a valid port address for the
installed video adaptor.
KDENABIO
Enable in's and out's to video adaptor ports. No
argument.
KDDISABIO
Disable in's and out's to video adaptor ports. No
argument.
KDMAPDISP
Maps display memory into user process address space.
Argument is a pointer to structure type "kd_memloc".
Structure definition is as follows:
struct kd_memloc {
char *vaddr; /* virtual address to map to */
char *physaddr; /* physical address to map from */
long length; /* size in bytes to map */
long ioflg; /* enable i/o addresses if set */
}
KDUNMAPDISP
Unmap display memory from user process address space.
No argument required.
VT_SETMODE
Set the virtual terminal mode. The argument is a
pointer to a "vt_mode" structure, as defined below.
VT_GETMODE
Determine what mode the active virtual terminal is
currently in, either VT_AUTO or VT_PROCESS. The
argument to the ioctl is the address of the following
type of structure:
struct vt_mode {
char mode; /* VT mode */
char waitv; /* if set, hang on writes when not active */
short relsig; /* signal to use for release request */
short acqsig; /* signal to use for display acquired */
short frsig; /* signal to use for forced release */
}
#define VT_AUTO 0x00 /* automatic VT switching */
#define VT_PROCESS 0x01 /* process controls switching */
The "vt_mode" structure will be filled in with the current
value for each field.
VT_RELDISP
Used to tell the virtual terminal manager that the
display has or has not been released by the process.
0 == release refused
1 == release acknowledged
2 == acquire acknowledged
VT_ACTIVATE
Makes the virtual terminal number specified
in the argument the active "VT".
The "VT" manager will cause a switch to occur in the same manner
as if a hotkey sequence had been typed at the keyboard.
If the specified "VT" is not open or does not exist,
the call will fail and errno will be set to ENXIO.
Graphics Adapter Port I/O
You can use ioctl(S) to read or write a byte from or to the
graphics adapter port. The arg parameter of the ioctl call
uses the io_arg data structure:
struct port_io_arg {
struct port_io_struct args[4];
};
As shown above, the io_arg structure points to an array of
four port_io data structures. The port_io structure has the
following format:
struct port_io_struct {
char dir; /* direction flag (in vs. out) */
unsigned short port; /* port address */
char data; /* byte of data */
};
You may specify one, two, three, or four of the
port_io_struct structures in the array for one ioctl call.
The value of dir can be either IN_ON_PORT to specify a byte
being input to the graphics adapter port or OUT_ON_PORT to
specify a byte being output to the graphics adapter port.
Port is an integer specifying the port address of the
desired graphics adapter port. Data is the byte of data
being input or output as specified by the call.
If you are not using any of the port_io structures, load the
port with 0, and leave the unused structures at the end of
the array. Refer to the hardware manuals for port addresses
and functions for the various adapters.
You can use the following ioctl(S) commands to input or
output a byte on the graphics adapter port:
CONSIO Inputs or outputs a byte on the current
graphics adapter port as specified. (All)
MGAIO Inputs or outputs a byte on the monochrome
adapter port as specified. (MONO only)
CGAIO Inputs or outputs a byte on the color graphics
adapter port as specified. (CGA only)
EGAIO Inputs or outputs a byte on the enhanced
graphics adapter port as specified. (EGA only)
VGAIO Inputs or outputs a byte on the video graphics
array adapter port as specified. (VGA only)
To input a byte on any of the graphics adapter ports, load
dir with IN_ON_PORT and load port with the port address of
the graphics adapter. The byte input from the graphics
adapter port will be returned in data.
To output a byte, load dir with OUT_ON_PORT, load port with
the port address of the graphics adapter, and load data with
the byte you want output to the graphics adapter port.
Function Keys
ioctl(S) can be used to define or obtain the current
definition of a function key. The arg parameter of the
ioctl call uses the fkeyarg data structure:
struct fkeyarg {
unassigned int keynum;
char keydef [MAXFK];
/* Comes from
char flen; ioctl.h via comcrt.h */
}
You can use the following ioctl(S) requests to obtain or
assign function key definitions:
GETFKEY Obtains the current definition of a
function key. The function key
number must be passed in keynum.
The string currently assigned to
the key will be returned in keydef
and the length of the string will
be returned in flen when the ioctl
is performed.
SETFKEY Assigns a given string to a
function key. The function key
number must be passed in keydef and
the length of the string (number of
characters) must be passed in flen.
SETLOCKLOCK Toggles the <Caps Lock> and <Num
Lock> keys to be either global to
all the multiscreens, or local to
each individual multiscreen. To
make the <Caps Lock> global (its
default), set the arg parameter to
1. To make the <Caps Lock> local
to each screen, set the arg
parameter to 0.
ANSI Screen Attribute Sequences
The following character sequences are defined by ANSI
X3.64-1979 and may be used to control and modify the screen
display. Each n is replaced by the appropriate ASCII number
(decimal) to produce the desired effect. The last column is
for termcap(M) codes, where means not applicable.
The use of 7 or 8 bit characters in the escape sequence is a
valid invocation for each action defined. For example the
ANSI ED command can be invoked via the ``ESC [ n J'' (0x1b-
0x5b-n-0x4a, 7 bit chars) sequence or the ``CSI n J''
(0x9b-n-0x4n, 8 bit chars) sequence.
ISO Sequence Action Termcap
Code
_________________________________________________________________
ED CSIn J Erases all or part cd
(Erase in of a display. n=0:
Display) erases from active
position to end of
display. n=1:
erases from the
beginning of display
to active position.
n=2: erases entire
display.
EL CSIn K Erases all or part ce
(Erase in of a line. n=0:
Line) erases from active
position to end of
line. n=1: erases
from beginning of
line to active
position. n=2:
erases entire line.
ECH CSIn X Erases n characters n/a
(Erase
Character)
CBT CSIn Z Moves active bt
(Cursor position back n tab
Backward stops.
Tabulation)
SU CSIn S Scroll screen up n sf
(Scroll lines, introducing
Up) new blank lines at
bottom.
SD CSIn T Scrolls screen down sr
(Scroll n lines, introducing
Down) new blank lines at
top.
CUP CSIm;n H Moves active cm
(Cursor position to location
Position) m (vertical) and n
(horizontal).
HVP CSIm;n f Moves active n/a
(Horizontal position to location
& Vertical m (vertical) and n
Position) (horizontal).
CUU CSIn A Moves active up (ku)
(Cursor Up) position up n number
of lines.
CUD CSIn B Moves active do (kd)
(Cursor position down n num-
Down) ber of lines.
CUF CSIn C Moves active nd (kr)
(Cursor position n spaces to
Forward) the right.
CUB CSIn D Moves active bs (kl)
(Cursor position n spaces
Backward) backward.
HPA CSIn ` Moves active n/a
(Horizontal position to column
Position given by n.
Absolute)
HPR CSIn a Moves active n/a
(Horizontal position n
Position characters to the
Relative) right.
VPA CSIn d Moves active n/a
(Vertical position to line
Position given by n.
Absolute)
VPR CSIn e Moves active n/a
(Vertical position down n num-
Position ber of lines.
Relative)
IL CSIn L Inserts n new, blank al
(Insert lines.
Line)
ICH CSIn @ Inserts n blank ic
(Insert places for n
Character) characters.
DL CSIn M Deletes n lines. dl
(Delete
Line)
DCH CSIn P Deletes n number of dc
(Delete characters.
Character)
CPL CSIn F Moves active n/a
(Cursor to position to
Previous beginning of line, n
Line) lines up.
CNL CSIn E Moves active n/a
(Cursor position to
Next beginning of line, n
Line) lines down.
SGR CSIn m Character n/a
(Select attributes, as
Graphic summarized in the
Rendition) chart below.
Multiple attributes
can be specified in
the form: CSI n1;
n2; n3 m
__________________________________________________
| Select Graphic Rendition (SGR) Chart |
|_________________________________________________|
|n Meaning |
|_________________________________________________|
|0 all attributes off (normal display) |
|1 bold intensity (or light color) |
|4 underscore on (if hardware supports it) |
|5 blink on (if hardware supports it) |
|7 reverse video |
|8 sets blank (non-display) |
|10 selects the primary font |
|11 selects the first alternate font; lets |
| ASCII characters less than 32 be |
| displayed as ROM characters |
|12 selects a second alternate font; |
| toggles high bit of extended ASCII code |
| before displaying as ROM characters |
|30 black foreground |
|31 red foreground |
|32 green foreground |
|33 brown foreground |
|34 blue foreground |
|35 magenta foreground |
|36 cyan foreground |
|37 white foreground |
|38 enables underline option; white |
| foreground with white underscore |
|39 disables underline option |
|40 black background |
|41 red background |
|42 green background |
|43 brown background |
|44 blue background |
|45 magenta background |
|46 cyan background |
|47 white background |
|_________________________________________________|
ISO Sequence Action Termcap
Code
_________________________________________________________________
SM CSI[2h Lock keyboard. n/a
(Set Mode) Ignores keyboard
input until
unlocked.
Characters are not
saved.
MC CSI[2i Send screen to host. n/a
(Media Current screen
Copy) contents are sent to
the application.
RM CSI[2l Unlock keyboard. n/a
(Reset Re-enable keyboard
Mode) input.
Additional Screen Attribute Sequences
Termcap
Name Sequence Action Code
_________________________________________________________________
n/a CSI=p;dB Set the bell parameter to n/a
the decimal values of p
and d. p is the period
of the bell tone in units
of 840.3 nanoseconds, and
d is the duration of the
tone in units of 100
milliseconds.
n/a CSI=s;eC Set the cursor to start n/a
on scanline s and end on
scanline e.
n/a CSI=xD Turn on or off (x=1 or 0) n/a
the intensity of the
background color.
n/a CSI=xE Set or clear (x=1 or 0) n/a
the Blink vs. Bold
background bit in the
6845 crt controller.
n/a CSI=cA Set overscan color to n/a
color c. c is a decimal
value taken from Color
Table above. (This
sequence may not be
supported on all
hardware.)
n/a CSI=cF Set normal foreground n/a
color to c. (c is a
decimal parameter taken
from Color Table.)
n/a CSI=c0G Set normal background. n/a
(See Color Table.)
n/a CSI=c H Set reverse foreground. n/a
(See Color Table.)
n/a CSI=c I Set reverse background. n/a
(See Color Table.)
n/a CSI=c J Set graphic foreground. n/a
(See Color Table.)
n/a CSI=c K Set graphic background. n/a
(See Color Table.)
_________________________________
| Color Table |
|________________________________|
|Cn | Color ||Cn | Color |
|___|_________||___|_____________|
|0 | Black || 8 | Grey |
|1 | Blue || 9 | Lt. Blue |
|2 | Green ||10 | Lt. Green |
|3 | Cyan ||11 | Lt. Cyan |
|4 | Red ||12 | Lt. Red |
|5 | Magenta ||13 | Lt. Magenta |
|6 | Brown ||14 | Yellow |
|7 | White ||15 | Lt. White |
|___|_________||___|_____________|
Termcap
Name Sequence Action Code
_________________________________________________________________
n/a CSI[ng Accesses alternate n/a
graphics set. Not the
same as
``graphics mode.'' Refer
to your owner's manual
for decimal/character
codes (Pn) and possible
output characters.
n/a ESCQFn'string' Define function key Fn n/a
with string. String
delimiters ' and ' may be
any character not in
string. Fn is defined as
the key number starting
at zero plus the ASCII
value of zero. For
example, F1 = 0... F16 =
?, and so on.
In this escape sequence,
the ^ character will
cause the next character
to have 32 subtracted
from its ASCII value.
Thus ^! results in a soh
(^A) characters.
n/a CSInz n should be equal to the n/a
number of the screen to
switch to. If screen
does not exist, no action
will take place.
Files
/dev/console
/dev/tty[02 -n]
/dev/color
/dev/monochrome
/dev/ega
/dev/vga
See Also
console(M), ioctl(S), keyboard(HW), keymap(M), mapkey(M),
mapchan(M), multiscreen(M), setcolor(C), stty(C), systty(M),
vidi(C), termcap(M), tty(M)
(printed 8/30/89) SCREEN(HW)