summaryrefslogtreecommitdiff
path: root/usr/src/man/man4i
diff options
context:
space:
mode:
authorDan McDonald <danmcd@joyent.com>2022-03-15 12:07:15 -0400
committerGitHub <noreply@github.com>2022-03-15 12:07:15 -0400
commit83decd22b44019b0fe369224fb19e1ef21263ab6 (patch)
tree0bbbaea9d4231f77a406362904280d6ba53e1d55 /usr/src/man/man4i
parentad491f11d9af43fd3f0d6159c9e08112de475a54 (diff)
downloadillumos-joyent-83decd22b44019b0fe369224fb19e1ef21263ab6.tar.gz
OS-8361 IPD 4 (man page renumbering) tracking issue
Reviewed by: Brian Bennett <brian.bennett@joyent.com> Approved by: Brian Bennett <brian.bennett@joyent.com>
Diffstat (limited to 'usr/src/man/man4i')
-rw-r--r--usr/src/man/man4i/Makefile52
-rw-r--r--usr/src/man/man4i/audio.4i999
-rw-r--r--usr/src/man/man4i/cdio.4i692
-rw-r--r--usr/src/man/man4i/dkio.4i867
-rw-r--r--usr/src/man/man4i/dsp.4i602
-rw-r--r--usr/src/man/man4i/fbio.4i160
-rw-r--r--usr/src/man/man4i/fdio.4i277
-rw-r--r--usr/src/man/man4i/hdio.4i112
-rw-r--r--usr/src/man/man4i/iec61883.4i674
-rw-r--r--usr/src/man/man4i/ipnat.4i436
-rw-r--r--usr/src/man/man4i/mhd.4i386
-rw-r--r--usr/src/man/man4i/mixer.4i767
-rw-r--r--usr/src/man/man4i/mtio.4i1190
-rw-r--r--usr/src/man/man4i/prnio.4i370
-rw-r--r--usr/src/man/man4i/quotactl.4i227
-rw-r--r--usr/src/man/man4i/sesio.4i95
-rw-r--r--usr/src/man/man4i/sockio.4i97
-rw-r--r--usr/src/man/man4i/streamio.4i1550
-rw-r--r--usr/src/man/man4i/termio.4i2193
-rw-r--r--usr/src/man/man4i/termiox.4i413
-rw-r--r--usr/src/man/man4i/uscsi.4i395
-rw-r--r--usr/src/man/man4i/visual_io.4i738
-rw-r--r--usr/src/man/man4i/vt.4i329
23 files changed, 13621 insertions, 0 deletions
diff --git a/usr/src/man/man4i/Makefile b/usr/src/man/man4i/Makefile
new file mode 100644
index 0000000000..4c8d7406af
--- /dev/null
+++ b/usr/src/man/man4i/Makefile
@@ -0,0 +1,52 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet
+# at http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2011, Richard Lowe
+# Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+#
+
+include $(SRC)/Makefile.master
+
+MANSECT= 4i
+
+MANFILES= audio.4i \
+ cdio.4i \
+ dkio.4i \
+ dsp.4i \
+ fbio.4i \
+ fdio.4i \
+ hdio.4i \
+ iec61883.4i \
+ ipnat.4i \
+ mhd.4i \
+ mixer.4i \
+ mtio.4i \
+ prnio.4i \
+ quotactl.4i \
+ sesio.4i \
+ sockio.4i \
+ streamio.4i \
+ termio.4i \
+ termiox.4i \
+ uscsi.4i \
+ visual_io.4i \
+ vt.4i
+
+MANLINKS= uccid.4i
+
+uccid.7i := LINKSRC = ../man4d/ccid.4d
+
+.KEEP_STATE:
+
+include $(SRC)/man/Makefile.man
+
+install: $(ROOTMANFILES) $(ROOTMANLINKS)
diff --git a/usr/src/man/man4i/audio.4i b/usr/src/man/man4i/audio.4i
new file mode 100644
index 0000000000..5059b4746a
--- /dev/null
+++ b/usr/src/man/man4i/audio.4i
@@ -0,0 +1,999 @@
+.\" Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
+.\" Copyright 2018, Joyent, Inc.
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd July 8, 2018
+.Dt AUDIO 4I
+.Os
+.Sh NAME
+.Nm audio
+.Nd generic audio device interface
+.Sh SYNOPSIS
+.In sys/audio.h
+.Sh OVERVIEW
+An audio device is used to play and/or record a stream of audio data.
+Since a
+specific audio device may not support all functionality described below, refer
+to the device-specific manual pages for a complete description of each hardware
+device.
+An application can use the
+.Dv AUDIO_GETDEV
+.Xr ioctl 2
+to determine the current audio hardware associated with
+.Pa /dev/audio .
+.Pp
+The audio framework provides a software mixing engine (audio mixer) for all
+audio devices, allowing more than one process to play or record audio at the
+same time.
+.Ss "Backward Compatibility"
+It is no longer possible to disable the mixing function.
+Applications must not
+assume that they have exclusive access to the audio device.
+.Ss "Multi-Stream Codecs"
+The audio mixer supports multi-stream Codecs.
+These devices have DSP engines
+that provide sample rate conversion, hardware mixing, and other features.
+The use of such hardware features is opaque to applications.
+.Sh AUDIO FORMATS
+Digital audio data represents a quantized approximation of an analog audio
+signal waveform.
+In the simplest case, these quantized numbers represent the
+amplitude of the input waveform at particular sampling intervals.
+To achieve the best approximation of an input signal, the highest possible sampling
+frequency and precision should be used.
+However, increased accuracy comes at a cost of increased data storage requirements.
+For instance, one minute of
+monaural audio recorded in \(*m-Law format (pronounced
+.Em mew-law )
+at 8 KHz requires nearly 0.5 megabytes of storage, while the standard Compact Disc
+audio format (stereo 16-bit linear
+.Sy PCM
+data sampled at 44.1 KHz) requires approximately 10 megabytes per minute.
+.Pp
+Audio data may be represented in several different formats.
+An audio device's
+current audio data format can be determined by using the
+.Dv AUDIO_GETINFO
+.Xr ioctl 2
+described below.
+.Pp
+An audio data format is characterized in the audio driver by four parameters:
+Sample Rate, Encoding, Precision, and Channels.
+Refer to the device-specific
+manual pages for a list of the audio formats that each device supports.
+In addition to the formats that the audio device supports directly, other formats
+provide higher data compression.
+Applications may convert audio data to and
+from these formats when playing or recording.
+.Ss "Sample Rate"
+Sample rate is a number that represents the sampling frequency (in samples per
+second) of the audio data.
+.Pp
+The audio mixer always configures the hardware for the highest possible sample
+rate for both play and record.
+This ensures that none of the audio streams
+require compute-intensive low pass filtering.
+The result is that high sample rate audio streams are not degraded by filtering.
+.Pp
+Sample rate conversion can be a compute-intensive operation, depending on the
+number of channels and a device's sample rate.
+For example, an 8KHz signal can
+be easily converted to 48KHz, requiring a low cost up sampling by 6.
+However,
+converting from 44.1KHz to 48KHz is compute intensive because it must be up
+sampled by 160 and then down sampled by 147.
+This is only done using integer multipliers.
+.Pp
+Applications can greatly reduce the impact of sample rate conversion by
+carefully picking the sample rate.
+Applications should always use the highest
+sample rate the device supports.
+An application can also do its own sample rate
+conversion (to take advantage of floating point and accelerated instruction or
+use small integers for up and down sampling.
+.Pp
+All modern audio devices run at 48 kHz or a multiple thereof, hence just using
+48 kHz may be a reasonable compromise if the application is not prepared to
+select higher sample rates.
+.Ss "Encodings"
+An encoding parameter specifies the audio data representation.
+\(*m-Law
+encoding corresponds to
+.Em CCITT G.711 ,
+and is the standard for voice data
+used by telephone companies in the United States, Canada, and Japan.
+A-Law encoding is also part of
+.Em CCITT G.711
+and is the standard encoding for telephony elsewhere in the world.
+A-Law and \(*m-Law audio data are sampled at
+a rate of 8000 samples per second with 12-bit precision, with the data
+compressed to 8-bit samples.
+The resulting audio data quality is equivalent to
+that of standard analog telephone service.
+.Pp
+Linear Pulse Code Modulation (PCM) is an uncompressed, signed audio format in
+which sample values are directly proportional to audio signal voltages.
+Each sample is a 2's complement number that represents a positive or negative
+amplitude.
+.Ss "Precision"
+Precision indicates the number of bits used to store each audio sample.
+For instance, \(*m-Law and A-Law data are stored with 8-bit precision.
+.Sy PCM
+data may be stored at various precisions, though 16-bit is the most common.
+.Ss "Channels"
+Multiple channels of audio may be interleaved at sample boundaries.
+A sample frame consists of a single sample from each active channel.
+For example, a sample frame of stereo 16-bit
+.Sy PCM
+data consists of two 16-bit samples,
+corresponding to the left and right channel data.
+.Pp
+The audio mixer sets the hardware to the maximum number of channels supported.
+If a mono signal is played or recorded, it is mixed on the first two (usually
+the left and right) channels only.
+Silence is mixed on the remaining channels
+.Ss "Supported Formats"
+The audio mixer supports the following audio formats:
+.Bl -column "Signed Linear PCM" "Precision" "Mono or Stereo" -offset 2n
+.It Encoding Ta Precision Ta Channels
+.It "Signed Linear PCM" Ta "32-bit" Ta "Mono or Stereo"
+.It "Signed Linear PCM" Ta "16-bit" Ta "Mono or Stereo"
+.It "Signed Linear PCM" Ta "8-bit" Ta "Mono or Stereo"
+.It "\(*m-Law" Ta "8-bit" Ta "Mono or Stereo"
+.It "A-Law" Ta "8-bit" Ta "Mono or Stereo"
+.El
+.Pp
+The audio mixer converts all audio streams to 24-bit Linear PCM before mixing.
+After mixing, conversion is made to the best possible Codec format.
+The
+conversion process is not compute intensive and audio applications can choose
+the encoding format that best meets their needs.
+.Pp
+Note that the mixer discards the low order 8 bits of 32-bit Signed Linear PCM
+in order to perform mixing.
+(This is done to allow for possible overflows to
+fit into 32-bits when mixing multiple streams together.)
+Hence, the maximum effective precision is 24-bits.
+.Sh DESCRIPTION
+The device
+.Pa /dev/audio
+is a device driver that dispatches audio requests
+to the appropriate underlying audio hardware.
+The audio driver is implemented as a
+.Sy STREAMS
+driver.
+In order to record audio input, applications
+.Xr open 2
+the
+.Pa /dev/audio
+device and read data from it using the
+.Xr read 2
+system call.
+Similarly, sound data is queued to the audio output port by using the
+.Xr write 2
+system call.
+Device configuration is performed using the
+.Xr ioctl 2
+interface.
+.Pp
+Because some systems may contain more than one audio device, application
+writers are encouraged to query the
+.Ev AUDIODEV
+environment variable.
+If this variable is present in the environment, its value should identify the
+path name of the default audio device.
+.Ss "Opening the Audio Device"
+The audio device is not treated as an exclusive resource.
+Each process may open the audio device once.
+.Pp
+Each
+.Xr open 2
+completes as long as there are channels available to be allocated.
+If no channels are available to be allocated:
+.Bl -bullet -offset indent
+.It
+if either the
+.Dv O_NDELAY
+or
+.Dv O_NONBLOCK
+flags are set in the
+.Xr open 2
+.Fa oflag
+argument, then -1 is immediately returned, with
+.Va errno
+set to
+.Er EBUSY .
+.It
+if neither the
+.Dv O_NDELAY
+nor the
+.Dv O_NONBLOCK
+flag are set, then
+.Xr open 2
+hangs until the device is available or a signal is delivered to
+the process, in which case a -1 is returned with
+.Va errno
+set to
+.Er EINTR .
+.El
+.Pp
+Upon the initial
+.Xr open 2
+of the audio channel, the audio mixer sets the data
+format of the audio channel to the default state of 8-bit, 8Khz, mono \(*m-Law
+data.
+.Pp
+If the audio device does not support this configuration, it informs the
+audio mixer of the initial configuration.
+Audio applications should explicitly set the encoding characteristics to match the
+audio data requirements, and not depend on the default configuration.
+.Ss "Recording Audio Data"
+The
+.Xr read 2
+system call copies data from the system's buffers to the application.
+Ordinarily,
+.Xr read 2
+blocks until the user buffer is filled.
+The
+.Dv I_NREAD
+.Sy ioctl
+(see
+.Xr streamio 4I )
+may be used to determine the amount of data that may be read without blocking.
+The device may alternatively be set to a non-blocking mode, in which case
+.Xr read 2
+completes immediately, but may return fewer bytes than requested.
+Refer to the
+.Xr read 2
+manual page for a complete description of this behavior.
+.Pp
+When the audio device is opened with read access, the device driver immediately
+starts buffering audio input data.
+Since this consumes system resources,
+processes that do not record audio data should open the device write-only
+.Pq Dv O_WRONLY .
+.Pp
+The transfer of input data to
+.Sy STREAMS
+buffers may be paused (or resumed) by using the
+.Dv AUDIO_SETINFO
+.Sy ioctl
+to set (or clear) the
+.Fa record.pause
+flag in the audio information structure (see below).
+All unread input data in the
+.Sy STREAMS
+queue may be discarded by using the
+.Dv I_FLUSH
+.Sy STREAMS
+ioctl.
+See
+.Xr streamio 4I .
+When changing record parameters, the input stream should be paused and flushed
+before the change, and resumed afterward.
+Otherwise, subsequent reads may return samples
+in the old format followed by samples in the new format.
+This is particularly important when new parameters result in a changed sample size.
+.Pp
+Input data can accumulate in
+.Sy STREAMS
+buffers very quickly.
+At a minimum,
+it will accumulate at 8000 bytes per second for 8-bit, 8 KHz, mono, \(*m-Law data.
+If the device is configured for 16-bit linear or higher sample rates, it will
+accumulate even faster.
+If the application that consumes the data cannot keep
+up with this data rate, the
+.Sy STREAMS
+queue may become full.
+When this occurs, the
+.Fa record.error
+flag is set in the audio information structure and input sampling ceases until
+there is room in the input queue for additional data.
+In such cases, the input data stream contains a discontinuity.
+For this reason, audio recording applications should open the audio device when
+they are prepared to begin reading data, rather than at the start of extensive
+initialization.
+.Ss "Playing Audio Data"
+The
+.Xr write 2
+system call copies data from an application's buffer to the
+.Sy STREAMS
+output queue.
+Ordinarily,
+.Xr write 2
+blocks until the entire user buffer is transferred.
+The device may alternatively be set to a non-blocking mode, in which case
+.Xr write 2
+completes immediately, but may have transferred fewer bytes than requested.
+See
+.Xr write 2 .
+.Pp
+Although
+.Xr write 2
+returns when the data is successfully queued, the actual
+completion of audio output may take considerably longer.
+The
+.Dv AUDIO_DRAIN
+ioctl may be issued to allow an application to block until all of the
+queued output data has been played.
+Alternatively, a process may request
+asynchronous notification of output completion by writing a zero-length buffer
+(end-of-file record) to the output stream.
+When such a buffer has been
+processed, the
+.Fa play.eof
+flag in the audio information structure is incremented.
+.Pp
+The final
+.Xr close 2
+of the file descriptor hangs until all of the audio
+output has drained.
+If a signal interrupts the
+.Xr close 2 ,
+or if the process exits without closing the device, any remaining data queued
+for audio output is flushed and the device is closed immediately.
+.Pp
+The consumption of output data may be paused (or resumed) by using the
+.Dv AUDIO_SETINFO
+ioctl to set (or clear) the
+.Fa play.pause
+flag in the audio information structure.
+Queued output data may be discarded by using
+the
+.Dv I_FLUSH
+.Sy STREAMS
+ioctl.
+(See
+.Xr streamio 4I ) .
+.Pp
+Output data is played from the
+.Sy STREAMS
+buffers at a default rate of at
+least 8000 bytes per second for \(*m-Law, A-Law or 8-bit PCM data (faster for
+16-bit linear data or higher sampling rates).
+If the output queue becomes
+empty, the
+.Fa play.error
+flag is set in the audio information structure and
+output is stopped until additional data is written.
+If an application attempts
+to write a number of bytes that is not a multiple of the current sample frame
+size, an error is generated and the bad data is thrown away.
+Additional writes are allowed.
+.Ss "Asynchronous I/O"
+The
+.Dv I_SETSIG
+.Sy STREAMS
+ioctl
+enables asynchronous notification, through the
+.Dv SIGPOLL
+signal, of input and output ready condition changes.
+The
+.Dv O_NONBLOCK
+flag may be set using the
+.Dv F_SETFL
+.Xr fcntl 2
+to
+enable non-blocking
+.Xr read 2
+and
+.Xr write 2
+requests.
+This is normally
+sufficient for applications to maintain an audio stream in the background.
+.Ss "Audio Control Pseudo-Device"
+It is sometimes convenient to have an application, such as a volume control
+panel, modify certain characteristics of the audio device while it is being
+used by an unrelated process.
+.Pp
+The
+.Pa /dev/audioctl
+pseudo-device is provided for this purpose.
+Any number of processes may open
+.Pa /dev/audioctl
+simultaneously.
+However,
+.Xr read 2
+and
+.Xr write 2
+system calls are ignored by
+.Pa /dev/audioctl .
+The
+.Dv AUDIO_GETINFO
+and
+.Dv AUDIO_SETINFO
+ioctl commands may be issued to
+.Pa /dev/audioctl
+to determine the status or alter the behavior of
+.Pa /dev/audio .
+Note: In general, the audio control device name is
+constructed by appending the letters
+.Qq Sy ctl
+to the path name of the audio device.
+.Ss "Audio Status Change Notification"
+Applications that open the audio control pseudo-device may request asynchronous
+notification of changes in the state of the audio device by setting the
+.Dv S_MSG
+flag in an
+.Dv I_SETSIG
+.Sy STREAMS
+ioctl.
+Such processes receive a
+.Dv SIGPOLL
+signal when any of the following events occur:
+.Bl -bullet -offset indent
+.It
+An
+.Dv AUDIO_SETINFO
+ioctl has altered the device state.
+.It
+An input overflow or output underflow has occurred.
+.It
+An end-of-file record (zero-length buffer) has been processed on output.
+.It
+An
+.Xr open 2
+or
+.Xr close 2
+of
+.Pa /dev/audio
+has altered the device state.
+.It
+An external event (such as speakerbox's volume control) has altered the device
+state.
+.El
+.Sh IOCTLS
+.Ss "Audio Information Structure"
+The state of the audio device may be polled or modified using the
+.Dv AUDIO_GETINFO
+and
+.Dv AUDIO_SETINFO
+ioctl commands.
+These commands operate on the
+.Vt audio_info
+structure as defined, in
+.In sys/audio.h ,
+as follows:
+.Bd -literal -offset 2n
+/*
+ * This structure contains state information for audio device
+ * IO streams
+ */
+
+struct audio_prinfo {
+ /*
+ * The following values describe the
+ * audio data encoding
+ */
+ uint_t sample_rate; /* samples per second */
+ uint_t channels; /* number of interleaved channels */
+ uint_t precision; /* number of bits per sample */
+ uint_t encoding; /* data encoding method */
+
+ /*
+ * The following values control audio device
+ * configuration
+ */
+ uint_t gain; /* volume level */
+ uint_t port; /* selected I/O port */
+ uint_t buffer_size; /* I/O buffer size */
+
+ /*
+ * The following values describe the current device
+ * state
+ */
+ uint_t samples; /* number of samples converted */
+ uint_t eof; /* End Of File counter (play only) */
+ uchar_t pause; /* non-zero if paused, zero to resume */
+ uchar_t error; /* non-zero if overflow/underflow */
+ uchar_t waiting; /* non-zero if a process wants access */
+ uchar_t balance; /* stereo channel balance */
+
+ /*
+ * The following values are read-only device state
+ * information
+ */
+ uchar_t open; /* non-zero if open access granted */
+ uchar_t active; /* non-zero if I/O active */
+ uint_t avail_ports; /* available I/O ports */
+ uint_t mod_ports; /* modifiable I/O ports */
+};
+typedef struct audio_prinfo audio_prinfo_t;
+
+/*
+ * This structure is used in AUDIO_GETINFO and AUDIO_SETINFO ioctl
+ * commands
+ */
+struct audio_info {
+ audio_prinfo_t record;/* input status info */
+ audio_prinfo_t play; /* output status info */
+ uint_t monitor_gain; /* input to output mix */
+ uchar_toutput_muted; /* non-zero if output muted */
+ uint_t hw_features; /* supported H/W features */
+ uint_t sw_features; /* supported S/W features */
+ uint_t sw_features_enabled;
+ /* supported S/W features enabled */
+};
+typedef struct audio_info audio_info_t;
+
+/* Audio encoding types */
+#define AUDIO_ENCODING_ULAW (1) /* u-Law encoding */
+#define AUDIO_ENCODING_ALAW (2) /* A-Law encoding */
+#define AUDIO_ENCODING_LINEAR (3) /* Signed Linear PCM encoding */
+
+/*
+ * These ranges apply to record, play, and
+ * monitor gain values
+ */
+#define AUDIO_MIN_GAIN (0)/* minimum gain value */
+#define AUDIO_MAX_GAIN (255) /* maximum gain value */
+
+/*
+ * These values apply to the balance field to adjust channel
+ * gain values
+ */
+#define AUDIO_LEFT_BALANCE (0) /* left channel only */
+#define AUDIO_MID_BALANCE (32) /* equal left/right balance */
+#define AUDIO_RIGHT_BALANCE (64) /* right channel only */
+
+/*
+ * Define some convenient audio port names
+ * (for port, avail_ports and mod_ports)
+ */
+
+/* output ports (several might be enabled at once) */
+#define AUDIO_SPEAKER (0x01) /* built-in speaker */
+#define AUDIO_HEADPHONE (0x02) /* headphone jack */
+#define AUDIO_LINE_OUT (0x04) /* line out */
+#define AUDIO_SPDIF_OUT (0x08) /* SPDIF port */
+#define AUDIO_AUX1_OUT (0x10) /* aux1 out */
+#define AUDIO_AUX2_OUT (0x20) /* aux2 out */
+
+/*
+ * input ports (usually only one may be enabled at a time)
+ */
+#define AUDIO_MICROPHONE (0x01) /* microphone */
+#define AUDIO_LINE_IN (0x02) /* line in */
+#define AUDIO_CD (0x04) /* on-board CD inputs */
+#define AUDIO_SPDIF_IN (0x08) /* SPDIF port */
+#define AUDIO_AUX1_IN (0x10) /* aux1 in */
+#define AUDIO_AUX2_IN (0x20) /* aux2 in */
+#define AUDIO_CODEC_LOOPB_IN (0x40) /* Codec inter. loopback */
+
+/* These defines are for hardware features */
+#define AUDIO_HWFEATURE_DUPLEX (0x00000001u)
+/* simult. play & cap. supported */
+
+#define AUDIO_HWFEATURE_MSCODEC (0x00000002u)
+/* multi-stream Codec */
+
+/* These defines are for software features *
+#define AUDIO_SWFEATURE_MIXER (0x00000001u)
+/* audio mixer audio pers. mod. */
+
+/*
+ * Parameter for the AUDIO_GETDEV ioctl
+ * to determine current audio devices
+ */
+#define MAX_AUDIO_DEV_LEN (16)
+struct audio_device {
+ char name[MAX_AUDIO_DEV_LEN];
+ char version[MAX_AUDIO_DEV_LEN];
+ char config[MAX_AUDIO_DEV_LEN];
+};
+typedef struct audio_device audio_device_t;
+.Ed
+.Pp
+The
+.Fa play.gain
+and
+.Fa record.gain
+fields specify the output and input volume levels.
+A value of
+.Dv AUDIO_MAX_GAIN
+indicates maximum volume.
+Audio output may also be temporarily muted by setting a non-zero value in the
+.Fa output_muted
+field.
+Clearing this field restores audio output to the normal state.
+.Pp
+The
+.Va monitor_gain
+field is present for compatibility, and is no longer supported.
+See
+.Xr dsp 4I
+for more detail.
+.Pp
+Likewise, the
+.Fa play.port ,
+.Fa play.ports ,
+.Fa play.mod_ports ,
+.Fa record.port ,
+.Fa record.ports ,
+and
+.Fa record.mod_ports
+are no longer supported.
+See
+.Xr dsp 4I
+for more detail.
+.Pp
+The
+.Fa play.balance
+and
+.Fa record.balance
+fields are fixed to
+.Dv AUDIO_MID_BALANCE .
+Changes to volume levels for different channels can be
+made using the interfaces in
+.Xr dsp 4I .
+.Pp
+The
+.Fa play.pause
+and
+.Fa record.pause
+flags may be used to pause and
+resume the transfer of data between the audio device and the
+.Sy STREAMS
+buffers.
+The
+.Fa play.error
+and
+.Fa record.error
+flags indicate that data underflow or overflow has occurred.
+The
+.Fa play.active
+and
+.Fa record.active
+flags indicate that data transfer is currently active in the corresponding
+direction.
+.Pp
+The
+.Fa play.open
+and
+.Fa record.open
+flags indicate that the device is
+currently open with the corresponding access permission.
+The
+.Fa play.waiting
+and
+.Fa record.waiting
+flags provide an indication that a process may be waiting to access the device.
+These flags are set automatically when a process blocks on
+.Xr open 2 ,
+though they may also be set using the
+.Dv AUDIO_SETINFO
+ioctl command.
+They are cleared only when a process relinquishes access by closing the device.
+.Pp
+The
+.Fa play.samples
+and
+.Fa record.samples
+fields are zeroed at
+.Xr open 2
+and are incremented each time a data sample is copied to or from
+the associated
+.Sy STREAMS
+queue.
+Some audio drivers may be limited to counting
+buffers of samples, instead of single samples for their samples accounting.
+For this reason, applications should not assume that the samples fields contain a
+perfectly accurate count.
+The
+.Fa play.eof
+field increments whenever a zero-length output buffer is synchronously processed.
+Applications may use this
+field to detect the completion of particular segments of audio output.
+.Pp
+The
+.Fa record.buffer_size
+field controls the amount of input data that is
+buffered in the device driver during record operations.
+Applications that have
+particular requirements for low latency should set the value appropriately.
+Note however that smaller input buffer sizes may result in higher system
+overhead.
+The value of this field is specified in bytes and drivers will
+constrain it to be a multiple of the current sample frame size.
+Some drivers may place other requirements on the value of this field.
+Refer to the audio device-specific manual page for more details.
+If an application changes the
+format of the audio device and does not modify the
+.Fa record.buffer_size
+field, the device driver may use a default value to compensate for the new data
+rate.
+Therefore, if an application is going to modify this field, it should
+modify it during or after the format change itself, not before.
+When changing
+the
+.Fa record.buffer_size
+parameters, the input stream should be paused and
+flushed before the change, and resumed afterward.
+Otherwise, subsequent reads
+may return samples in the old format followed by samples in the new format.
+This is particularly important when new parameters result in a changed sample
+size.
+If you change the
+.Fa record.buffer_size
+for the first packet, this protocol must be followed or the first buffer will
+be the default buffer size for the device, followed by packets of the requested
+change size.
+.Pp
+The
+.Fa record.buffer_size
+field may be modified only on the
+.Pa /dev/audio
+device by processes that have it opened for reading.
+.Pp
+The
+.Fa play.buffer_size
+field is currently not supported.
+.Pp
+The audio data format is indicated by the
+.Fa sample_rate ,
+.Fa channels ,
+.Fa precision ,
+and
+.Fa encoding
+fields.
+The values of these fields correspond to the
+descriptions in the
+.Sx "AUDIO FORMATS"
+section of this man page.
+Refer to the
+audio device-specific manual pages for a list of supported data format
+combinations.
+.Pp
+The data format fields can be modified only on the
+.Pa /dev/audio
+device.
+.Pp
+If the parameter changes requested by an
+.Dv AUDIO_SETINFO
+ioctl cannot all be accommodated,
+.Xr ioctl 2
+returns with
+.Va errno
+set to
+.Er EINVAL
+and no changes are made to the device state.
+.Ss "Streamio IOCTLS"
+All of the
+.Xr streamio 4I
+.Xr ioctl 2
+commands may be issued for the
+.Pa /dev/audio
+device.
+Because the
+.Pa /dev/audioctl
+device has its own
+.Sy STREAMS
+queues, most of these commands neither modify nor report the
+state of
+.Pa /dev/audio
+if issued for the
+.Pa /dev/audioctl
+device.
+The
+.Dv I_SETSIG
+ioctl may be issued for
+.Pa /dev/audioctl
+to enable the notification of audio status changes, as described above.
+.Ss "Audio IOCTLS"
+The audio device additionally supports the following
+.Xr ioctl 2
+commands:
+.Bl -tag -width "AUDIO_GETINFO"
+.It Dv AUDIO_DRAIN
+The argument is ignored.
+This command suspends the calling process until the
+output STREAMS queue is empty and all queued samples have been played, or until
+a signal is delivered to the calling process.
+It may not be issued for the
+.Pa /dev/audioctl
+device.
+An implicit
+.Dv AUDIO_DRAIN
+is performed on the final
+.Xr close 2
+of
+.Pa /dev/audio .
+.It Dv AUDIO_GETDEV
+The argument is a pointer to an
+.Vt audio_device_t
+structure.
+This command may be issued for either
+.Pa /dev/audio
+or
+.Pa /dev/audioctl .
+The returned
+value in the name field will be a string that will identify the current
+.Pa /dev/audio
+hardware device, the value in version will be a string
+indicating the current version of the hardware, and
+.Fa config
+will be a device-specific string identifying the properties of the audio stream
+associated with that file descriptor.
+Refer to the audio device-specific manual
+pages to determine the actual strings returned by the device driver.
+.It Dv AUDIO_GETINFO
+The argument is a pointer to an
+.Vt audio_info_t
+structure.
+This command may be issued for either
+.Pa /dev/audio
+or
+.Pa /dev/audioctl .
+The current state of the
+.Pa /dev/audio
+device is returned in the structure.
+Values return pertain to a logical view of the device as seen by and private to
+the process, and do not necessarily reflect the actual hardware device itself.
+.It Dv AUDIO_SETINFO
+The argument is a pointer to an
+.Vt audio_info_t
+structure.
+This command may be issued for either the
+.Pa /dev/audio
+or the
+.Pa /dev/audioctl
+device with some restrictions.
+This command configures the audio device according to
+the supplied structure and overwrites the existing structure with the new state
+of the device.
+Note: The
+.Fa play.samples ,
+.Fa record.samples ,
+.Fa play.error ,
+.Fa record.error ,
+and
+.Fa play.eof
+fields are modified to reflect the state of the device when the
+.Dv AUDIO_SETINFO
+is issued.
+This allows programs to automatically modify these fields while retrieving the
+previous value.
+.Pp
+As with
+.Dv AUDIO_SETINFO ,
+the settings managed by this ioctl deal with a
+logical view of the device which is private to the process, and don't
+necessarily have any impact on the hardware device itself.
+.El
+.Pp
+Certain fields in the audio information structure, such as the pause flags, are
+treated as read-only when
+.Pa /dev/audio
+is not open with the corresponding access permission.
+Other fields, such as the gain levels and encoding
+information, may have a restricted set of acceptable values.
+Applications that
+attempt to modify such fields should check the returned values to be sure that
+the corresponding change took effect.
+The
+.Fa sample_rate ,
+.Fa channels ,
+.Fa precision ,
+and
+.Fa encoding
+fields treated as read-only for
+.Pa /dev/audioctl ,
+so that applications can be guaranteed that the existing
+audio format will stay in place until they relinquish the audio device.
+.Dv AUDIO_SETINFO
+will return
+.Er EINVAL
+when the desired configuration is not possible, or
+.Er EBUSY
+when another process has control of the audio device.
+.Pp
+All of the logical device state is reset when the corresponding I/O stream of
+.Pa /dev/audio
+is closed.
+.Pp
+The
+.Vt audio_info_t
+structure may be initialized through the use of the
+.Dv AUDIO_INITINFO
+macro.
+This macro sets all fields in the structure to
+values that are ignored by the
+.Dv AUDIO_SETINFO
+command.
+For instance, the following code switches the output port from the built-in
+speaker to the headphone jack without modifying any other audio parameters:
+.Bd -literal -offset 2n
+audio_info_t info;
+AUDIO_INITINFO();
+info.play.port = AUDIO_HEADPHONE;
+err = ioctl(audio_fd, AUDIO_SETINFO, );
+.Ed
+.Pp
+This technique eliminates problems associated with using a sequence of
+.Dv AUDIO_GETINFO
+followed by
+.Dv AUDIO_SETINFO .
+.Sh FILES
+The physical audio device names are system dependent and are rarely used by
+programmers.
+Programmers should use the following generic device names:
+.Bl -tag -width "/usr/share/audio/samples"
+.It Pa /dev/audio
+Symbolic link to the system's primary audio device
+.It Pa /dev/audioctl
+Symbolic link to the control device for
+.Pa /dev/audio
+.It Pa /dev/sound/0
+First audio device in the system
+.It Pa /dev/sound/0ctl
+Audio control device for
+.Pa /dev/sound/0
+.It Pa /usr/share/audio/samples
+Audio files
+.El
+.Sh ERRORS
+An
+.Xr open 2
+call will fail if:
+.Bl -tag -width "EINTR"
+.It Er EBUSY
+The requested play or record access is busy and either the
+.Dv O_NDELAY
+or
+.Dv O_NONBLOCK
+flag was set in the
+.Xr open 2
+request.
+.It Er EINTR
+The requested play or record access is busy and a signal interrupted the
+.Xr open 2
+request.
+.El
+.Pp
+An
+.Xr ioctl 2
+call will fail if:
+.Bl -tag -width "EINVAL"
+.It Er EINVAL
+The parameter changes requested in the
+.Dv AUDIO_SETINFO
+ioctl are invalid or are not supported by the device.
+.El
+.Sh ARCHITECTURE
+SPARC
+X86
+.Sh INTERFACE STABILITY
+Obsolete Uncommitted
+.Sh SEE ALSO
+.Xr close 2 ,
+.Xr fcntl 2 ,
+.Xr ioctl 2 ,
+.Xr open 2 ,
+.Xr poll 2 ,
+.Xr read 2 ,
+.Xr write 2 ,
+.Xr dsp 4I ,
+.Xr streamio 4I ,
+.Xr attributes 7
+.Sh BUGS
+Due to a feature of the
+.Sy STREAMS
+implementation, programs that are terminated or
+exit without closing the audio device may hang for a short period while audio
+output drains.
+In general, programs that produce audio output should catch the
+.Dv SIGINT
+signal and flush the output stream before exiting.
diff --git a/usr/src/man/man4i/cdio.4i b/usr/src/man/man4i/cdio.4i
new file mode 100644
index 0000000000..cf86e92801
--- /dev/null
+++ b/usr/src/man/man4i/cdio.4i
@@ -0,0 +1,692 @@
+.\" Copyright (c) 2001, Sun Microsystems, Inc. All Rights Reserved
+.\" Copryright 2017, Joyent, Inc.
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd October 22, 2017
+.Dt CDIO 4I
+.Os
+.Sh NAME
+.Nm cdio
+.Nd CD-ROM control operations
+.Sh SYNOPSIS
+.In sys/cdio.h
+.Sh DESCRIPTION
+The set of
+.Xr ioctl 2
+commands described below are used to perform audio and
+.Sy CD-ROM
+specific operations.
+Basic to these
+.Sy cdio
+ioctl requests are the definitions in
+.In sys/cdio.h .
+.Pp
+Several
+.Sy CD-ROM
+specific commands can report addresses either in
+.Sy LBA
+(Logical Block Address) format or in
+.Sy MSF
+(Minute, Second, Frame) format.
+The
+.Sy READ HEADER ,
+.Sy BREAD SUBCHANNEL ,
+and
+.Sy BREAD TABLE OF CONTENTS
+commands have this feature.
+.Pp
+.Sy LBA
+format represents the logical block address for the
+.Sy CD-ROM
+absolute address field or for the offset from the beginning of the current
+track expressed as a number of logical blocks in a
+.Sy CD-ROM
+track relative address field.
+.Sy MSF
+format represents the physical address written on
+.Sy CD-ROM
+discs, expressed as a sector count relative to either the
+beginning of the medium or the beginning of the current track.
+.Sh IOCTLS
+The following
+.Sy I/O
+controls do not have any additional data passed into or received from them.
+.Bl -tag -width CDROMCLOSETRAY
+.It Dv CDROMSTART
+This
+.Xr ioctl 2
+spins up the disc and seeks to the last address requested.
+.It Dv CDROMSTOP
+This
+.Xr ioctl 2
+spins down the disc.
+.It Dv CDROMPAUSE
+This
+.Xr ioctl 2
+pauses the current audio play operation.
+.It Dv CDROMRESUME
+This
+.Xr ioctl 2
+resumes the paused audio play operation.
+.It Dv CDROMEJECT
+This
+.Xr ioctl 2
+ejects the caddy with the disc.
+.It Dv CDROMCLOSETRAY
+This
+.Xr ioctl 2
+closes the caddy with the disc.
+.El
+.Pp
+The following
+.Sy I/O
+controls require a pointer to the structure for that
+.Xr ioctl 2 ,
+with data being passed into the
+.Xr ioctl 2 .
+.Bl -tag -width CDROMPLAYTRKIND
+.It Dv CDROMPLAYMSF
+This
+.Xr ioctl 2
+command requests the drive to output the audio signals at
+the specified starting address and continue the audio play until the specified
+ending address is detected.
+The address is in
+.Sy MSF
+format.
+The third argument of this
+.Xr ioctl 2
+call is a pointer to the type
+.Vt "struct cdrom_msf" .
+.Bd -literal -offset 2n
+/*
+ * definition of play audio msf structure
+ */
+struct cdrom_msf {
+ /* starting minute */
+ unsigned char cdmsf_min0;
+ /* starting second */
+ unsigned char cdmsf_sec0;
+ /* starting frame */
+ unsigned char cdmsf_frame0;
+ /* ending minute */
+ unsigned char cdmsf_min1;
+ /* ending second */
+ unsigned char cdmsf_sec1;
+ /* ending frame */
+ unsigned char cdmsf_frame1;
+};
+.Ed
+.Pp
+The
+.Dv CDROMREADTOCENTRY
+ioctl request may be used to obtain the start time for a track.
+An approximation of the finish time can be obtained by using the
+.Dv CDROMREADTOCENTRY
+ioctl request to retrieve the start time of the track
+following the current track.
+.Pp
+The leadout track is the next consecutive track after the last audio track.
+Hence, the start time of the leadout track may be used as the effective finish
+time of the last audio track.
+.It Dv CDROMPLAYTRKIND
+This
+.Xr ioctl 2
+command is similar to
+.Dv CDROMPLAYMSF .
+The starting and ending address is in track/index format.
+The third argument of the
+.Xr ioctl 2
+call is a pointer to the type
+.Vt "struct cdrom_ti" .
+.Bd -literal -offset 2n
+/*
+ * definition of play audio track/index structure
+ */
+struct cdrom_ti {
+ /* starting track */
+ unsigned char cdti_trk0;
+ /* starting index */
+ unsigned char cdti_ind0;
+ /* ending track */
+ unsigned char cdti_trk1;
+ /* ending index */
+ unsigned char cdti_ind1;
+};
+.Ed
+.It Dv CDROMVOLCTRL
+This
+.Xr ioctl 2
+command controls the audio output level.
+The
+.Sy SCSI
+command allows the control of up to four channels.
+The current implementation of the supported
+.Sy CD-ROM
+drive only uses channel 0 and channel 1.
+The valid values of volume control are between 0x00 and 0xFF, with a value of
+0xFF indicating maximum volume.
+The third argument of the
+.Xr ioctl 2
+call is a pointer to
+.Vt "struct cdrom_volctrl"
+which contains the output volume values.
+.Bd -literal -offset 2n
+/*
+ * definition of audio volume control structure
+ */
+struct cdrom_volctrl {
+ unsigned char channel0;
+ unsigned char channel1;
+ unsigned char channel2;
+ unsigned char channel3;
+};
+.Ed
+.El
+.Pp
+The following
+.Sy I/O
+controls take a pointer that will have data returned to
+the user program from the
+.Sy CD-ROM
+driver.
+.Bl -tag -width CDROMREADOFFSET
+.It Dv CDROMREADTOCHDR
+This
+.Xr ioctl 2
+command returns the header of the table of contents (TOC).
+The header consists of the starting track number and the ending track number
+of the disc.
+These two numbers are returned through a pointer of
+.Vt "struct cdrom_tochdr" .
+While the disc can start at any number, all tracks between the
+first and last tracks are in contiguous ascending order.
+.Bd -literal -offset 2n
+/*
+ * definition of read toc header structure
+ */
+struct cdrom_tochdr {
+ unsigned char cdth_trk0; /* starting track */
+ unsigned char cdth_trk1; /* ending track */
+};
+.Ed
+.It Dv CDROMREADTOCENTRY
+This
+.Xr ioctl 2
+command returns the information of a specified track.
+The third argument of the function call is a pointer to the type
+.Vt "struct cdrom_tocentry" .
+The caller needs to supply the track number and the address format.
+This command will return a 4-bit
+.Sy adr
+field, a 4-bit
+.Sy ctrl
+field, the starting address in
+.Sy MSF
+format or
+.Sy LBA
+format, and the data mode if the track is a data track.
+The
+.Sy ctrl
+field specifies whether the track is data or audio.
+.Bd -literal -offset 2n
+/*
+ * definition of read toc entry structure
+ */
+struct cdrom_tocentry {
+ unsigned char cdte_track;
+ unsigned char cdte_adr :4;
+ unsigned char cdte_ctrl :4;
+ unsigned char cdte_format;
+ union {
+ struct {
+ unsigned char minute;
+ unsigned char second;
+ unsigned char frame;
+ } msf;
+ int lba;
+ } cdte_addr;
+ unsigned char cdte_datamode;
+};
+.Ed
+.Pp
+To get the information from the leadout track, the following value is
+appropriate for the
+.Fa cdte_track
+field:
+.\" These next few lists all use the same width so they align better
+.Bl -tag -offset indent -width CDROM_DATA_TRACK
+.It Dv CDROM_LEADOUT
+Leadout track
+.El
+.Pp
+To get the information from the data track, the following value is appropriate
+for the
+.Fa cdte_ctrl
+field:
+.Bl -tag -offset indent -width CDROM_DATA_TRACK
+.It Dv CDROM_DATA_TRACK
+Data track
+.El
+.Pp
+The following values are appropriate for the
+.Fa cdte_format
+field:
+.Bl -tag -offset indent -width CDROM_DATA_TRACK
+.It Dv CDROM_LBA
+.Sy LBA
+format
+.It Dv CDROM_MSF
+.Sy MSF
+format
+.El
+.It Dv CDROMSUBCHNL
+This
+.Xr ioctl 2
+command reads the Q sub-channel data of the current block.
+The subchannel data includes track number, index number, absolute
+.Sy CD-ROM
+address, track relative
+.Sy CD-ROM
+address, control data and audio status.
+All information is returned through a pointer to
+.Vt "struct cdrom_subchnl" .
+The caller needs to supply the address format for the returned address.
+.Bd -literal -offset 2n
+struct cdrom_subchnl {
+ unsigned char cdsc_format;
+ unsigned char cdsc_audiostatus;
+ unsigned char cdsc_adr :4;
+ unsigned char cdsc_ctrl :4;
+ unsigned char cdsc_trk;
+ unsigned char cdsc_ind;
+ union {
+ struct {
+ unsigned char minute;
+ unsigned char second;
+ unsigned char frame;
+ } msf;
+ int lba;
+ } cdsc_absaddr;
+ union {
+ struct {
+ unsigned char minute;
+ unsigned char second;
+ unsigned char frame;
+ } msf;
+ int lba;
+ } cdsc_reladdr;
+};
+.Ed
+.Pp
+The following values are valid for the audio status field returned from
+.Sy "READ SUBCHANNEL"
+command:
+.Bl -tag -width CDROM_AUDIO_NO_STATUS
+.It Dv CDROM_AUDIO_INVALID
+Audio status not supported.
+.It Dv CDROM_AUDIO_PLAY
+Audio play operation in progress.
+.It Dv CDROM_AUDIO_PAUSED
+Audio play operation paused.
+.It Dv CDROM_AUDIO_COMPLETED
+Audio play successfully completed.
+.It Dv CDROM_AUDIO_ERROR
+Audio play stopped due to error.
+.It Dv CDROM_AUDIO_NO_STATUS
+No current audio status to return.
+.El
+.It Dv CDROMREADOFFSET
+This
+.Xr ioctl 2
+command returns the absolute
+.Sy CD-ROM
+address of the first track in the last session of a Multi-Session
+.Sy CD-ROM .
+The third argument of the
+.Xr ioctl 2
+call is a pointer to an
+.Vt int .
+.It Dv CDROMCDDA
+This
+.Xr ioctl 2
+command returns the
+.Sy CD-DA
+data or the subcode data.
+The third argument of the
+.Xr ioctl 2
+call is a pointer to the type
+.Vt "struct cdrom_cdda" .
+In addition to allocating memory and supplying its address, the
+caller needs to supply the starting address of the data, the transfer length in
+terms of the number of blocks to be transferred, and the subcode options.
+The caller also needs to issue the
+.Dv CDROMREADTOCENTRY
+.Xr ioctl 2
+to find out which tracks contain
+.Sy CD-DA
+data before issuing this
+.Xr ioctl 2 .
+.Bd -literal -offset 2n
+/*
+ * Definition of CD-DA structure
+ */
+struct cdrom_cdda {
+ unsigned int cdda_addr;
+ unsigned int cdda_length;
+ caddr_t cdda_data;
+ unsigned char cdda_subcode;
+};
+.Ed
+.Pp
+.Sy cdda_addr
+signifies the starting logical block address.
+.Sy cdda_length
+signifies the transfer length in blocks.
+The length of the block depends on the
+.Sy cdda_subcode
+selection, which is explained below.
+To get the subcode information related to
+.Sy CD-DA
+data, the following values are appropriate for the
+.Sy cdda_subcode
+field:
+.Bl -tag -width CDROM_DA_SUBCODE_ONLY
+.It Sy CDROM_DA_NO_SUBCODE
+.Sy CD-DA
+data with no subcode.
+.It Sy CDROM_DA_SUBQ
+.Sy CD-DA
+data with sub Q code.
+.It Sy CDROM_DA_ALL_SUBCODE
+.Sy CD-DA
+data with all subcode.
+.It Sy CDROM_DA_SUBCODE_ONLY
+All subcode only.
+.El
+.Pp
+To allocate the memory related to
+.Sy CD-DA
+and/or subcode data, the
+following values are appropriate for each data block transferred:
+.Bl -tag -width "CD-DA data with all subcode"
+.It Sy CD-DA data with no subcode
+2352 bytes
+.It Sy CD-DA data with sub Q code
+2368 bytes
+.It Sy CD-DA data with all subcode
+2448 bytes
+.It Sy "All subcode only"
+96 bytes
+.El
+.It Dv CDROMCDXA
+This
+.Xr ioctl 2
+command returns the
+.Sy "CD-ROM XA"
+(CD-ROM Extended Architecture) data according to
+.Sy "CD-ROM XA"
+format.
+The third argument of the
+.Xr ioctl 2
+call is a pointer to the type
+.Vt "struct cdrom_cdxa" .
+In addition to allocating memory and supplying its address, the
+caller needs to supply the starting address of the data, the transfer length
+in terms of number of blocks, and the format.
+The caller also needs to issue
+the
+.Sy CDROMREADTOCENTRY
+.Xr ioctl 2
+to find out which tracks contain
+.Sy "CD-ROM XA"
+data before issuing this
+.Xr ioctl 2 .
+.Bd -literal -offset 2n
+/*
+ * Definition of CD-ROM XA structure
+ */
+struct cdrom_cdxa {
+ unsigned int cdxa_addr;
+ unsigned int cdxa_length;
+ caddr_t cdxa_data;
+ unsigned char cdxa_format;
+};
+.Ed
+.Pp
+To get the proper
+.Sy "CD-ROM XA"
+data, the following values are appropriate for the
+.Fa cdxa_format
+field:
+.Bl -tag -width CDROM_XA_DATA_W_ERROR
+.It Dv CDROM_XA_DATA
+.Sy "CD-ROM XA"
+data only
+.It Dv CDROM_XA_SECTOR_DATA
+.Sy "CD-ROM XA"
+all sector data
+.It Dv CDROM_XA_DATA_W_ERROR
+.Sy CD-ROM \fBXA\fR
+data with error flags data
+.El
+.Pp
+To allocate the memory related to
+.Sy "CD-ROM XA"
+format, the following values are appropriate for each data block transferred:
+.Bl -tag -width "CD-ROM XA data with error flags data"
+.It Sy "CD-ROM XA" data only
+2048 bytes
+.It Sy "CD-ROM XA" all sector data
+2352 bytes
+.It Sy "CD-ROM XA" data with error flags data
+2646 bytes
+.El
+.It Dv CDROMSUBCODE
+This
+.Xr ioctl 2
+command returns raw subcode data (subcodes P ~ W are
+described in the "Red Book," see
+.Sx SEE ALSO )
+to the initiator while the target is playing audio.
+The third argument of the
+.Xr ioctl 2
+call is a pointer to the type
+.Vt "struct cdrom_subcode" .
+The caller needs to supply the transfer length in terms of number of blocks and
+allocate memory for subcode data.
+The memory allocated should be a multiple of 96 bytes depending on the
+transfer length.
+.Bd -literal -offset 2n
+/*
+ * Definition of subcode structure
+ */
+struct cdrom_subcode {
+ unsigned int cdsc_length;
+ caddr_t cdsc_addr;
+};
+.Ed
+.El
+.Pp
+The next group of
+.Sy I/O
+controls get and set various
+.Sy CD-ROM
+drive parameters.
+.Bl -tag -width CDROMGDRVSPEED
+.It Dv CDROMGBLKMODE
+This
+.Xr ioctl 2
+command returns the current block size used by the
+.Sy CD-ROM
+drive.
+The third argument of the
+.Xr ioctl 2
+call is a pointer to an integer.
+.It Dv CDROMSBLKMODE
+This
+.Xr ioctl 2
+command requests the
+.Sy CD-ROM
+drive to change from the current block size to the requested block size.
+The third argument of the
+.Xr ioctl 2
+call is an integer which contains the requested block size.
+This
+.Xr ioctl 2
+command operates in exclusive-use mode only.
+The caller must ensure that no other processes can operate on the same
+.Sy CD-ROM
+device before issuing this
+.Xr ioctl 2 .
+.Xr read 2
+behavior subsequent to this
+.Xr ioctl 2
+remains the same: the caller is still constrained to read the raw
+device on block boundaries and in block multiples.
+To set the proper block size, the following values are appropriate:
+.Bl -tag -width CDROM_BLK_1024
+.It Dv CDROM_BLK_512
+512 bytes
+.It Dv CDROM_BLK_1024
+1024 bytes
+.It Dv CDROM_BLK_2048
+2048 bytes
+.It Dv CDROM_BLK_2056
+2056 bytes
+.It Dv CDROM_BLK_2336
+2336 bytes
+.It Dv CDROM_BLK_2340
+2340 bytes
+.It Dv CDROM_BLK_2352
+2352 bytes
+.It Dv CDROM_BLK_2368
+2368 bytes
+.It Dv CDROM_BLK_2448
+2448 bytes
+.It Dv CDROM_BLK_2646
+2646 bytes
+.It Dv CDROM_BLK_2647
+2647 bytes
+.El
+.It Dv CDROMGDRVSPEED
+This
+.Xr ioctl 2
+command returns the current
+.Sy CD-ROM
+drive speed.
+The third argument of the
+.Xr ioctl 2
+call is a pointer to an integer.
+.It Dv CDROMSDRVSPEED
+This
+.Xr ioctl 2
+command requests the
+.Sy CD-ROM
+drive to change the current drive speed to the requested drive speed.
+This speed setting is only applicable when reading data areas.
+The third argument of the
+.Xr ioctl 2
+is an integer which contains the requested drive speed.
+To set the
+.Sy CD-ROM
+drive to the proper speed, the following values are appropriate:
+.Bl -tag -width CDROM_MAXIMUM_SPEED
+.It Dv CDROM_NORMAL_SPEED
+150k/second
+.It Dv CDROM_DOUBLE_SPEED
+300k/second
+.It Dv CDROM_QUAD_SPEED
+600k/second
+.It Dv CDROM_MAXIMUM_SPEED
+300k/second (2x drive)
+.Pp
+600k/second (4x drive)
+.El
+.Pp
+Note that these numbers are only accurate when reading 2048 byte blocks.
+The
+.Sy CD-ROM
+drive will automatically switch to normal speed when playing audio
+tracks and will switch back to the speed setting when accessing data.
+.El
+.Sh ARCHITECTURE
+All
+.Sh INTERFACE STABILITY
+Uncommitted
+.Sh SEE ALSO
+.Xr ioctl 2 ,
+.Xr read 2 ,
+.Xr attributes 7
+.Rs
+.%Q N. V. Phillips
+.%Q Sony Corporation
+.%B System Description Compact Disc Digital Audio
+.%O ("Red Book")
+.Re
+.Rs
+.%Q N. V. Phillips
+.%Q Sony Corporation
+.%B System Description of Compact Disc Read Only Memory
+.%O ("Yellow Book")
+.Re
+.Rs
+.%Q N. V. Phillips
+.%Q Microsoft
+.%Q Sony Corporation
+.%B System Description CD-ROM XA
+.%D 1991
+.Re
+.Rs
+.%T Volume and File Structure of CD-ROM for Information Interchange
+.%N ISO 9660:1988(E)
+.Re
+.Rs
+.%T SCSI-2 Standard
+.%N document X3T9.2/86-109
+.Re
+.Rs
+.%T SCSI Multimedia Commands, Version 2 (MMC-2)
+.Re
+.Sh NOTES
+The
+.Dv CDROMCDDA ,
+.Dv CDROMCDXA ,
+.Dv CDROMSUBCODE ,
+.Dv CDROMGDRVSPEED ,
+.Dv CDROMSDRVSPEED ,
+and some of the block sizes in
+.Dv CDROMSBLKMODE
+are designed for new Sun-supported
+.Sy CD-ROM
+drives and might not work on some of the older
+.Sy CD-ROM
+drives.
+.Pp
+.Dv CDROMCDDA ,
+.Dv CDROMCDXA ,
+and
+.Dv CDROMSUBCODE
+will return error if the transfer length exceeds valid limits as determined appropriate.
+Example: for MMC-2 drives, length can not exceed 3 bytes (i\&.e\&. 0xffffff).
+The same restriction is enforced for older, pre-MMC-2 drives, as no limit was
+published for these older drives (and 3 bytes is reasonable for all media).
+Note that enforcing this limit does not imply that values passed in below this
+limit will actually be applicable for each and every piece of media.
+.Pp
+The interface to this device is preliminary and subject to change in future
+releases.
+Programs should be written in a modular fashion so that future
+changes can be easily incorporated.
diff --git a/usr/src/man/man4i/dkio.4i b/usr/src/man/man4i/dkio.4i
new file mode 100644
index 0000000000..05f1e48bee
--- /dev/null
+++ b/usr/src/man/man4i/dkio.4i
@@ -0,0 +1,867 @@
+.\"
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.\"
+.\"
+.\" Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
+.\" Copyright 2016 Nexenta Systems, Inc.
+.\" Copyright (c) 2017, Joyent, Inc.
+.\"
+.Dd October 23, 2017
+.Dt DKIO 4I
+.Os
+.Sh NAME
+.Nm dkio
+.Nd disk control operations
+.Sh SYNOPSIS
+.In sys/dkio.h
+.In sys/vtoc.h
+.Sh DESCRIPTION
+Disk drivers support a set of
+.Xr ioctl 2
+requests for disk controller, geometry, and partition information.
+Basic to these
+.Xr ioctl 2
+requests are the definitions in
+.In sys/dkio.h .
+.Sh IOCTLS
+The following
+.Xr ioctl 2
+requests set and/or retrieve the current disk
+controller, partitions, or geometry information on all architectures:
+.Bl -tag -width 1n
+.It Dv DKIOCINFO
+.Pp
+The argument is a pointer to a
+.Vt dk_cinfo
+structure (described below).
+This structure tells the controller-type and attributes regarding bad-block
+processing done on the controller.
+.Bd -literal -offset 2n
+/*
+ * Structures and definitions for disk I/O control commands
+ */
+#define DK_DEVLEN 16 /* device name max length, */
+ /* including unit # and NULL */
+
+/* Used for controller info */
+struct dk_cinfo {
+ char dki_cname[DK_DEVLEN]; /* controller name */
+ /* (no unit #) */
+ ushort_t dki_ctype; /* controller type */
+ ushort_t dki_flags; /* flags */
+ ushort_t dki_cnum; /* controller number */
+ uint_t dki_addr; /* controller address */
+ uint_t dki_space; /* controller bus type */
+ uint_t dki_prio; /* interrupt priority */
+ uint_t dki_vec; /* interrupt vector */
+ char dki_dname[DK_DEVLEN]; /* drive name (no unit #) */
+ uint_t dki_unit; /* unit number */
+ uint_t dki_slave; /* slave number */
+ ushort_t dki_partition; /* partition number */
+ ushort_t dki_maxtransfer; /* maximum transfer size */
+ /* in DEV_BSIZE */
+ };
+
+ /*
+ * Controller types
+ */
+ #define DKC_UNKNOWN 0
+ #define DKC_CDROM 1 /* CD-ROM, SCSI or other */
+ #define DKC_WDC2880 2
+ #define DKC_XXX_0 3 /* unassigned */
+ #define DKC_XXX_1 4 /* unassigned */
+ #define DKC_DSD5215 5
+ #define DKC_ACB4000 7
+ #define DKC_XXX_2 9 /* unassigned */
+ #define DKC_NCRFLOPPY 10
+ #define DKC_SMSFLOPPY 12
+ #define DKC_SCSI_CCS 13 /* SCSI CCS compatible */
+ #define DKC_INTEL82072 14 /* native floppy chip */
+ #define DKC_INTEL82077 19 /* 82077 floppy disk */
+ /* controller */
+ #define DKC_DIRECT 20 /* Intel direct attached */
+ /* device (IDE) */
+ #define DKC_PCMCIA_MEM 21 /* PCMCIA memory disk-like */
+ /* type */
+ #define DKC_PCMCIA_ATA 22 /* PCMCIA AT Attached type */
+
+ /*
+ * Sun reserves up through 1023
+ */
+
+ #define DKC_CUSTOMER_BASE 1024
+
+ /*
+ * Flags
+ */
+ #define DKI_BAD144 0x01 /* use DEC std 144 */
+ /* bad sector fwding */
+ #define DKI_MAPTRK 0x02 /* controller does */
+ /* track mapping */
+ #define DKI_FMTTRK 0x04 /* formats only full
+ /* track at a time */
+ #define DKI_FMTVOL 0x08 /* formats only full */
+ /* volume at a time */
+ #define DKI_FMTCYL 0x10 /* formats only full */
+ /* cylinders at a time */
+ #define DKI_HEXUNIT 0x20 /* unit number printed */
+ /* as 3 hexdigits */
+ #define DKI_PCMCIA_PFD 0x40 /* PCMCIA pseudo-floppy */
+ /* memory card */
+.Ed
+.It Dv DKIOCGAPART
+.Pp
+The argument is a pointer to a
+.Vt dk_allmap
+structure (described below).
+This
+.Xr ioctl 2
+gets the controller's notion of the current partition table
+for disk drive.
+.It Dv DKIOCSAPART
+.Pp
+The argument is a pointer to a
+.Vt dk_allmap
+structure (described below).
+This
+.Xr ioctl 2
+sets the controller's notion of the partition table without
+changing the disk itself.
+.Bd -literal -offset 2n
+/*
+ * Partition map (part of dk_label)
+ */
+struct dk_map {
+ daddr_t dkl_cylno; /* starting cylinder */
+ daddr_t dkl_nblk; /* number of blocks */
+};
+
+/*
+ * Used for all partitions
+ */
+struct dk_allmap {
+ struct dk_map dka_map[NDKMAP];
+};
+.Ed
+.It Dv DKIOCGGEOM
+.Pp
+The argument is a pointer to a
+.Vt dk_geom
+structure (described below).
+This
+.Xr ioctl 2
+gets the controller's notion of the current geometry of the disk drive.
+.It Dv DKIOCSGEOM
+.Pp
+The argument is a pointer to a
+.Vt dk_geom
+structure (described below).
+This
+.Xr ioctl 2
+sets the controller's notion of the geometry without changing the disk itself.
+.It Dv DKIOCGVTOC
+.Pp
+The argument is a pointer to a
+.Vt vtoc
+structure (described below).
+This
+.Xr ioctl 2
+returns the device's current volume table of contents (VTOC).
+For disks larger than 1TB,
+.Dv DKIOCGEXTVTOC
+must be used instead.
+.It Dv DKIOCSVTOC
+.Pp
+The argument is a pointer to a
+.Vt vtoc
+structure (described below).
+This
+.Xr ioctl 2
+changes the VTOC associated with the device.
+For disks larger than 1TB,
+.Dv DKIOCSEXTVTOC
+must be used instead.
+.Bd -literal -offset 2n
+struct partition {
+ ushort_t p_tag; /* ID tag of partition */
+ ushort_t p_flag; /* permission flags */
+ daddr_t p_start; /* start sector of partition */
+ long p_size; /* # of blocks in partition */
+};
+.Ed
+.Pp
+If
+.Dv DKIOCSVTOC
+is used with a floppy diskette, the
+.Fa p_start
+field must be the first sector of a cylinder.
+To compute the number of sectors per
+cylinder, multiply the number of heads by the number of sectors per track.
+.Bd -literal -offset 2n
+struct vtoc {
+ unsigned long v_bootinfo[3]; /* info needed by mboot */
+ /* (unsupported) */
+ unsigned long v_sanity; /* to verify vtoc */
+ /* sanity */
+ unsigned long v_version; /* layout version */
+ char v_volume[LEN_DKL_VVOL]; /* volume name */
+ ushort_t v_sectorsz; /* sector size in bytes */
+ ushort_t v_nparts; /* number of partitions */
+ unsigned long v_reserved[10]; /* free space */
+ struct partition v_part[V_NUMPAR]; /* partition headers */
+ time_t timestamp[V_NUMPAR]; /* partition timestamp */
+ /* (unsupported) */
+ char v_asciilabel[LEN_DKL_ASCII]; /* compatibility */
+};
+
+/*
+ * Partition permission flags
+ */
+#define V_UNMNT 0x01 /* Unmountable partition */
+#define V_RONLY 0x10 /* Read only */
+
+/*
+ * Partition identification tags
+ */
+#define V_UNASSIGNED 0x00 /* unassigned partition */
+#define V_BOOT 0x01 /* Boot partition */
+#define V_ROOT 0x02 /* Root filesystem */
+#define V_SWAP 0x03 /* Swap filesystem */
+#define V_USR 0x04 /* Usr filesystem */
+#define V_BACKUP 0x05 /* full disk */
+#define V_VAR 0x07 /* Var partition */
+#define V_HOME 0x08 /* Home partition */
+#define V_ALTSCTR 0x09 /* Alternate sector partition */
+.Ed
+.It Dv DKIOCGEXTVTOC
+.Pp
+The argument is a pointer to an
+.Vt extvtoc
+structure (described below).
+This ioctl returns the device's current volume table of contents (VTOC).
+VTOC is extended to support a disk up to 2TB in size.
+For disks larger than 1TB this ioctl must be used instead of
+.Dv DKIOCGVTOC .
+.It Dv DKIOCSEXTVTOC
+.Pp
+The argument is a pointer to an
+.Vt extvtoc
+structure (described below).
+This ioctl changes the VTOC associated with the device.
+VTOC is extended to support a disk up to 2TB in size.
+For disks larger than 1TB this ioctl must be used instead of
+.Vt DKIOCSVTOC .
+.Bd -literal -offset 2n
+struct extpartition {
+ ushort_t p_tag; /* ID tag of partition */
+ ushort_t p_flag; /* permission flags */
+ ushort_t p_pad[2]; /* reserved */
+ diskaddr_t p_start; /* start sector no of partition */
+ diskaddr_t p_size; /* # of blocks in partition */
+};
+
+struct extvtoc {
+ uint64_t v_bootinfo[3]; /* info needed by mboot (unsupported) */
+ uint64_t v_sanity; /* to verify vtoc sanity */
+ uint64_t v_version; /* layout version */
+ char v_volume[LEN_DKL_VVOL]; /* volume name */
+ ushort_t v_sectorsz; /* sector size in bytes */
+ ushort_t v_nparts; /* number of partitions */
+ ushort_t pad[2];
+ uint64_t v_reserved[10];
+ struct extpartition v_part[V_NUMPAR]; /* partition headers */
+ uint64_t timestamp[V_NUMPAR]; /* partition timestamp */
+ /* (unsupported) */
+ char v_asciilabel[LEN_DKL_ASCII]; /* for compatibility */
+};
+.Ed
+.Pp
+Partition permissions flags and identification tags
+are defined the same as vtoc structure.
+.It Dv DKIOCEJECT
+.Pp
+If the drive supports removable media, this
+.Xr ioctl 2
+requests the disk drive to eject its disk.
+.It Dv DKIOCREMOVABLE
+.Pp
+The argument to this
+.Xr ioctl 2
+is an integer.
+After successful completion, this
+.Xr ioctl 2
+sets that integer to a non-zero value if the drive in
+question has removable media.
+If the media is not removable, the integer is set to
+.Sy 0 .
+.It Dv DKIOCHOTPLUGGABLE
+.Pp
+The argument to this
+.Xr ioctl 2
+is an integer.
+After successful completion, this
+.Xr ioctl 2
+sets that integer to a non-zero value if the drive in question is hotpluggable.
+If the media is not hotpluggable, the integer is set to 0.
+.It Dv DKIOCSTATE
+.Pp
+This
+.Xr ioctl 2
+blocks until the state of the drive, inserted or ejected, is changed.
+The argument is a pointer to a
+.Vt dkio_state ,
+enum, whose possible enumerations are listed below.
+The initial value should be either the last
+reported state of the drive, or
+.Dv DKIO_NONE .
+Upon return, the enum pointed
+to by the argument is updated with the current state of the drive.
+.Bd -literal -offset 2n
+enum dkio_state {
+ DKIO_NONE, /* Return disk's current state */
+ DKIO_EJECTED, /* Disk state is 'ejected' */
+ DKIO_INSERTED /* Disk state is 'inserted' */
+};
+.Ed
+.It Dv DKIOCLOCK
+.Pp
+For devices with removable media, this
+.Xr ioctl 2
+requests the disk drive to lock the door.
+.It Dv DKIOCUNLOCK
+.Pp
+For devices with removable media, this
+.Xr ioctl 2
+requests the disk drive to unlock the door.
+.It Dv DKIOCGMEDIAINFO
+.Pp
+The argument to this
+.Xr ioctl 2
+is a pointer to a
+.Vt dk_minfo
+structure.
+The structure indicates the type of media or the command set profile used by
+the drive to operate on the media.
+The
+.Vt dk_minfo
+structure also indicates the logical media block size the drive uses as the
+basic unit block size of operation and the raw formatted capacity of the media
+in number of logical blocks.
+.It Dv DKIOCGMEDIAINFOEXT
+.Pp
+The argument to this
+.Xr ioctl 2
+is a pointer to a
+.Vt dk_minfo_ext
+structure.
+The structure indicates the type of media or the command set profile
+used by the drive to operate on the media.
+The
+.Vt dk_minfo_ext
+structure
+also indicates the logical media block size the drive uses as the basic unit
+block size of operation, the raw formatted capacity of the media in number of
+logical blocks and the physical block size of the media.
+.Bd -literal -offset 2n
+/*
+ * Used for media info or profile info
+ */
+struct dk_minfo {
+ uint_t dki_media_type; /* Media type or profile info */
+ uint_t dki_lbsize; /* Logical blocksize of media */
+ diskaddr_t dki_capacity; /* Capacity as # of dki_lbsize blks */
+};
+
+/*
+ * Used for media info or profile info and physical blocksize
+ */
+struct dk_minfo_ext {
+ uint_t dki_media_type; /* Media type or profile info */
+ uint_t dki_lbsize; /* Logical blocksize of media */
+ diskaddr_t dki_capacity; /* Capacity as # of dki_lbsize blks */
+ uint_t dki_pbsize; /* Physical blocksize of media */
+};
+
+
+/*
+ * Media types or profiles known
+ */
+#define DK_UNKNOWN 0x00 /* Media inserted - type unknown */
+
+/*
+ * SFF 8090 Specification Version 3, media types 0x01 - 0xfffe are
+ * retained to maintain compatibility with SFF8090. The following
+ * define the optical media type.
+ */
+#define DK_MO_ERASABLE 0x03 /* MO Erasable */
+#define DK_MO_WRITEONCE 0x04 /* MO Write once */
+#define DK_AS_MO 0x05 /* AS MO */
+#define DK_CDROM 0x08 /* CDROM */
+#define DK_CDR 0x09 /* CD-R */
+#define DK_CDRW 0x0A /* CD-RW */
+#define DK_DVDROM 0x10 /* DVD-ROM */
+#define DK_DVDR 0x11 /* DVD-R */
+#define DK_DVDRAM 0x12 /* DVD_RAM or DVD-RW */
+
+/*
+ * Media types for other rewritable magnetic media
+ */
+#define DK_FIXED_DISK 0x10001 /* Fixed disk SCSI or otherwise */
+#define DK_FLOPPY 0x10002 /* Floppy media */
+#define DK_ZIP 0x10003 /* IOMEGA ZIP media */
+#define DK_JAZ 0x10004 /* IOMEGA JAZ media */
+.Ed
+.Pp
+If the media exists and the host can obtain a current profile list, the command
+succeeds and returns the
+.Vt dk_minfo
+structure with data representing that media.
+.Pp
+If there is no media in the drive, the command fails and the host returns an
+.Er ENXIO
+error, indicating that it cannot gather the information requested.
+.Pp
+If the profile list is not available, the host attempts to identify the
+media-type based on the available information.
+.Pp
+If identification is not possible, the host returns media type
+.Dv DK_UNKNOWN .
+See
+.Sx NOTES
+for blocksize usage and capacity information.
+.It Dv DKIOCSMBOOT
+.Pp
+The argument is a pointer to struct
+.Vt mboot .
+.Pp
+Copies the
+.Vt mboot
+information supplied in the argument to the absolute sector 0 of the device.
+Prior to copying the information, this
+.Xr ioctl 2
+performs the following checks on the
+.Vt mboot
+data:
+.Bl -bullet -offset indent
+.It
+Ensures that the signature field is set to 0xAA55.
+.It
+Ensures that partitions do not overlap.
+.It
+On SPARC platforms, determines if the device is a removable media.
+.El
+.Pp
+If the above verification fails,
+.Va errno
+is set to
+.Er EINVAL
+and the
+.Xr ioctl 2
+command fails.
+.Pp
+x86 Platforms \(em Upon successful write of
+.Vt mboot ,
+the partition map structure maintained in the driver is updated.
+If the new Solaris partition is
+different from the previous one, the internal VTOC table maintained in the
+driver is set as follows:
+.Pp
+If
+.Dv _SUNOS_VTOC_8
+is defined:
+.Bd -unfilled -offset 4n
+Partition: 0 Start: 0 Capacity = Capacity of device.
+Partition: 2 Start: 0 Capacity = Capacity of device.
+.Ed
+.Pp
+If
+.Dv _SUNOS_VTOC_16
+is defined:
+.Bd -unfilled -offset 4n
+Partition: 2 Start: 0 Size = Size specified in mboot - 2 cylinders.
+Partition: 8 Start: 0 Size = Sectors/cylinder.
+Partition: 9 Start: Sectors/cylinder Size = 2 * sectors/cylinder
+.Ed
+.Pp
+To determine if the Solaris partition has changed:
+.Bd -offset 4n -ragged
+If either offset or the size of the Solaris partition is different from the
+previous one then it shall be deemed to have changed.
+In all other cases, the
+internal VTOC info remains as before.
+.Ed
+.Pp
+SPARC Platforms \(em The VTOC label and
+.Vt mboot
+both occupy the same location, namely sector 0.
+As a result, following the successful write of
+.Vt mboot
+info, the internal VTOC table maintained in the driver is set as follows:
+.Bd -unfilled -offset 4n
+Partition: 0 Start: 0 Size = Capacity of device.
+Partition: 2 Start: 0 Size = Capacity of device.
+.Ed
+.Pp
+See the
+.Sx NOTES
+section for usage of
+.Dv DKIOCSMBOOT
+when modifying Solaris partitions.
+.It Dv DKIOCGETVOLCAP
+.Pp
+This ioctl provides information and status of available capabilities.
+.Fa vc_info
+is a bitmap and the valid flag values are:
+.Pp
+.Bl -tag -width DKV_ABR_CAP -compact -offset 2n
+.It Dv DKV_ABR_CAP
+Capable of application-based recovery
+.It Dv DKV_DMR_CAP
+Ability to read specific copy of data when multiple copies exist.
+For example, in a two way mirror, this ioctl is used to read each
+side of the mirror.
+.El
+.Pp
+.Fa vc_set
+is a bitmap and the valid flag values are:
+.Pp
+.Bl -tag -width DKV_ABR_CAP -compact -offset 2n
+.It Dv DKV_ABR_CAP
+This flag is set if ABR has been set on a device that supports ABR functionality.
+.It Dv DKV_DMR_CAP
+Directed read has been enabled.
+.El
+.Pp
+These capabilities are not required to be persistent across a system reboot and
+their persistence depends upon the implementation.
+For example, if the ABR
+capability for a DRL mirror simply clears the dirty-region list and
+subsequently stops updating this list, there is no reason for persistence
+because the VM recovery is a no-op.
+Conversely, if the ABR capability is
+applied to a non-DRL mirror to indicate that the VM should not perform a full
+recovery of the mirror following a system crash, the capability must be
+persistent so that the VM know whether or not to perform recovery.
+.Pp
+Return Errors:
+.Pp
+.Bl -tag -width ENOTSUP -compact -offset 2n
+.It Er EINVAL
+Invalid device for this operation.
+.It Er ENOTSUP
+Functionality that is attempted to be set is not supported.
+.El
+.It Dv DKIOCSETVOLCAP
+.Pp
+This ioctl sets the available capabilities for the device.
+If a capability flag
+is not set in
+.Fa vc_set ,
+that capability is cleared.
+.Pp
+.Fa vc_info
+flags are ignored.
+.Pp
+.Fa vc_set
+valid flags are:
+.Pp
+.Bl -tag -width DKV_ABR_CAP -compact -offset 2n
+.It Dv DKV_ABR_CAP
+Flag to set application-based recovery.
+A device can successfully support ABR only if it is capable.
+.It Dv DKV_DMR_CAP
+Flag to set directed read.
+.El
+.It Dv DKIODMR
+.Pp
+.Ft int
+.Fo ioctl
+.Fa int ,
+.\" This could be .Fa as well -- but mandoc doesn't seem to allow both
+.Dv DKIODMR ,
+.Fa "vol_directed_rd *"
+.Fc
+.Pp
+This ioctl allows highly available applications to perform round-robin reads
+from the underlying devices of a replicated device.
+.Pp
+.Bl -tag -width vdr_bytesread -offset 2n -compact
+.It Fa vdr_offset
+Offset at which the read should occur.
+.It Fa vdr_nbytes
+Number of bytes to be read
+.It Fa vdr_bytesread
+Number of bytes successfully read by the kernel.
+.It Fa vdr_data
+Pointer to a user allocated buffer to return the data read
+.It Fa vdr_side
+Side to be read.
+Initialized to
+.Dv DKV_SIDE_INIT
+.It Fa vdr_side_name
+The volume name that has been read.
+.El
+.Pp
+Valid
+.Fa vdr_flags
+are:
+.Pp
+.Bl -tag -width DKV_DMR_NEXT_SIDE -offset 2n -compact
+.It Dv DKV_DMR_NEXT_SIDE
+Set by user
+.It Dv DKV_DMR_DONE
+Return value
+.It Dv DKV_DMR_ERROR
+Return value
+.It Dv DKV_DMR_SUCCESS
+Return value
+.It Dv DKV_DMR_SHORT
+Return value
+.El
+.Pp
+The calling sequence is as follows: The caller sets the
+.Fa vdr_flags
+to
+.Dv DK_DMR_NEXT_SIDE
+and
+.Fa vdr_side
+to
+.Dv DKV_SIDE_INIT
+at the start.
+Subsequent calls should be made without any changes to these values.
+If they are changed the results of the ioctl are indeterminate.
+.Pp
+When
+.Dv DKV_SIDE_INIT
+is set, the call results in the kernel reading from the first side.
+The kernel updates
+.Fa vdr_side
+to indicate the side that was read, and
+.Fa vdr_side_name
+to contain the name of that side.
+.Fa vdr_data
+contains the data that was read.
+Therefore to perform a round-robin read all of
+the valid sides, there is no need for the caller to change the contents of
+.Fa vdr_side .
+.Pp
+Subsequent
+.Xr ioctl 2
+calls result in reads from the next valid side until all valid
+sides have been read.
+On success, the kernel sets
+.Dv DKV_DMR_SUCCESS .
+The following table shows the values of
+.Fa vdr_flags
+that are returned when an error occurs:
+.Bl -column DKV_DMR_SHORT DKV_SIDE_INIT "Bytes requested cannot" -offset 2n
+.It Fa vda_flags Ta Fa vdr_side Ta Notes
+.It Dv DKV_DMR_ERROR Ta Dv DKV_SIDE_INIT Ta \&No valid side to read
+.It Dv DKV_DMR_DONE Ta Not Init side Ta All valid sides read
+.It Dv DKV_DMR_SHORT Ta Any value Ta Bytes requested cannot be read Fa vdr_bytesread No set to bytes actually read
+.El
+Typical code fragment:
+.Bd -literal -offset 2n
+enable->vc_set |= DKV_ABR_SET;
+retval = ioctl(filedes, DKIOSETVOLCAP, enable);
+if (retval != EINVAL || retval != ENOTSUP) {
+ if (info->vc_set & DKV_DMR_SET) {
+ dr->vdr_flags |= DKV_DMR_NEXT_SIDE;
+ dr->vdr_side = DKV_SIDE_INIT;
+ dr->vdr_nbytes = 1024;
+ dr->vdr_offset = 0xff00;
+ do {
+ rval = ioctl(fildes, DKIODMR, dr);
+ if (rval != EINVAL) {
+ /* Process data */
+ }
+ } while (rval != EINVAL || dr->vdr_flags &
+ (DKV_DMR_DONE | DKV_DMR_ERROR | DKV_DMR_SHORT)
+ }
+}
+.Ed
+.El
+.Ss "RETURN VALUES"
+Upon successful completion, the value returned is
+.Sy 0 .
+Otherwise,
+.Sy -1
+is returned and
+.Va errno
+is set to indicate the error.
+.Ss "x86 Only"
+The following
+.Xr ioctl 2
+requests set and/or retrieve the current disk
+controller, partitions, or geometry information on the x86 architecture.
+.Bl -tag -width 1n
+.It Dv DKIOCG_PHYGEOM
+.Pp
+The argument is a pointer to a
+.Vt dk_geom
+structure (described below).
+This
+.Xr ioctl 2
+gets the driver's notion of the physical geometry of the disk drive.
+It is functionally identical to the
+.Dv DKIOCGGEOM
+.Xr ioctl 2 .
+.It Dv DKIOCG_VIRTGEOM
+.Pp
+The argument is a pointer to a
+.Vt dk_geom
+structure (described below).
+This
+.Xr ioctl 2
+gets the controller's (and hence the driver's) notion of the
+virtual geometry of the disk drive.
+Virtual geometry is a view of the disk
+geometry maintained by the firmware in a host bus adapter or disk controller.
+If the disk is larger than 8 Gbytes, this ioctl fails because a CHS-based
+geometry is not relevant or useful for this drive.
+.Bd -literal -offset 2n
+/*
+ * Definition of a disk's geometry
+ */
+struct dk_geom {
+ unsigned shor dkg_ncyl; /* # of data cylinders */
+ unsigned shor dkg_acyl; /* # of alternate cylinders */
+ unsigned short dkg_bcyl; /* cyl offset (for fixed head */
+ /* area) */
+ unsigned short dkg_nhead; /* # of heads */
+ unsigned short dkg_obs1; /* obsolete */
+ unsigned short dkg_nsect; /* # of sectors per track */
+ unsigned short dkg_intrlv; /* interleave factor */
+ unsigned short dkg_obs2; /* obsolete */
+ unsigned short dkg_obs3; /* obsolete */
+ unsigned short dkg_apc; /* alternates per cylinder */
+ /* (SCSI only) */
+ unsigned short dkg_rpm; /* revolutions per min */
+ unsigned short dkg_pcyl; /* # of physical cylinders */
+ unsigned short dkg_write_reinstruct; /* # sectors to skip, */
+ /* writes */
+ unsigned short dkg_read_reinstruct; /* # sectors to skip ,*/
+ /* reads */
+ unsigned short dkg_extra[7]; /* for compatible expansion */
+};
+.Ed
+.It Dv DKIOCADDBAD
+.Pp
+This
+.Xr ioctl 2
+forces the driver to re-examine the alternates slice and
+rebuild the internal bad block map accordingly.
+It should be used whenever the
+alternates slice is changed by any method other than the
+.Xr addbadsec 8
+or
+.Xr format 8
+utilities.
+.Dv DKIOCADDBAD
+can only be used for software
+remapping on
+.Sy IDE
+drives;
+.Sy SCSI
+drives use hardware remapping of alternate sectors.
+.It Dv DKIOCPARTINFO
+.Pp
+The argument is a pointer to a
+.Vt part_info
+structure (described below).
+This
+.Xr ioctl 2
+gets the driver's notion of the size and extent of the
+partition or slice indicated by the file descriptor argument.
+.Bd -literal -offset 2n
+/*
+ * Used by applications to get partition or slice information
+ */
+struct part_info {
+ daddr_t p_start;
+ int p_length;
+};
+.Ed
+.It Dv DKIOCEXTPARTINFO
+.Pp
+The argument is a pointer to an
+.Vt extpart_info
+structure (described below).
+This ioctl gets the driver's notion of the size and extent of the partition or
+slice indicated by the file descriptor argument.
+On disks larger than 1TB, this ioctl must be used instead of
+.Dv DKIOCPARTINFO .
+.Bd -literal -offset 2n
+/*
+ * Used by applications to get partition or slice information
+ */
+struct extpart_info {
+ diskkaddr_t p_start;
+ diskaddr_t p_length;
+};
+.Ed
+.It Dv DKIOCSETEXTPART
+.Pp
+This ioctl is used to update the in-memory copy of the logical drive
+information maintained by the driver.
+The ioctl takes no arguments.
+It causes a re-read of the partition information and recreation of minor nodes
+if required.
+Prior to updating the data structures, the ioctl ensures that the partitions do
+not overlap.
+Device nodes are created only for valid partition entries.
+If there is any change in the partition offset, size or ID from the previous
+read, the partition is deemed to have been changed and hence the device nodes
+are recreated.
+Any modification to any of the logical partitions results in the
+recreation of all logical device nodes.
+.El
+.Sh SEE ALSO
+.Xr ioctl 2 ,
+.Xr cmdk 4D ,
+.Xr sd 4D ,
+.Xr cdio 4I ,
+.Xr fdio 4I ,
+.Xr hdio 4I ,
+.Xr addbadsec 8 ,
+.Xr fdisk 8 ,
+.Xr format 8
+.Sh NOTES
+Blocksize information provided in
+.Dv DKIOCGMEDIAINFO
+is the size (in bytes) of the device's basic unit of operation and can differ
+from the blocksize that the Solaris operating environment exports to the user.
+Capacity information provided in the
+.Dv DKIOCGMEDIAINFO
+are for reference only and you are advised to use the values returned by
+.Dv DKIOCGGEOM
+or other appropriate
+.Xr ioctl 2
+for accessing data using the standard interfaces.
+.Pp
+For x86 only: If the
+.Dv DKIOCSMBOOT
+command is used to modify the Solaris partitions, the VTOC information should
+also be set appropriately to reflect the changes to partition.
+Failure to do so leads to unexpected results when the
+device is closed and reopened fresh at a later time.
+This is because a default VTOC is assumed by driver when a Solaris partition
+is changed.
+The default VTOC persists until the ioctl
+.Dv DKIOCSVTOC
+is called to modify VTOC or the device is closed and reopened.
+At that point, the old valid VTOC is read from
+the disk if it is still available.
diff --git a/usr/src/man/man4i/dsp.4i b/usr/src/man/man4i/dsp.4i
new file mode 100644
index 0000000000..0690b359d8
--- /dev/null
+++ b/usr/src/man/man4i/dsp.4i
@@ -0,0 +1,602 @@
+.\" Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
+.\" Copyright 2018, Joyent, Inc.
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd July 9, 2018
+.Dt DSP 4I
+.Os
+.Sh NAME
+.Nm dsp
+.Nd generic audio device interface
+.Sh SYNOPSIS
+.In sys/soundcard.h
+.Sh DESCRIPTION
+To record audio input, applications
+.Xr open 2
+the appropriate device and
+read data from it using the
+.Xr read 2
+system call.
+Similarly, sound data is queued to the audio output port by using the
+.Xr write 2
+system call.
+Device configuration is performed using the
+.Xr ioctl 2
+interface.
+.Pp
+Because some systems can contain more than one audio device, application
+writers are encouraged to open the
+.Pa /dev/mixer
+device and determine the
+physical devices present on the system using the
+.Dv SNDCTL_SYSINFO
+and
+.Dv SNDCTL_AUDIOINFO
+ioctls.
+See
+.Xr mixer 4I .
+The user should be provided
+wth the ability to select a different audio device, or alternatively, an
+environment variable such as
+.Ev AUDIODSP
+can be used.
+In the absence of any
+specific configuration from the user, the generic device file,
+.Pa /dev/dsp ,
+can be used.
+This normally points to a reasonably appropriate default audio
+device for the system.
+.Ss "Opening the Audio Device"
+The audio device is not treated as an exclusive resource.
+.Pp
+Each
+.Xr open 2
+completes as long as there are channels available to be allocated.
+If no channels are available to be allocated, the call returns
+.Sy -1
+with the
+.Va errno
+set to
+.Er EBUSY .
+.Pp
+Audio applications should explicitly set the encoding characteristics to match
+the audio data requirements after opening the device, and not depend on any
+default configuration.
+.Ss "Recording Audio Data"
+The
+.Xr read 2
+system call copies data from the system's buffers to the application.
+Ordinarily,
+.Xr read 2
+blocks until the user buffer is filled.
+The
+.Xr poll 2
+system call can be used to determine the presence of data
+that can be read without blocking.
+The device can alternatively be set to a
+non-blocking mode, in which case
+.Xr read 2
+completes immediately, but can return fewer bytes than requested.
+Refer to the
+.Xr read 2
+manual page for a complete description of this behavior.
+.Pp
+When the audio device is opened with read access, the device driver allocates
+resources for recording.
+Since this consumes system resources, processes that
+do not record audio data should open the device write-only
+.Pq Dv O_WRONLY .
+.Pp
+The recording process can be stopped by using the
+.Dv SNDCTL_DSP_HALT_INPUT
+ioctl, which also discards all pending record data in underlying device FIFOs.
+.Pp
+Before changing record parameters, the input should be stopped using the
+.Dv SNDCTL_DSP_HALT_INPUT
+ioctl, which also flushes the any underlying device input FIFOs.
+(This is not necessary if the process never started recording by calling
+.Xr read 2 .
+Otherwise, subsequent reads can return samples in the
+old format followed by samples in the new format.
+This is particularly
+important when new parameters result in a changed sample size.
+.Pp
+Input data can accumulate in device buffers very quickly.
+At a minimum, it accumulates at 8000 bytes per second for 8-bit, 8 KHz, mono,
+.Sy \(*m-Law
+data.
+If the device is configured for more channels, higher sample resolution, or
+higher sample rates, it accumulates even faster.
+If the application that consumes the data cannot keep up with this data rate,
+the underlying FIFOs can become full.
+When this occurs, any new incoming data is lost until the
+application makes room available by consuming data.
+Additionally, a record overrun is noted, which can be retrieved using the
+.Dv SNDCTL_DSP_GETERROR
+ioctl.
+.Pp
+Record volume for a stream can be adjusted by issuing the
+.Dv SNDCTL_DSP_SETRECVOL
+ioctl.
+The volume can also be retrieved using the
+.Dv SNDCTL_DSP_GETRECVOL .
+.Ss "Playing Audio Data"
+The
+.Xr write 1
+system call copies data from an application's buffer to the device output FIFO.
+Ordinarily,
+.Xr write 2
+blocks until the entire user
+buffer is transferred.
+The device can alternatively be set to a non-blocking
+mode, in which case
+.Xr write 2
+completes immediately, but might have
+transferred fewer bytes than requested.
+See
+.Xr write 2 .
+.Pp
+Although
+.Xr write 2
+returns when the data is successfully queued, the actual
+completion of audio output might take considerably longer.
+The
+.Dv SNDCTL_DSP_SYNC
+ioctl can be issued to allow an application to block
+until all of the queued output data has been played.
+.Pp
+The final
+.Xr close 2
+of the file descriptor waits until all of the audio output has drained.
+If a signal interrupts the
+.Xr close 2 ,
+or if the process
+exits without closing the device, any remaining data queued for audio output is
+flushed and the device is closed immediately.
+.Pp
+The output of playback data can be halted entirely, by calling the
+.Dv SNDCTL_DSP_HALT_OUTPUT
+ioctl.
+This also discards any data that is queued for playback in device FIFOs.
+.Pp
+Before changing playback parameters, the output should be drained using the
+.Dv SNDCTL_DSP_SYNC
+ioctl, and then stopped using the
+.Dv SNDCTL_DSP_HALT_OUTPUT
+ioctl, which also flushes the any underlying device output FIFOs.
+This is not necessary if the process never started playback, such as by calling
+.Xr write 2 .
+This is particularly important
+when new parameters result in a changed sample size.
+.Pp
+Output data is played from the playback buffers at a default rate of at least
+8000 bytes per second for \(*m-Law, A-Law or 8-bit PCM data (faster for 16-bit
+linear data or higher sampling rates).
+If the output FIFO becomes empty, the
+framework plays silence, resulting in audible stall or click in the output,
+until more data is supplied by the application.
+The condition is also noted as
+a play underrun, which can be determined using the
+.Dv SNDCTL_DSP_GETERROR
+ioctl.
+.Pp
+Playback volume for a stream can be adjusted by issuing the
+.Dv SNDCTL_DSP_SETPLAYVOL
+ioctl.
+The volume can also be retrieved using the
+.Dv SNDCTL_DSP_GETPLAYVOL .
+.Ss "Asynchronous I/O"
+The
+.Dv O_NONBLOCK
+flag can be set using the
+.Dv F_SETFL
+.Xr fcntl 2
+to enable non-blocking
+.Xr read 2
+and
+.Xr write 2
+requests.
+This is normally
+sufficient for applications to maintain an audio stream in the background.
+.Pp
+It is also possible to determine the amount of data that can be transferred for
+playback or recording without blocking using the
+.Dv SNDCTL_DSP_GETOSPACE
+or
+.Dv SNDCTL_DSP_GETISPACE
+ioctls, respectively.
+.Ss "Mixer Pseudo-Device"
+The
+.Pa /dev/mixer
+provides access to global hardware settings such as master volume settings, etc.
+It is also the interface used for determining the
+hardware configuration on the system.
+.Pp
+Applications should
+.Xr open 2
+.Pa /dev/mixer ,
+and use the
+.Dv SNDCTL_SYSINFO
+and
+.Dv SNDCTL_AUDIOINFO
+ioctls to determine the device node names of audio devices on the system.
+See
+.Xr mixer 4I
+for additional details.
+.Sh IOCTLS
+.Ss "Information IOCTLs"
+The following ioctls are supported on the audio device, as well as the mixer
+device.
+See
+.Xr mixer 4I
+for details.
+.Bd -literal -offset 2n
+.Dv OSS_GETVERSION
+.Dv SNDCTL_SYSINFO
+.Dv SNDCTL_AUDIOINFO
+.Dv SNDCTL_MIXERINFO
+.Dv SNDCTL_CARDINFO
+.Ed
+.Ss "Audio IOCTLs"
+The
+.Nm
+device supports the following ioctl commands:
+.Pp
+.\" A compact list is used so that items with multiple tags don't have
+.\" vertical whitespace. However that means explicit .Pp statements must
+.\" be added.
+.Bl -tag -width "SNDCTL_DSP_CURRENT_IPTR" -compact
+.It Dv SNDCTL_DSP_SYNC
+The argument is ignored.
+This command suspends the calling process until the
+output FIFOs are empty and all queued samples have been played, or until a
+signal is delivered to the calling process.
+An implicit
+.Dv SNDCTL_DSP_SYNC
+is performed on the final
+.Xr close 2
+of the
+.Nm
+device.
+.Pp
+This ioctl should not be used unnecessarily, as if it is used in the middle of
+playback it causes a small click or pause, as the FIFOs are drained.
+The correct use of this ioctl is just before changing sample formats.
+.Pp
+.It Dv SNDCTL_DSP_HALT
+.It Dv SNDCTL_DSP_HALT_INPUT
+.It Dv SNDCTL_DSP_HALT_OUTPUT
+The argument is ignored.
+All input or output (or both) associated with the file
+is halted, and any pending data is discarded.
+.Pp
+.It Dv SNDCTL_DSP_SPEED
+The argument is a pointer to an integer, indicating the sample rate (in Hz) to
+be used.
+The rate applies to both input and output for the file descriptor.
+On return the actual rate, which can differ from that requested, is stored in
+the integer pointed to by the argument.
+To query the configured speed without
+changing it the value 0 can be used by the application.
+.Pp
+.It Dv SNDCTL_DSP_GETFMTS
+The argument is a pointer to an integer, which receives a bit mask of encodings
+supported by the device.
+Possible values are:
+.Pp
+.Bl -tag -width "AFMT_S24_PACKED" -compact -offset 2n
+.It Dv AFMT_MU_LAW
+8-bit unsigned \(*m-Law
+.It Dv AFMT_A_LAW
+8-bit unsigned a-Law
+.It Dv AFMT_U8
+8-bit unsigned linear PCM
+.It Dv AFMT_S16_LE
+16-bit signed little-endian linear PCM
+.It Dv AFMT_S16_BE
+16-bit signed big-endian linear PCM
+.It Dv AFMT_S16_NE
+16-bit signed native-endian linear PCM
+.It Dv AFMT_U16_LE
+16-bit unsigned little-endian linear PCM
+.It Dv AFMT_U16_BE
+16-bit unsigned big-endian linear PCM
+.It Dv AFMT_U16_NE
+16-bit unsigned native-endian linear PCM
+.It Dv AFMT_S24_LE
+24-bit signed little-endian linear PCM, 32-bit aligned
+.It Dv AFMT_S24_BE
+24-bit signed big-endian linear PCM, 32-bit aligned
+.It Dv AFMT_S24_NE
+24-bit signed native-endian linear PCM, 32-bit aligned
+.It Dv AFMT_S32_LE
+32-bit signed little-endian linear PCM
+.It Dv AFMT_S32_BE
+32-bit signed big-endian linear PCM
+.It Dv AFMT_S32_NE
+32-bit signed native-endian linear PCM
+.It Dv AFMT_S24_PACKED
+24-bit signed little-endian packed linear PCM
+.El
+.Pp
+Not all devices support all of these encodings.
+This implementation uses
+.Dv AFMT_S24_LE
+or
+.Dv AFMT_S24_BE ,
+whichever is native, internally.
+.Pp
+.It Dv SNDCTL_DSP_SETFMT
+The argument is a pointer to an integer, which indicates the encoding to be
+used.
+The same values as for
+.Dv SNDCTL_DSP_GETFMT
+can be used, but the caller can only specify a single option.
+The encoding is used for both input
+and output performed on the file descriptor.
+.Pp
+.It Dv SNDCTL_DSP_CHANNELS
+The argument is a pointer to an integer, indicating the number of channels to
+be used (1 for mono, 2 for stereo, etc.)
+The value applies to both input and output for the file descriptor.
+On return the actual channel configuration (which can differ from that
+requested) is stored in the integer pointed to by the argument.
+To query the configured channels without changing it the value 0
+can be used by the application.
+.Pp
+.It Dv SNDDCTL_DSP_GETCAPS
+The argument is a pointer to an integer bit mask, which indicates the
+capabilities of the device.
+The bits returned can include:
+.Pp
+.Bl -tag -width "PCM_CAP_DUPLEX" -compact -offset 2n
+.It Dv PCM_CAP_OUTPUT
+Device supports playback
+.It Dv PCM_CAP_INPUT
+Device supports recording
+.It Dv PCM_CAP_DUPLEX
+Device supports simultaneous playback and recording
+.El
+.Pp
+.It Dv SNDCTL_DSP_GETPLAYVOL
+.It Dv SNDCTL_DSP_GETRECVOL
+The argument is a pointer to an integer to receive the volume level for either
+playback or record.
+The value is encoded as a stereo value with the values for
+two channels in the least significant two bytes.
+The value for each channel thus has a range of 0-100.
+In this implementation, only the low order byte is
+used, as the value is treated as a monophonic value, but a stereo value (with
+both channel levels being identical) is returned for compatibility.
+.Pp
+.It Dv SNDCTL_DSP_SETPLAYVOL
+.It Dv SNDCTL_DSP_SETRECVOL
+The argument is a pointer to an integer indicating volume level for either
+playback or record.
+The value is encoded as a stereo value with the values for
+two channels in the least significant two bytes.
+The value for each channel has a range of 0-100.
+Note that in this implementation, only the low order byte is
+used, as the value is treated as a monophonic value.
+Portable applications should assign the same value to both bytes.
+.Pp
+.It Dv SNDCTL_DSP_GETISPACE
+.It Dv SNDCTL_DSP_GETOSPACE
+The argument is a pointer to a
+.Vt struct audio_buf_info ,
+which has the following structure:
+.Bd -literal -offset 2n
+typedef struct audio_buf_info {
+ int fragments; /* # of available fragments */
+ int fragstotal;
+ /* Total # of fragments allocated */
+ int fragsize;
+ /* Size of a fragment in bytes */
+ int bytes;
+ /* Available space in bytes */
+ /*
+ * Note! 'bytes' could be more than
+ * fragments*fragsize
+ */
+} audio_buf_info;
+.Ed
+.Pp
+The fields
+.Fa fragments ,
+.Fa fragstotal ,
+and
+.Fa fragsize
+are intended for use with compatible applications (and in the future with
+.Xr mmap 2 )
+only, and need not be used by typical applications.
+On successful return the bytes member
+contains the number of bytes that can be transferred without blocking.
+.Pp
+.It Dv SNDCTL_DSP_CURRENT_IPTR
+.It Dv SNDCTL_DSP_CURRENT_OPTR
+The argument is a pointer to an
+.Vt oss_count_t ,
+which has the following definition:
+.Bd -literal -offset 2n
+typedef struct {
+ long long samples;
+ /* Total # of samples */
+ int fifo_samples;
+ /* Samples in device FIFO */
+ int filler[32]; /* For future use */
+} oss_count_t;
+.Ed
+.Pp
+The
+.Fa samples
+field contains the total number of samples transferred by the
+device so far.
+The
+.Fa fifo_samples
+is the depth of any hardware FIFO.
+This structure can be useful for accurate stream positioning and latency
+calculations.
+.Pp
+.It Dv SNDCTL_DSP_GETIPTR
+.It Dv SNDCTL_DSP_GETOPTR
+The argument is a pointer to a
+.Vt struct count_info ,
+which has the following definition:
+.Bd -literal -offset 2n
+typedef struct count_info {
+ unsigned int bytes;
+ /* Total # of bytes processed */
+ int blocks;
+ /*
+ * # of fragment transitions since
+ * last time
+ */
+ int ptr; /* Current DMA pointer value */
+} count_info;
+.Ed
+.Pp
+These ioctls are primarily supplied for compatibility, and should not be used
+by most applications.
+.Pp
+.It Dv SNDCTL_DSP_GETODELAY
+The argument is a pointer to an integer.
+On return, the integer contains the
+number of bytes still to be played before the next byte written are played.
+This can be used for accurate determination of device latency.
+The result can differ from actual value by up the depth of the internal device
+FIFO, which is typically 64 bytes.
+.Pp
+.It Dv SNDCTL_DSP_GETERROR
+The argument is a pointer to a
+.Vt struct audio_errinfo ,
+defined as follows:
+.Bd -literal -offset 2n
+typedef struct audio_errinfo {
+ int play_underruns;
+ int rec_overruns;
+ unsigned int play_ptradjust;
+ unsigned int rec_ptradjust;
+ int play_errorcount;
+ int rec_errorcount;
+ int play_lasterror;
+ int rec_lasterror;
+ int play_errorparm;
+ int rec_errorparm;
+ int filler[16];
+} audio_errinfo;
+.Ed
+.Pp
+For this implementation, only the
+.Fa play_underruns
+and
+.Fa rec_overruns
+values are significant.
+No other fields are used in this implementation.
+.Pp
+These fields are reset to zero each time their value is retrieved using this
+ioctl.
+.El
+.Ss "Compatibility IOCTLS"
+These ioctls are supplied exclusively for compatibility with existing
+applications.
+Their use is not recommended, and they are not documented here.
+Many of these are implemented as simple no-ops.
+.Pp
+.Bl -tag -width "Dv" -offset 2n -compact
+.It Dv SNDCTL_DSP_POST
+.It Dv SNDCTL_DSP_STEREO
+.It Dv SNDCTL_DSP_SETDUPLEX
+.It Dv SNDCTL_DSP_LOW_WATER
+.It Dv SNDCTL_DSP_PROFILE
+.It Dv SNDCTL_DSP_GETBLKSIZE
+.It Dv SNDCTL_DSP_SUBDIVIDE
+.It Dv SNDCTL_DSP_SETFRAGMENT
+.It Dv SNDCTL_DSP_COOKEDMODE
+.It Dv SNDCTL_DSP_READCTL
+.It Dv SNDCTL_DSP_WRITECTL
+.It Dv SNDCTL_DSP_SILENCE
+.It Dv SNDCTL_DSP_SKIP
+.It Dv SNDCTL_DSP_POST
+.It Dv SNDCTL_DSP_GET_RECSRC
+.It Dv SNDCTL_DSP_SET_RECSRC
+.It Dv SNDCTL_DSP_SET_RECSRC_NAMES
+.It Dv SNDCTL_DSP_GET_PLAYTGT
+.It Dv SNDCTL_DSP_SET_PLAYTGT
+.It Dv SNDCTL_DSP_SET_PLAYTGT_NAMES
+.It Dv SNDCTL_DSP_GETTRIGGER
+.It Dv SNDCTL_DSP_SETTRIGGER
+.It Dv SNDCTL_AUDIOINFO_EX
+.It Dv SNDCTL_ENGINEINFO
+.El
+.Sh FILES
+The physical audio device names are system dependent and are rarely used by
+programmers.
+Programmers should use the generic device names listed below.
+.Bl -tag -width "/usr/share/audio/samples"
+.It Pa /dev/dsp
+Symbolic link to the system's primary audio device
+.It Pa /dev/mixer
+Symbolic link to the pseudo mixer device for the system
+.It Pa /dev/sndstat
+Symbolic link to the pseudo mixer device for the system
+.It Pa /usr/share/audio/samples
+Audio files
+.El
+.Sh ERRORS
+An
+.Xr open 2
+call fails if:
+.Bl -tag -width "EINVAL"
+.It Er EBUSY
+The requested play or record access is busy and either the
+.Dv O_NDELAY
+or
+.Dv O_NONBLOCK
+flag was set in the
+.Xr open 2
+request.
+.It Er EINTR
+The requested play or record access is busy and a signal interrupted the
+.Xr open 2
+request.
+.It Er EINVAL
+The device cannot support the requested play or record access.
+.El
+.Pp
+An
+.Xr ioctl 2
+call fails if:
+.Bl -tag -width "EINVAL"
+.It Er EINVAL
+The parameter changes requested in the ioctl are invalid or are not supported
+by the device.
+.El
+.Sh ARCHITECTURE
+SPARC
+X86
+.Sh INTERFACE STABILITY
+Uncommitted
+.Sh SEE ALSO
+.Xr close 2 ,
+.Xr fcntl 2 ,
+.Xr ioctl 2 ,
+.Xr mmap 2 ,
+.Xr open 2 ,
+.Xr poll 2 ,
+.Xr read 2 ,
+.Xr write 2 ,
+.Xr audio 4D ,
+.Xr mixer 4I ,
+.Xr attributes 7
diff --git a/usr/src/man/man4i/fbio.4i b/usr/src/man/man4i/fbio.4i
new file mode 100644
index 0000000000..e05c3ee787
--- /dev/null
+++ b/usr/src/man/man4i/fbio.4i
@@ -0,0 +1,160 @@
+.\" Copyright (c) 2003, Sun Microsystems, Inc.
+.\" Copyright (c) 2017, Joyent, Inc.
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the fields
+.\" enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd October 22, 2017
+.Dt FBIO 4I
+.Os
+.Sh NAME
+.Nm fbio
+.Nd frame buffer control operations
+.Sh DESCRIPTION
+The frame buffers provided with this release support the same general interface
+that is defined by
+.In sys/fbio.h .
+Each responds to an
+.Dv FBIOGTYPE
+.Xr ioctl 2
+request which returns information in a
+.Vt fbtype
+structure.
+.Pp
+Each device has an
+.\" FBTYPE isn't macro, enum, or type, just used to describe a number of
+.\" CPP-macros of the form #define FBTYPE_xxxx
+.Sy FBTYPE
+which is used by higher-level software to
+determine how to perform graphics functions.
+Each device is used by opening it, doing an
+.Dv FBIOGTYPE
+.Xr ioctl 2
+to see which frame buffer type is
+present, and thereby selecting the appropriate device-management routines.
+.Pp
+.Dv FBIOGINFO
+returns information specific to the GS accelerator.
+.Pp
+.Dv FBIOSVIDEO
+and
+.Dv FBIOGVIDEO
+are general-purpose
+.Xr ioctl 2
+requests for controlling possible video features of frame buffers.
+These
+.Xr ioctl 2
+requests either set or return the value of a flags integer.
+At this point, only the
+.Dv FBVIDEO_ON
+option is available, controlled by
+.Dv FBIOSVIDEO .
+.Dv FBIOGVIDEO
+returns the current video state.
+.Pp
+The
+.Dv FBIOSATTR
+and
+.Dv FBIOGATTR
+.Xr ioctl 2
+requests allow access to special features of newer frame buffers.
+They use the
+.Vt fbsattr
+and
+.Vt fbgattr
+structures.
+.Pp
+Some color frame buffers support the
+.Dv FBIOPUTCMAP
+and
+.Dv FBIOGETCMAP
+.Xr ioctl 2
+requests, which provide access to the colormap.
+They use the
+.Vt fbcmap
+structure.
+.Pp
+Also, some framebuffers with multiple colormaps will either encode the colormap
+identifier in the high-order bits of the
+.Dq index
+field in the
+.Vt fbcmap
+structure, or use the
+.Dv FBIOPUTCMAPI
+and
+.Dv FBIOGETCMAPI
+.Xr ioctl 2
+requests.
+.Pp
+.Dv FBIOVERTICAL
+is used to wait for the start of the next vertical retrace
+period.
+.Pp
+.Dv FBIOVRTOFFSET
+Returns the offset to a read-only
+.Dq Em vertical retrace page
+for those framebuffers that support it.
+This vertical retrace page may be mapped into user space with
+.Xr mmap 2 .
+The first word of the vertical
+retrace page (type
+.Vt "unsigned int" )
+is a counter that is incremented every time there is a vertical retrace.
+The user process can use this counter in a variety of ways.
+.Pp
+.Dv FBIOMONINFO
+returns a
+.Vt mon_info
+structure which contains information about
+the monitor attached to the framebuffer, if available.
+.Pp
+.Dv FBIOSCURSOR ,
+.Dv FBIOGCURSOR ,
+.Dv FBIOSCURPOS
+and
+.Dv FBIOGCURPOS
+are used to control the hardware cursor for those framebuffers that have this
+feature.
+.Dv FBIOGCURMAX
+returns the maximum sized cursor supported by the framebuffer.
+Attempts to create a cursor larger than this will fail.
+.Pp
+Finally
+.Dv FBIOSDEVINFO
+and
+.Dv FBIOGDEVINFO
+are used to transfer
+variable-length, device-specific information into and out of framebuffers.
+.Sh SEE ALSO
+.Xr ioctl 2 ,
+.Xr mmap 2 ,
+.Xr cgsix 4D
+.Sh BUGS
+The
+.Dv FBIOSATTR
+and
+.Dv FBIOGATTR
+.Xr ioctl 2
+requests are only
+supported by frame buffers which emulate older frame buffer types.
+If a frame buffer emulates another frame buffer,
+.Dv FBIOGTYPE
+returns the emulated type.
+To get the real type, use
+.Dv FBIOGATTR .
+.Pp
+The
+.Dv FBIOGCURPOS
+ioctl was incorrectly defined in previous operating
+systems, and older code running in binary compatibility mode may get incorrect
+results.
diff --git a/usr/src/man/man4i/fdio.4i b/usr/src/man/man4i/fdio.4i
new file mode 100644
index 0000000000..a3f01b1021
--- /dev/null
+++ b/usr/src/man/man4i/fdio.4i
@@ -0,0 +1,277 @@
+.\" Copyright (c) 2001, Sun Microsystems, Inc. All Rights Reserved
+.\" Copyright (c) 2017, Joyent, Inc.
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd October 22, 2017
+.Dt FDIO 4I
+.Os
+.Sh NAME
+.Nm fdio
+.Nd floppy disk control operations
+.Sh SYNOPSIS
+.In sys/fdio.h
+.Sh DESCRIPTION
+The Solaris floppy driver supports a set of
+.Xr ioctl 2
+requests for getting and setting the floppy drive characteristics.
+Basic to these
+.Xr ioctl 2
+requests are the definitions in
+.In sys/fdio.h .
+.Sh IOCTLS
+The following
+.Xr ioctl 2
+requests are available on the Solaris floppy driver.
+.Bl -tag -width FDDEFGEOCHAR
+.It Dv FDDEFGEOCHAR
+x86 based systems: This
+.Xr ioctl 2
+forces the floppy driver to restore
+the diskette and drive characteristics and geometry, and partition information
+to default values based on the device configuration.
+.It Dv FDGETCHANGE
+The argument is a pointer to an
+.Vt int .
+This
+.Xr ioctl 2
+returns the status of the diskette-changed signal from the floppy interface.
+The following defines are provided for cohesion.
+.El
+.Pp
+Note: For x86 based systems, use
+.Dv FDGC_DETECTED
+(which is available only on x86 based systems) instead of
+.Dv FDGC_HISTORY .
+.Bd -literal -offset 2n
+/*
+ * Used by FDGETCHANGE, returned state of the sense disk change bit.
+ */
+#define FDGC_HISTORY 0x01 /*
+ * disk has changed since insertion or
+ * last FDGETCHANGE call
+ */
+#define FDGC_CURRENT 0x02 /*
+ * if set, indicates drive has floppy,
+ * otherwise, drive is empty
+ */
+#define FDGC_CURWPROT 0x10 /* current state of write protect */
+#define FDGC_DETECTED 0x20 /* previous state of DISK CHANGE */
+.Ed
+.Bl -tag -width FDIOGCHAR
+.It Dv FDIOGCHAR
+The argument is a pointer to an
+.Vt fd_char
+structure (described below).
+This
+.Xr ioctl 2
+gets the characteristics of the floppy diskette from the floppy controller.
+.It Dv FDIOSCHAR
+The argument is a pointer to an
+.Vt fd_char
+structure (described below).
+This
+.Xr ioctl 2
+sets the characteristics of the floppy diskette for the floppy controller.
+Typical values in the
+.Vt fd_char
+structure for a high density diskette:
+.Bl -column fdc_stransfer_rate value "{ This field doesn't apply. }"
+.It Field Ta Value Ta
+.It fdc_medium Ta 0 Ta
+.It fdc_transfer_rate Ta 500 Ta
+.It fdc_ncyl Ta 80 Ta
+.It fdc_nhead Ta 2 Ta
+.It fdc_sec_size Ta 512 Ta
+.It fdc_secptrack Ta 18 Ta
+.It fdc_steps Ta -1 Ta { This field doesn't apply. }
+.El
+.El
+.Bd -literal -offset 2n
+/*
+ * Floppy characteristics
+ */
+struct fd_char {
+ uchar_t fdc_medium; /* equals 1 if floppy is medium density format */
+ int fdc_transfer_rate; /* transfer rate */
+ int fdc_ncyl; /* number of cylinders */
+ int fdc_nhead; /* number of heads */
+ int fdc_sec_size; /* sector size */
+ int fdc_secptrack; /* sectors per track */
+ int fdc_steps; /* no. of steps per data track */
+};
+.Ed
+.Bl -tag -width FDGETDRIVECHAR
+.It Dv FDGETDRIVECHAR
+The argument to this
+.Xr ioctl 2
+is a pointer to an
+.Vt fd_drive
+structure (described below).
+This
+.Xr ioctl 2
+gets the characteristics of the floppy drive from the floppy controller.
+.It Dv FDSETDRIVECHAR
+x86 based systems: The argument to this
+.Xr ioctl 2
+is a pointer to an
+.Vt fd_drive
+structure (described below).
+This
+.Xr ioctl 2
+sets the characteristics of the floppy drive for the floppy controller.
+Only
+.Fa fdd_steprate ,
+.Fa fdd_headsettle ,
+.Fa fdd_motoron ,
+and
+.Fa fdd_motoroff
+are actually used by the floppy disk driver.
+.El
+.Bd -literal -offset 2n
+/*
+ * Floppy Drive characteristics
+ */
+struct fd_drive {
+ int fdd_ejectable; /* does the drive support eject? */
+ int fdd_maxsearch; /* size of per-unit search table */
+ int fdd_writeprecomp; /* cyl to start write precompensation */
+ int fdd_writereduce; /* cyl to start recucing write current */
+ int fdd_stepwidth; /* width of step pulse in 1 us units */
+ int fdd_steprate; /* step rate in 100 us units */
+ int fdd_headsettle; /* delay, in 100 us units */
+ int fdd_headload; /* delay, in 100 us units */
+ int fdd_headunload; /* delay, in 100 us units */
+ int fdd_motoron; /* delay, in 100 ms units */
+ int fdd_motoroff; /* delay, in 100 ms units */
+ int fdd_precomplevel; /* bit shift, in nano-secs */
+ int fdd_pins; /* defines meaning of pin 1, 2, 4 and 34 */
+ int fdd_flags; /* TRUE READY, Starting Sector #, & Motor On */
+};
+.Ed
+.Bl -tag -width FDGETSEARCH
+.It Dv FDGETSEARCH
+Not available.
+.It Dv FDSETSEARCH
+Not available.
+.It Dv FDEJECT
+SPARC: This
+.Xr ioctl 2
+requests the floppy drive to eject the diskette.
+.It Dv FDIOCMD
+The argument is a pointer to an
+.Vt fd_cmd
+structure (described below).
+This
+.Xr ioctl 2
+allows access to the floppy diskette using the floppy device driver.
+Only the
+.Dv FDCMD_WRITE ,
+.Dv FDCMD_READ ,
+and
+.Dv FDCMD_FORMAT_TRACK
+commands are currently available.
+.El
+.Bd -literal -offset 2n
+struct fd_cmd {
+ ushort_t fdc_cmd; /* command to be executed */
+ int fdc_flags; /* execution flags (x86 only) */
+ daddr_t fdc_blkno; /* disk address for command */
+ int fdc_secnt; /* sector count for command */
+ caddr_t fdc_bufaddr; /* user's buffer address */
+ uint_t fdc_buflen; /* size of user's buffer */
+};
+.Ed
+.Pp
+Please note that the
+.Fa fdc_buflen
+field is currently unused.
+The
+.Fa fdc_secnt
+field is used to calculate the transfer size, and the buffer is
+assumed to be large enough to accommodate the transfer.
+.Bd -literal -offset 2n
+/*
+ * Floppy commands
+ */
+#define FDCMD_WRITE 1
+#define FDCMD_READ 2
+#define FDCMD_SEEK 3
+#define FDCMD_REZERO 4
+#define FDCMD_FORMAT_UNIT 5
+#define FDCMD_FORMAT_TRACK 6
+.Ed
+.Bl -tag -width FDRAW
+.It Dv FDRAW
+The argument is a pointer to an
+.Vt fd_raw
+structure (described below).
+This
+.Xr ioctl 2
+allows direct control of the floppy drive using the floppy controller.
+Refer to the appropriate floppy-controller data sheet for full
+details on required command bytes and returned result bytes.
+The following commands are supported.
+.El
+.Bd -literal -offset 2n
+/*
+ * Floppy raw commands
+ */
+#define FDRAW_SPECIFY 0x03
+#define FDRAW_READID 0x0a (x86 only)
+#define FDRAW_SENSE_DRV 0x04
+#define FDRAW_REZERO 0x07
+#define FDRAW_SEEK 0x0f
+#define FDRAW_SENSE_INT 0x08 (x86 only)
+#define FDRAW_FORMAT 0x0d
+#define FDRAW_READTRACK 0x02
+#define FDRAW_WRCMD 0x05
+#define FDRAW_RDCMD 0x06
+#define FDRAW_WRITEDEL 0x09
+#define FDRAW_READDEL 0x0c
+.Ed
+.Pp
+Please note that when using
+.Dv FDRAW_SEEK
+or
+.Dv FDRAW_REZERO ,
+the driver automatically issues a
+.Dv FDRAW_SENSE_INT
+command to clear the interrupt from the
+.Dv FDRAW_SEEK
+or the
+.Dv FDRAW_REZERO .
+The result bytes returned by these commands are the results from the
+.Dv DRAW_SENSE_INT
+command.
+Please see the floppy-controller data sheet for
+more details on
+.Dv FDRAW_SENSE_INT .
+.Bd -literal -offset 2n
+/*
+ * Used by FDRAW
+ */
+struct fd_raw {
+ char fdr_cmd[10]; /* user-supplied command bytes */
+ short fdr_cnum; /* number of command bytes */
+ char fdr_result[10]; /* controller-supplied result bytes */
+ ushort_t fdr_nbytes; /* number to transfer if read/write command */
+ char *fdr_addr; /* where to transfer if read/write command */
+};
+.Ed
+.Sh SEE ALSO
+.Xr ioctl 2 ,
+.Xr fd 4D ,
+.Xr dkio 4I ,
+.Xr hdio 4I
diff --git a/usr/src/man/man4i/hdio.4i b/usr/src/man/man4i/hdio.4i
new file mode 100644
index 0000000000..1f80a9a055
--- /dev/null
+++ b/usr/src/man/man4i/hdio.4i
@@ -0,0 +1,112 @@
+.\" Copyright (c) 2002, Sun Microsystems, Inc.
+.\" Copyright (c) 2017, Joyent, Inc.
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd October 23, 2017
+.Dt HDIO 4I
+.Os
+.Sh NAME
+.Nm hdio
+.Nd SMD and IPI disk control operations
+.Sh SYNOPSIS
+.In sys/hdio.h
+.Sh DESCRIPTION
+Note \(em the SMC and IPI drivers have been discontinued.
+.Xr dkio 4I
+is now the preferred method for retrieving disk information.
+.Pp
+The SMD and IPI disk drivers supplied with this release support a set of
+.Xr ioctl 2
+requests for diagnostics and bad sector information.
+Basic to these
+.Xr ioctl 2
+requests are the definitions in
+.In sys/hdio.h .
+.Sh IOCTLS
+.Bl -tag -width HDKIOCGTYPE
+.It Dv HDKIOCGTYPE
+The argument is a pointer to a
+.Vt hdk_type
+structure (described below).
+This
+.Xr ioctl 2
+gets specific information from the hard disk.
+.It Dv HDKIOCSTYPE
+The argument is a pointer to a
+.Vt hdk_type
+structure (described below).
+This
+.Xr ioctl 2
+sets specific information about the hard disk.
+.El
+.Bd -literal -offset 2n
+/*
+ * Used for drive info
+ */
+struct hdk_type {
+ ushort_t hdkt_hsect; /* hard sector count (read only) */
+ ushort_t hdkt_promrev; /* prom revision (read only) */
+ uchar_t hdkt_drtype; /* drive type (ctlr specific) */
+ uchar_t hdkt_drstat; /* drive status (ctlr specific, ro) */
+};
+.Ed
+.Bl -tag -width HDKIOCGBAD
+.It Dv HDKIOCGBAD
+The argument is a pointer to a
+.Vt hdk_badmap
+structure (described below).
+This
+.Xr ioctl 2
+is used to get the bad sector map from the disk.
+.It Dv HDKIOCSBAD
+The argument is a pointer to a
+.Vt hdk_badmap
+structure (described below).
+This
+.Xr ioctl 2
+is used to set the bad sector map on the disk.
+.El
+.Bd -literal -offset 2n
+/*
+ * Used for bad sector map
+ */
+struct hdk_badmap {
+ caddr_t hdkb_bufaddr; /* address of user's map buffer */
+};
+.Ed
+.Bl -tag -width HDKIOCGDIAG
+.It Dv HDKIOCGDIAG
+The argument is a pointer to a
+.Vt hdk_diag
+structure (described below).
+This
+.Xr ioctl 2
+gets the most recent command that failed along with the
+sector and error number from the hard disk.
+.El
+.Bd -literal -offset 2n
+/*
+ * Used for disk diagnostics
+ */
+struct hdk_diag {
+ ushort_t hdkd_errcmd; /* most recent command in error */
+ daddr_t hdkd_errsect; /* most recent sector in error */
+ uchar_t hdkd_errno; /* most recent error number */
+ uchar_t hdkd_severe; /* severity of most recent error */
+};
+.Ed
+.Sh SEE ALSO
+.Xr ioctl 2 ,
+.Xr dkio 4I
diff --git a/usr/src/man/man4i/iec61883.4i b/usr/src/man/man4i/iec61883.4i
new file mode 100644
index 0000000000..fb0857852e
--- /dev/null
+++ b/usr/src/man/man4i/iec61883.4i
@@ -0,0 +1,674 @@
+.\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved
+.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd July 9, 2018
+.Dt IEC61883 4I
+.Os
+.Sh NAME
+.Nm iec61883
+.Nd IEC 61883 interfaces
+.Sh SYNOPSIS
+.In sys/av/iec61883.h
+.Sh DESCRIPTION
+The set of interfaces described in this man page can be used to control and
+exchange data with consumer audio/video devices using protocols specified
+in
+.%T "IIEC 61883 Consumer Electronic Audio/Video Equipment - Digital Interface"
+including Common Isochronous Packet (CIP), Connection Management
+Procedures (CMP) and Function Control Protocol (FCP).
+.Pp
+An
+.Nm
+compliant driver exports two device nodes for isochronous and
+for asynchronous transactions.
+See the
+.Sx FILES
+section of this man page for the namespace definition.
+.Ss "Isochronous Transfers"
+Two methods are provided to receive/transmit isochronous data: using
+.Xr mmap 2
+in combination with
+.Xr ioctl 2 ,
+and
+.Xr read 2
+or
+.Xr write 2 .
+.Ss "Mmap/Ioctl"
+This method provides better performance and finer-grained control than
+read/write, and is a method of choice for most applications.
+The data buffer is
+mapped into a user process address space, which means no data copying between
+the kernel and an application is necessary.
+Synchronization between user
+processes and the driver is performed using
+.Xr ioctl 2
+commands.
+.Pp
+An application allocates resources for isochronous transfer using
+.Dv IEC61883_ISOCH_INIT .
+Then the data buffer can be mapped into the process
+space using
+.Xr mmap 2 .
+.Pp
+A circular data buffer consists of one or more equal size frame buffers
+(further referred to as frames, unless to avoid ambiguity with AV frames).
+Frames are numbered starting with zero and are always transferred sequentially.
+Frames consist equal sized packets.
+Each packet contains a CIP header and one or more data blocks.
+.Pp
+A driver and an application act as a producer and a consumer: producer supplies
+.Em full
+frames (filled with data) to the consumer, and the producer is not
+allowed to access those frames until the consumer claims them
+.Em empty .
+.Pp
+A transfer can be initiated and suspended with
+.Dv IEC61883_START
+and
+.Dv IEC61883_STOP
+commands respectively.
+.Dv IEC61883_RECV
+or
+.Dv IEC61883_XMIT
+is used for producer-consumer synchronization.
+.Ss "Read/Write"
+Using this method, an application calls
+.Xr read 2
+or
+.Xr write 2
+to receive or transmit a specified amount of data.
+Bus-specific overhead, such as isochronous packet headers, is handled by the driver
+and is not exposed to applications.
+Data returned by
+.Xr read 2
+contains CIP headers and data blocks.
+Empty packets are not returned by
+.Xr read 2 .
+.Xr write 2
+data should meet the same requirements.
+.Pp
+If one or more channels have been allocated since
+.Xr open 2
+(see
+.Dv IEC61883_ISOCH_INIT ) ,
+the data is received/transmitted using channel that was created the last.
+.Pp
+If no channels were allocated, the driver uses the broadcast channel by default
+and allocates the default-size data buffer.
+During transmit, the first packet's CIP header is used to auto-detect the data format.
+If it is one of the formats supported by the driver, it is properly transmitted (with
+inserted empty packets and timestamps).
+.Pp
+For both methods, if during transmit the driver runs out of data, it transmits
+empty packets containing only a CIP header of the next to be transmitted
+packet, as defined in
+.Em IEC 61883-1 .
+.Ss "Connection Management Procedures"
+Applications wishing to follow Connection Management Procedures (CMP) in
+combination with isochronous transfers should use the
+.Xr ioctl 2
+.Dv IEC61883_PLUG_INIT ,
+.Dv IEC61883_PLUG_FINI ,
+.Dv IEC61883_PLUG_REG_READ
+and
+.Dv IEC61883_PLUG_REG_CAS
+commands.
+.Ss "Asynchronous Transactions"
+.Xr read 2 ,
+.Xr write 2 ,
+.Xr ioctl 2 ,
+and
+.Xr poll 2
+can be used
+with asynchronous nodes.
+Asynchronous data exchange between a driver and an
+application utilizes a common data structure called asynchronous request (ARQ):
+.Bd -literal -offset 2n
+typedef struct iec61883_arq {
+ int arq_type;
+ int arq_len;
+ union {
+ uint32_t quadlet;
+ uint64_t octlet;
+ uint8_t buf[8];
+ } arq_data;
+} iec61883_arq_t;
+.Ed
+.Pp
+.Fa arq_type
+contains
+.Sy ARQ
+type:
+.Pp
+.Bl -tag -width " " -compact
+.It Dv IEC61883_ARQ_FCP_CMD
+.It Dv IEC61883_ARQ_FCP_RESP
+.Pp
+.Sy FCP
+command and response frame respectively.
+Outgoing frames are sent using
+.Xr write 2 ,
+incoming frames are received with
+.Xr read 2 .
+.Pp
+See
+.Em IIEC 61883-1
+for the FCP frame structure definition.
+.Pp
+.It Dv IEC61883_ARQ_BUS_RESET
+.Pp
+Returned by the driver when a bus reset occurs.
+There is no data associated with this request type, and \fBarq_len\fR is set to 0.
+.El
+.Pp
+If
+.Fa arq_len
+is 4 or 8, then data should be supplied in
+.Fa arq_data.quadlet
+or
+.Fa arq_data.octlet
+respectively, otherwise up to 8 bytes can be put in
+.Fa arq_data.buf ,
+with the rest of the data following immediately after.
+.Ss "write(2)"
+For a request to be sent to a target, an
+.Vt iec61883_arq_t
+structure along with associated data is passed to the driver using
+.Xr write 2 .
+.Xr write 2
+blocks until the request is completed.
+.Ss "read(2)"
+A driver collects incoming ARQs in the internal buffer.
+Buffer size can be changed using the
+.Xr ioctl 2
+command
+.Vt IEC61883_FCP_SET_IBUF_SIZE .
+.Pp
+Reading an ARQ takes one or two steps depending on data length.
+An application
+first reads
+.Ql sizeof (iec61883_arq_t)
+bytes: if
+.Fa arq_len
+is less than or equal 4, which is usually the case, no additional step is needed.
+Otherwise,
+the remaining
+.Ql arq_len - 4
+bytes should be read and concatenated.
+.Pp
+.Xr read 2
+blocks until the specified amount of data is available, unless
+.Dv O_NONBLOCK
+or
+.Dv O_NDELAY
+flag was set during
+.Xr open 2 ,
+in which case
+.Xr read 2
+returns immediately.
+.Ss "poll(2)"
+Applications can
+.Xr poll 2
+asynchronous nodes on the
+.Dv POLLIN
+event.
+.Ss "Bus Reset"
+In case of a bus reset, the driver notifies an application by generating an
+.Sy ARQ
+of type
+.Dv IEC61883_ARQ_BUS_RESET .
+.Pp
+If there were established isochronous connections before bus reset, the driver
+attempts to restore all connections as described in
+.Em IEC 61883
+and resume any active transfers that were in progress.
+.Sh IOCTLS
+The following commands only apply to isochronous nodes:
+.Bl -tag -width " "
+.It Dv IEC61883_ISOCH_INIT
+.Pp
+This command allocates a data buffer and isochronous resources (if necessary)
+for the isochronous transfer.
+The argument is a pointer to the structure:
+.Bd -literal -offset 2n
+typedef struct iec61883_isoch_init {
+ int ii_version; /* interface version */
+ int ii_pkt_size; /* packet size */
+ int ii_frame_size; /* packets/frame */
+ int ii_frame_cnt; /* # of frames */
+ int ii_direction; /* xfer direction */
+ int ii_bus_speed; /* bus speed */
+ uint64_t ii_channel; /* channel mask */
+ int ii_dbs; /* DBS */
+ int ii_fn; /* FN */
+ int ii_rate_n; /* rate numerator */
+ int ii_rate_d; /* rate denominator */
+ int ii_ts_mode; /* timestamp mode */
+ int ii_flags; /* flags */
+ int ii_handle; /* isoch handle */
+ int ii_frame_rcnt; /* # of frames */
+ off_t *ii_mmap_off /* mmap offset */
+ int ii_rchannel; /* channel */
+ int ii_error; /* error code */
+} iec61883_isoch_init_t;
+.Ed
+.Pp
+.Fa ii_version
+should be set to
+.Dv IEC61883_V1_0 .
+.Pp
+The driver attempts to allocate a data buffer consisting of
+.Fa ii_frame_cnt
+frames, with
+.Fa ii_frame_size
+packets in each frame.
+Packet size in bytes is specified by
+.Fa ii_pkt_size
+specifies and should be a multiple of 512 and compatible with
+.Fa ii_bus_speed .
+.Pp
+.Fa ii_direction
+can take one of the following values:
+.Bl -tag -width "IEC61883_DIR_RECV"
+.It Dv IEC61883_DIR_RECV
+Receiving isochronous data.
+.It Dv IEC61883_DIR_XMIT
+Transmitting isochronous data.
+.El
+.Pp
+.Fa ii_bus_speed
+chooses bus speed to be used and can be either
+.Dv IEC61883_S100 ,
+.Dv IEC61883_S200
+or
+.Dv IEC61883_S400 .
+.Pp
+.Fa ii_channel
+is a mask that specifies an isochronous channel number to be
+used, with the
+.Em N Ns th
+bit representing channel
+.Em N .
+When transmitting data, several bits can be set at a time, in which case the
+driver chooses one, for example,
+.Sy 0x3FF
+means a range from 0 to 9.
+In case of receive, only one bit can be set.
+.Pp
+.Fa ii_dbs
+specifies data block size in quadlets, for example, DBS value for
+.Dv SD-DVCR
+is
+.Sy 0x78 .
+Refer to
+.Em IEC 61883
+for more details on DBS.
+.Pp
+.Fa ii_fn
+specifies fraction number, which defines the number of blocks in which a
+source packet is divided.
+Allowed values are from 0 to 3.
+Refer to
+.Em IEC 61883
+for more details on FN.
+.Pp
+Data rate expected by the AV device can be lower than the bus speed, in which
+case the driver has to periodically insert empty packets into the data stream
+to avoid device buffer overflows.
+This rate is specified with a fraction N/D,
+set by
+.Fa ii_rate_n
+and
+.Fa ii_rate_d
+respectively.
+Any integer numbers can be used, or the following predefined constants:
+.Pp
+.Bl -tag -width "IEC61883_RATE_N_DV_NTSC" -compact
+.It Dv IEC61883_RATE_N_DV_NTSC
+.It Dv IEC61883_RATE_D_DV_NTSC
+Data rate expected by
+.Sy DV-NTSC
+devices.
+.Pp
+.It Dv IEC61883_RATE_N_DV_PAL
+.It Dv IEC61883_RATE_D_DV_PAL
+Data rate expected by
+.Sy DV-PAL
+devices.
+.El
+.Pp
+During data transmission, a timestamp based on the current value of the cycle
+timer is usually required.
+.Fa ii_ts_mode
+defines timestamp mode to be used:
+.Bl -tag -width IEC61883_TS_NONE
+.It Dv IEC61883_TS_SYT
+Driver puts a timestamp in the SYT field of the first CIP header of each frame.
+.It Dv IEC61883_TS_NONE
+No timestamps.
+.El
+.Pp
+.Fa ii_dbs ,
+.Fa ii_fn ,
+.Fa ii_rate_n ,
+.Fa ii_rate_d
+and
+.Fa ii_ts_mode
+are only required for transmission.
+In other case these should be set to 0.
+.Pp
+.Fa ii_flags
+should be set to 0.
+.Pp
+If command succeeds,
+.Fa ii_handle
+contains a handle that should be used with other isochronous commands.
+.Fa ii_frame_rcnt
+contains the number of allocated frames (can be less than
+.Fa ii_frame_cnt ) .
+.Fa ii_mmap_off
+contains an offset to be used in
+.Xr mmap 2 ,
+for example, to map an entire data receive buffer:
+.Bd -literal -offset 2n
+pa = mmap(NULL, init.ii_pkt_size *
+ init.ii_frame_size * init.ii_frame_rcnt,
+ PROT_READ, MAP_PRIVATE, fd, init.ii_mmap_off);
+.Ed
+.Pp
+.Fa ii_rchannel
+contains channel number.
+.Pp
+In case of command success,
+.Fa ii_error
+is set to 0; otherwise one of the following values can be returned:
+.Bl -tag -width IEC61883_ERR_NOCHANNEL
+.It Dv IEC61883_ERR_NOMEM
+Not enough memory for the data buffer.
+.It Dv IEC61883_ERR_NOCHANNEL
+Cannot allocate isochronous channel.
+.It Dv IEC61883_ERR_PKT_SIZE
+Packet size is not allowed at this bus speed.
+.It Dv IEC61883_ERR_VERSION
+Interface version is not supported.
+.It Dv IEC61883_ERR_INVAL
+One or more the parameters are invalid
+.It Dv IEC61883_ERR_OTHER
+Unspecified error type.
+.El
+.It Dv IEC61883_ISOCH_FINI
+.Pp
+Argument is a handle returned by
+.Dv IEC61883_ISOCH_INIT .
+This command frees any resources associated with this handle.
+There must be no active transfers
+and the data buffer must be unmapped; otherwise the command fails.
+.It Dv IEC61883_START
+.Pp
+This command starts an isochronous transfer.
+The argument is a handle returned
+by
+.Dv IEC61883_ISOCH_INIT .
+.It Dv IEC61883_STOP
+.Pp
+This command stops an isochronous transfer.
+The argument is a handle returned by
+.Dv IEC61883_ISOCH_INIT .
+.It Dv IEC61883_RECV
+.Pp
+This command is used to receive full frames and return empty frames to the driver.
+The argument is a pointer to the structure:
+.Bd -literal -offset 2n
+typedef struct iec61883_recv {
+ int rx_handle; /* isoch handle */
+ int rx_flags; /* flags */
+ iec61883_xfer_t rx_xfer; /* xfer params */
+} iec61883_recv_t;
+
+typedef struct iec61883_xfer {
+ int xf_empty_idx; /* first empty frame */
+ int xf_empty_cnt; /* empty frame count */
+ int xf_full_idx; /* first full frame */
+ int xf_full_cnt; /* full frame count */
+ int xf_error; /* error */
+} iec61883_xfer_t;
+.Ed
+.Pp
+.Fa rx_flags
+should be set to 0.
+.Pp
+An application sets
+.Fa xf_empty_idx
+and
+.Fa xf_empty_cnt
+to indicate frames it no longer needs.
+E. g. if a buffer consists of 6 frames,
+.Fa xf_empty_idx
+is 4,
+.Fa xf_empty_cnt
+is 3 - means that frames 4, 5 and 0 can now be reused by the driver.
+If there are no empty frames, for example, the
+first time this command is called,
+.Fa xf_empty_cnt
+should be set to 0.
+.Pp
+When the command returns,
+.Fa xf_full_idx
+and
+.Fa xf_full_cnt
+specifies the frames that are full.
+.Fa xf_error
+is always 0.
+.Pp
+In general, AV frame boundaries are not aligned with the frame buffer
+boundaries, because the first received packet might not be the first packet of
+an AV frame, and, in contrast with the read/write method, the driver does not
+remove empty CIP packets.
+.Pp
+Applications should detect empty packets by comparing adjacent packets'
+continuity counters (DBC field of the CIP header).
+.It Dv IEC61883_XMIT
+.Pp
+This command is used to transmit full frames and get more empty frames from the
+driver.
+The argument is a pointer to the structure:
+.Bd -literal -offset 2n
+typedef struct iec61883_xmit {
+ int tx_handle; /* isoch handle */
+ int tx_flags; /* flags */
+ iec61883_xfer_t tx_xfer; /* xfer params */
+ int tx_miss_cnt; /* missed cycles */
+ } iec61883_xmit_t;
+.Ed
+.Pp
+.Fa tx_flags
+should be set to zero.
+.Pp
+The application sets
+.Fa xf_full_idx
+and
+.Fa xf_full_cnt
+to specify frames it wishes to transmit.
+If there are no frames to transmit (e. g. the first time this command is called),
+.Fa xf_full_cnt
+should be set to 0.
+.Pp
+When the command returns,
+.Fa xf_empty_idx
+and
+.Fa xf_empty_cnt
+specifies empty frames which can be to transmit more data.
+.Fa xf_error
+is always 0.
+.Pp
+.Fa tx_miss_cnt
+contains the number of isochronous cycles missed since last
+transfer due to data buffer under run.
+This can happen when an application does not supply data fast enough.
+For the purposes of time stamping, the driver considers the first packet in a
+frame buffer to be the first packet of an AV frame.
+.It Dv IEC61883_PLUG_INIT
+.Pp
+This command returns a handle for the specified plug.
+The argument is a pointer
+to the structure:
+.Bd -literal -offset 2n
+typedef struct iec61883_plug_init {
+ int pi_ver; /* interface version */
+ int pi_loc; /* plug location */
+ int pi_type; /* plug type */
+ int pi_num; /* plug number */
+ int pi_flags; /* flags */
+ int pi_handle; /* plug handle */
+ int pi_rnum; /* plug number */
+ } iec61883_plug_init_t;
+.Ed
+.Pp
+.Fa pi_ver
+should be set to
+.Dv IEC61883_V1_0 .
+.Pp
+.Fa pi_loc
+specifies plug location:
+.Bl -tag -width IEC61883_LOC_REMOTE
+.It Dv IEC61883_LOC_LOCAL
+On the local unit (local plug).
+A plug control register (PCR) is allocated.
+Command fails if the plug already exists
+.It Dv IEC61883_LOC_REMOTE
+On the remote unit (remote plug).
+The plug should exist on the remote unit,
+otherwise the command fails.
+.El
+.Pp
+.Fa pi_type
+specifies isochronous plug type:
+.Pp
+.Bl -tag -width " " -compact
+.It Dv IEC61883_PLUG_IN
+.It Dv IEC61883_PLUG_OUT
+.Pp
+Input or output plugs.
+.Pp
+.It Dv IEC61883_PLUG_MASTER_IN
+.It Dv IEC61883_PLUG_MASTER_OUT
+.Pp
+Master input or master output plug.
+These plugs always exist on the local unit.
+.El
+.Pp
+.Fa pi_num
+specifies plug number.
+This should be 0 for master plugs, and from 0 to 31 for input/output plugs.
+Alternatively, a special value
+.Dv IEC61883_PLUG_ANY
+can be used to let the driver choose a free plug
+number, create the plug and return the number in
+.Fa pi_rnum .
+.Pp
+.Fa pi_flags
+should be set to 0.
+.Pp
+If the command succeeds,
+.Fa pi_handle
+contains a handle that should be used with other plug commands.
+.It Dv IEC61883_PLUG_FINI
+.Pp
+Argument is a handle returned by
+.Dv IEC61883_PLUG_INIT .
+This command frees any resources associated with this handle, including the PCR.
+.It Dv IEC61883_PLUG_REG_READ
+.Pp
+Read plug register value.
+The argument is a pointer to the structure:
+.Bd -literal -offset 2n
+typedef struct iec61883_plug_reg_val {
+ int pr_handle; /* plug handle */
+ uint32_t pr_val; /* register value */
+} iec61883_plug_reg_val_t;
+.Ed
+.Pp
+.Fa pr_handle
+is a handle returned by
+.Dv IEC61883_PLUG_INIT .
+Register
+value is returned in
+.Fa pr_val .
+.It Dv IEC61883_PLUG_REG_CAS
+.Pp
+Atomically compare and swap plug register value.
+The argument is a pointer to the structure:
+.Bd -literal -offset 2n
+typedef struct iec61883_plug_reg_lock {
+ int pl_handle; /* plug handle */
+ uint32_t pl_arg; /* compare arg */
+ uint32_t pl_data; /* write value */
+ UINT32_t pl_old; /* original value */
+} iec61883_plug_reg_lock_t;
+.Ed
+.Pp
+.Fa pr_handle
+is a handle returned by IEC61883_PLUG_INIT.
+.Pp
+Original register value is compared with
+.Fa pl_arg
+and if they are equal, register value is replaced with
+.Fa pl_data .
+In any case, the original value is stored in
+.Fa pl_old .
+.El
+.Pp
+The following commands only apply to asynchronous nodes:
+.Bl -tag -width " "
+.It Dv IEC61883_ARQ_GET_IBUF_SIZE
+.Pp
+This command returns current incoming ARQ buffer size.
+The argument is a
+pointer to
+.Vt int .
+.It Dv IEC61883_ARQ_SET_IBUF_SIZE
+.Pp
+This command changes incoming ARQ buffer size.
+The argument is the new buffer
+size in bytes.
+.El
+.Sh FILES
+.Bl -tag -width /dev/av/N/async
+.It Pa /dev/av/N/async
+Device node for asynchronous data
+.It Pa /dev/av/N/isoch
+Device has been disconnected
+.El
+.Sh ERRORS
+.Bl -tag -width EFAULT
+.It Er EIO
+Bus operation failed.
+DMA failure.
+.It Er EFAULT
+.Xr ioctl 2
+argument points to an illegal address.
+.It Er EINVAL
+Invalid argument or argument combination.
+.It Er ENODEV
+Device has been disconnected.
+.El
+.Sh ARCHITECTURE
+All
+.Sh INTERFACE STABILITY
+Committed
+.Sh SEE ALSO
+.Xr ioctl 2 ,
+.Xr mmap 2 ,
+.Xr open 2 ,
+.Xr poll 2 ,
+.Xr read 2 ,
+.Xr write 2 ,
+.Xr av1394 4D ,
+.Xr attributes 7
+.Rs
+.%B IIEC 61883 Consumer audio/video equipment - Digital interface
+.Re
+.Rs
+.%B IEEE Std 1394-1995 Standard for a High Performance Serial Bus
+.Re
diff --git a/usr/src/man/man4i/ipnat.4i b/usr/src/man/man4i/ipnat.4i
new file mode 100644
index 0000000000..1df2b96e2d
--- /dev/null
+++ b/usr/src/man/man4i/ipnat.4i
@@ -0,0 +1,436 @@
+.\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved
+.\" Copyright (c) 2017, Joyent, Inc.
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd October 23, 2017
+.Dt IPNAT 4I
+.Os
+.Sh NAME
+.Nm ipnat
+.Nd IP Filter/NAT module interface
+.Sh DESCRIPTION
+The
+.Sy ipnat
+device provides interfaction with the NAT features of the Solaris IPFilter.
+.Sh APPLICATION PROGRAMMING INTERFACE
+The NAT features programming model is a component of the Solaris IP Filter and
+is accessed via the NAT device file
+.Pa /dev/ipnat .
+Opening the device for
+reading or writing determines which ioctl calls can be successfully made.
+.Sh IOCTLS
+The caller must construct a
+.Vt ipfobj
+structure when issuing a
+.Sy SIOCGNATL
+or
+SIOCSTPUT
+ioctl.
+The
+.Vt ipfobj
+structure is then passed
+to the ioctl call and is filled out with
+.Fa ipfo_type
+set to
+.Dv IPFOBJ_ Ns value .
+.Dv IPFOBJ_ Ns value
+provides a matching name for the structure, while
+.Fa ipfo_size
+is set to the total size of the structure being passed and
+.Fa ipfo_ptr
+is set to the structure address.
+The
+.Fa ipfo_rev
+structure should be set to the current value of
+.Dv IPFILTER_VERSION ,
+while
+.Fa ipfo_offset
+and
+.Fa ipfo_xxxpad
+should be set to 0.
+.Bd -literal -offset 2n
+/*
+ * Structure used with SIOCGNATL/SIOCSTPUT.
+ */
+
+/*
+ * Object structure description. For passing through in ioctls.
+ */
+typedef struct ipfobj {
+ u_32_t ipfo_rev; /* IPFilter version (IPFILTER_VERSION) */
+ u_32_t ipfo_size; /* size of object at ipfo_ptr */
+ void *ipfo_ptr; /* pointer to object */
+ int ipfo_type; /* type of object being pointed to */
+ int ipfo_offset; /* bytes from ipfo_ptr where to start */
+ u_char ipfo_xxxpad[32]; /* reserved for future use */
+} ipfobj_t;
+
+#define IPFILTER_VERSION 4010901 /* IPFilter version */
+#define IPFOBJ_NATSAVE 8 /* struct nat_save */
+#define IPFOBJ_NATLOOKUP 9 /* struct natlookup */
+.Ed
+.Pp
+The following
+.Xr ioctl 2
+calls may be used to manipulate the ipnat sub-system inside of ipf.
+Note that the ipnat driver only accept calls from applications
+using the same data model as the kernel.
+In other words, 64-bit kernels can only accept calls from 64-bit applications.
+Calls from 32-bit applications fail
+with
+.Er EINVAL .
+.Bl -tag -width SIOCSTLCK
+.It Dv SIOCSTLCK
+Set or clear the NAT lock to prevent table updates attributable to packet
+flow-through.
+.It Dv SIOCGNATL
+Search the NAT table for the rdr entry that matches the fields in the natlookup
+structure.
+The caller must populate the structure with the address/port
+information of the accepted TCP connection
+.Pq Fa nl_inip , Fa nl_inport
+and the
+address/port information of the peer
+.Pq Fa nl_outip , Fa nl_outport .
+The
+.Fa nl_flags
+field must have the
+.Dv IPN_TCP
+option set.
+All other fields must be set to 0.
+If the call succeeds,
+.Fa nl_realip
+and
+.Fa nl_realport
+are set to the real destination address and port, respectively.
+The
+.Fa nl_inport
+and
+.Fa nl_outport
+fields must be in host byte order.
+If
+.Dv IPN_FINDFORWARD
+is set in
+.Fa nl_flags ,
+a check is made to see if it is
+possible to create an outgoing NAT session by checking if a packet coming from
+.Pq Fa nl_realip , Fa nl_realport
+and destined for
+.Pq Fa nl_outip , Fa nl_outport
+can be translated.
+If translation is possible, the flag remains set, otherwise it is
+cleared in the structure returned to the caller.
+.Bd -literal -offset indent
+/*
+ * Structure used with SIOCGNATL.
+ */
+typedef struct natlookup {
+ i6addr_t nl_inipaddr;
+ i6addr_t nl_outipaddr;
+ i6addr_t nl_realipaddr;
+ int nl_v;
+ int nl_flags;
+ u_short nl_inport;
+ u_short nl_outport;
+ u_short nl_realport;
+} natlookup_t
+
+#define nl_inip nl_inipaddr.in4
+#define nl_outip nl_outipaddr.in4
+#define nl_realip nl_realipaddr.in4
+#define nl_inip6 nl_inipaddr.in6
+#define nl_outip6 nl_outipaddr.in6
+#define nl_realip6 nl_realipaddr.in6
+
+/*
+ * Accepted values for nl_flags
+ */
+#define IPN_TCP 0x00001
+#define IPN_FINDFORWARD 0x400000
+.Ed
+.It Dv SIOCSTPUT
+Move a NAT mapping structure from user space into the kernel.
+This ioctl is used by
+.Xr ipfs 8
+to restore NAT sessions saved in
+.Pa /var/db/ipf/ipnat.ipf .
+The
+.Vt nat_save
+structure must have its
+.Fa ipn_nat
+and
+.Fa ipn_ipnat
+structures filled out correctly.
+Fields not assigned a value must be initialised to 0.
+All pointer fields are adjusted, as appropriate, once the
+structure is passed into the kernel and none are preserved.
+.Pp
+To create a translation, the following fields must be set:
+.\" Force item bodies to next line using 2n width
+.Bl -tag -width 2n
+.It "Interface name"
+The interface name on which the host is to be exited must be
+set in
+.Fa nat_ifnames[0] .
+.It "Local IP address and port number"
+The connection's local IP address and port
+number are stored in network byte order using
+.Fa nat_inip Ns / Ns Fa nat_inport .
+.It "Destination address/port"
+The destination address/port are stored in
+.Fa nat_oip Ns / Ns Fa nat_oport .
+.It "Target address/port"
+The translation's target address/port is stored in
+.Fa nat_outip Ns / Ns Fa nat_outport .
+.El
+.Pp
+The caller must also precalculate the checksum adjustments necessary to
+complete the translation and store those values in
+.Fa nat_sumd
+(delta required for TCP header) and
+.Fa nat_ipsumd
+(delta required for IP header).
+.Bd -literal -offset indent
+/*
+ * Structures used with SIOCSTPUT.
+ */
+typedef struct nat_save {
+ void *ipn_next;
+ struct nat ipn_nat;
+ struct ipnat ipn_ipnat;
+ struct frentry ipn_fr;
+ int ipn_dsize;
+ char ipn_data[4];
+} nat_save_t;
+
+typedef struct nat {
+ ipfmutex_t nat_lock;
+ struct nat *nat_next;
+ struct nat **nat_pnext;
+ struct nat *nat_hnext[2];
+ struct nat **nat_phnext[2];
+ struct hostmap *nat_hm;
+ void *nat_data;
+ struct nat **nat_me;
+ struct ipstate *nat_state;
+ struct ap_session *nat_aps;
+ frentry_t *nat_fr;
+ struct ipnat *nat_ptr;
+ void *nat_ifps[2];
+ void *nat_sync;
+ ipftqent_t nat_tqe;
+ u_32_t nat_flags;
+ u_32_t nat_sumd[2];
+ u_32_t nat_ipsumd;
+ u_32_t nat_mssclamp;
+ i6addr_t nat_inip6;
+ i6addr_t nat_outip6;
+ i6addr_t nat_oip6;
+ U_QUAD_T nat_pkts[2];
+ U_QUAD_T nat_bytes[2];
+ union {
+ udpinfo_t nat_unu;
+ tcpinfo_t nat_unt;
+ icmpinfo_t nat_uni;
+ greinfo_t nat_ugre;
+ } nat_un;
+ u_short nat_oport;
+ u_short nat_use;
+ u_char nat_p;
+ int nat_dir;
+ int nat_ref;
+ int nat_hv[2];
+ char nat_ifnames[2][LIFNAMSIZ];
+ int nat_rev;
+ int nat_v;
+} nat_t;
+
+#define nat_inip nat_inip6.in4
+#define nat_outip nat_outip6.in4
+#define nat_oip nat_oip6.in4
+#define nat_inport nat_un.nat_unt.ts_sport
+#define nat_outport nat_un.nat_unt.ts_dport
+/*
+ * Values for nat_dir
+ */
+#define NAT_INBOUND 0
+#define NAT_OUTBOUND 1
+/*
+ * Definitions for nat_flags
+ */
+#define NAT_TCP 0x0001 /* IPN_TCP */
+.Ed
+.El
+.Sh EXAMPLES
+The following example shows how to prepare and use
+.Fa SIOCSTPUT
+to insert a NAT session directly into the table.
+Note that the usual TCP/IP code is omitted is this example.
+.Pp
+In the code segment below,
+.Fa incoming_fd
+is the TCP connection file descriptor
+that is accepted as part of the redirect process, while
+.Fa remote_fd
+is the outgoing TCP connection to the remote server being translated back to the
+original IP address/port pair.
+.Pp
+Note \(em
+The following ipnat headers must be included before you can use the code shown
+in this example:
+.Bd -literal -offset 2n
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <net/if.h>
+#include <netinet/ipl.h>
+#include <netinet/ip_compat.h>
+#include <netinet/ip_fil.h>
+#include <netinet/ip_nat.h>
+#include <string.h>
+#include <fcntl.h>
+.Ed
+.Pp
+Note \(em
+In the example below, various code fragments have been excluded to enhance
+clarity.
+.Bd -literal -offset 2n
+int
+translate_connection(int incoming_fd)
+{
+ struct sockaddr_in usin;
+ struct natlookup nlp;
+ struct nat_save ns;
+ struct ipfobj obj;
+ struct nat *nat;
+ int remote_fd;
+ int nat_fd;
+ int onoff;
+
+ memset(&ns, 0, sizeof(ns));
+ nat = &ns.ipn_nat
+
+ namelen = sizeof(usin);
+ getsockname(remote_fd, (struct sockaddr *)&usin, &namelen);
+
+ namelen = sizeof(sin);
+ getpeername(incoming_fd, (struct sockaddr *) &sin, &namelen);
+
+ namelen = sizeof(sloc);
+ getsockname(incoming_fd, (struct sockaddr *) &sloc, &namelen);
+
+ bzero((char *) &obi, sizeof(obj));
+ obj.ipfo_rev = IPFILTER_VERSION;
+ obj.ipfo_size = sizeof(nlp);
+ obj.ipfo_ptr = &nip;
+ obj.ipfo_type = IPFOBJ_NATLOOKUP;
+
+ /*
+ * Build up the NAT natlookup structure.
+ */
+ bzero((char *) &nlp, sizeof(nlp));
+ nlp.nl_outip = sin.sin_addr;
+ nlp.nl_inip = sloc.sin_addr;
+ nlp.nl_flags = IPN_TCP;
+ nlp.nl_outport = ntohs(sin.sin_port);
+ nlp.nl_inport = ntohs(sloc.sin_port);
+
+ /*
+ * Open the NAT device and lookup the mapping pair.
+ */
+ nat_fd = open(IPNAT_NAME, O_RDWR);
+ if (ioctl(nat_fd, SIOCGNATL, &obj) != 0)
+ return -1;
+
+ nat->nat_inip = usin.sin_addr;
+ nat->nat_outip = nlp.nl_outip;
+ nat->nat_oip = nlp.nl_realip;
+
+ sum1 = LONG_SUM(ntohl(usin.sin_addr.s_addr)) +
+ ntohs(usin.sin_port);
+ sum2 = LONG_SUM(ntohl(nat->nat_outip.s_addr)) +
+ ntohs(nlp.nl_outport);
+ CALC_SUMD(sum1, sum2, sumd);
+ nat->nat_sumd[0] = (sumd & 0xffff) + (sumd >> 16);
+ nat->nat_sumd[1] = nat->nat_sumd[0];
+
+ sum1 = LONG_SUM(ntohl(usin.sin_addr.s_addr));
+ sum2 = LONG_SUM(ntohl(nat->nat_outip.s_addr));
+ CALC_SUMD(sum1, sum2, sumd);
+ nat->nat_ipsumd = (sumd & 0xffff) + (sumd >> 16);
+
+ nat->nat_inport = usin.sin_port;
+ nat->nat_outport = nlp.nl_outport;
+ nat->nat_oport = nlp.nl_realport;
+
+ nat->nat_flags = IPN_TCPUDP;
+
+ /*
+ * Prepare the ipfobj structure, accordingly.
+ */
+ bzero((char *)&obi, sizeof(obj));
+ obj.ipfo_rev = IPFILTER_VERSION;
+ obj.ipfo_size = sizeof(*nsp);
+ obj.ipfo_ptr = nsp;
+ obj.ipfo_type = IPFOBJ_NATSAVE;
+
+ onoff = 1;
+ if (ioctl(nat_fd, SIOCSTPUT, &obj) != 0)
+ fprintf(stderr, "Error occurred\en");
+
+ return connect(rem_fd, (struct sockaddr)&usin, sizeof(usin));
+}
+.Ed
+.Sh ERRORS
+.Bl -tag -width Er
+.It Er EPERM
+The device has been opened for reading only.
+To succeed, the ioctl call must be opened for both reading and writing.
+The call may be returned if it is
+privileged and the calling process did not assert
+.Brq Sy PRIV_SYS_NET_CONFIG
+in the effective set.
+.It Er ENOMEM
+More memory was allocated than the kernel can provide.
+The call may also be returned if the application inserts a NAT entry that
+exceeds the hash bucket chain's maximum length.
+.It Er EFAULT
+The calling process specified an invalid pointer in the ipfobj structure.
+.It Er EINVAL
+The calling process detected a parameter or field set to an unacceptable value.
+.It Er EEXIST
+The calling process, via
+.Dv SIOCSTPUT ,
+attempted to add a NAT entry that already exists in the NAT table.
+.It Er ESRCH
+The calling process called
+.Dv SIOCSTPUT
+before setting the
+.Dv SI_NEWFR
+flag and providing a pointer in the
+.Fa nat_fr
+field that cannot be found in the current rule set.
+.It Er EACESS
+The calling process issued a
+.Dv SIOCSTPUT
+before issuing a
+.Dv SIOCSTLCK .
+.El
+.Sh INTERFACE STABILITY
+Committed
+.Sh SEE ALSO
+.Xr ioctl 2 ,
+.Xr attributes 7 ,
+.Xr ipfs 8 ,
+.Xr ipnat 8
diff --git a/usr/src/man/man4i/mhd.4i b/usr/src/man/man4i/mhd.4i
new file mode 100644
index 0000000000..735e69982e
--- /dev/null
+++ b/usr/src/man/man4i/mhd.4i
@@ -0,0 +1,386 @@
+.\" Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
+.\" Copyright (c) 2017, Joyent, Inc.
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd October 23, 2017
+.Dt MHD 4I
+.Os
+.Sh NAME
+.Nm mhd
+.Nd multihost disk control operations
+.Sh SYNOPSIS
+.In sys/mhd.h
+.Sh DESCRIPTION
+The
+.Nm
+.Xr ioctl 2
+control access rights of a multihost disk, using
+disk reservations on the disk device.
+.Pp
+The stability level of this interface (see
+.Xr attributes 7 )
+is evolving.
+As a result, the interface is subject to change and you should limit your use of
+it.
+.Pp
+The mhd ioctls fall into two major categories: (1) ioctls for non-shared
+multihost disks and (2) ioctls for shared multihost disks.
+.Pp
+One ioctl,
+.Dv MHIOCENFAILFAST ,
+is applicable to both non-shared and shared multihost disks.
+It is described after the first two categories.
+.Pp
+All the ioctls require root privilege.
+.Pp
+For all of the ioctls, the caller should obtain the file descriptor for the
+device by calling
+.Xr open 2
+with the
+.Dv O_NDELAY
+flag; without the
+.Dv O_NDELAY
+flag, the open may fail due to another host already having a
+conflicting reservation on the device.
+Some of the ioctls below permit the caller to forcibly clear a conflicting
+reservation held by another host, however, in order to call the ioctl, the
+caller must first obtain the open file descriptor.
+.Ss "Non-shared multihost disks"
+Non-shared multihost disks ioctls consist of
+.Dv MHIOCTKOWN ,
+.Dv MHIOCRELEASE ,
+.Dv HIOCSTATUS ,
+and
+.Dv MHIOCQRESERVE .
+These ioctl requests control the access rights of non-shared multihost disks.
+A non-shared multihost disk is one that supports serialized, mutually exclusive
+I/O mastery by the connected hosts.
+This is in contrast to the shared-disk model, in which
+concurrent access is allowed from more than one host (see below).
+.Pp
+A non-shared multihost disk can be in one of two states:
+.Bl -bullet -width indent
+.It
+Exclusive access state, where only one connected host has I/O access
+.It
+Non-exclusive access state, where all connected hosts have I/O access.
+An external hardware reset can cause the disk to enter the non-exclusive access
+state.
+.El
+.Pp
+Each multihost disk driver views the machine on which it's running as the
+.Dq local host ;
+each views all other machines as
+.Dq remote hosts .
+For each I/O or ioctl request, the requesting host is the local host.
+.Pp
+Note that the non-shared ioctls are designed to work with SCSI-2 disks.
+The
+SCSI-2 RESERVE/RELEASE command set is the underlying hardware facility in the
+device that supports the non-shared ioctls.
+.Pp
+The function prototypes for the non-shared ioctls are:
+.Bd -literal -offset 2n
+.Fn ioctl fd MHIOCTKOWN ;
+.Fn ioctl fd MHIOCRELEASE ;
+.Fn ioctl fd MHIOCSTATUS ;
+.Fn ioctl fd MHIOCQRESERVE ;
+.Ed
+.Bl -tag -width MHIOCQRESERVE
+.It Dv MHIOCTKOWN
+Forcefully acquires exclusive access rights to the multihost disk for the local
+host.
+Revokes all access rights to the multihost disk from remote hosts.
+Causes the disk to enter the exclusive access state.
+.Pp
+Implementation Note: Reservations (exclusive access rights) broken via random
+resets should be reinstated by the driver upon their detection, for example, in
+the automatic probe function described below.
+.It Dv MHIOCRELEASE
+Relinquishes exclusive access rights to the multihost disk for the local host.
+On success, causes the disk to enter the non- exclusive access state.
+.It Dv MHIOCSTATUS
+Probes a multihost disk to determine whether the local host has access rights
+to the disk.
+Returns
+.Sy 0
+if the local host has access to the disk,
+.Sy 1
+if it doesn't, and
+.Sy -1
+with
+.Va errno
+set to
+.Er EIO
+if the probe failed for some other reason.
+.It Dv MHIOCQRESERVE
+Issues, simply and only, a SCSI-2 Reserve command.
+If the attempt to reserve
+fails due to the SCSI error Reservation Conflict (which implies that some other
+host has the device reserved), then the ioctl will return
+.Sy -1
+with
+.Va errno
+set to
+.Er EACCES .
+The
+.Dv MHIOCQRESERVE
+ioctl does NOT issue a bus device
+reset or bus reset prior to attempting the SCSI-2 reserve command.
+It also
+does not take care of re-instating reservations that disappear due to bus
+resets or bus device resets; if that behavior is desired, then the caller can
+call
+.Dv MHIOCTKOWN
+after the
+.Dv MHIOCQRESERVE
+has returned success.
+If
+the device does not support the SCSI-2 Reserve command, then the ioctl returns
+.Er -1
+with
+.Va errno
+set to
+.Er ENOTSUP .
+The
+.Dv MHIOCQRESERVE
+ioctl is intended to be used by high-availability or clustering software for a
+.Dq quorum
+disk, hence, the
+.Dq Q
+in the name of the ioctl.
+.El
+.Ss "Shared Multihost Disks"
+Shared multihost disks ioctls control access to shared multihost disks.
+The ioctls are merely a veneer on the SCSI-3 Persistent Reservation facility.
+Therefore, the underlying semantic model is not described in detail here, see
+instead the SCSI-3 standard.
+The SCSI-3 Persistent Reservations support the
+concept of a group of hosts all sharing access to a disk.
+.Pp
+The function prototypes and descriptions for the shared multihost ioctls are as
+follows:
+.Bl -tag -width 1n
+.It Fn ioctl fd MHIOCGRP_INKEYS "(mhioc_inkeys_t *)k"
+.Pp
+Issues the SCSI-3 command Persistent Reserve In Read Keys to the device.
+On input, the field
+.Fa k->li
+should be initialized by the caller with
+.Fa k->li.listsize
+reflecting how big of an array the caller has allocated for the
+.Fa k->lilist
+field and with
+.Ql k->li.listlen\& ==\& 0 .
+On return, the field
+.Fa k->li.listlen
+is updated to indicate the number of
+reservation keys the device currently has: if this value is larger than
+.Fa k->li.listsize
+then that indicates that the caller should have passed a bigger
+.Fa k->li.list
+array with a bigger
+.Fa k->li.listsize .
+The number of array elements actually written by the callee into
+.Fa k->li.list
+is the minimum of
+.Fa k->li.listlen
+and
+.Fa k->li.listsize .
+The field
+.Fa k->generation
+is updated with the generation information returned by the SCSI-3
+Read Keys query.
+If the device does not support SCSI-3 Persistent Reservations,
+then this ioctl returns
+.Sy -1
+with
+.Va errno
+set to
+.Er ENOTSUP .
+.It Fn ioctl fd MHIOCGRP_INRESV "(mhioc_inresvs_t *)r"
+.Pp
+Issues the SCSI-3 command Persistent Reserve In Read Reservations to the
+device.
+Remarks similar to
+.Dv MHIOCGRP_INKEYS
+apply to the array manipulation.
+If the device does not support SCSI-3 Persistent Reservations,
+then this ioctl returns
+.Sy -1
+with
+.Va errno
+set to
+.Er ENOTSUP .
+.It Fn ioctl fd MHIOCGRP_REGISTER "(mhioc_register_t *)r"
+.Pp
+Issues the SCSI-3 command Persistent Reserve Out Register.
+The fields of structure
+.Va r
+are all inputs; none of the fields are modified by the ioctl.
+The field
+.Fa r->aptpl
+should be set to true to specify that registrations
+and reservations should persist across device power failures, or to false to
+specify that registrations and reservations should be cleared upon device power
+failure; true is the recommended setting.
+The field
+.Fa r->oldkey
+is the key that the caller believes the device may already have for this host
+initiator; if the caller believes that that this host initiator is not already
+registered with this device, it should pass the special key of all zeros.
+To achieve the effect of unregistering with the device, the caller should pass
+its current key for the
+.Fa r->oldkey
+field and an
+.Fa r->newkey
+field containing the special key of all zeros.
+If the device returns the SCSI error code
+Reservation Conflict, this ioctl returns
+.Sy -1
+with
+.Va errno
+set to
+.Er EACCES .
+.It Fn ioctl fd MHIOCGRP_RESERVE "(mhioc_resv_desc_t *)r"
+.Pp
+Issues the SCSI-3 command Persistent Reserve Out Reserve.
+The fields of
+structure
+.Va r
+are all inputs; none of the fields are modified by the ioctl.
+If the device returns the SCSI error code Reservation Conflict, this ioctl
+returns
+.Sy -1
+with
+.Va errno
+set to
+.Er EACCES .
+.It Fn ioctl fd MHIOCGRP_PREEMPTANDABORT "(mhioc_preemptandabort_t *)r"
+.Pp
+Issues the SCSI-3 command Persistent Reserve Out Preempt-And-Abort.
+The fields
+of structure
+.Va r
+are all inputs; none of the fields are modified by the ioctl.
+The key of the victim host is specified by the field
+.Fa r->victim_key .
+The field
+.Fa r->resvdesc
+supplies the preempter's key and the reservation that it is requesting as part
+of the SCSI-3 Preempt-And-Abort command.
+If the device returns the SCSI error code
+Reservation Conflict, this ioctl returns
+.Sy -1
+with
+.Va errno
+set to
+.Er EACCES .
+.It Fn ioctl fd MHIOCGRP_PREEMPT "(mhioc_preemptandabort_t *)r"
+.Pp
+Similar to
+.Dv MHIOCGRP_PREEMPTANDABORT ,
+but instead issues the SCSI-3 command Persistent Reserve Out Preempt.
+(Note: This command is not implemented).
+.It Fn ioctl fd MHIOCGRP_CLEAR "(mhioc_resv_key_t *)r"
+Issues the SCSI-3 command Persistent Reserve Out Clear.
+The input parameter
+.Va r
+is the reservation key of the caller, which should have been already
+registered with the device, by an earlier call to
+.Dv MHIOCGRP_REGISTER .
+.El
+.Pp
+For each device, the non-shared ioctls should not be mixed with the Persistent
+Reserve Out shared ioctls, and vice-versa, otherwise, the underlying device is
+likely to return errors, because SCSI does not permit SCSI-2 reservations to be
+mixed with SCSI-3 reservations on a single device.
+It is, however, legitimate
+to call the Persistent Reserve In ioctls, because these are query only.
+Issuing the
+.Dv MHIOCGRP_INKEYS
+ioctl is the recommended way for a caller to
+determine if the device supports SCSI-3 Persistent Reservations (the ioctl
+will return
+.Sy -1
+with
+.Va errno
+set to
+.Er ENOTSUP
+if the device does not).
+.Ss "MHIOCENFAILFAST Ioctl"
+The
+.Dv MHIOCENFAILFAST
+ioctl is applicable for both non-shared and shared
+disks, and may be used with either the non-shared or shared ioctls.
+.Bl -tag -width 1n
+.It Fn ioctl fd MHIOENFAILFAST "(unsigned int *)millisecs"
+.Pp
+Enables or disables the failfast option in the multihost disk driver and
+enables or disables automatic probing of a multihost disk, described below.
+The argument is an unsigned integer specifying the number of milliseconds to
+wait between executions of the automatic probe function.
+An argument of zero disables the failfast option and disables automatic probing.
+If the
+.Dv MHIOCENFAILFAST
+ioctl is never called, the effect is defined to be that
+both the failfast option and automatic probing are disabled.
+.El
+.Ss "Automatic Probing"
+The
+.Dv MHIOCENFAILFAST
+ioctl sets up a timeout in the driver to periodically
+schedule automatic probes of the disk.
+The automatic probe function works in this manner: The driver is scheduled to
+probe the multihost disk every n milliseconds, rounded up to the next integral
+multiple of the system clock's resolution.
+If
+.Bl -enum -offset indent
+.It
+the local host no longer has access rights to the multihost disk, and
+.It
+access rights were expected to be held by the local host,
+.El
+.Pp
+the driver immediately panics the machine to comply with the failfast model.
+.Pp
+If the driver makes this discovery outside the timeout function, especially
+during a read or write operation, it is imperative that it panic the system
+then as well.
+.Sh RETURN VALUES
+Each request returns
+.Sy -1
+on failure and sets
+.Va errno
+to indicate the error.
+.Bl -tag -width Er
+.It Er EPERM
+Caller is not root.
+.It Er EACCES
+Access rights were denied.
+.It Er EIO
+The multihost disk or controller was unable to successfully complete the
+requested operation.
+.It Er EOPNOTSUP
+The multihost disk does not support the operation.
+For example, it does not support the SCSI-2 Reserve/Release command set, or the
+SCSI-3 Persistent Reservation command set.
+.El
+.Sh STABILITY
+Uncommitted
+.Sh SEE ALSO
+.Xr ioctl 2 ,
+.Xr open 2 ,
+.Xr attributes 7
diff --git a/usr/src/man/man4i/mixer.4i b/usr/src/man/man4i/mixer.4i
new file mode 100644
index 0000000000..6d4487796b
--- /dev/null
+++ b/usr/src/man/man4i/mixer.4i
@@ -0,0 +1,767 @@
+.\" Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
+.\" Copyright 2019, Joyent, Inc.
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd February 1, 2019
+.Dt MIXER 4I
+.Os
+.Sh NAME
+.Nm mixer
+.Nd generic mixer device interface
+.Sh SYNOPSIS
+.In sys/soundcard.h
+.Sh DESCRIPTION
+.Ss "Mixer Pseudo-Device"
+The
+.Pa /dev/mixer
+pseudo-device is provided for two purposes:
+.Bl -bullet -offset indent
+.It
+The first purpose is for applications that wish to learn about the list of
+audio devices on the system, so that they can select (or provide for users to
+select) an appropriate audio device.
+The
+.Pa /dev/mixer
+pseudo-device
+provides interfaces to enumerate all of the audio devices on the system.
+.It
+The second purpose is for mixer panel type applications which need to control
+master settings for the audio hardware in the system, such as gain levels,
+balance, port functionality, and other device features.
+.El
+.Pp
+Ordinary audio applications should
+.Em not
+attempt to adjust their playback
+or record volumes or other device settings using this device.
+Instead, they
+should use the
+.Dv SNDCTL_DSP_SETPLAYVOL
+and
+.Dv SNDCTL_DSP_SETRECVOL
+ioctls that are documented in
+.Xr dsp 4I .
+.Ss "Sndstat Device"
+The
+.Pa /dev/sndstat
+device supports
+.Xr read 2 ,
+and can be read to
+retrieve human-readable information about the audio devices on the system.
+Software should not attempt to interpret the contents of this device.
+.Sh IOCTLS
+.Ss "Information IOCTLs"
+The following ioctls are intended to aid applications in identifying the audio
+devices available on the system.
+These ioctls can be issued against either the
+pseudo-device
+.Pa /dev/mixer ,
+or a against a file descriptor open to any
+other audio device in the system.
+.Pp
+Applications should issue
+.Dv SNDCTL_SYSINFO
+first to learn what audio
+devices and mixers are available on the system, and then use
+.Dv SNDCTL_AUDIOINFO
+or
+.Dv SNDCTL_MIXERINFO
+to obtain more information
+about the audio devices or mixers, respectively.
+.Bl -tag -width SNDCTL_AUDIOINFO
+.It Dv OSS_GETVERSION
+The argument is a pointer to an integer, which retrieves the version of the
+.Sy OSS API
+used.
+The value is encoded with the major version (currently 4)
+encoded in the most significant 16 bits, and a minor version encoded in the
+lower 16 bits.
+.It Dv SNDCTL_SYSINFO
+The argument is a pointer to an
+.Vt oss_sysinfo
+structure, which has the following definition:
+.Bd -literal -offset 2n
+typedef struct oss_sysinfo {
+ char product[32]; /* E.g. SunOS Audio */
+ char version[32]; /* E.g. 4.0a */
+ int versionnum; /* See OSS_GETVERSION */
+ char options[128]; /* NOT SUPPORTED */
+
+ int numaudios; /* # of audio/dsp devices */
+ int openedaudio[8]; /* Reserved, always 0 */
+
+ int numsynths; /* NOT SUPPORTED, always 0 */
+ int nummidis; /* NOT SUPPORTED, always 0 */
+ int numtimers; /* NOT SUPPORTED, always 0 */
+ int nummixers; /* # of mixer devices */
+
+ /* Mask of midi devices are busy */
+ int openedmidi[8];
+
+ /* Number of sound cards in the system */
+ int numcards;
+
+ /* Number of audio engines in the system */
+ int numaudioengines;
+ char license[16]; /* E.g. "GPL" or "CDDL" */
+ char revision_info[256]; /* Reserved */
+ int filler[172]; /* Reserved */
+} oss_sysinfo;
+.Ed
+.Pp
+The important fields here are
+.Fa numaudios ,
+which is used to determine the
+number of audio devices that can be queried with
+.Dv SNDCTL_AUDIOINFO ,
+.Fa nummixers
+which provides a count of mixers on the system, and
+.Fa numcards
+which counts to total number of aggregate devices.
+A
+.Sy card
+can consist of one or more audio devices and one or more mixers, although more
+typically there is exactly one audio device and one mixer for each card.
+.It Dv SNDCTL_AUDIOINFO
+The argument is a pointer to an
+.Vt oss_audioinfo
+structure, which has the following structure:
+.Bd -literal -offset 2n
+typedef struct oss_audioinfo {
+ int dev; /* Device to query */
+ char name[64]; /* Human readable name */
+ int busy; /* reserved */
+ int pid; /* reserved */
+
+ /* PCM_CAP_INPUT, PCM_CAP_OUTPUT */
+ int caps;
+ int iformats; /* Supported input formats */
+ int oformats; /* Supported output formats */
+ int magic; /* reserved */
+ char cmd[64]; /* reserved */
+ int card_number;
+ int port_number; /* reserved */
+ int mixer_dev;
+
+ /* Obsolete field. Replaced by devnode */
+ int legacy_device;
+ int enabled; /* reserved */
+ int flags; /* reserved */
+ int min_rate; /* Minimum sample rate */
+ int max_rate; /* Maximum sample rate */
+ int min_channels; /* Minimum number of channels */
+ int max_channels; /* Maximum number of channels */
+ int binding; /* reserved */
+ int rate_source; /* reserved */
+ char handle[32]; /* reserved */
+ unsigned int nrates; /* reserved */
+ unsigned int rates[20]; /* reserved */
+ char song_name[64]; /* reserved */
+ char label[16]; /* reserved */
+ int latency; /* reserved */
+
+ /* Device special file name (absolute path) */
+ char devnode[32];
+ int next_play_engine; /* reserved */
+ int next_rec_engine; /* reserved */
+ int filler[184]; /* reserved */
+} oss_audioinfo;
+.Ed
+.Pp
+In the above structure, all of the fields are reserved except the following:
+.Fa dev ,
+.Fa name ,
+.Fa card_number ,
+.Fa mixer_dev ,
+.Fa caps ,
+.Fa min_rate ,
+.Fa max_rate ,
+.Fa min_channels ,
+.Fa max_channels ,
+and
+.Fa devnode .
+The reserved fields are provided for compatibility with other OSS
+implementations, and available for legacy applications.
+New applications should not attempt to use these fields.
+.Pp
+The
+.Fa dev
+field should be initialized by the application to the number of
+the device to query.
+This is a number between zero (inclusive) and value of
+.Fa numaudios
+(exclusive) returned by
+.Dv SNDCTL_SYSINFO .
+Alternatively,
+when issuing the ioctl against a real mixer or
+.Sy dsp
+device, the special
+value
+.Sy -1
+can be used to indicate that the query is being made against the device opened.
+If
+.Sy -1
+is used, the field is overwritten with the device
+number for the current device on successful return.
+.Pp
+No other fields are significant upon entry, but a successful return contains
+details of the device.
+.Pp
+The
+.Fa name
+field is a human readable name representing the device.
+Applications should not try to interpret it.
+.Pp
+The
+.Fa card_number
+field indicates the number assigned to the aggregate device.
+This can be used with the
+.Dv SNDCTL_CARDINFO
+ioctl.
+.Pp
+The
+.Fa mixer_dev
+is the mixer device number for the mixing device associated
+with the audio device.
+This can be used with the
+.Dv SNDCTL_MIXERINFO
+ioctl.
+.Pp
+The
+.Fa caps
+field contains any of the bits
+.Dv PCM_CAP_INPUT ,
+.Dv PCM_CAP_OUTPUT ,
+and
+.Dv PCM_CAP_DUPLEX .
+Indicating whether the device
+support input, output, and whether input and output can be used simultaneously.
+All other bits are reserved.
+.Pp
+The
+.Fa min_rate
+and
+.Fa max_rate
+fields indicate the minimum and maximum sample rates supported by the device.
+Most applications should try to use the maximum supported rate for the best
+audio quality and lowest system resource consumption.
+.Pp
+The
+.Fa min_channels
+and
+.Fa max_channels
+provide an indication of the number of channels (1 for mono, 2 for stereo,
+6 for 5\&.1, etc\&.) supported by the device.
+.Pp
+The
+.Fa devnode
+field contains the actual full path to the device node for this device, such as
+.Pa /dev/sound/audio810:0dsp .
+Applications should open this file to access the device.
+.It Dv SNDCTL_CARDINFO
+The argument is a pointer to a
+.Vt struct oss_card_info ,
+which has the following definition:
+.Bd -literal -offset 2n
+typedef struct oss_card_info {
+ int card;
+ char shortname[16];
+ char longname[128];
+ int flags; /* reserved */
+ char hw_info[400];
+ int intr_count; /* reserved */
+ int ack_count; /* reserved */
+ int filler[154];
+} oss_card_info;
+.Ed
+.Pp
+This ioctl is used to query for information about the aggregate audio device.
+.Pp
+The
+.Fa card
+field should be initialized by the application to the number of
+the card to query.
+This is a number between zero
+.Pq inclusive
+and value of
+.Fa numcards
+.Pq exclusive
+returned by
+.Dv SNDCTL_SYSINFO .
+Alternatively,
+when issuing the ioctl against a real mixer or
+.Sy dsp
+device, the special value
+.Sy -1
+can be used to indicate that the query is being made against the device opened.
+If
+.Sy -1
+is used, the field is overwritten with the number
+for the current hardware device on successful return.
+.Pp
+The
+.Fa shortname ,
+.Fa longname ,
+and
+.Fa hw_info
+contain
+.Sy ASCIIZ
+strings describing the device in more detail.
+The
+.Fa hw_info
+member can contain multiple lines of detail, each line ending in a NEWLINE.
+.Pp
+The
+.Fa flag ,
+.Fa intr_count ,
+and
+.Fa ack_count
+fields are not used by this implementation.
+.It Dv SNDCTL_MIXERINFO
+The argument is a pointer to a
+.Vt struct oss_mixer_info ,
+which has the following definition:
+.Bd -literal -offset 2n
+typedef struct oss_mixerinfo {
+ int dev;
+ char id[16]; /* Reserved */
+ char name[32];
+ int modify_counter;
+ int card_number;
+ int port_number; /* Reserved */
+ char handle[32]; /* Reserved */
+ int magic; /* Reserved */
+ int enabled; /* Reserved */
+ int caps; /* Reserved */
+ int flags; /* Reserved */
+ int nrext;
+ int priority;
+
+ /* Deice special file name (absolute path) */
+ char devnode[32];
+ int legacy_device; /* Reserved */
+ int filler[245]; /* Reserved */
+} oss_mixerinfo;
+.Ed
+.Pp
+In the above structure, all of the fields are reserved except the following:
+.Fa dev ,
+.Fa name ,
+.Fa modify_counter ,
+.Fa card_number ,
+.Fa nrext ,
+.Fa priority ,
+and
+.Fa devnode .
+The reserved fields are provided for compatibility with other
+OSS implementations, and available for legacy applications.
+New applications should not attempt to use these fields.
+.Pp
+The
+.Fa dev
+field should be initialized by the application to the number of
+the device to query.
+This is a number between zero inclusive and value of
+.Fa nummixers
+(exclusive) returned by
+.Dv SNDCTL_SYSINFO ,
+or by
+.Dv SNDCTL_MIX_NRMIX .
+Alternatively, when issuing the ioctl against a real mixer or
+.Sy dsp
+device, the special value
+.Sy -1
+can be used to indicate
+that the query is being made against the device opened.
+If
+.Sy -1
+is used,
+the field is overwritten with the mixer number for the current open file on
+successful return.
+.Pp
+No other fields are significant upon entry, but on successful return contains
+details of the device.
+.Pp
+The
+.Fa name
+field is a human readable name representing the device.
+Applications should not try to interpret it.
+.Pp
+The
+.Fa modify_counter
+is changed by the mixer framework each time the
+settings for the various controls or extensions of the device are changed.
+Applications can poll this value to learn if any other changes need to be
+searched for.
+.Pp
+The
+.Fa card_number
+field is the number of the aggregate audio device this
+mixer is located on.
+It can be used with the
+.Dv SNDCTL_CARDINFO
+ioctl.
+.Pp
+The
+.Fa nrext
+field is the number of mixer extensions available on this mixer.
+See the
+.Dv SNDCTL_MIX_NREXT
+description.
+.Pp
+The priority is used by the framework to assign a preference that applications
+can use in choosing a device.
+Higher values are preferable.
+Mixers with priorities less than -1 should never be selected by default.
+.Pp
+The
+.Fa devnode
+field contains the actual full path to the device node for
+the physical mixer, such as
+.Pa /dev/sound/audio810:0mixer .
+Applications
+should open this file to access the mixer settings.
+.El
+.Ss "Mixer Extension IOCTLs"
+The pseudo
+.Pa /dev/mixer
+device supports ioctls that can change the
+oarious settings for the audio hardware in the system.
+.Pp
+Those ioctls should only be used by dedicated mixer applications or desktop
+olumme controls, and not by typical ordinary audio applications such as media
+players.
+Ordinary applications that wish to adjust their own volume settings
+should use the
+.Dv SNDCTL_DSP_SETPLAYVOL
+or
+.Dv SNDCTL_DSP_SETRECVOL
+ioctls for that purpose.
+See
+.Xr dsp 4I
+for more information.
+Ordinary
+applications should never attempt to change master port selection or hardware
+settings such as monitor gain settings.
+.Pp
+The ioctls in this section can only be used to access the mixer device that is
+associated with the current file descriptor.
+.Pp
+Applications should not assume that a single
+.Pa /dev/mixer
+node is able to access any physical settings.
+Instead, they should use the ioctl
+.Dv SNDCTL_MIXERINFO
+to determine the device path for the real mixer device,
+and issue ioctls on a file descriptor opened against the corresponding
+.Fa devnode
+field.
+.Pp
+When a
+.Fa dev
+member is specified in each of the following ioctls, the
+application should specify
+.Sy -1 ,
+although for compatibility the mixer
+allows the application to specify the mixer device number.
+.Pp
+.Bl -tag -width SNDCTL_MIX_ENUMINFO -compact
+.It Dv SNDCTL_MIX_NRMIX
+The argument is a pointer to an integer, which receives the number of mixer
+devices in the system.
+Each can be queried by using its number with the
+.Dv SNDCTL_MIXERINFO
+ioctl.
+The same information is available using the
+.Fa SNDCTL_SYSINFO
+ioctl.
+.Pp
+.It Dv SNDCTL_MIX_NREXT
+The argument is a pointer to an integer.
+On entry, the integer should contain
+the special value
+.Sy -1 .
+On return the argument receives the number of mixer
+extensions (or mixer controls) supported by the mixer device.
+More details
+about each extension can be obtained by
+.Fa SNDCTL_MIX_EXTINFO
+ioctl.
+.Pp
+.It Dv SNDCTL_MIX_EXTINFO
+The argument is a pointer to an
+.Vt oss_mixext
+structure which is defined as follows:
+.Bd -literal -offset 2n
+typedef struct oss_mixext {
+ int dev; /* Mixer device number */
+ int ctrl; /* Extension number */
+ int type; /* Entry type */
+ int maxvalue;
+ int minvalue;
+ int flags;
+ char id[16]; /* Mnemonic ID (internal use) */
+ int parent; /* Entry# of parent (-1 if root) */
+ int dummy; /* NOT SUPPORTED */
+ int timestamp;
+ char data[64]; /* Reserved */
+
+ /* Mask of allowed enum values */
+ unsigned char enum_present[32];
+ int control_no; /* Reserved */
+ unsigned int desc; /* NOT SUPPORTED */
+ char extname[32];
+ int update_counter;
+ int filler[7]; /* Reserved */
+} oss_mixext;
+.Ed
+.Pp
+On entry, the
+.Fa dev
+field should be initialized to the value
+.Sy -1 ,
+and
+the
+.Fa ctrl
+field should be initialized with the number of the extension
+being accessed.
+Between 0, inclusive, and the value returned by
+.Dv SNDCTL_MIX_NREXT ,
+exclusive.
+.Pp
+Mixer extensions are organized as a logical tree, starting with a root node.
+The root node always has a
+.Fa ctrl
+value of zero.
+The structure of the tree can be determined by looking at the parent field,
+which contains the extension number of the parent extension, or
+.Sy -1
+if the extension is the root extension.
+.Pp
+The type indicates the type of extension used.
+This implementation supports the following values:
+.Bl -column -offset 2n "MIXT_STEREOSLIDER" "Enumerated value, 0 to maxvalue"
+.It Dv MIXT_DEVROOT Ta Root node for extension tree
+.It Dv MIXT_GROUP Ta Logical grouping of controls
+.It Dv MXIT_ONOFF Ta Boolean value, 0 = off, 1 = on.
+.It Dv MIXT_ENUM Ta Enumerated value, 0 to maxvalue.
+.It Dv MIXT_MONOSLIDER Ta Monophonic slider, 0 to 255.
+.It Dv MIXT_STEREOSLIDER Ta Stereophonic slider, 0 to 255 (encoded as lower two bytes in value.)
+.It Dv MIXT_MARKER Ta Place holder, can ignore.
+.El
+.Pp
+The flags field is a bit array.
+This implementation makes use of the following
+possible bits:
+.Bl -column -offset 2n "MIXF_WRITEABLE" "Extensions value is modifiable"
+.It Dv MIXF_READABLE Ta Extension's value is readable.
+.It Dv MIXF_WRITEABLE Ta Extension's value is modifiable.
+.It Dv MIXF_POLL Ta Extension can self-update.
+.It Dv MIXF_PCMVOL Ta Extension is for master PCM playback volume.
+.It Dv MIXF_MAINVOL Ta Extension is for a typical analog volume
+.It Dv MIXF_RECVOL Ta Extension is for master record gain.
+.It Dv MIXF_MONVOL Ta Extension is for a monitor source's gain.
+.El
+.Pp
+The
+.Fa id
+field contains an
+.Sy ASCIIZ
+identifier for the extension.
+.Pp
+The timestamp field is set when the extension tree is first initialized.
+Applications must use the same timestamp value when attempting to change the
+values.
+A change in the timestamp indicates a change a in the structure of the
+extension tree.
+.Pp
+The
+.Fa enum_present
+field is a bit mask of possible enumeration values.
+If a
+bit is present in the
+.Fa enum_present
+mask, then the corresponding enumeration value is legal.
+The mask is in little endian order.
+.Pp
+The
+.Fa desc
+field provides information about scoping, which can be useful as
+layout hints to applications.
+The following hints are available:
+.Bl -column -offset 2n "MIXEXT_SCOPE_MONITOR" "No scoping hint provided."
+.It Dv MIXEXT_SCOPE_MASK Ta Mask of possible scope values.
+.It Dv MIXEXT_SCOPE_INPUT Ta Extension is an input control.
+.It Dv MIXEXT_SCOPE_OUTPUT Ta Extension is an output control.
+.It Dv MIXEXT_SCOPE_MONITOR Ta Extension relates to input monitoring.
+.It Dv MIXEXT_SCOPE_OTHER Ta No scoping hint provided.
+.El
+.Pp
+The
+.Fa extname
+is the full name of the extension.
+.Pp
+The
+.Fa update_counter
+is incremented each time the control's value is changed.
+.Pp
+.It Dv SNDCTL_MIX_ENUMINFO
+The argument is a pointer to an
+.Vt oss_mixer_enuminfo
+structure, which is defined as follows:
+.Bd -literal -offset 2n
+typedef struct oss_mixer_enuminfo {
+ int dev;
+ int ctrl;
+ int nvalues;
+ int version;
+ short strindex[255];
+ char strings[3000];
+} oss_mixer_enuminfo;
+.Ed
+.Pp
+On entry, the
+.Fa dev
+field should be initialized to the value
+.Sy -1 ,
+and
+the
+.Fa ctrl
+field should be initialized with the number of the extension being accessed.
+Between 0, inclusive, and the value returned by
+.Dv SNDCTL_MIX_NREXT ,
+exclusive.
+.Pp
+On return the
+.Fa nvalues
+field contains the number of values, and
+.Fa strindex
+contains an array of indices into the strings member, each index
+pointing to an
+.Sy ASCIIZ
+describing the enumeration value.
+.Pp
+.It Dv SNDCTL_MIX_READ
+.It Dv SNDCTL_MIX_WRITE
+The argument is a pointer to an
+.Vt oss_mixer_value
+structure, defined as follows:
+.Bd -literal -offset 2n
+typedef struct oss_mixer_value {
+ int dev;
+ int ctrl;
+ int value;
+
+ /* Reserved for future use. Initialize to 0 */
+ int flags;
+
+ /* Must be set to oss_mixext.timestamp */
+ int timestamp;
+
+ /* Reserved for future use. Initialize to 0 */
+ int filler[8];
+} oss_mixer_value;
+.Pp
+.Ed
+On entry, the
+.Fa dev
+field should be initialized to the value
+.Sy -1 ,
+and the
+.Fa ctrl
+field should be initialized with the number of the extension
+being accessed.
+Between 0, inclusive, and the value returned by
+.Dv SNDCTL_MIX_NREXT ,
+exclusive.
+Additionally, the timestamp member must be
+initialized to the same value as was supplied in the
+.Vt oss_mixext
+structure
+used with
+.Dv SNDCTL_MIX_EXTINFO .
+.Pp
+For
+.Dv SNDCTL_MIX_WRITE ,
+the application should supply the new value for the extension.
+For
+.Dv SNDCTL_MIX_READ ,
+the mixer returns the extensions current value in value.
+.El
+.Ss "Compatibility IOCTLs"
+The following ioctls are for compatibility use only:
+.Pp
+.Bl -tag -offset 2n -width SNDCTL_MIX_ENUMINFO -compact
+.It Dv SOUND_MIXER_READ_VOLUME
+.It Dv SOUND_MIXER_READ_PCM
+.It Dv SOUND_MIXER_READ_OGAIN
+.It Dv SOUND_MIXER_READ_RECGAIN
+.It Dv SOUND_MIXER_READ_RECLEV
+.It Dv SOUND_MIXER_READ_IGAIN
+.It Dv SOUND_MIXER_READ_RECSRC
+.It Dv SOUND_MIXER_READ_RECMASK
+.It Dv SOUND_MIXER_READ_DEVMASK
+.It Dv SOUND_MIXER_READ_STEREODEVS
+.It Dv SOUND_MIXER_WRITE_VOLUME
+.It Dv SOUND_MIXER_WRITE_PCM
+.It Dv SOUND_MIXER_WRITE_OGAIN
+.It Dv SOUND_MIXER_WRITE_RECGAIN
+.It Dv SOUND_MIXER_WRITE_RECLEV
+.It Dv SOUND_MIXER_WRITE_IGAIN
+.It Dv SOUND_MIXER_WRITE_RECSRC
+.It Dv SOUND_MIXER_WRITE_RECMASK
+.It Dv SOUND_MIXER_INFO
+.It Dv SNDCTL_AUDIOINFO_EX
+.It Dv SNDCTL_ENGINEINFO
+.El
+.Pp
+These ioctls can affect the software volume levels associated with the calling
+process.
+They have no effect on the physical hardware levels or settings.
+They should not be used in new applications.
+.Sh FILES
+.Bl -tag -width /dev/sndstat
+.It Pa /dev/mixer
+Symbolic link to the pseudo mixer device for the system
+.It Pa /dev/sndstat
+Sound status device
+.El
+.Sh ERRORS
+An
+.Xr ioctl 2
+fails if:
+.Bl -tag -width EINVAL
+.It Er EINVAL
+The parameter changes requested in the ioctl are invalid or are not supported
+by the device.
+.It Er ENXIO
+The device or extension referenced does not exist.
+.El
+.Sh ARCHITECTURE
+SPARC
+x86
+.Sh INTERFACE STABILITY
+The information and mixer extension IOCTLs are Uncommitted.
+The Compatibility IOCTLs are Obsolete Uncommitted.
+The extension names are Uncommitted.
+.Sh SEE ALSO
+.Xr close 2 ,
+.Xr ioctl 2 ,
+.Xr open 2 ,
+.Xr read 2 ,
+.Xr dsp 4I ,
+.Xr attributes 7
+.Sh BUGS
+The names of mixer extensions are not guaranteed to be predictable.
diff --git a/usr/src/man/man4i/mtio.4i b/usr/src/man/man4i/mtio.4i
new file mode 100644
index 0000000000..93db7028c7
--- /dev/null
+++ b/usr/src/man/man4i/mtio.4i
@@ -0,0 +1,1190 @@
+.\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved
+.\" Copyright 2018, Joyent, Inc.
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd August 28, 2021
+.Dt MTIO 4I
+.Os
+.Sh NAME
+.Nm mtio
+.Nd general magnetic tape interface
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/ioctl.h
+.In sys/mtio.h
+.Sh DESCRIPTION
+1/2", 1/4", 4mm, and 8mm magnetic tape drives all share the same general
+character device interface.
+.Pp
+There are two types of tape records: data records and end-of-file (EOF)
+records.
+.Sy EOF
+records are also known as tape marks and file marks.
+A record is separated by interrecord (or tape) gaps on a tape.
+.Pp
+End-of-recorded-media (EOM) is indicated by two
+.Sy EOF
+marks on 1/2\(dq tape; by one
+.Sy EOF
+mark on 1/4\(dq, 4mm, and 8mm cartridge tapes.
+.Ss "1/2\(dq Reel Tape"
+Data bytes are recorded in parallel onto the 9-track tape.
+Since it is a
+variable-length tape device, the number of bytes in a physical record may vary.
+.Pp
+The recording formats available (check specific tape drive) are 800
+.Sy BPI ,
+1600
+.Sy BPI ,
+6250
+.Sy BPI ,
+and data compression.
+Actual storage capacity is a function of the recording format and the length of the tape reel.
+For example, using a 2400 foot tape, 20 Mbyte can be stored using 800
+.Sy BPI ,
+40 Mbyte using 1600
+.Sy BPI ,
+140 Mbyte using 6250
+.Sy BPI ,
+or up to 700 Mbyte using data compression.
+.Ss "1/4\(dq Cartridge Tape"
+Data is recorded serially onto 1/4\(dq cartridge tape.
+The number of bytes per
+record is determined by the physical record size of the device.
+The I/O request
+size must be a multiple of the physical record size of the device.
+For
+.Sy QIC-11 ,
+.Sy QIC-24 ,
+and
+.Sy QIC-150
+tape drives, the block size is 512 bytes.
+.Pp
+The records are recorded on tracks in a serpentine motion.
+As one track is
+completed, the drive switches to the next and begins writing in the opposite
+direction, eliminating the wasted motion of rewinding.
+Each file, including the last, ends with one file mark.
+.Pp
+Storage capacity is based on the number of tracks the drive is capable of
+recording.
+For example, 4-track drives can only record 20 Mbyte of data on a
+450 foot tape; 9-track drives can record up to 45 Mbyte of data on a tape of
+the same length.
+.Sy QIC-11
+is the only tape format available for 4-track
+tape drives.
+In contrast, 9-track tape drives can use either
+.Sy QIC-24
+or
+.Sy QIC-11 .
+Storage capacity is not appreciably affected by using either format.
+.Sy QIC-24
+is preferable to
+.Sy QIC-11
+because it records a
+reference signal to mark the position of the first track on the tape, and each
+block has a unique block number.
+.Pp
+The
+.Sy QIC-150
+tape drives require
+.Sy DC-6150
+(or equivalent) tape cartridges for writing.
+However, they can read other tape cartridges in
+.Sy QIC-11 ,
+.Sy QIC-24 ,
+or
+.Sy QIC-120
+tape formats.
+.Ss "8mm Cartridge Tape"
+Data is recorded serially onto 8mm helical scan cartridge tape.
+Since it is a
+variable-length tape device, the number of bytes in a physical record may
+vary.
+The recording formats available (check specific tape drive) are standard
+2Gbyte, 5Gbyte, and compressed format.
+.Ss "4mm DAT Tape"
+Data is recorded either in Digital Data Storage (DDS) tape format or in Digital
+Data Storage, Data Compressed (DDS-DC) tape format.
+Since it is a
+variable-length tape device, the number of bytes in a physical record may vary.
+The recording formats available are standard 2Gbyte and compressed format.
+.Ss "Persistent Error Handling"
+Persistent error handling is a modification of the current error handling
+behaviors, BSD and SVR4.
+With persistent error handling enabled, all tape
+operations after an error or exception will return immediately with an error.
+Persistent error handling can be most useful with asynchronous tape operations
+that use the
+.Xr aioread 3C
+and
+.Xr aiowrite 3C
+functions.
+.Pp
+To enable persistent error handling, the ioctl
+.Dv MTIOCPERSISTENT
+must be issued.
+If this ioctl succeeds, then persistent error handling is enabled and
+changes the current error behavior.
+This ioctl will fail if the device driver
+does not support persistent error handling.
+.Pp
+With persistent error handling enabled, all tape operations after an exception
+or error will return with the same error as the first command that failed; the
+operations will not be executed.
+An exception is some event that might stop
+normal tape operations, such as an End Of File (EOF) mark or an End Of Tape
+(EOT) mark.
+An example of an error is a media error.
+The
+.Dv MTIOCLRERR
+ioctl must be issued to allow normal tape operations to continue and to clear
+the error.
+.Pp
+Disabling persistent error handling returns the error behavior to normal SVR4
+error handling, and will not occur until all outstanding operations are
+completed.
+Applications should wait for all outstanding operations to complete
+before disabling persistent error handling.
+Closing the device will also
+disable persistent error handling and clear any errors or exceptions.
+.Pp
+The
+.Sx Read Operation
+and
+.Sx Write Operation
+subsections contain more pertinent information regarding persistent error handling.
+.Ss "Read Operation"
+The
+.Xr read 2
+function reads the next record on the tape.
+The record size is passed back as the number of bytes read, provided it is not
+greater than the number requested.
+When a tape mark or end of data is read, a zero byte count is
+returned; all successive reads after the zero read will return an error and
+.Va errno
+will be set to
+.Er EIO .
+To move to the next file, an
+.Dv MTFSF
+ioctl can be issued before or after the read causing the error.
+This error
+handling behavior is different from the older
+.Sy BSD
+behavior, where another read will fetch the first record of the next tape file.
+If the
+.Sy BSD
+behavior is required, device names containing the letter
+.Ql b
+(for
+.Sy BSD
+behavior) in the final component should be used.
+If persistent error handling
+was enabled with either the BSD or SVR4 tape device behavior, all operations
+after this read error will return
+.Er EIO
+errors until the
+.Dv MTIOCLRERR
+ioctl is issued.
+An
+.Dv MTFSF
+ioctl can then he issued.
+.Pp
+Two successful successive reads that both return zero byte counts indicate
+.Sy EOM
+on the tape.
+No further reading should be performed past the
+.Sy EOM .
+.Pp
+Fixed-length I/O tape devices require the number of bytes read to be a multiple
+of the physical record size.
+For example, 1/4\(dq cartridge tape devices only read
+multiples of 512 bytes.
+If the blocking factor is greater than 64,512 bytes
+(minphys limit), fixed-length I/O tape devices read multiple records.
+.Pp
+Most tape devices which support variable-length I/O operations may read a range
+of 1 to 65,535 bytes.
+If the record size exceeds 65,535 bytes, the driver reads
+multiple records to satisfy the request.
+These multiple records are limited to
+65,534 bytes.
+Newer variable-length tape drivers may relax the above limitation
+and allow applications to read record sizes larger than 65,534.
+Refer to the
+specific tape driver man page for details.
+.Pp
+Reading past logical
+.Sy EOT
+is transparent to the user.
+A read operation
+should never hit physical EOT.
+.Pp
+Read requests that are lesser than a physical tape record are not allowed.
+Appropriate error is returned.
+.Ss "Write Operation"
+The
+.Xr write 2
+function writes the next record on the tape.
+The record has
+the same length as the given buffer.
+.Pp
+Writing is allowed on 1/4" tape at either the beginning of tape or after the
+last written file on the tape.
+With the Exabyte 8200, data may be appended only
+at the beginning of tape, before a filemark, or after the last written file on
+the tape.
+.Pp
+Writing is not so restricted on 1/2\(dq, 4mm, and the other 8mm cartridge tape
+drives.
+Care should be used when appending files onto 1/2\(dq reel tape devices,
+since an extra file mark is appended after the last file to mark the
+.Sy EOM .
+This extra file mark must be overwritten to prevent the creation of a null file.
+To facilitate write append operations, a space to the
+.Sy EOM
+ioctl is provided.
+Care should be taken when overwriting records; the erase head is just
+forward of the write head and any following records will also be erased.
+.Pp
+Fixed-length I/O tape devices require the number of bytes written to be a
+multiple of the physical record size.
+For example, 1/4\(dq cartridge tape devices
+only write multiples of 512 bytes.
+.Pp
+Fixed-length I/O tape devices write multiple records if the blocking factor is
+greater than 64,512 bytes (minphys limit).
+These multiple writes are limited to
+64,512 bytes.
+For example, if a write request is issued for 65,536 bytes using
+a 1/4\(dq cartridge tape, two writes are issued; the first for 64,512 bytes and
+the second for 1024 bytes.
+.Pp
+Most tape devices which support variable-length I/O operations may write a
+range of 1 to 65,535 bytes.
+If the record size exceeds 65,535 bytes, the driver
+writes multiple records to satisfy the request.
+These multiple records are
+limited to 65,534 bytes.
+As an example, if a write request for 65,540 bytes is
+issued, two records are written; one for 65,534 bytes followed by another
+record for 6 bytes.
+Newer variable-length tape drivers may relax the above
+limitation and allow applications to write record sizes larger than 65,534.
+effer to the specific tape driver man page for details.
+.Pp
+When logical
+.Sy EOT
+is encountered during a write, that write operation
+completes and the number of bytes successfully transferred is returned (note
+that a 'short write' may have occurred and not all the requested bytes would
+have been transferred.
+The actual amount of data written will depend on the
+type of device being used).
+The next write will return a zero byte count.
+A third write will successfully transfer some bytes (as indicated by the
+returned byte count, which again could be a short write); the fourth will
+transfer zero bytes, and so on, until the physical
+.Sy EOT
+is reached and all writes will
+fail with
+.Er EIO .
+.Pp
+When logical
+.Sy EOT
+is encountered with persistent error handling enabled,
+the current write may complete or be a short write.
+The next write will return a zero byte count.
+At this point an application should act appropriately for
+end of tape cleanup or issue yet another write, which will return the error
+.Er ENOSPC .
+After clearing the exception with
+.Dv MTIOCLRERR ,
+the next write will succeed (possibly short), followed by another zero byte
+write count, and then another
+.Er ENOSPC
+error.
+.Pp
+Allowing writes after
+.Sy EOT
+has been encountered enables the flushing of buffers.
+However, it is strongly recommended to terminate the writing and close
+the file as soon as possible.
+.Pp
+Seeks are ignored in tape I/O.
+.Ss "Close Operation"
+Magnetic tapes are rewound when closed, except when the "no-rewind" devices
+have been specified.
+The names of no-rewind device files use the letter
+.Ql n
+as the end of the final component.
+The no-rewind version of
+.Pa /dev/rmt/0l
+is
+.Pa /dev/rmt/0ln .
+In case of error for a no-rewind device, the next open rewinds the device.
+.Pp
+If the driver was opened for reading and a no-rewind device has been specified,
+the close advances the tape past the next filemark (unless the current file
+position is at
+.Sy EOM ) ,
+leaving the tape correctly positioned to read the first record of the next file.
+However, if the tape is at the first record of a
+file it doesn't advance again to the first record of the next file.
+These semantics are different from the older
+.Sy BSD
+behavior.
+If
+.Sy BSD
+behavior is required where no implicit space operation is executed on close,
+the non-rewind device name containing the letter
+.Ql b
+(for
+.Sy BSD
+behavior) in the final component should be specified.
+.Pp
+If data was written, a file mark is automatically written by the driver upon
+close.
+If the rewinding device was specified, the tape will be rewound after
+the file mark is written.
+If the user wrote a file mark prior to closing, then
+no file mark is written upon close.
+If a file positioning ioctl, like rewind,
+is issued after writing, a file mark is written before repositioning the tape.
+.Pp
+All buffers are flushed on closing a tape device.
+Hence, it is strongly recommended that the application wait for all buffers to
+be flushed before closing the device.
+This can be done by writing a filemark via
+.Dv MTWEOF ,
+even with a zero count.
+.Pp
+Note that for 1/2\(dq reel tape devices, two file marks are written to mark the
+.Sy EOM
+before rewinding or performing a file positioning ioctl.
+If the user
+wrote a file mark before closing a 1/2\(dq reel tape device, the driver will
+always write a file mark before closing to insure that the end of recorded
+media is marked properly.
+If the non-rewinding device was specified, two file
+marks are written and the tape is left positioned between the two so that the
+second one is overwritten on a subsequent
+.Xr open 2
+and
+.Xr write 2 .
+.Pp
+If no data was written and the driver was opened for
+.Sy WRITE-ONLY
+access, one or two file marks are written, thus creating a null file.
+.Pp
+After closing the device, persistent error handling will be disabled and any
+error or exception will be cleared.
+.Sh IOCTLS
+Not all devices support all
+.Sy ioctls .
+The driver returns an
+.Er ENOTTY
+error on unsupported ioctls.
+.Pp
+The following structure definitions for magnetic tape
+.Xr ioctl 2
+commands are from
+.In sys/mtio.h .
+.Pp
+The minor device byte structure is:
+.Bd -literal
+15 7 6 5 4 3 2 1 0
+________________________________________________________________________
+Unit # BSD Reserved Density Density No rewind Unit #
+Bits 7-15 behavior Select Select on Close Bits 0-1
+.Ed
+.Bd -literal
+/*
+ * Layout of minor device byte:
+ */
+#define MTUNIT(dev) (((minor(dev) & 0xff80) >> 5) + (minor(dev) & 0x3))
+#define MT_NOREWIND (1 <<2)
+#define MT_DENSITY_MASK (3 <<3)
+#define MT_DENSITY1 (0 <<3) /* Lowest density/format */
+#define MT_DENSITY2 (1 <<3)
+#define MT_DENSITY3 (2 <<3)
+#define MT_DENSITY4 (3 <<3) /* Highest density/format */
+#define MTMINOR(unit) (((unit & 0x7fc) << 5) + (unit & 0x3))
+#define MT_BSD (1 <<6) /* BSD behavior on close */
+
+/* Structure for MTIOCTOP - magnetic tape operation command */
+
+struct mtop {
+ short mt_op; /* operation */
+ daddr_t mt_count; /* number of operations */
+};
+
+/* Structure for MTIOCLTOP - magnetic tape operation command */
+Works exactly like MTIOCTOP except passes 64 bit mt_count values.
+struct mtlop {
+ short mt_op;
+ short pad[3];
+ int64_t mt_count;
+};
+.Ed
+.Pp
+The following operations of
+.Dv MTIOCTOP
+and
+.Dv MTIOCLTOP
+ioctls are supported:
+.Pp
+.Bl -tag -width MTIOCGETERROR -compact -offset 2n
+.It Dv MTWEOF
+Write an end-of-file record
+.It Dv MTFSF
+Forward space over file mark
+.It Dv MTBSF
+Backward space over file mark (1/2", 8mm only)
+.It Dv MTFSR
+Forward space to inter-record gap
+.It Dv MTBSR
+Backward space to inter-record gap
+.It Dv MTREW
+Rewind
+.It Dv MTOFFL
+Rewind and take the drive off-line
+.It Dv MTNOP
+No operation, sets status only
+.It Dv MTRETEN
+Retension the tape (cartridge tape only)
+.It Dv MTERASE
+Erase the entire tape and rewind
+.It Dv MTEOM
+Position to EOM
+.It Dv MTNBSF
+Backward space file to beginning of file
+.It Dv MTSRSZ
+Set record size
+.It Dv MTGRSZ
+Get record size
+.It Dv MTTELL
+Get current position
+.It Dv MTSEEK
+Go to requested position
+.It Dv MTFSSF
+Forward to requested number of sequential file marks
+.It Dv MTBSSF
+Backward to requested number of sequential file marks
+.It Dv MTLOCK
+Prevent media removal
+.It Dv MTUNLOCK
+Allow media removal
+.It Dv MTLOAD
+Load the next tape cartridge into the tape drive
+.It Dv MTIOCGETERROR
+Retrieve error records from the st driver
+.El
+.Bd -literal -offset 2n
+/* structure for MTIOCGET - magnetic tape get status command */
+
+struct mtget {
+ short mt_type; /* type of magtape device */
+
+ /* the following two registers are device dependent */
+ short mt_dsreg; /* "drive status" register */
+ short mt_erreg; /* "error" register */
+
+ /* optional error info. */
+ daddr_t mt_resid; /* residual count */
+ daddr_t mt_fileno; /* file number of current position */
+ daddr_t mt_blkno; /* block number of current position */
+ ushort_t mt_flags;
+ short mt_bf; /* optimum blocking factor */
+};
+
+/* structure for MTIOCGETDRIVETYPE - get tape config data command */
+struct mtdrivetype_request {
+ int size;
+ struct mtdrivetype *mtdtp;
+};
+struct mtdrivetype {
+ char name[64]; /* Name, for debug */
+ char vid[25]; /* Vendor id and product id */
+ char type; /* Drive type for driver */
+ int bsize; /* Block size */
+ int options; /* Drive options */
+ int max_rretries; /* Max read retries */
+ int max_wretries; /* Max write retries */
+ uchar_t densities[MT_NDENSITIES]; /* density codes,low->hi */
+ uchar_t default_density; /* Default density chosen */
+ uchar_t speeds[MT_NSPEEDS]; /* speed codes, low->hi */
+ ushort_t non_motion_timeout; /* Seconds for non-motion */
+ ushort_t io_timeout; /* Seconds for data to from tape */
+ ushort_t rewind_timeout; /* Seconds to rewind */
+ ushort_t space_timeout; /* Seconds to space anywhere */
+ ushort_t load_timeout; /* Seconds to load tape and ready */
+ ushort_t unload_timeout; /* Seconds to unload */
+ ushort_t erase_timeout; /* Seconds to do long erase */
+};
+.Ed
+.Bd -literal -offset 2n
+/* structure for MTIOCGETPOS and MTIOCRESTPOS - get/set tape position */
+/*
+ * eof/eot/eom codes.
+ */
+ typedef enum {
+ ST_NO_EOF,
+ ST_EOF_PENDING, /* filemark pending */
+ ST_EOF, /* at filemark */
+ ST_EOT_PENDING, /* logical eot pend. */
+ ST_EOT, /* at logical eot */
+ ST_EOM, /* at physical eot */
+ ST_WRITE_AFTER_EOM /* flag allowing writes after EOM */
+} pstatus;
+
+typedef enum { invalid, legacy, logical } posmode;
+
+typedef struct tapepos {
+ uint64_t lgclblkno; /* Blks from start of partition */
+ int32_t fileno; /* Num. of current file */
+ int32_t blkno; /* Blk number in current file */
+ int32_t partition; /* Current partition */
+ pstatus eof; /* eof states */
+ posmode pmode; /* which pos. data is valid */
+ char pad[4];
+} tapepos_t;
+.Ed
+.Pp
+.Bd -ragged -compact
+If the
+.Fa pmode
+is legacy,
+.Fa fileno
+and
+.Fa blkno
+fields are valid.
+.Pp
+If the
+.Fa pmode
+is logical,
+.Fa lgclblkno
+field is valid.
+.Ed
+.Pp
+The
+.Dv MTWEOF
+ioctl is used for writing file marks to tape.
+Not only does
+this signify the end of a file, but also usually has the side effect of
+flushing all buffers in the tape drive to the tape medium.
+A zero count
+.Dv MTWEOF
+will just flush all the buffers and will not write any file marks.
+Because a successful completion of this tape operation will guarantee that all
+tape data has been written to the tape medium, it is recommended that this tape
+operation be issued before closing a tape device.
+.Pp
+When spacing forward over a record (either data or
+.Sy EOF ) ,
+the tape head is
+positioned in the tape gap between the record just skipped and the next record.
+When spacing forward over file marks (EOF records), the tape head is positioned
+in the tape gap between the next
+.Sy EOF
+record and the record that follows it.
+.Pp
+When spacing backward over a record (either data or
+.Sy EOF ) ,
+the tape head is positioned in the tape gap immediately preceding the tape
+record where the tape head is currently positioned.
+When spacing backward over file marks (EOF records), the tape head is
+positioned in the tape gap preceding the
+.Sy EOF .
+Thus the next read would fetch the
+.Sy EOF .
+.Pp
+Record skipping does not go past a file mark; file skipping does not go past
+the
+.Sy EOM .
+After an
+.Dv MTFSR
+<huge number> command, the driver leaves
+the tape logically positioned
+.Em before
+the
+.Sy EOF .
+A related feature is that
+.Sy EOF Ns s
+remain pending until the tape is closed.
+For example, a program
+which first reads all the records of a file up to and including the \fBEOF\fR
+and then performs an
+.Dv MTFSF
+command will leave the tape positioned just
+after that same
+.Sy EOF ,
+rather than skipping the next file.
+.Pp
+The
+.Dv MTNBSF
+and
+.Dv MTFSF
+operations are inverses.
+Thus, an
+.Dq Dv MTFSF \(mi1
+is equivalent to an
+.Dq Dv MTNBSF 1 .
+An
+.Dq Dv MTNBSF 0
+is the same as
+.Dq Dv MTFSF 0 ;
+both position the tape device at the beginning of the current file.
+.Pp
+.Dv MTBSF
+moves the tape backwards by file marks.
+The tape position will end
+on the beginning of the tape side of the desired file mark.
+An
+.Dq Dv MTBSF 0
+will position the tape at the end of the current file, before the filemark.
+.Pp
+.Dv MTBSR
+and
+.Dv MTFSR
+operations perform much like space file operations,
+except that they move by records instead of files.
+Variable-length I/O devices
+(1/2\(dq reel, for example) space actual records; fixed-length I/O devices space
+physical records (blocks).
+1/4\(dq cartridge tape, for example, spaces 512 byte
+physical records.
+The status ioctl residual count contains the number of files
+or records not skipped.
+.Pp
+.Dv MTFSSF
+and
+.Dv MTBSSF
+space forward or backward, respectively, to the next
+occurrence of the requested number of file marks, one following another.
+If there are more sequential file marks on tape than were requested, it spaces
+over the requested number and positions after the requested file mark.
+Note that not all drives support this command and if a request is sent to a
+drive that does not,
+.Er ENOTTY
+is returned.
+.Pp
+.Dv MTOFFL
+rewinds and, if appropriate, takes the device off-line by unloading the tape.
+It is recommended that the device be closed after offlining
+and then re-opened after a tape has been inserted to facilitate portability to
+other platforms and other operating systems.
+Attempting to re-open the device
+with no tape will result in an error unless the
+.Dv O_NDELAY
+flag is used.
+.Po
+See
+.Xr open 2 .
+.Pc
+.Pp
+The
+.Dv MTRETEN
+retension ioctl applies only to 1/4\(dq cartridge tape devices.
+It is used to restore tape tension, improving the tape's soft error rate after
+extensive start-stop operations or long-term storage.
+.Pp
+.Dv MTERASE
+rewinds the tape, erases it completely, and returns to the
+beginning of tape.
+Erasing may take a long time depending on the device and/or
+tapes.
+For time details, refer to the drive specific manual.
+.Pp
+.Dv MTEOM
+positions the tape at a location just after the last file written
+on the tape.
+For 1/4\(dq cartridge and 8mm tape, this is after the last file mark
+on the tape.
+For 1/2\(dq reel tape, this is just after the first file mark but
+before the second (and last) file mark on the tape.
+Additional files can then
+be appended onto the tape from that point.
+.Pp
+Note the difference between
+.Dv MTBSF
+(backspace over file mark) and
+.Dv MTNBSF
+(backspace file to beginning of file).
+The former moves the tape
+backward until it crosses an
+.Sy EOF
+mark, leaving the tape positioned
+.Em before
+the file mark.
+The latter leaves the tape positioned
+.Em after
+the file mark.
+Hence,
+.Dq Dv MTNBSF n
+is equivalent to
+.Dq Dv MTBSF (n+1)
+followed by
+.Dq Dv MTFSF 1 .
+The 1/4\(dq cartridge tape devices do not support
+.Dv MTBSF .
+.Pp
+.Dv MTSRSZ
+and
+.Dv MTGRSZ
+are used to set and get fixed record lengths.
+The
+.Dv MTSRSZ
+ioctl allows variable length and fixed length tape drives that
+support multiple record sizes to set the record length.
+The
+.Fa mt_count
+field of the
+.Vt mtop
+struct is used to pass the record size to/from the
+.Xr st 4D
+driver.
+A value of
+.Ql 0
+indicates variable record size.
+The
+.Dv MTSRSZ
+ioctl makes a variable-length tape device behave like a
+fixed-length tape device.
+Refer to the specific tape driver man page for
+details.
+.Pp
+.Dv MTLOAD
+loads the next tape cartridge into the tape drive.
+This is generally only used with stacker and tower type tape drives which handle
+multiple tapes per tape drive.
+A tape device without a tape inserted can be
+opened with the
+.Dv O_NDELAY
+flag, in order to execute this operation.
+.Pp
+.Dv MTIOCGETERROR
+allows user-level applications to retrieve error records
+from the
+.Xr st 4D
+driver.
+An error record consists of the SCSI command cdb
+which causes the error and a
+.Xr scsi_arq_status 9S
+structure if available.
+The user-level application is responsible for allocating and releasing the
+memory for
+.Fa mtee_cdb_buf
+and
+.Fa scsi_arq_status of each
+.Vt mterror_entry .
+Before issuing the ioctl, the
+.Fa mtee_arq_status_len
+value should be at least equal to
+.Ql sizeof (struct scsi_arq_status) .
+If more sense data than the size of
+.Xr scsi_arq_status 9S
+is desired, the
+.Fa mtee_arq_status_len
+may be larger than
+.Ql sizeof (struct scsi_arq_status)
+by the amount of additional extended sense data desired.
+The
+.Fa es_add_len
+field of
+.Xr scsi_extended_sense 9S
+can be used to determine the amount of valid sense data returned by the device.
+.Pp
+The
+.Dv MTIOCGET
+get status
+.Xr ioctl 2
+call returns the drive ID
+.Pq Fa mt_type ,
+sense key error
+.Pq Fa mt_erreg ,
+file number
+.Pq Fa mt_fileno ,
+optimum blocking factor
+.Pq Fa mt_bf
+and record number
+.Pq Fa mt_blkno
+of the last error.
+The residual count
+.Pq Fa mt_resid
+is set to the number of bytes not transferred or files/records not spaced.
+The flags word
+.Pq Fa mt_flags
+contains information indicating if the device is SCSI, if the device is a reel
+device and whether the device supports absolute file positioning.
+The
+.Fa mt_flags
+also indicates if the device is requesting cleaning media be used, whether the
+device is capable of reporting the requirement of cleaning media and if the
+currently loaded media is WORM (Write Once Read Many) media.
+.Pp
+Note \(em When tape alert cleaning is managed by the st driver, the tape
+target driver may continue to return a
+.Dq drive needs cleaning
+status unless an
+.Dv MTIOCGE
+.Xr ioctl 2
+call is made while the cleaning media is in the drive.
+.Pp
+The
+.Dv MTIOCGETDRIVETYPE
+get drivetype ioctl call returns the name of the
+tape drive as defined in
+.Pa st.conf
+.Pq Fa name ,
+Vendor
+.Sy ID
+and model
+.Pq Fa product ,
+.Sy ID
+.Pq Fa vid ,
+type of tape device
+.Pq Fa type ,
+block size
+.Pq Fa size ,
+drive options
+.Pq Fa options ,
+maximum read retry count
+.Pq Fa max_rretries ,
+maximum write retry count
+.Pq Fa max_wretries ,
+densities supported by the drive
+.Pq Fa densities ,
+and default density of the tape drive
+.Pq Fa default_density .
+.Pp
+The
+.Dv MTIOCGETPOS
+ioctl returns the current tape position of the drive.
+It is returned in struct tapepos as defined in
+.Pa /usr/include/sys/scsi/targets/stdef.h .
+.Pp
+The
+.Dv MTIOCRESTPOS
+ioctl restores a saved position from the
+.Dv MTIOCGETPOS .
+.Ss "Persistent Error Handling IOCTLs and Asynchronous Tape Operations"
+.Bl -tag -width MTIOCPERSISTENTSTATUS -compact
+.It Dv MTIOCPERSISTENT
+enables/disables persistent error handling
+.It Dv MTIOCPERSISTENTSTATUS
+queries for persistent error handling
+.It Dv MTIOCLRERR
+clears persistent error handling
+.It Dv MTIOCGUARANTEEDORDER
+checks whether driver guarantees order of I/O's
+.El
+.Pp
+The
+.Dv MTIOCPERSISTENT
+ioctl enables or disables persistent error handling.
+It takes as an argument a pointer to an integer that turns it either on or off.
+If the ioctl succeeds, the desired operation was successful.
+It will wait for
+all outstanding I/O's to complete before changing the persistent error handling
+status.
+For example,
+.Bd -literal -offset 2n
+int on = 1;
+ioctl(fd, MTIOCPERSISTENT, &on);
+int off = 0;
+ioctl(fd, MTIOCPERSISTENT, &off);
+.Ed
+.Pp
+The
+.Dv MTIOCPERSISTENTSTATUS
+ioctl enables or disables persistent error
+handling.
+It takes as an argument a pointer to an integer inserted by the
+driver.
+The integer can be either 1 if persistent error handling is
+.Sq on ,
+or 0 if persistent error handling is
+.Sq off .
+It will not wait for outstanding I/O's.
+For example,
+.Bd -literal -offset 2n
+int query;
+ioctl(fd, MTIOCPERSISTENTSTATUS, &query);
+.Ed
+.Pp
+The
+.Dv MTIOCLRERR
+ioctl clears persistent error handling and allows tape
+operations to continual normally.
+This ioctl requires no argument and will
+always succeed, even if persistent error handling has not been enabled.
+It will wait for any outstanding I/O's before it clears the error.
+.Pp
+The
+.Dv MTIOCGUARANTEEDORDER
+ioctl is used to determine whether the driver
+guarantees the order of I/O's.
+It takes no argument.
+If the ioctl succeeds, the driver will support guaranteed order.
+If the driver does not support guaranteed order, then it should not be used
+for asynchronous I/O with
+.Xr libaio 3lib .
+It will wait for any outstanding I/O's before it returns.
+For example,
+.Bd -literal -offset 2n
+ioctl(fd, MTIOCGUARANTEEDORDER)
+.Ed
+.Pp
+See the
+.Sx Persistent Error Handling
+subsection above for more information on persistent error handling.
+.Ss "Asynchronous and State Change IOCTLS"
+.Bl -tag -width 1n
+.It Dv MTIOCSTATE
+This ioctl blocks until the state of the drive, inserted or ejected, is
+changed.
+The argument is a pointer to a
+.Vt enum mtio_state ,
+whose possible enumerations are listed below.
+The initial value should be either the last reported state of the drive, or
+.Dv MTIO_NONE .
+Upon return, the
+enum pointed to by the argument is updated with the current state of the drive.
+.Bd -literal -offset 2n
+enum mtio_state {
+ MTIO_NONE /* Return tape's current state */
+ MTIO_EJECTED /* Tape state is "ejected" */
+ MTIO_INSERTED /* Tape state is "inserted" */
+};
+.Ed
+.El
+.Pp
+When using asynchronous operations, most ioctls will wait for all outstanding
+commands to complete before they are executed.
+.Ss "IOCTLS for Multi-initiator Configurations"
+.Bl -tag -width MTIOCFORCERESERVE -compact
+.It Dv MTIOCRESERVE
+reserve the tape drive
+.It Dv MTIOCRELEASE
+revert back to the default behavior of reserve on open/release on close
+.It Dv MTIOCFORCERESERVE
+reserve the tape unit by breaking reservation held by another host
+.El
+.Pp
+The
+.Dv MTIOCRESERVE
+ioctl reserves the tape drive such that it does not
+release the tape drive at close.
+This changes the default behavior of releasing the device upon close.
+Reserving the tape drive that is already reserved has no effect.
+For example,
+.Bd -literal -offset 2n
+ioctl(fd, MTIOCRESERVE);
+.Ed
+.Pp
+The
+.Dv MTIOCRELEASE
+ioctl reverts back to the default behavior of reserve on
+open/release on close operation, and a release will occur during the next
+close.
+Releasing the tape drive that is already released has no effect.
+For example,
+.Bd -literal -offset 2n
+ioctl(fd, MTIOCRELEASE);
+.Ed
+.Pp
+The
+.Dv MTIOCFORCERESERVE
+ioctl breaks a reservation held by another host, interrupting any I/O in
+progress by that other host, and then reserves the tape unit.
+This ioctl can be executed only with super-user privileges.
+It is recommended to open the tape device in
+.Dv O_NDELAY
+mode when this ioctl needs to be executed, otherwise the open will fail if
+another host indeed has it reserved.
+For example,
+.Bd -literal -offset 2n
+ioctl(fd, MTIOCFORCERESERVE);
+.Ed
+.Ss "IOCTLS for Handling Tape Configuration Options"
+.Bl -tag -width MTIOCREADIGNOREEOFS
+.It Dv MTIOCSHORTFMK
+enables/disables support for writing short filemarks.
+This is specific to Exabyte drives.
+.It Dv MTIOCREADIGNOREILI
+enables/disables suppress incorrect length indicator (SILI) support during reads
+.It Dv MTIOCREADIGNOREEOFS
+enables/disables support for reading past two EOF marks which otherwise indicate
+End-Of-recording-Media (EOM) in the case of 1/2\(dq reel tape drives
+.El
+.Pp
+The
+.Dv MTIOCSHORTFMK
+ioctl enables or disables support for short filemarks.
+This ioctl is only applicable to Exabyte drives which support short filemarks.
+As an argument, it takes a pointer to an integer.
+If 0 (zero) is the specified integer, then long filemarks will be written.
+If 1 is the specified integer, then short filemarks will be written.
+The specified tape behavior will be in effect until the device is closed.
+.Pp
+For example:
+.Bd -literal -offset 2n
+int on = 1;
+int off = 0;
+/* enable short filemarks */
+ioctl(fd, MTIOSHORTFMK, &on);
+/* disable short filemarks */
+ioctl(fd, MTIOCSHORTFMK, &off);
+.Ed
+.Pp
+Tape drives which do not support short filemarks will return an
+.Va errno
+of
+.Er ENOTTY .
+.Pp
+The
+.Dv MTIOCREADIGNOREILI
+ioctl enables or disables the suppress incorrect
+length indicator (SILI) support during reads.
+As an argument, it takes a pointer to an integer.
+If 0 (zero) is the specified integer, SILI will not be
+used during reads and incorrect length indicator will not be suppressed.
+If 1 is the specified integer, SILI will be used during reads and incorrect
+length indicator will be suppressed.
+The specified tape behavior will be in effect until the device is closed.
+.Pp
+For example:
+.Bd -literal -offset 2n
+int on = 1;
+int off = 0;
+ioctl(fd, MTIOREADIGNOREILI, &on);
+ioctl(fd, MTIOREADIGNOREILI, &off);
+.Ed
+.Pp
+The
+.Dv MTIOCREADIGNOREEOFS
+ioctl enables or disables support for reading
+past double EOF marks which otherwise indicate End-Of-recorded-media (EOM) in
+the case of 1/2\(dq reel tape drives.
+As an argument, it takes a pointer to an integer.
+If 0 (zero) is the specified integer, then double EOF marks indicate
+End-Of-recorded-media (EOM).
+If 1 is the specified integer, the double EOF marks no longer indicate EOM,
+thus allowing applications to read past two EOF marks.
+In this case it is the responsibility of the application to detect
+End-Of-recorded-media (EOM).
+The specified tape behavior will be in effect until the device is closed.
+.Pp
+For example:
+.Bd -literal -offset 2n
+int on = 1;
+int off = 0;
+ioctl(fd, MTIOREADIGNOREEOFS, &on);
+ioctl(fd, MTIOREADIGNOREEOFS, &off);
+.Ed
+.Pp
+Tape drives other than 1/2\(dq reel tapes will return an
+.Va errno
+of
+.Er ENOTTY .
+.Sh FILES
+.Pa /dev/rmt/ Ns Ao unit number Ac \
+ Ns Ao density Ac \
+ Ns Bo Ao BSD behavior Ac Bc \
+ Ns Bo Ao no rewind Ac Bc
+.Pp
+Where
+.Aq density
+can be
+.Ql l ,
+.Ql m ,
+.Ql h ,
+.Ql u/c
+(low, medium, high, ultra/compressed, respectively), the
+.Aq BSD behavior
+option is
+.Ql b , and the
+.Aq no rewind
+option is
+.Ql n .
+.Pp
+For example,
+.Pa /dev/rmt/0hbn
+specifies unit 0, high density,
+.Sy BSD
+behavior and no rewind.
+.Sh EXAMPLES
+.Bl -inset
+.It Sy Example 1
+Tape Positioning and Tape Drives
+.Pp
+Suppose you have written three files to the non-rewinding 1/2\(dq tape device,
+.Pa /dev/rmt/0ln ,
+and that you want to go back and
+.Xr dd 8
+the second file off the tape.
+The commands to do this are:
+.Bd -literal -offset 2n
+mt -F /dev/rmt/0lbn bsf 3
+mt -F /dev/rmt/0lbn fsf 1
+dd if=/dev/rmt/0ln
+.Ed
+.Pp
+To accomplish the same tape positioning in a C program, followed by a get
+status ioctl:
+.Bd -literal -offset 2n
+struct mtop mt_command;
+struct mtget mt_status;
+mt_command.mt_op = MTBSF;
+mt_command.mt_count = 3;
+ioctl(fd, MTIOCTOP, &mt_command);
+mt_command.mt_op = MTFSF;
+mt_command.mt_count = 1;
+ioctl(fd, MTIOCTOP, &mt_command);
+ioctl(fd, MTIOCGET, (char *)&mt_status);
+.Ed
+.Pp
+or
+.Bd -literal -offset 2n
+mt_command.mt_op = MTNBSF;
+mt_command.mt_count = 2;
+ioctl(fd, MTIOCTOP, &mt_command);
+ioctl(fd, MTIOCGET, (char *)&mt_status);
+.Ed
+.Pp
+To get information about the tape drive:
+.Bd -literal -offset 2n
+struct mtdrivetype mtdt;
+struct mtdrivetype_request mtreq;
+mtreq.size = sizeof(struct mtdrivetype);
+mtreq.mtdtp = &mtdt;
+ioctl(fd, MTIOCGETDRIVETYPE, &mtreq);
+.Ed
+.El
+.Sh SEE ALSO
+.Xr mt 1 ,
+.Xr tar 1 ,
+.Xr open 2 ,
+.Xr read 2 ,
+.Xr write 2 ,
+.Xr aioread 3C ,
+.Xr aiowrite 3C ,
+.Xr ar.h 3HEAD ,
+.Xr st 4D ,
+.Xr dd 8
+.Pp
+.%T 1/4 Inch Tape Drive Tutorial
diff --git a/usr/src/man/man4i/prnio.4i b/usr/src/man/man4i/prnio.4i
new file mode 100644
index 0000000000..be44b17a66
--- /dev/null
+++ b/usr/src/man/man4i/prnio.4i
@@ -0,0 +1,370 @@
+.\" Copyright (c) 20002 Sun Microsystems, Inc.
+.\" All Rights Reserved.
+.\" Copyright 2018, Joyent, Inc.
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd August 31, 2018
+.Dt PRNIO 4I
+.Os
+.Sh NAME
+.Nm prnio
+.Nd generic printer interface
+.Sh SYNOPSIS
+.In sys/prnio.h
+.Sh DESCRIPTION
+The
+.Nm
+generic printer interface defines ioctl commands and data
+structures for printer device drivers.
+.Pp
+.Nm
+defines and provides facilities for five basic phases of the printing process:
+.Bl -bullet -offset indent
+.It
+Identification \(em Retrieve device information/attributes
+.It
+Setup \(em Set device attributes
+.It
+Transfer \(em Transfer data to or from the device
+.It
+Cleanup \(em Transfer phase conclusion
+.It
+Abort \(em Transfer phase interruption
+.El
+.Pp
+During the Identification phase, the application retrieves a set of device
+capabilities and additional information using the
+.Dv PRNIOC_GET_IFCAP ,
+.Dv PRNIOC_GET_STATUS ,
+.Dv PRNIOC_GET_TIMEOUTS ,
+.Dv PRNIOC_GET_IFINFO ,
+and
+.Dv PRNIOC_GET_1284_DEVID
+commands.
+.Pp
+During the Setup phase the application sets some interface attributes and
+probably resets the printer as described in the
+.Dv PRNIOC_SET_IFCAP ,
+.Dv PRNIOC_SET_TIMEOUTS ,
+and
+.Dv PRNIOC_RESET
+sections.
+.Pp
+During the Transfer phase, data is transferred in a forward (host to
+peripheral) or reverse direction (peripheral to host).
+Transfer is accomplished
+using
+.Xr write 2
+and
+.Xr read 2
+system calls.
+For
+.Nm
+compliant
+printer drivers, forward transfer support is mandatory, while reverse transfer
+support is optional.
+Applications can also use
+.Dv PRNIOC_GET_STATUS
+and
+.Dv PRNIOC_GET_1284_STATUS
+commands during the transfer to monitor the device state.
+.Pp
+The Cleanup phase is accomplished by closing the device using
+.Xr close 2 .
+Device drivers supporting
+.Nm
+may set non-zero error code as appropriate.
+Applications should explicitly
+.Xr close 2
+a device before
+exiting and check
+.Va errno
+value.
+.Pp
+The Abort phase is accomplished by interrupting the
+.Xr write 2
+and
+.Xr read 2
+system calls.
+The application can perform some additional cleanup
+during the Abort phase as described in
+.Dv PRNIOC_GET_IFCAP
+section.
+.Sh IOCTLS
+.Bl -tag -width PRNIOC_GET_IFINFO
+.It Dv PRNIOC_GET_IFCAP
+Application can retrieve printer interface capabilities using this command.
+The
+.Xr ioctl 2
+argument is a pointer to
+.Vt uint_t ,
+a bit field representing
+a set of properties and services provided by a printer driver.
+Set bit means supported capability.
+The following values are defined:
+.Bl -tag -width PRN_1284_STATUS
+.It Dv PRN_BIDI
+When this bit is set, the interface operates in a
+bidirectional mode, instead of forward-only mode.
+.It Dv PRN_HOTPLUG
+If this bit is set, the interface allows device hot-plugging.
+.It Dv PRN_1284_DEVID
+If this bit is set, the device is capable of returning
+.Em 1284
+device ID (see
+.Dv PRNIOC_GET_1284_DEVID ) .
+.It Dv PRN_1284_STATUS
+If this bit is set, the device driver can return device
+status lines (see
+.Dv PRNIOC_GET_1284_STATUS ) .
+Some devices support this
+ioctl in unidirectional mode only.
+.It Dv PRN_TIMEOUTS
+If this bit is set the peripheral may stall during the
+transfer phase and the driver can timeout and return from the
+.Xr write 2
+and
+.Xr read 2
+returning the number of bytes that have been transferred.
+If
+.Dv PRN_TIMEOUTS
+is set, the driver supports this functionality and the
+timeout values can be retrieved and modified via the
+.Dv PRNIOC_GET_TIMEOUTS
+and
+.Dv PRNIOC_SET_TIMEOUTS
+ioctls.
+Otherwise, applications can implement
+their own timeouts and abort phase.
+.It Dv PRN_STREAMS
+This bit impacts the application abort phase behaviour.
+If the device claimed
+.Dv PRN_STREAMS
+capability, the application must issue an
+.Dv I_FLUSH
+.Xr ioctl 2
+before
+.Xr close 2
+to dismiss the untransferred
+data.
+Only STREAMS drivers can support this capability.
+.El
+.It Dv PRNIOC_SET_IFCAP
+This ioctl can be used to change interface capabilities.
+The argument is a pointer to
+.Vt uint_t
+bit field that is described in detail in the
+.Dv PRNIOC_GET_IFCAP
+section.
+Capabilities should be set one at a time;
+otherwise the command will return
+.Er EINVAL .
+The following capabilities can be changed by this ioctl:
+.Bl -tag -width PRN_BIDI
+.It Dv PRN_BIDI
+When this capability is set, the interface operates in a
+bidirectional mode, instead of forward-only mode.
+Devices that support only one
+mode will not return error; applications should use
+.Dv PRNIOC_GET_IFCAP
+to check if the mode was successfully changed.
+Because some capabilities may be
+altered as a side effect of changing other capabilities, this command should be
+followed by
+.Dv PRNIOC_GET_IFCAP .
+.El
+.It Dv PRNIOC_GET_IFINFO
+This command can be used to retrieve printer interface info string, which is an
+arbitrary format string usually describing the bus type.
+The argument is a
+pointer to
+.Vt struct prn_interface_info
+as described below.
+.Bd -literal -offset 2n
+struct prn_interface_info {
+ uint_t if_len; /* length of buffer */
+ uint_t if_rlen; /* actual info length */
+ char *if_data; /* buffer address */
+};
+.Ed
+.Pp
+The application allocates a buffer and sets
+.Fa if_data
+and
+.Fa if_len
+values to its address and length, respectively.
+The driver returns the string
+to this buffer and sets
+.Fa if_len
+to its length.
+If
+.Fa if_len
+is less
+than
+.Fa if_rlen ,
+the driver must return the first
+.Fa if_len
+bytes of the string.
+The application may then repeat the command with a bigger buffer.
+.Pp
+Although
+.Nm
+does not limit the contents of the interface info string,
+some values are recommended and defined in
+.In sys/prnio.h
+by the following macros:
+.Pp
+.Bl -tag -width PRN_PARALLEL -compact
+.It Dv PRN_PARALLEL
+Centronics or
+.Em IEEE 1284
+compatible devices
+.It Dv PRN_SERIAL
+EIA-232/EIA-485 serial ports
+.It Dv PRN_USB
+Universal Serial Bus printers
+.It Dv PRN_1394
+.Em IEEE 1394
+peripherals
+.El
+.Pp
+Printer interface info string is for information only: no implications should
+be made from its value.
+.It Dv PRNIOC_RESET
+Some applications may want to reset the printer state during Setup and/or
+Cleanup phase using
+.Dv PRNIOC_RESET
+command.
+Reset semantics are
+device-specific, and in general, applications using this command should be
+aware of the printer type.
+.Pp
+Each
+.Nm
+compliant driver is required to accept this request, although
+performed actions are completely driver-dependent.
+More information on the
+.Dv PRNIOC_RESET
+implementation for the particular driver is available in the
+corresponding man page and printer manual.
+.It Dv PRNIOC_GET_1284_DEVID
+This command can be used to retrieve printer device ID as defined by
+.Em IEEE 1284-1994 .
+The
+.Xr ioctl 2
+argument is a pointer to
+.Vt struct prn_1284_device_id
+as described below.
+.Bd -literal -offset 2n
+struct prn_1284_device_id {
+ uint_t id_len; /* length of buffer */
+ uint_t id_rlen; /* actual ID length */
+ char *id_data; /* buffer address */
+};
+.Ed
+.Pp
+For convenience, the two-byte length field is not considered part of device ID
+string and is not returned in the user buffer.
+Instead,
+.Fa id_rlen
+value shall be set to (length - 2) by the driver, where length is the ID
+length field value.
+If buffer length is less than
+.Fa id_rlen ,
+the driver returns the first
+.Fa id_len
+bytes of the ID.
+.Pp
+The printer driver must return the most up-to-date value of the device ID.
+.It Dv PRNIOC_GET_STATUS
+This command can be used by applications to retrieve current device status.
+The argument is a pointer to
+.Vt uint_t ,
+where the status word is returned.
+Status is a combination of the following bits:
+.Bl -tag -width PRN_ONLINE
+.It Dv PRN_ONLINE
+For devices that support
+.Dv PRN_HOTPLUG
+capability, this bit is set when the device is online, otherwise the device is
+offline.
+Devices without
+.Dv PRN_HOTPLUG
+support should always have this bit set.
+.It Dv PRN_READY
+This bit indicates if the device is ready to receive/send data.
+Applications may use this bit for an outbound flow control.
+.El
+.It Dv PRNIOC_GET_1284_STATUS
+Devices that support
+.Dv PRN_1284_STATUS
+capability accept this ioctl to
+retrieve the device status lines defined in
+.Em IEEE 1284
+for use in Compatibility mode.
+The following bits may be set by the driver:
+.Pp
+.Bl -tag -width PRN_1284_NOFAULT -compact
+.It Dv PRN_1284_NOFAULT
+Device is not in error state
+.It Dv PRN_1284_SELECT
+Device is selected
+.It Dv PRN_1284_PE
+Paper error
+.It Dv PRN_1284_BUSY
+Device is busy
+.El
+.It Dv PRNIOC_GET_TIMEOUTS
+This command retrieves current transfer timeout values for the driver.
+The argument is a pointer to
+.Vt struct prn_timeouts
+as described below.
+.Bd -literal -offset 2n
+struct prn_timeouts {
+ uint_t tmo_forward; /* forward transfer timeout */
+ uint_t tmo_reverse; /* reverse transfer timeout */
+};
+.Ed
+.Pp
+.Fa tmo_forward
+and
+.Fa tmo_reverse
+define forward and reverse transfer timeouts in seconds.
+This command is only valid for drivers that support
+.Dv PRN_TIMEOUTS
+capability.
+.It Dv PRNIOC_SET_TIMEOUTS
+This command sets current transfer timeout values for the driver.
+The argument is a pointer to
+.Vt struct prn_timeouts .
+See
+.Sx PRNIOC_GET_TIMEOUTS
+for description of this structure.
+This command is only valid for drivers that support
+.Dv PRN_TIMEOUTS
+capability.
+.El
+.Sh SEE ALSO
+.Xr close 2 ,
+.Xr ioctl 2 ,
+.Xr read 2 ,
+.Xr write 2 ,
+.Xr ecpp 4D ,
+.Xr lp 4D ,
+.Xr usbprn 4D ,
+.Xr attributes 7
+.Rs
+.%T IEEE Std 1284-1994
+.Re
diff --git a/usr/src/man/man4i/quotactl.4i b/usr/src/man/man4i/quotactl.4i
new file mode 100644
index 0000000000..47ede04ec9
--- /dev/null
+++ b/usr/src/man/man4i/quotactl.4i
@@ -0,0 +1,227 @@
+.\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved
+.\" Copyright (c) 2017, Joyent, Inc.
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd October 28, 2017
+.Dt QUOTACTL 4I
+.Os
+.Sh NAME
+.Nm quotactl
+.Nd manipulate disk quotas
+.Sh SYNOPSIS
+.In sys/fs/ufs_quota.h
+.Fn "int ioctl" "int fd" "Q_QUOTACTL" "struct quotctl *qp"
+.Sh DESCRIPTION
+This
+.Fn ioctl
+call manipulates disk quotas.
+.Fa fd
+is the file descriptor returned by the
+.Xr open 2
+system call after opening the
+.Pa quotas
+file (located in the root directory of the filesystem running quotas).
+.Dv Q_QUOTACTL
+is defined in
+.Pa /usr/include/sys/fs/ufs_quota.h .
+.Fa qp
+is the address of the
+.Vt quotctl
+structure which is defined as
+.Bd -literal -offset 2n
+struct quotctl {
+ int op;
+ uid_t uid;
+ caddr_t addr;
+};
+.Ed
+.Pp
+.Fa op
+indicates an operation to be applied to the user
+.Sy ID
+.Fa uid .
+.Po
+See below.
+.Pc
+.Fa addr
+is the address of an optional, command specific, data
+structure which is copied in or out of the system.
+The interpretation of
+.Fa addr
+is given with each value of
+.Fa op
+below.
+.Bl -tag -width Q_GETQUOTA
+.It Sy Q_QUOTAON
+Turn on quotas for a file system.
+.Fa addr
+points to the full pathname of the
+.Pa quotas
+file.
+.Fa uid
+is ignored.
+It is recommended that
+.Fa uid
+have the value of
+.Sy 0 .
+This call is restricted to the super-user.
+.It Dv Q_QUOTAOFF
+Turn off quotas for a file system.
+.Fa addr
+and
+.Fa uid
+are ignored.
+It is
+recommended that
+.Fa addr
+have the value of
+.Sy NULL
+and
+.Fa uid
+have the value of
+.Sy 0 .
+This call is restricted to the super-user.
+.It Dv Q_GETQUOTA
+Get disk quota limits and current usage for user
+.Fa uid .
+.Fa addr
+is a pointer to a
+.Vt dqblk
+structure
+.Po
+defined in
+.In sys/fs/ufs_quota.h
+.Pc .
+Only the super-user may get the quotas of a user other than himself.
+.It Dv Q_SETQUOTA
+Set disk quota limits and current usage for user
+.Fa uid .
+.Fa addr
+is a pointer to a
+.Vt dqblk
+structure
+.Po
+defined in
+.In sys/fs/ufs_quota.h
+.Pc .
+This call is restricted to the super-user.
+.It Dv Q_SETQLIM
+Set disk quota limits for user
+.Fa uid .
+.Fa addr
+is a pointer to a
+.Vt dqblk
+structure
+.Po
+defined in
+.In sys/fs/ufs_quota.h
+.Pc .
+This call is restricted to the super-user.
+.It Dv Q_SYNC
+Update the on-disk copy of quota usages for this file system.
+.Fa addr
+and
+.Fa uid
+are ignored.
+.It Dv Q_ALLSYNC
+Update the on-disk copy of quota usages for all file systems with active
+quotas.
+.Fa addr
+and
+.Fa uid
+are ignored.
+.El
+.Sh RETURN VALUES
+This
+Fn ioctl
+returns:
+.Bl -tag -width xx
+.It Sy 0
+on success.
+.It Sy \(mi1
+on failure and sets
+.Va errno
+to indicate the error.
+.El
+.Sh FILES
+.Bl -tag -width x
+.It Pa /usr/include/sys/fs/ufs_quota.h
+quota-related structure/function definitions and defines
+.El
+.Sh ERRORS
+.Bl -tag -width EFAULT
+.It Er EFAULT
+.Fa addr
+is invalid.
+.It Er EINVAL
+The kernel has not been compiled with the
+.Sy QUOTA
+option.
+.Fa op
+is invalid.
+.It Er ENOENT
+The
+.Pa quotas
+file specified by
+.Fa addr
+does not exist.
+.It Er EPERM
+The call is privileged and the calling process did not assert
+.Brq Sy PRIV_SYS_MOUNT
+in the effective set.
+.It Er ESRCH
+No disk quota is found for the indicated user.
+Quotas have not been turned on for this file system.
+.It Er EUSERS
+The quota table is full.
+.El
+.Pp
+If
+.Fa op
+is
+.Dv Q_QUOTAON ,
+.Fn ioctl
+may set
+.Va errno
+to:
+.Bl -tag -width EACCES
+.It Er EACCES
+The quota file pointed to by
+.Fa addr
+exists but is not a regular file.
+The quota file pointed to by
+.Fa addr
+exists but is not on the file system pointed to by
+.Fa special .
+.It Er EIO
+Internal I/O error while attempting to read the
+.Pa quotas
+file pointed to by
+.Fa addr .
+.El
+.Sh SEE ALSO
+.Xr getrlimit 2 ,
+.Xr mount 2 ,
+.Xr quota 8 ,
+.Xr quotacheck 8 ,
+.Xr quotaon 8
+.Sh BUGS
+There should be some way to integrate this call with the resource limit
+interface provided by
+.Xr setrlimit 2
+and
+.Xr getrlimit 2 .
+.Pp
+This call is incompatible with Melbourne quotas.
diff --git a/usr/src/man/man4i/sesio.4i b/usr/src/man/man4i/sesio.4i
new file mode 100644
index 0000000000..94d12dd64d
--- /dev/null
+++ b/usr/src/man/man4i/sesio.4i
@@ -0,0 +1,95 @@
+.\" Copyright (c) 1997, Sun Microsystems, Inc. All Rights Reserved
+.\" Copyright (c) 2017, Joyent, Inc.
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd October 23, 2017
+.Dt SESIO 4I
+.Os
+.Sh NAME
+.Nm sesio
+.Nd enclosure services device driver interface
+.Sh SYNOPSIS
+.In sys/scsi/targets/sesio.h
+.Sh DESCRIPTION
+The
+.Nm ses
+device driver provides the following ioctls as a means to access
+SCSI enclosure services devices.
+.Sh IOCTLS
+The
+.Nm ses
+driver supports the following ioctls:
+.Bl -tag -width SES_IOCTL_GETSTATE
+.It Dv SES_IOCTL_GETSTATE
+This ioctl obtains enclosure state in the
+.Vt ses_ioctl
+structure.
+.It Dv SES_IOCTL_SETSTATE
+This ioctl is used to set parameters on the enclosure services device.
+The
+.Vt ses_ioctl
+structure is used to pass information into the driver.
+.El
+.Sh EXAMPLES
+.Bl -tag -width "Example 1"
+.It Sy "Example 1"
+Using the
+.Dv SES_IOCTL_GETSTATE
+ioctl
+.El
+.Pp
+The following example uses the
+.Dv SES_IOCTL_GETSTATE
+ioctl to recover 20 bytes of page 4 from a previously opened device.
+.Bd -literal -offset 2n
+char abuf[30];
+struct ses_ioctl *sesp;
+int status;
+
+sesp = (ses_ioctl *)abuf;
+sesp->size = 20;
+sesp->page_code = 4;
+status = ioctl(fd, SES_IOCTL_GETSTATE, abuf);
+.Ed
+.Sh ERRORS
+.Bl -tag -width ENOTTY
+.It Er EIO
+The
+.Nm ses
+driver was unable to obtain data from the enclosure services
+device or the data transfer could not be completed.
+.It Er ENOTTY
+The
+.Nm ses
+driver does not support the requested ioctl function.
+.It Er ENXIO
+The enclosure services device does not exist.
+.It Er EFAULT
+The user specified a bad data length.
+.El
+.Sh STRUCTURES
+The
+.Vt ses_ioctl
+structure has the following fields:
+.Bd -literal -offset 2n
+uint32_t page_size; /* Size of buffer that follows */
+uint8_t page_code: /* Page to be read/written */
+uint8_t reserved[3]; /* Reserved; Set to 0 */
+.Ed
+.Sh ARCHITECTURE
+SPARC
+.Sh SEE ALSO
+.Xr ses 4D ,
+.Xr ioctl 9E
diff --git a/usr/src/man/man4i/sockio.4i b/usr/src/man/man4i/sockio.4i
new file mode 100644
index 0000000000..e2ba308312
--- /dev/null
+++ b/usr/src/man/man4i/sockio.4i
@@ -0,0 +1,97 @@
+.\" Copyright (c) 2017, Joyent, Inc.
+.\" Copyright 1989 AT&T Copyright (c) 1996, Sun Microsystems, Inc. All Rights Reserved
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd October 29, 2017
+.Dt SOCKIO 4I
+.Os
+.Sh NAME
+.Nm sockio
+.Nd ioctls that operate directly on sockets
+.Sh SYNOPSIS
+.In sys/sockio.h
+.Sh DESCRIPTION
+The
+.Sy ioctl Ns s
+listed in this manual page apply directly to sockets,
+independent of any underlying protocol.
+The
+.Xr setsockopt 3SOCKET
+call
+.Po
+see
+.Xr getsockopt 3SOCKET
+.Pc
+is the primary method for operating on sockets,
+rather than on the underlying protocol or network interface.
+.Sy ioctl Ns s
+for a specific network interface or protocol are documented in the manual page
+for that interface or protocol.
+.Bl -tag -width SIOCCATMARK
+.It Dv SIOCSPGRP
+The argument is a pointer to an
+.Vt int .
+Set the process-group
+.Sy ID
+that will subsequently receive
+.Dv SIGIO
+or
+.Dv SIGURG
+signals for the socket
+referred to by the descriptor passed to
+.Sy ioctl
+to the value of that
+.Vt int .
+The argument must be either positive (in which case it must be a
+process
+.Sy ID )
+or negative (in which case it must be a process group).
+.It Dv SIOCGPGRP
+The argument is a pointer to an
+.Vt int .
+Get the value of that
+.Vt int
+to the process-group
+.Sy ID
+that is receiving
+.Dv SIGIO
+or
+.Dv SIGURG
+signals for the socket referred to by the descriptor passed to
+.Sy ioctl .
+.It Dv SIOCCATMARK
+The argument is a pointer to an
+.Vt int .
+Set the value of that
+.Vt int
+to
+.Sy 1
+if the read pointer for the socket referred to by the descriptor passed
+to
+.Xr ioctl 2
+points to a mark in the data stream for an out-of-band message.
+Set the value of that
+.Vt int
+to
+.Sy 0
+if the read pointer for the socket
+referred to by the descriptor passed to
+.Sy ioctl
+does not point to a mark
+in the data stream for an out-of-band message.
+.El
+.Sh SEE ALSO
+.Xr ioctl 2 ,
+.Xr getsockopt 3SOCKET
diff --git a/usr/src/man/man4i/streamio.4i b/usr/src/man/man4i/streamio.4i
new file mode 100644
index 0000000000..4e99ba3dfe
--- /dev/null
+++ b/usr/src/man/man4i/streamio.4i
@@ -0,0 +1,1550 @@
+.\" Copyright (c) 2017, Joyent, Inc.
+.\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
+.\" Copyright 1989 AT&T
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd October 29, 2017
+.Dt STREAMIO 4I
+.Os
+.Sh NAME
+.Nm streamio
+.Nd STREAMS ioctl commands
+.Sh SYNOPSIS
+.In sys/types.h
+.In stropts.h
+.In sys/conf.h
+.Ft int
+.Fo ioctl
+.Fa "int fildes"
+.Fa "int command"
+.Fa "\&... /*arg*/"
+.Fc
+.Sh DESCRIPTION
+STREAMS (see
+.Xr Intro 3 )
+.Fn ioctl
+commands are a subset of the
+.Xr ioctl 2
+commands and perform a variety of control functions on streams.
+.Pp
+The
+.Fa fildes
+argument is an open file descriptor that refers to a stream.
+The
+.Fa command
+argument determines the control function to be performed as
+described below.
+The
+.Fa arg
+argument represents additional information that
+is needed by this command.
+The type of
+.Fa arg
+depends upon the command, but
+it is generally an integer or a pointer to a command-specific data structure.
+The
+.Fa command
+and
+.Fa arg
+arguments are interpreted by the STREAM head.
+Certain combinations of these arguments may be passed to a module or driver in
+the stream.
+.Pp
+Since these STREAMS commands are
+.Sy ioctls ,
+they are subject to the errors described in
+.Xr ioctl 2 .
+In addition to those errors, the call will fail
+with
+.Va errno
+set to
+.Er EINVAL ,
+without processing a control function, if the STREAM referenced by
+.Fa fildes
+is linked below a multiplexor, or if
+.Fa command
+is not a valid value for a stream.
+.Pp
+Also, as described in
+.Xr ioctl 2 ,
+STREAMS modules and drivers can detect
+errors.
+In this case, the module or driver sends an error message to the STREAM
+head containing an error value.
+This causes subsequent calls to fail with
+.Va errno
+set to this value.
+.Sh IOCTLS
+The following
+.Fn ioctl
+commands, with error values indicated, are applicable to all STREAMS files:
+.Bl -tag -width I_SETCLTIME
+.It Dv I_PUSH
+Pushes the module whose name is pointed to by
+.Va arg
+onto the top of the current stream, just below the STREAM head.
+If the STREAM is a pipe, the module
+will be inserted between the stream heads of both ends of the pipe.
+It then calls the open routine of the newly-pushed module.
+On failure,
+.Va errno
+is set to one of the following values:
+.Bl -tag -width ENOTSUP
+.It Er EINVAL
+Invalid module name.
+.It Er EFAULT
+.Va arg
+points outside the allocated address space.
+.It Er ENXIO
+Open routine of new module failed.
+.It Er ENXIO
+Hangup received on
+.Va fildes .
+.It Er ENOTSUP
+Pushing a module is not supported on this stream.
+.El
+.It Dv I_POP
+Removes the module just below the STREAM head of the STREAM pointed to by
+.Fa fildes .
+To remove a module from a pipe requires that the module was
+pushed on the side it is being removed from.
+.Fa arg
+should be
+.Sy 0
+in an
+.Dv I_POP
+request.
+On failure,
+.Va errno
+is set to one of the following values:
+.Bl -tag -width ENOTSUP
+.It Er EINVAL
+No module present in the stream.
+.It Er ENXIO
+Hangup received on
+.Fa fildes .
+.It Er EPERM
+Attempt to pop through an anchor by an unprivileged process.
+.It Er ENOTSUP
+Removal is not supported.
+.El
+.It Dv I_ANCHOR
+Positions the stream anchor to be at the stream's module directly below the
+stream head.
+Once this has been done, only a privileged process may pop modules
+below the anchor on the stream.
+.Va arg
+must be
+.Sy 0
+in an
+.Dv I_ANCHOR
+request.
+On failure,
+.Va errno
+is set to the following value:
+.Bl -tag -width EINVAL
+.It Er EINVAL
+Request to put an anchor on a pipe.
+.El
+.It Dv I_LOOK
+Retrieves the name of the module just below the stream head of the stream
+pointed to by
+.Fa fildes ,
+and places it in a null terminated character string
+pointed at by
+.Fa arg .
+The buffer pointed to by
+.Fa arg
+should be at least
+.Dv FMNAMESZ Ns +1
+bytes long.
+This requires the declaration
+.Ql "#include <sys/conf.h>" .
+On failure,
+.Dv errno
+is set to one of the following values:
+.Bl -tag -width EFAULT
+.It Er EFAULT
+.Fa arg
+points outside the allocated address space.
+.It Er EINVAL
+No module present in stream.
+.El
+.It Dv I_FLUSH
+This request flushes all input and/or output queues, depending on the value of
+.Fa arg .
+Legal
+.Fa arg
+values are:
+.Bl -tag -width FLUSHRW
+.It Dv FLUSHR
+Flush read queues.
+.It Dv FLUSHW
+Flush write queues.
+.It Dv FLUSHRW
+Flush read and write queues.
+.El
+.Pp
+If a pipe or FIFO does not have any modules pushed, the read queue of the
+stream head on either end is flushed depending on the value of
+.Fa arg .
+.Pp
+If
+.Dv FLUSHR
+is set and
+.Fa fildes
+is a pipe, the read queue for that end
+of the pipe is flushed and the write queue for the other end is flushed.
+If
+.Fa fildes
+is a FIFO, both queues are flushed.
+.Pp
+If
+.Dv FLUSHW
+is set and
+.Fa fildes
+is a pipe and the other end of the pipe
+exists, the read queue for the other end of the pipe is flushed and the write
+queue for this end is flushed.
+If
+.Fa fildes
+is a FIFO, both queues of the
+FIFO are flushed.
+.Pp
+If
+.Dv FLUSHRW
+is set, all read queues are flushed, that is, the read queue
+for the FIFO and the read queue on both ends of the pipe are flushed.
+.Pp
+Correct flush handling of a pipe or FIFO with modules pushed is achieved via
+the
+.Sy pipemod
+module.
+This module should be the first module pushed onto a
+pipe so that it is at the midpoint of the pipe itself.
+.Pp
+On failure,
+.Va errno
+is set to one of the following values:
+.Bl -tag -width EINVAL
+.It Er ENOSR
+Unable to allocate buffers for flush message due to insufficient stream memory
+resources.
+.It Er EINVAL
+Invalid
+.Va arg
+value.
+.It Er ENXIO
+Hangup received on
+.Fa fildes .
+.El
+.It Dv I_FLUSHBAND
+Flushes a particular band of messages.
+.Fa arg
+points to a
+.Vt bandinfo
+structure that has the following members:
+.Bd -literal -offset 2n
+unsigned char bi_pri;
+int bi_flag;
+.Ed
+.Pp
+The
+.Fa bi_flag
+field may be one of
+.Dv FLUSHR ,
+.Dv FLUSHW ,
+or
+.Dv FLUSHRW
+as described earlier.
+.It Dv I_SETSIG
+Informs the stream head that the user wishes the kernel to issue the
+.Dv SIGPOLL
+signal (see
+.Xr signal 3C )
+when a particular event has occurred on the stream associated with
+.Fa fildes .
+.Dv I_SETSIG
+supports an asynchronous processing capability in streams.
+The value of
+.Fa arg
+is a bitmask that specifies the events for which the user should be signaled.
+It is the bitwise OR of any combination of the following constants:
+.Bl -tag -width S_BANDURG
+.It Dv S_INPUT
+Any message other than an
+.Dv M_PCPROTO
+has arrived on a stream head read queue.
+This event is maintained for compatibility with previous releases.
+This event is triggered even if the message is of zero length.
+.It Dv S_RDNORM
+An ordinary (non-priority) message has arrived on a stream head read queue.
+This event is triggered even if the message is of zero length.
+.It Dv S_RDBAND
+A priority band message (band > 0) has arrived on a stream head read queue.
+This event is triggered even if the message is of zero length.
+.It Dv S_HIPRI
+A high priority message is present on the stream head read queue.
+This event is triggered even if the message is of zero length.
+.It Dv S_OUTPUT
+The write queue just below the stream head is no longer full.
+This notifies the
+user that there is room on the queue for sending (or writing) data downstream.
+.It Dv S_WRNORM
+This event is the same as
+.Dv S_OUTPUT .
+.It Dv S_WRBAND
+A priority band greater than 0 of a queue downstream exists and is writable.
+This notifies the user that there is room on the queue for sending (or writing)
+priority data downstream.
+.It Dv S_MSG
+A STREAMS signal message that contains the
+.Dv SIGPOLL
+signal has reached the
+front of the stream head read queue.
+.It Dv S_ERROR
+An
+.Dv M_ERROR
+message has reached the stream head.
+.It Dv S_HANGUP
+An
+.Dv M_HANGUP
+message has reached the stream head.
+.It Dv S_BANDURG
+When used in conjunction with
+.Dv S_RDBAND ,
+.Dv SIGURG
+is generated instead of
+.Dv SIGPOLL
+when a priority message reaches the front of the stream head
+read queue.
+.El
+.Pp
+A user process may choose to be signaled only of high priority messages by
+setting the
+.Fa arg
+bitmask to the value
+.Dv S_HIPRI .
+.Pp
+Processes that wish to receive
+.Dv SIGPOLL
+signals must explicitly register
+to receive them using
+.Dv I_SETSIG .
+If several processes register to receive
+this signal for the same event on the same stream, each process will be
+signaled when the event occurs.
+.Pp
+If the value of
+.Fa arg
+is zero, the calling process will be unregistered and
+will not receive further
+.Dv SIGPOLL
+signals.
+On failure,
+.Va errno
+is set to one of the following values:
+.Bl -tag -width EINVAL
+.It Sy EINVAL
+.Fa arg
+value is invalid or
+.Fa arg
+is zero and process is not registered to receive the
+.Dv SIGPOLL
+signal.
+.It Sy EAGAIN
+Allocation of a data structure to store the signal request failed.
+.El
+.It Dv I_GETSIG
+Returns the events for which the calling process is currently registered to be
+sent a
+.Dv SIGPOLL
+signal.
+The events are returned as a bitmask pointed to by
+.Va arg ,
+where the events are those specified in the description of
+.Dv I_SETSIG
+above.
+On failure,
+.Va errno
+is set to one of the following values:
+.Bl -tag -width EINVAL
+.It Sy EINVAL
+Process not registered to receive the
+.Dv SIGPOLL
+signal.
+.It Sy EFAULT
+.Fa arg
+points outside the allocated address space.
+.El
+.It Dv I_FIND
+Compares the names of all modules currently present in the stream to the name
+pointed to by
+.Fa arg ,
+and returns 1 if the named module is present in the stream.
+It returns 0 if the named module is not present.
+On failure,
+.Va errno
+is set to one of the following values:
+.Bl -tag -width EINVAL
+.It Sy EFAULT
+.Fa arg
+points outside the allocated address space.
+.It Sy EINVAL
+.Fa arg
+does not contain a valid module name.
+.El
+.It Dv I_PEEK
+Allows a user to retrieve the information in the first message on the stream
+head read queue without taking the message off the queue.
+.Dv I_PEEK
+is analogous to
+.Xr getmsg 2
+except that it does not remove the message from the queue.
+.Fa arg
+points to a
+.Vt strpeek
+structure, which contains the following members:
+.Bd -literal -offset 2n
+struct strbuf ctlbuf;
+struct strbuf databuf;
+long flags;
+.Ed
+.Pp
+The
+.Ft maxlen
+field in the
+.Vt ctlbuf
+and
+.Vt databuf
+.Vt strbuf
+structures (see
+.Xr getmsg 2 )
+must be set to the number of bytes of control
+information and/or data information, respectively, to retrieve.
+.Fa flags
+may be set to
+.Dv RS_HIPRI
+or
+.Sy 0 .
+If
+.Dv RS_HIPRI
+is set,
+.Dv I_PEEK
+will look for a high priority message on the stream head read queue.
+Otherwise,
+.Dv I_PEEK
+will look for the first message on the stream head read queue.
+.Pp
+.Dv I_PEEK
+returns
+.Sy 1
+if a message was retrieved, and returns
+.Sy 0
+if no message was found on the stream head read queue.
+It does not wait for a message to arrive.
+On return,
+.Vt ctlbuf
+specifies information in the control buffer,
+.Vt databuf
+specifies information in the data buffer, and
+.Fa flags
+contains the value
+.Dv RS_HIPRI
+or
+.Sy 0 .
+On failure,
+.Va errno
+is set to the following value:
+.Bl -tag -width EBADMSG
+.It Er EFAULT
+.Fa arg
+points, or the buffer area specified in
+.Vt ctlbuf
+or
+.Vt databuf
+is, outside the allocated address space.
+.It Er EBADMSG
+Queued message to be read is not valid for
+.Dv I_PEEK .
+.It Er EINVAL
+Illegal value for
+.Vt flags .
+.It Er ENOSR
+Unable to allocate buffers to perform the
+.Dv I_PEEK
+due to insufficient STREAMS memory resources.
+.El
+.It Dv I_SRDOPT
+Sets the read mode (see
+.Xr read 2 )
+using the value of the argument
+.Va arg .
+Legal
+.Va arg
+values are:
+.Bl -tag -width RNORM
+.It Dv RNORM
+Byte-stream mode, the default.
+.It Dv RMSGD
+Message-discard mode.
+.It Dv RMSGN
+Message-nondiscard mode.
+.El
+.Pp
+In addition, the stream head's treatment of control messages may be changed by
+setting the following flags in
+.Va arg :
+.Bl -tag -width RPROTNORM
+.It Dv RPROTNORM
+Reject
+.Xr read 2
+with
+.Er EBADMSG
+if a control message is at the front of the stream head read queue.
+.It Dv RPROTDAT
+Deliver the control portion of a message as data when a user issues
+.Xr read 2 .
+This is the default behavior.
+.It Dv RPROTDIS
+Discard the control portion of a message, delivering any data portion, when a
+user issues a
+.Xr read 2 .
+.El
+.Pp
+On failure,
+.Va errno
+is set to the following value:
+.Bl -tag -width EINVAL
+.It Er EINVAL
+.Va arg
+is not one of the above legal values, or
+.Va arg
+is the bitwise
+inclusive
+.Sy OR
+of
+.Dv RMSGD
+and
+.Dv RMSGN .
+.El
+.It Dv I_GRDOPT
+Returns the current read mode setting in an
+.Vt int
+pointed to by the argument
+.Fa arg .
+Read modes are described in
+.Xr read 2 .
+On failure,
+.Va errno
+is set to the following value:
+.Bl -tag -width EFAULT
+.It Er EFAULT
+.Fa arg
+points outside the allocated address space.
+.El
+.It Dv I_NREAD
+Counts the number of data bytes in data blocks in the first message on the
+stream head read queue, and places this value in the location pointed to by
+.Fa arg .
+The return value for the command is the number of messages on the
+stream head read queue.
+For example, if zero is returned in
+.Fa arg ,
+but the
+.Fn ioctl
+return value is greater than zero, this indicates that a
+zero-length message is next on the queue.
+On failure,
+.Va errno
+is set to the following value:
+.Bl -tag -width EFAULT
+.It Er EFAULT
+.Fa arg
+points outside the allocated address space.
+.El
+.It Dv I_FDINSERT
+Creates a message from specified buffer(s), adds information about another
+stream and sends the message downstream.
+The message contains a control part and an optional data part.
+The data and control parts to be sent are
+distinguished by placement in separate buffers, as described below.
+.Pp
+The
+.Fa arg
+argument points to a
+.Vt strfdinsert
+structure, which contains
+the following members:
+.Bd -literal -offset 2n
+struct strbuf ctlbuf;
+struct strbuf databuf;
+t_uscalar_t flags;
+int fildes;
+int offset;
+.Ed
+.Pp
+The
+.Fa len
+member in the
+.Vt ctlbuf
+.Vt strbuf
+structure (see
+.Xr putmsg 2 )
+must be set to the size of a
+.Vt t_uscalar_t
+plus the number of bytes of
+control information to be sent with the message.
+The
+.Fa fildes
+member specifies the file descriptor of the other stream, and the
+.Fa offset
+member, which must be suitably aligned for use as a
+.Vt t_uscalar_t ,
+specifies the offset from the start of the control buffer where
+.Dv I_FDINSERT
+will store a
+.Vt t_uscalar_t
+whose interpretation is specific to the stream end.
+The
+.Fa len
+member in the
+.Vt databuf
+.Vt strbuf
+structure must be set to the number of bytes of data information to be sent with
+the message, or to 0 if no data part is to be sent.
+.Pp
+The
+.Fa flags
+member specifies the type of message to be created.
+A normal message is created if
+.Fa flags
+is set to 0, and a high-priority message is created if
+.Fa flags
+is set to
+.Dv RS_HIPRI .
+For non-priority messages,
+.Dv I_FDINSERT
+will block if the stream write queue is full due to internal
+flow control conditions.
+For priority messages,
+.Dv I_FDINSERT
+does not block on this condition.
+or non-priority messages,
+.Dv I_FDINSERT
+does not
+block when the write queue is full and
+.Dv O_NDELAY
+or
+.Dv O_NONBLOCK
+is set.
+Instead, it fails and sets
+.Va errno
+to
+.Er EAGAIN .
+.Pp
+.Dv I_FDINSERT
+also blocks, unless prevented by lack of internal resources, waiting for the
+availability of message blocks in the stream, regardless of priority or whether
+.Dv O_NDELAY
+or
+.Dv O_NONBLOCK
+has been specified.
+No partial message is sent.
+.Pp
+The
+.Fn ioctl
+function with the
+.Dv I_FDINSERT
+command will fail if:
+.Bl -tag -width EAGAIN
+.It Er EAGAIN
+A non-priority message is specified, the
+.Dv O_NDELAY
+or
+.Dv O_NONBLOCK
+flag is set, and the stream write queue is full due to internal flow control
+conditions.
+.It Er ENOSR
+Buffers can not be allocated for the message that is to be created.
+.It Er EFAULT
+The
+.Fa arg
+argument points, or the buffer area specified in
+.Vt ctlbuf
+or
+.Vt databuf
+is, outside the allocated address space.
+.It Er EINVAL
+One of the following: The
+.Fa fildes
+member of the
+.Vt strfdinsert
+structure is not a valid, open stream file descriptor; the size of a
+.Vt t_uscalar_t
+plus
+.Fa offset
+is greater than the
+.Fa len
+member for the buffer specified through
+.Fa ctlptr ;
+the
+.Fa offset
+member does not specify a properly-aligned location in the data buffer; or an
+undefined value is stored in
+.Fa flags .
+.It Er ENXIO
+Hangup received on the
+.Fa fildes
+argument of the
+.Fn ioctl
+call or the
+.Fa fildes
+member of the
+.Vt strfdinsert
+structure.
+.It Er ERANGE
+The
+.Fa len
+field for the buffer specified through
+.Vt databuf
+does not fall within the range specified by the maximum and minimum packet
+sizes of the topmost stream module; or the
+.Fa len
+member for the buffer specified through
+.Vt databuf
+is larger than the maximum configured size of the data part of a message; or the
+.Fa len
+member for the buffer specified through
+.Vt ctlbuf
+is larger than the maximum configured size of the control part of a message.
+.El
+.Pp
+.Dv I_FDINSERT
+can also fail if an error message was received by the stream
+head of the stream corresponding to the
+.Fa fildes
+member of the
+.Vt strfdinsert
+structure.
+In this case,
+.Va errno
+will be set to the value in the message.
+.It Dv I_STR
+Constructs an internal
+.Sy STREAMS
+ioctl message from the data pointed to by
+.Fa arg ,
+and sends that message downstream.
+.Pp
+This mechanism is provided to send user
+.Fn ioctl
+requests to downstream modules and drivers.
+It allows information to be sent with the
+.Fn ioctl ,
+and will return to the user any information sent upstream by the downstream
+recipient.
+.Dv I_STR
+blocks until the system responds with either a positive or negative
+acknowledgement message, or until the request times out after some period of
+time.
+If the request times out, it fails with
+.Va errno
+set to
+.Er ETIME .
+.Pp
+To send requests downstream,
+.Fa arg
+must point to a
+.Vt strioctl
+structure which contains the following members:
+.Bd -literal -offset 2n
+int ic_cmd;
+int ic_timout;
+int ic_len;
+char *ic_dp;
+.Ed
+.Pp
+.Fa ic_cmd
+is the internal
+.Fn ioctl
+command intended for a downstream module or driver and
+.Fa ic_timout
+is the number of seconds (-1 = infinite, 0 = use default, >0 = as specified) an
+.Dv I_STR
+request will wait for acknowledgement before timing out.
+.Fa ic_len
+is the number of bytes in the data argument and
+.Fa ic_dp
+is a pointer to the data argument.
+The
+.Fa ic_len
+field has two uses: on input, it contains the length of the data
+argument passed in, and on return from the command, it contains the number of
+bytes being returned to the user (the buffer pointed to by
+.Fa ic_dp
+should be large enough to contain the maximum amount of data that any module or
+the driver in the stream can return).
+.Pp
+At most one
+.Dv I_STR
+can be active on a stream.
+Further
+.Dv I_STR
+calls
+will block until the active
+.Dv I_STR
+completes via a positive or negative
+acknowlegment, a timeout, or an error condition at the stream head.
+By setting the
+.Fa ic_timout
+field to 0, the user is requesting STREAMS to provide
+the
+.Sy DEFAULT
+timeout.
+The default timeout is specific to the STREAMS
+implementation and may vary depending on which release of Solaris you are
+using.
+For Solaris 8 (and earlier versions), the default timeout is fifteen
+seconds.
+The
+.Dv O_NDELAY
+and
+.Dv O_NONBLOCK
+(see
+.Xr open 2 )
+flags have no effect on this call.
+.Pp
+The stream head will convert the information pointed to by the
+.Vt strioctl
+structure to an internal
+.Fn ioctl
+command message and send it downstream.
+On failure,
+.Va errno
+is set to one of the following values:
+.Bl -tag -width EFAULT
+.It Er ENOSR
+Unable to allocate buffers for the
+.Fn ioctl
+message due to insufficient STREAMS memory resources.
+.It Er EFAULT
+Either
+.Fa arg
+points outside the allocated address space, or the buffer area
+specified by
+.Fa ic_dp
+and
+.Fa ic_len
+(separately for data sent and data returned) is outside the allocated address
+space.
+.It Er EINVAL
+.Fa ic_len
+is less than 0 or
+.Fa ic_len
+is larger than the maximum configured size of the data part of a message or
+.Fa ic_timout
+is less than \(mi1.
+.It Er ENXIO
+Hangup received on
+.Fa fildes .
+.It Er ETIME
+A downstream
+.Fn ioctl
+timed out before acknowledgement was received.
+.El
+.Pp
+An
+.Dv I_STR
+can also fail while waiting for an acknowledgement if a message
+indicating an error or a hangup is received at the stream head.
+In addition, an
+error code can be returned in the positive or negative acknowledgement message,
+in the event the ioctl command sent downstream fails.
+For these cases,
+.Dv I_STR
+will fail with
+.Va errno
+set to the value in the message.
+.It Dv I_SWROPT
+Sets the write mode using the value of the argument
+.Fa arg .
+Legal bit settings for
+.Fa arg
+are:
+.Bl -tag -width SNDZERO
+.It Dv SNDZERO
+Send a zero-length message downstream when a write of 0 bytes occurs.
+.El
+.Pp
+To not send a zero-length message when a write of 0 bytes occurs, this bit must
+not be set in
+.Fa arg .
+.Pp
+On failure,
+.Va errno
+may be set to the following value:
+.Bl -tag -width EINVAL
+.It Sy EINVAL
+.Fa arg
+is not the above legal value.
+.El
+.It Dv I_GWROPT
+Returns the current write mode setting, as described above, in the
+.Vt int
+that is pointed to by the argument
+.Fa arg .
+.It Dv I_SENDFD
+Requests the stream associated with
+.Fa fildes
+to send a message, containing
+a file pointer, to the stream head at the other end of a stream pipe.
+The file
+pointer corresponds to
+.Fa arg ,
+which must be an open file descriptor.
+.Pp
+.Dv I_SENDFD
+converts
+.Fa arg
+into the corresponding system file pointer.
+It allocates a message block and inserts the file pointer in the block.
+The user id and group id associated with the sending process are also inserted.
+This message is placed directly on the read queue (see
+.Xr Intro 3 )
+of the stream head at the other end of the stream pipe to which it is connected.
+On failure,
+.Va errno
+is set to one of the following values:
+.Bl -tag -width EAGAIN
+.It Er EAGAIN
+The sending stream is unable to allocate a message block to contain the file
+pointer.
+.It Er EAGAIN
+The read queue of the receiving stream head is full and cannot accept the
+message sent by
+.Dv I_SENDFD .
+.It Er EBADF
+.Fa arg
+is not a valid, open file descriptor.
+.It Er EINVAL
+.Va fildes
+is not connected to a stream pipe.
+.It Er ENXIO
+Hangup received on
+.Fa fildes .
+.El
+.It Dv I_RECVFD
+Retrieves the file descriptor associated with the message sent by an
+.Dv I_SENDFD
+.Fn ioctl
+over a stream pipe.
+.Fa arg
+is a pointer to a data buffer large enough to hold an
+.Vt strrecvfd
+data structure containing the following members:
+.Bd -literal -offset 2n
+int fd;
+uid_t uid;
+gid_t gid;
+.Ed
+.Pp
+.Fa fd
+is an integer file descriptor.
+.Fa uid
+and
+.Fa gid
+are the user id and group id, respectively, of the sending stream.
+.Pp
+If
+.Dv O_NDELAY
+and
+.Dv O_NONBLOCK
+are clear (see
+.Xr open 2 ) ,
+.Dv I_RECVFD
+will block until a message is present at the stream head.
+If
+.Dv O_NDELAY
+or
+.Dv O_NONBLOCK
+is set,
+.Dv I_RECVFD
+will fail with
+.Va errno
+set to
+.Er EAGAIN
+if no message is present at the stream head.
+.Pp
+If the message at the stream head is a message sent by an
+.Dv I_SENDFD ,
+a new
+user file descriptor is allocated for the file pointer contained in the
+message.
+The new file descriptor is placed in the
+.Fa fd
+field of the
+.Vt strrecvfd
+structure.
+The structure is copied into the user data buffer pointed to by
+.Fa arg .
+On failure,
+.Va errno
+is set to one of the following values:
+.Bl -tag -width EOVERFLOW
+.It Er EAGAIN
+A message is not present at the stream head read queue, and the
+.Dv O_NDELAY
+or
+.Dv O_NONBLOCK
+flag is set.
+.It Er EBADMSG
+The message at the stream head read queue is not a message containing a passed
+file descriptor.
+.It Er EFAULT
+.Fa arg
+points outside the allocated address space.
+.It Er EMFILE
+.Dv NOFILES
+file descriptors are currently open.
+.It Er ENXIO
+Hangup received on
+.Fa fildes .
+.It Er EOVERFLOW
+.Fa uid
+or
+.Fa gid
+is too large to be stored in the structure pointed to by
+.Fa arg .
+.El
+.It Dv I_LIST
+Allows the user to list all the module names on the stream, up to and including
+the topmost driver name.
+If
+.Fa arg
+is
+.Dv NULL ,
+the return value is the number of modules, including the driver, that are on
+the stream pointed to by
+.Fa fildes .
+This allows the user to allocate enough space for the module
+names.
+If
+.Fa arg
+is non-null, it should point to an
+.Vt str_list
+structure that has the following members:
+.Bd -literal -offset 2n
+int sl_nmods;
+struct str_mlist *sl_modlist;
+.Ed
+.Pp
+The
+.Vt str_mlist
+structure has the following member:
+.Bd -literal -offset 2n
+char l_name[FMNAMESZ+1];
+.Ed
+.Pp
+The
+.Fa sl_nmods
+member indicates the number of entries the process has allocated in the array.
+Upon return, the
+.Fa sl_modlist
+member of the
+.Vt str_list
+structure contains the list of module names, and the number of
+entries that have been filled into the
+.Fa sl_modlist
+array is found in the
+.Fa sl_nmods
+member (the number includes the number of modules including the driver).
+The return value from
+.Fn ioctl
+is 0.
+The entries are filled in
+starting at the top of the stream and continuing downstream until either the
+end of the stream is reached, or the number of requested modules
+.Pq Fa sl_nmods
+is satisfied.
+On failure,
+.Va errno
+may be set to one of the following values:
+.Bl -tag -width EINVAL
+.It Er EINVAL
+The
+.Fa sl_nmods
+member is less than 1.
+.It Er EAGAIN
+Unable to allocate buffers
+.El
+.It Dv I_ATMARK
+Allows the user to see if the current message on the stream head read queue is
+.Dq marked
+by some module downstream.
+.Fa arg
+determines how the checking is
+done when there may be multiple marked messages on the stream head read queue.
+It may take the following values:
+.Bl -tag -width LASTMARK
+.It Dv ANYMARK
+Check if the message is marked.
+.It Dv LASTMARK
+Check if the message is the last one marked on the queue.
+.El
+.Pp
+The return value is
+.Sy 1
+if the mark condition is satisfied and
+.Sy 0
+otherwise.
+On failure,
+.Va errno
+is set to the following value:
+.Bl -tag -width EINVAL
+.It Er EINVAL
+Invalid
+.Fa arg
+value.
+.El
+.It Dv I_CKBAND
+Check if the message of a given priority band exists on the stream head read
+queue.
+This returns
+.Sy 1
+if a message of a given priority exists,
+.Sy 0
+if not, or
+.Sy \(mi1
+on error.
+.Fa arg
+should be an integer containing the value of the priority band in question.
+On failure,
+.Va errno
+is set to the following value:
+.Bl -tag -width EINVAL
+.It Er EINVAL
+Invalid
+.Fa arg
+value.
+.El
+.It Dv I_GETBAND
+Returns the priority band of the first message on the stream head read queue in
+the integer referenced by
+.Fa arg .
+On failure,
+.Va errno
+is set to the following value:
+.Bl -tag -width ENODATA
+.It Er ENODATA
+No message on the stream head read queue.
+.El
+.It Dv I_CANPUT
+Check if a certain band is writable.
+.Fa arg
+is set to the priority band in question.
+The return value is
+.Sy 0
+if the priority band
+.Fa arg
+is flow controlled,
+.Sy 1
+if the band is writable, or
+.Sy \(mi1
+on error.
+On failure,
+.Va errno
+is set to the following value:
+.Bl -tag -width EINVAL
+.It Sy EINVAL
+Invalid
+.Va arg
+value.
+.El
+.It Dv I_SETCLTIME
+Allows the user to set the time the stream head will delay when a stream is
+closing and there are data on the write queues.
+Before closing each module and driver, the stream head will delay for the
+specified amount of time to allow the data to drain.
+Note, however, that the module or driver may itself delay in its close routine;
+this delay is independent of the stream head's delay and is not settable.
+If, after the delay, data are still present, data will be flushed.
+.Fa arg
+is a pointer to an integer containing the number of
+milliseconds to delay, rounded up to the nearest legal value on the system.
+The default is fifteen seconds.
+On failure,
+.Va errno
+is set to the following value:
+.Bl -tag -width EINVAL
+.It Er EINVAL
+Invalid
+.Fa arg
+value.
+.El
+.It Dv I_GETCLTIME
+Returns the close time delay in the integer pointed by
+.Va arg .
+.It Dv I_SERROPT
+Sets the error mode using the value of the argument
+.Fa arg .
+.Pp
+Normally stream head errors are persistent; once they are set due to an
+.Dv M_ERROR
+or
+.Dv M_HANGUP ,
+the error condition will remain until the stream is closed.
+This option can be used to set the stream head into
+non-persistent error mode i\.e\. once the error has been returned in response
+to a
+.Xr read 2 ,
+.Xr getmsg 2 ,
+.Xr ioctl 2 ,
+.Xr write 2 ,
+or
+.Xr putmsg 2
+call the error condition will be cleared.
+The error mode can be controlled independently for read and write side errors.
+Legal
+.Fa arg
+values
+are either none or one of:
+.Bl -tag -width RERRNONPERSIST
+.It Dv RERRNORM
+Persistent read errors, the default.
+.It Dv RERRNONPERSIST
+Non-persistent read errors.
+.El
+.Pp
+.Sy OR Ns 'ed
+with either none or one of:
+.Bl -tag -width WERRNONPERSIST
+.It Dv WERRNORM
+Persistent write errors, the default.
+.It Dv WERRNONPERSIST
+Non-persistent write errors.
+.El
+.Pp
+When no value is specified e\.g\. for the read side error behavior then the
+behavior for that side will be left unchanged.
+.Pp
+On failure,
+.Va errno
+is set to the following value:
+.Bl -tag -width EINVAL
+.It Er EINVAL
+.Va arg
+is not one of the above legal values.
+.El
+.It Dv I_GERROPT
+Returns the current error mode setting in an
+.Vt int
+pointed to by the argument
+.Fa arg .
+Error modes are described above for
+.Dv I_SERROPT .
+On failure,
+.Va errno
+is set to the following value:
+.Bl -tag -width EFAULT
+.It Sy EFAULT
+.Fa arg
+points outside the allocated address space.
+.El
+.El
+.Pp
+The following four commands are used for connecting and disconnecting
+multiplexed STREAMS configurations.
+.Bl -tag -width I_PUNLINK
+.It Dv I_LINK
+Connects two streams, where
+.Fa fildes
+is the file descriptor of the stream
+connected to the multiplexing driver, and
+.Fa arg
+is the file descriptor of the stream connected to another driver.
+The stream designated by
+.Va arg
+gets
+connected below the multiplexing driver.
+.Dv I_LINK
+requires the multiplexing
+driver to send an acknowledgement message to the stream head regarding the
+linking operation.
+This call returns a multiplexor ID number (an identifier
+used to disconnect the multiplexor, see
+.Dv I_UNLINK )
+on success, and \(mi1 on failure.
+On failure,
+.Va errno
+is set to one of the following values:
+.Bl -tag -width EAGAIN
+.It Er ENXIO
+Hangup received on
+.Va fildes .
+.It Er ETIME
+Time out before acknowledgement message was received at stream head.
+.It Er EAGAIN
+Temporarily unable to allocate storage to perform the
+.Dv I_LINK .
+.It Er ENOSR
+Unable to allocate storage to perform the
+.Dv I_LINK
+due to insufficient
+.Sy STREAMS
+memory resources.
+.It Er EBADF
+.Va arg
+is not a valid, open file descriptor.
+.It Er EINVAL
+.Va fildes
+stream does not support multiplexing.
+.It Er EINVAL
+is not a stream, or is already linked under a multiplexor.
+.It Er EINVAL
+The specified link operation would cause a
+.Dq cycle
+in the resulting configuration; that is, a driver would be linked into the
+multiplexing configuration in more than one place.
+.It Er EINVAL
+.Va fildes
+is the file descriptor of a pipe or FIFO.
+.It Er EINVAL
+Either the upper or lower stream has a major number \(>= the maximum major
+number on the system.
+.El
+.Pp
+An
+.Dv I_LINK
+can also fail while waiting for the multiplexing driver to
+acknowledge the link request, if a message indicating an error or a hangup is
+received at the stream head of
+.Fa fildes .
+In addition, an error code can be
+returned in the positive or negative acknowledgement message.
+For these cases,
+.Dv I_LINK
+will fail with
+.Va errno
+set to the value in the message.
+.It Dv I_UNLINK
+Disconnects the two streams specified by
+.Fa fildes
+and
+.Fa arg .
+.Fa fildes
+is the file descriptor of the stream connected to the multiplexing
+driver.
+.Fa arg
+is the multiplexor ID number that was returned by the
+.Dv I_LINK .
+If
+.Fa arg
+is \(mi1, then all streams that were linked to
+.Fa fildes
+are disconnected.
+As in
+.Dv I_LINK ,
+this command requires the multiplexing driver to acknowledge the unlink.
+On failure,
+.Va errno
+is set to one of the following values:
+.Bl -tag -width EINVAL
+.It Er ENXIO
+Hangup received on
+.Va fildes .
+.It Er ETIME
+Time out before acknowledgement message was received at stream head.
+.It Er ENOSR
+Unable to allocate storage to perform the
+.Dv I_UNLINK
+due to insufficient
+STREAMS memory resources.
+.It Er EINVAL
+.Fa arg
+is an invalid multiplexor ID number or
+.Fa fildes
+is not the stream on which the
+.Dv I_LINK
+that returned
+.Fa arg
+was performed.
+.It Er EINVAL
+.Fa fildes
+is the file descriptor of a pipe or FIFO.
+.El
+.Pp
+An
+.Dv I_UNLINK
+can also fail while waiting for the multiplexing driver to
+acknowledge the link request, if a message indicating an error or a hangup is
+received at the stream head of
+.Fa fildes .
+In addition, an error code can be
+returned in the positive or negative acknowledgement message.
+For these cases,
+.Dv I_UNLINK
+will fail with
+.Va errno
+set to the value in the message.
+.It Dv I_PLINK
+Connects two streams, where
+.Fa fildes
+is the file descriptor of the stream
+connected to the multiplexing driver, and
+.Fa arg
+is the file descriptor of
+the stream connected to another driver.
+The stream designated by
+.Fa arg
+gets
+connected via a persistent link below the multiplexing driver.
+.Dv I_PLINK
+requires the multiplexing driver to send an acknowledgement message to the
+stream head regarding the linking operation.
+This call creates a persistent
+link that continues to exist even if the file descriptor
+.Fa fildes
+associated with the upper stream to the multiplexing driver is closed.
+This
+call returns a multiplexor ID number (an identifier that may be used to
+disconnect the multiplexor, see
+.Dv I_PUNLINK )
+on success, and \(mi1 on failure.
+On failure,
+.Va errno
+is set to one of the following values:
+.Bl -tag -width EAGAIN
+.It Er ENXIO
+Hangup received on
+.Fa fildes .
+.It Er ETIME
+Time out before acknowledgement message was received at the stream head.
+.It Er EAGAIN
+Unable to allocate STREAMS storage to perform the
+.Dv I_PLINK .
+.It Er EBADF
+.Va arg
+is not a valid, open file descriptor.
+.It Er EINVAL
+.Va fildes
+does not support multiplexing.
+.It Er EINVAL
+.Va arg
+is not a stream or is already linked under a multiplexor.
+.It Er EINVAL
+The specified link operation would cause a
+.Dq cycle
+in the resulting configuration; that is, if a driver would be linked into the
+multiplexing configuration in more than one place.
+.It Er EINVAL
+.Fa fildes
+is the file descriptor of a pipe or FIFO.
+.El
+.Pp
+An
+.Dv I_PLINK
+can also fail while waiting for the multiplexing driver to
+acknowledge the link request, if a message indicating an error on a hangup is
+received at the stream head of
+.Fa fildes .
+In addition, an error code can be
+returned in the positive or negative acknowledgement message.
+For these cases,
+.Dv I_PLINK
+will fail with
+.Va errno
+set to the value in the message.
+.It Dv I_PUNLINK
+Disconnects the two streams specified by
+.Fa fildes
+and
+.Fa arg
+that are
+connected with a persistent link.
+.Fa fildes
+is the file descriptor of the
+stream connected to the multiplexing driver.
+.Fa arg
+is the multiplexor ID number that was returned by
+.Dv I_PLINK
+when a stream was linked below the multiplexing driver.
+If
+.Fa arg
+is
+.Dv MUXID_ALL
+then all streams that are persistent links to
+.Fa fildes
+are disconnected.
+As in
+.Dv I_PLINK ,
+this command requires the multiplexing driver to acknowledge the unlink.
+On failure,
+.Va errno
+is set to one of the following values:
+.Bl -tag -width EAGAIN
+.It Sy ENXIO
+Hangup received on
+.Fa fildes .
+.It Er ETIME
+Time out before acknowledgement message was received at the stream head.
+.It Er EAGAIN
+Unable to allocate buffers for the acknowledgement message.
+.It Er EINVAL
+Invalid multiplexor ID number.
+.It Er EINVAL
+.Fa fildes
+is the file descriptor of a pipe or FIFO.
+.El
+.Pp
+An
+.Dv I_PUNLINK
+can also fail while waiting for the multiplexing driver to
+acknowledge the link request if a message indicating an error or a hangup is
+received at the stream head of
+.Fa fildes .
+In addition, an error code can be
+returned in the positive or negative acknowledgement message.
+For these cases,
+.Dv I_PUNLINK
+will fail with
+.Va errno
+set to the value in the message.
+.El
+.Sh RETURN VALUES
+Unless specified otherwise above, the return value from
+.Xr ioctl 2
+is
+.Sy 0
+upon success and
+.Sy \(mi1
+upon failure, with
+.Va errno
+set as indicated.
+.Sh SEE ALSO
+.Xr close 2 ,
+.Xr fcntl 2 ,
+.Xr getmsg 2 ,
+.Xr ioctl 2 ,
+.Xr open 2 ,
+.Xr poll 2 ,
+.Xr putmsg 2 ,
+.Xr read 2 ,
+.Xr write 2 ,
+.Xr Intro 3 ,
+.Xr signal 3C ,
+.Xr signal.h 3HEAD
+.Pp
+.%B STREAMS Programming Guide
diff --git a/usr/src/man/man4i/termio.4i b/usr/src/man/man4i/termio.4i
new file mode 100644
index 0000000000..c30fdd5262
--- /dev/null
+++ b/usr/src/man/man4i/termio.4i
@@ -0,0 +1,2193 @@
+.\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved.
+.\" Copyright 2019, Joyent, Inc. All Rights Reserved.
+.\" Copyright 1989 AT&T
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd August 13, 2021
+.Dt TERMIO 4I
+.Os
+.Sh NAME
+.Nm termio
+.Nd general terminal interface
+.Sh SYNOPSIS
+.In termio.h
+.Fn ioctl "int fildes" "int request" "struct termio *arg"
+.Fn ioctl "int fildes" "int request" "int arg"
+.Pp
+.In termios.h
+.Fn ioctl "int fildes" "int request" "struct termios *arg"
+.Sh DESCRIPTION
+This release supports a general interface for asynchronous communications ports
+that is hardware-independent.
+The user interface to this functionality is using
+function calls (the preferred interface) described in
+.Xr termios 3C
+or
+.Fn ioctl
+commands described in this section.
+This section also discusses the
+common features of the terminal subsystem which are relevant with both user
+interfaces.
+.Pp
+When a terminal file is opened, it normally causes the process to wait until a
+connection is established.
+In practice, user programs seldom open terminal
+files; they are opened by the system and become a user's standard input,
+output, and error files.
+The first terminal file opened by the session leader
+that is not already associated with a session becomes the controlling terminal
+for that session.
+The controlling terminal plays a special role in handling
+quit and interrupt signals, as discussed below.
+The controlling terminal is
+inherited by a child process during a
+.Xr fork 2 .
+A process can break this
+association by changing its session using
+.Xr setsid 2 .
+.Pp
+A terminal associated with one of these files ordinarily operates in
+full-duplex mode.
+Characters may be typed at any time, even while output is
+occurring, and are only lost when the character input buffers of the system
+become completely full, which is rare.
+For example, the number of characters in
+the line discipline buffer may exceed
+.Brq Dv MAX_CANON
+and
+.Dv IMAXBEL
+(see below) is not set, or the user may accumulate
+.Brq Dv MAX_INPUT
+number of input characters that have not yet been read by some program.
+When the input
+limit is reached, all the characters saved in the buffer up to that point are
+thrown away without notice.
+.Ss "Session Management (Job Control)"
+A control terminal will distinguish one of the process groups in the session
+associated with it to be the foreground process group.
+All other process
+groups in the session are designated as background process groups.
+This foreground process group plays a special role in handling signal-generating
+input characters, as discussed below.
+By default, when a controlling terminal
+is allocated, the controlling process's process group is assigned as
+foreground process group.
+.Pp
+Background process groups in the controlling process's session are subject to a
+job control line discipline when they attempt to access their controlling
+terminal.
+Process groups can be sent signals that will cause them to stop,
+unless they have made other arrangements.
+An exception is made for members of
+orphaned process groups.
+.Pp
+An orphaned process group is one where the process group (see
+.Xr getpgid 2 )
+has no members with a parent in a different process group but sharing the same
+controlling terminal.
+When a member of an orphaned process group attempts to
+access its controlling terminal, EIO is returned because there would be no way
+to restart the process if it were stopped on one of these signals.
+.Pp
+If a member of a background process group attempts to read its controlling
+terminal, its process group will be sent a
+.Dv SIGTTIN
+signal, which will
+normally cause the members of that process group to stop.
+If, however, the
+process is ignoring or holding
+.Dv SIGTTIN ,
+or is a member of an orphaned
+process group, the read will fail with
+.Va errno
+set to
+.Er EIO ,
+and no signal is sent.
+.Pp
+If a member of a background process group attempts to write its controlling
+terminal and the
+.Dv TOSTOP
+bit is set in the
+.Fa c_lflag
+field, its process group is sent a
+.Dv SIGTTOU
+signal, which will normally cause the
+members of that process group to stop.
+If, however, the process is ignoring or
+holding
+.Dv SIGTTOU ,
+the write will succeed.
+If the process is not ignoring
+or holding
+.Dv SIGTTOU
+and is a member of an orphaned process group, the
+write will fail with
+.Va errno
+set to
+.Er EIO ,
+and no signal will be sent.
+.Pp
+If
+.Dv TOSTOP
+is set and a member of a background process group attempts to
+.Fn ioctl
+its controlling terminal, and that
+.Fn ioctl
+will modify terminal parameters (for example,
+.Dv TCSETA ,
+.Dv TCSETAW ,
+.Dv TCSETAF ,
+or
+.Dv TIOCSPGRP ) ,
+its process group will be sent a
+.Dv SIGTTOU
+signal, which will normally cause the members of that process group to stop.
+If, however, the process is ignoring or holding
+.Dv SIGTTOU ,
+the ioctl will succeed.
+If the process is not ignoring or holding
+.Dv SIGTTOU
+and is a member of an orphaned
+process group, the write will fail with
+.Va errno
+set to
+.Er EIO ,
+and no signal will be sent.
+.Ss "Canonical Mode Input Processing"
+Normally, terminal input is processed in units of lines.
+A line is delimited by
+a newline
+.Po
+.Sy ASCII LF
+.Pc
+character, an end-of-file
+.Po
+.Sy ASCII EOT
+.Pc
+character, or an end-of-line character.
+This means that a program attempting to
+read will block until an entire line has been typed.
+Also, no matter how many
+characters are requested in the read call, at most one line will be returned.
+It is not necessary, however, to read a whole line at once; any number of
+characters may be requested in a read, even one, without losing information.
+.Pp
+During input, erase, erase2, and kill processing is normally done.
+The
+.Sy ERASE
+and
+.Sy ERASE2
+character (by default, the character
+.Sy DEL
+for
+.Sy ERASE
+and
+.Sy Control-h
+for
+.Sy ERASE2 )
+erases the last character typed.
+The
+.Sy WERASE
+character (the character
+.Sy Control-w )
+erases the
+last "word" typed in the current input line (but not any preceding spaces or
+tabs).
+A
+.Dq word
+is defined as a sequence of non-blank characters, with tabs counted as blanks.
+None of
+.Sy ERASE
+or
+.Sy ERASE2
+or
+.Sy WERASE
+will erase beyond the beginning of the line.
+The
+.Sy KILL
+character (by default,
+the character
+.Sy NAK )
+kills (deletes) the entire input line, and optionally
+outputs a newline character.
+All these characters operate on a key stroke basis,
+independent of any backspacing or tabbing that may have been done.
+The
+.Sy REPRINT
+character (the character
+.Sy Control-r )
+prints a newline followed by all characters that have not been read.
+Reprinting also occurs automatically if
+characters that would normally be erased from the screen are fouled by program
+output.
+The characters are reprinted as if they were being echoed;
+consequencely, if
+.Dv ECHO
+is not set, they are not printed.
+.Pp
+The
+.Sy ERASE ,
+.Sy ERASE2 ,
+and
+.Sy KILL
+characters may be entered literally by preceding them with the escape character.
+In this case, the escape character is not read.
+The erase, erase2, and kill characters may be changed.
+.Ss "Non-canonical Mode Input Processing"
+In non-canonical mode input processing, input characters are not assembled into
+lines, and erase and kill processing does not occur.
+The
+.Sy MIN
+and
+.Sy TIME
+values are used to determine how to process the characters received.
+.Pp
+.Sy MIN
+represents the minimum number of characters that should be received
+when the read is satisfied (that is, when the characters are returned to the
+user).
+.Sy TIME
+is a timer of 0\&.10-second granularity that is used to timeout
+bursty and short-term data transmissions.
+The four possible values for
+.Sy MIN
+and
+.Sy TIME
+and their interactions are described below.
+.Bl -tag -width "Case A: Min > 0, Time > 0"
+.It Sy Case A: MIN > 0, TIME > 0
+In this case,
+.Sy TIME
+serves as an intercharacter timer and is activated
+after the first character is received.
+Since it is an intercharacter timer, it
+is reset after a character is received.
+The interaction between
+.Sy MIN
+and
+.Sy TIME
+is as follows: as soon as one character is received, the
+intercharacter timer is started.
+If
+.Sy MIN
+characters are received before
+the intercharacter timer expires (note that the timer is reset upon receipt of
+each character), the read is satisfied.
+If the timer expires before
+.Sy MIN
+characters are received, the characters received to that point are returned to
+the user.
+Note that if
+.Sy TIME
+expires, at least one character will be
+returned because the timer would not have been enabled unless a character was
+received.
+In this case (MIN > 0, TIME > 0), the read sleeps until the
+.Sy MIN
+and
+.Sy TIME
+mechanisms are activated by the receipt of the first character.
+If the number of characters read is less than the number of characters
+available, the timer is not reactivated and the subsequent read is satisfied
+immediately.
+.It Sy Case B: MIN > 0, TIME = 0
+In this case, since the value of
+.Sy TIME
+is zero, the timer plays no role
+and only
+.Sy MIN
+is significant.
+A pending read is not satisfied until
+.Sy MIN
+characters are received (the pending read sleeps until
+.Sy MIN
+characters are received).
+A program that uses this case to read record based
+terminal
+.Sy I/O
+may block indefinitely in the read operation.
+.It Sy Case C: MIN = 0, TIME > 0
+In this case, since
+.Sy MIN
+0,
+.Sy TIME
+no longer represents an
+intercharacter timer: it now serves as a read timer that is activated as soon
+as a
+.Xr read 2
+is done.
+A read is satisfied as soon as a single character is
+received or the read timer expires.
+Note that, in this case, if the timer
+expires, no character is returned.
+If the timer does not expire, the only way
+the read can be satisfied is if a character is received.
+In this case, the
+read will not block indefinitely waiting for a character; if no character is
+received within
+.Sy TIME
+*\&.10 seconds after the read is initiated, the read
+returns with zero characters.
+.It Sy Case D: MIN = 0, TIME = 0
+In this case, return is immediate.
+The minimum of either the number of
+characters requested or the number of characters currently available is
+returned without waiting for more characters to be input.
+.El
+.Ss "Comparing Different Cases of MIN, TIME Interaction"
+Some points to note about
+.Sy MIN
+and
+.Sy TIME :
+.Bl -bullet -offset 2n
+.It
+In the following explanations, note that the interactions of
+.Sy MIN
+and
+.Sy TIME
+are not symmetric.
+For example, when
+.Sy MIN
+> 0 and
+.Sy TIME
+= 0,
+.Sy TIME
+has no effect.
+However, in the opposite case, where
+.Sy MIN
+= 0 and
+.Sy TIME
+> 0, both
+.Sy MIN
+and
+.Sy TIME
+play a role in that
+.Sy MIN
+is satisfied with the receipt of a single character.
+.It
+Also note that in case A
+.Po
+.Sy MIN
+> 0,
+.Sy TIME
+> 0
+.Pc ,
+.Sy TIME
+represents
+an intercharacter timer, whereas in case C
+.Po
+.Sy MIN
+= 0,
+.Sy TIME
+> 0
+.Pc ,
+.Sy TIME
+represents a read timer.
+.El
+.Pp
+These two points highlight the dual purpose of the
+.Sy MIN/TIME
+feature.
+Cases A and B, where
+.Sy MIN
+> 0, exist to handle burst mode activity (for
+example, file transfer programs), where a program would like to process at
+least
+.Sy MIN
+characters at a time.
+In case A, the inteercharacter timer is
+activated by a user as a safety measure; in case B, the timer is turned off.
+.Pp
+Cases C and D exist to handle single character, timed transfers.
+These cases
+are readily adaptable to screen-based applications that need to know if a
+character is present in the input queue before refreshing the screen.
+In case
+C, the read is timed, whereas in case D, it is not.
+.Pp
+Another important note is that
+.Sy MIN
+is always just a minimum.
+It does not
+denote a record length.
+For example, if a program does a read of 20 bytes,
+.Sy MIN
+is 10, and 25 characters are present, then 20 characters will be
+returned to the user.
+.Ss "Writing Characters"
+When one or more characters are written, they are transmitted to the terminal
+as soon as previously written characters have finished typing.
+nputt characters
+are echoed as they are typed if echoing has been enabled.
+If a process produces
+characters more rapidly than they can be typed, it will be suspended when its
+output queue exceeds some limit.
+When the queue is drained down to some
+threshold, the program is resumed.
+.Ss "Special Characters"
+Certain characters have special functions on input.
+These functions and their default character values are summarized as follows:
+.Bl -tag -width REPRINT
+.It Sy INTR
+(Control-c or
+.Sy ASCII ETX )
+generates a
+.Dv SIGINT
+signal.
+.Dv SIGINT
+is sent to all foreground processes associated with the controlling terminal.
+Normally, each such process is forced to terminate, but arrangements may be
+made either to ignore the signal or to receive a trap to an agreed upon
+location.
+(See
+.Xr signal.h 3HEAD ) .
+.It Sy QUIT
+(Control-| or
+.Sy ASCII FS )
+generates a
+.Dv SIGQUIT
+signal.
+Its treatment
+is identical to the interrupt signal except that, unless a receiving process
+has made other arrangements, it will not only be terminated but a core image
+file (called
+.Pa core )
+will be created in the current working directory.
+.It Sy ERASE
+(DEL) erases the preceding character.
+It does not erase beyond
+the start of a line, as delimited by a
+.Sy NL ,
+.Sy EOF ,
+.Sy EOL ,
+or
+.Sy EOL2
+character.
+.It Sy ERASE2
+(Control-h or
+.Sy ASCII BS )
+erases the preceding character, with behaviour identical to that of ERASE.
+.It Sy WERASE
+(Control-w or
+.Sy ASCII ETX )
+erases the preceding
+.Dq word .
+It does not erase beyond the start of a line, as delimited by a
+.Sy NL ,
+.Sy EOF ,
+.Sy EOL ,
+or
+.Sy EOL2
+character.
+.It Sy KILL
+(Control-u or
+.Sy ASCII NAK )
+deletes the entire line, as delimited by a
+.Sy NL ,
+.Sy EOF ,
+.Sy EOL ,
+or
+.Sy EOL2
+character.
+.It Sy REPRINT
+(Control-r or
+.Sy ASCII DC2 )
+reprints all characters, preceded by a newline, that have not been read.
+.It Sy EOF
+(Control-d or
+.Sy ASCII EOT )
+may be used to generate an end-of-file from a terminal.
+When received, all the characters waiting to be read are immediately
+passed to the program, without waiting for a newline, and the
+.Sy EOF
+is discarded.
+Thus, if no characters are waiting (that is, the
+.Sy EOF
+occurred
+at the beginning of a line) zero characters are passed back, which is the
+standard end-of-file indication.
+Unless escaped, the
+.Sy EOF
+character is not
+echoed.
+Because
+.Sy EOT
+is the default
+.Sy EOF
+character, this prevents
+terminals that respond to
+.Sy EOT
+from hanging up.
+.It Sy NL
+.Pq Sy ASCII LF
+is the normal line delimiter.
+It cannot be changed or escaped.
+.It Sy EOL
+.Pq Sy ASCII NULL
+is an additional line delimiter, like
+.Sy NL .
+It is not normally used.
+.It Sy EOL2
+is another additional line delimiter.
+.It Sy SWTCH
+(Control-z or
+.Sy ASCII EM )
+Header file symbols related to this special
+character are present for compatibility purposes only and the kernel takes no
+special action on matching SWTCH (except to discard the character).
+.It Sy SUSP
+(Control-z or
+.Sy ASCII SUB )
+generates a
+.Dv SIGTSTP
+signal.
+.Dv SIGTSTP
+stops all processes in the foreground process group for that terminal.
+.It Sy DSUSP
+(Control-y or
+.Sy ASCII EM ) .
+It generates a
+.Dv SIGTSTP
+signal as
+.Sy SUSP
+does, but the signal is sent when a process in the foreground
+process group attempts to read the
+.Sy DSUSP
+character, rather than when it is typed.
+.It Sy STOP
+(Control-s or
+.Sy ASCII DC3 )
+can be used to suspend output temporarily.
+It is useful with
+.Sy CRT
+terminals to prevent output from disappearing before it can be read.
+While output is suspended,
+.Sy STOP
+characters are ignored and
+not read.
+.It Sy START
+(Control-q or
+.Sy ASCII DC1 )
+is used to resume output.
+Output has been suspended by a
+.Sy STOP
+character.
+While output is not suspended,
+.Sy START
+characters are ignored and not read.
+.It Sy DISCARD
+(Control-o or
+.Sy ASCII SI )
+causes subsequent output to be discarded.
+Output is discarded until another
+.Sy DISCARD
+character is typed, more input
+arrives, or the condition is cleared by a program.
+.It Sy STATUS
+(Control-t or
+.Sy ASCII DC4 )
+generates a
+.Dv SIGINFO
+signal.
+Processes with a handler will output status information when they receive
+.Dv SIGINFO ,
+for
+example,
+.Xr dd 8 .
+If a process does not have a
+.Dv SIGINFO
+handler, the
+signal will be ignored.
+.It Sy LNEXT
+(Control-v or
+.Sy ASCII SYN )
+causes the special meaning of the next character to be ignored.
+This works for all the special characters mentioned above.
+It
+allows characters to be input that would otherwise be interpreted by the system
+(for example
+.Sy KILL ,
+.Sy QUIT ) .
+The character values for
+.Sy INTR ,
+.Sy QUIT ,
+.Sy ERASE ,
+.Sy ERASE2 ,
+.Sy WERASE ,
+.Sy KILL ,
+.Sy REPRINT ,
+.Sy EOF ,
+.Sy EOL ,
+.Sy EOL2 ,
+.Sy SWTCH ,
+.Sy SUSP ,
+.Sy DSUSP ,
+.Sy STOP ,
+.Sy START ,
+.Sy DISCARD ,
+.Sy STATUS ,
+and
+.Sy LNEXT
+may be changed to suit individual tastes.
+If the value of a special control character
+is
+.Dv _POSIX_VDISABLE
+(0), the function of that special control character is disabled.
+The
+.Sy ERASE ,
+.Sy ERASE2 ,
+.Sy KILL ,
+and
+.Sy EOF
+characters may be
+escaped by a preceding backslash (\e) character, in which case no special
+function is done.
+Any of the special characters may be preceded by the
+.Sy LNEXT
+character, in
+which case no special function is done.
+.El
+.Ss "Modem Disconnect"
+When a modem disconnect is detected, a
+.Dv SIGHUP
+signal is sent to the
+terminal's controlling process.
+Unless other arrangements have been made, these
+signals cause the process to terminate.
+If
+.Dv SIGHUP
+is ignored or caught,
+any subsequent read returns with an end-of-file indication until the terminal
+is closed.
+.Pp
+If the controlling process is not in the foreground process group of the
+terminal, a
+.Dv SIGTSTP
+is sent to the terminal's foreground process group.
+Unless other arrangements have been made, these signals cause the processes to
+stop.
+.Pp
+Processes in background process groups that attempt to access the controlling
+terminal after modem disconnect while the terminal is still allocated to the
+session will receive appropriate
+.Dv SIGTTOU
+and
+.Dv SIGTTIN
+signals.
+Unless other arrangements have been made, this signal causes the processes to
+stop.
+.Pp
+The controlling terminal will remain in this state until it is reinitialized
+ithh a successful open by the controlling process, or deallocated by the
+controlling process.
+.Ss "Terminal Parameters"
+The parameters that control the behavior of devices and modules providing the
+.Vt termios
+interface are specified by the
+.Vt termios
+structure defined by
+.In termios.h .
+Several
+.Xr ioctl 2
+system calls that fetch or change
+these parameters use this structure that contains the following members:
+.Bd -literal -offset 2n
+tcflag_t c_iflag; /* input modes */
+tcflag_t c_oflag; /* output modes */
+tcflag_t c_cflag; /* control modes */
+tcflag_t c_lflag; /* local modes */
+cc_t c_cc[NCCS]; /* control chars */
+.Ed
+.Pp
+The special control characters are defined by the array
+.Fa c_cc .
+The symbolic name
+.Dv NCCS
+is the size of the Control-character array and is also
+defined by
+.In termios.h .
+The relative positions, subscript names, and
+typical default values for each function are as follows:
+.Bl -column "Relative Position" "Subscript Name" "Typical Default Value"
+.It Relative Position Ta Subscript Name Ta Typical Default Value
+.It 0 Ta Dv VINTR Ta Sy ETX
+.It 1 Ta Dv VQUIT Ta Sy FS
+.It 2 Ta Dv VERASE Ta Sy DEL
+.It 3 Ta Dv VKILL Ta Sy NAK
+.It 4 Ta Dv VEOF Ta Sy EOT
+.It 5 Ta Dv VEOL Ta Sy NUL
+.It 6 Ta Dv VEOL2 Ta Sy NUL
+.It 7 Ta Dv VWSTCH Ta Sy NUL
+.It 8 Ta Dv VSTART Ta Sy NUL
+.It 9 Ta Dv VSTOP Ta Sy DC3
+.It 10 Ta Dv VSUSP Ta Sy SUB
+.It 11 Ta Dv VDSUSP Ta Sy EM
+.It 12 Ta Dv VREPRINT Ta Sy DC2
+.It 13 Ta Dv VDISCARD Ta Sy SI
+.It 14 Ta Dv VWERASE Ta Sy ETB
+.It 15 Ta Dv VLNEXT Ta Sy SYN
+.It 16 Ta Dv VSTATUS Ta Sy DC4
+.It 17 Ta Dv VERASE2 Ta Sy BS
+.It 18-19 Ta Reserved Ta
+.El
+.Ss "Input Modes"
+The
+.Fa c_iflag
+field describes the basic terminal input control:
+.Pp
+.Bl -tag -width "IMAXBEL" -offset 2n -compact
+.It Dv IGNBRK
+Ignore break condition.
+.It Dv BRKINT
+Signal interrupt on break.
+.It Dv IGNPAR
+Ignore characters with parity errors.
+.It Dv PARMRK
+Mark parity errors.
+.It Dv INPCK
+Enable input parity check.
+.It Dv ISTRIP
+Strip character.
+.It Dv INLCR
+Map NL to CR on input.
+.It Dv IGNCR
+Ignore CR.
+.It Dv ICRNL
+Map CR to NL on input.
+.It Dv IUCLC
+Map upper-case to lower-case on input.
+.It Dv IXON
+Enable start/stop output control.
+.It Dv IXANY
+Enable any character to restart output.
+.It Dv IXOFF
+Enable start/stop input control.
+.It Dv IMAXBEL
+Echo
+.Sy BEL
+on input line too long.
+.El
+.Pp
+If
+.Dv IGNBRK
+is set, a break condition (a character framing error with data
+all zeros) detected on input is ignored, that is, not put on the input queue
+and therefore not read by any process.
+If
+.Dv IGNBRK
+is not set and
+.Dv BRKINT
+is set, the break condition shall flush the input and output
+queues and if the terminal is the controlling terminal of a foreground process
+group, the break condition generates a single
+.Dv SIGINT
+signal to that
+foreground process group.
+If neither
+.Dv IGNBRK
+nor
+.Dv BRKINT
+is set, a
+break condition is read as a single
+.Ql \e0
+.Pq Sy ASCII NULL
+character, or if
+.Dv PARMRK
+is set, as
+.Ql \e377 ,
+.Ql \e0 ,
+.Em c ,
+where
+.Ql \e377
+is a single character
+with value 377 octal (0xff hex, 255 decimal),
+.Ql \e0
+is a single character with value
+.Sy 0 ,
+and
+.Em c
+is the errored character received.
+.Pp
+If
+.Dv IGNPAR
+is set, a byte with framing or parity errors (other than
+break) is ignored.
+.Pp
+If
+.Dv PARMRK
+is set, and
+.Dv IGNPAR
+is not set, a byte with a framing or
+parity error (other than break) is given to the application as the
+three-character sequence:
+.Ql \e377 ,
+.Ql \e0 ,
+c, where
+.Ql \e377
+is a single character with value 377 octal (0xff hex, 255 decimal),
+.Ql \e0
+is a single character with value 0, and c is the errored character received.
+To avoid ambiguity in this case, if
+.Dv ISTRIP
+is not set, a valid character
+of
+.Ql \e377
+is given to the application as
+.Ql \e377 .
+If neither
+.Dv IGNPAR
+nor
+.Dv PARMRK
+is set, a framing or parity error (other than break) is given to
+the application as a single
+.Ql \e0
+.Po
+.Sy ASCII NULL
+.Pc
+character.
+.Pp
+If
+.Dv INPCK
+is set, input parity checking is enabled.
+If
+.Dv INPCK
+is not
+set, input parity checking is disabled.
+This allows output parity generation
+without input parity errors.
+Note that whether input parity checking is
+enabled or disabled is independent of whether parity detection is enabled or
+disabled.
+If parity detection is enabled but input parity checking is
+disabled, the hardware to which the terminal is connected will recognize the
+parity bit, but the terminal special file will not check whether this is set
+correctly or not.
+.Pp
+If
+.Dv ISTRIP
+is set, valid input characters are first stripped to seven
+bits, otherwise all eight bits are processed.
+.Pp
+If
+.Dv INLCR
+is set, a received
+.Sy NL
+character is translated into a
+.Sy CR
+character.
+If
+.Dv IGNCR
+is set, a received
+.Sy CR
+character is ignored (not read).
+Otherwise, if
+.Dv ICRNL
+is set, a received
+.Sy CR
+character is translated into a
+.Sy NL
+character.
+.Pp
+If
+.Dv IUCLC
+is set, a received upper case, alphabetic character is
+translated into the corresponding lower case character.
+.Pp
+If
+.Dv IXON
+is set, start/stop output control is enabled.
+A received
+.Sy STOP
+character suspends output and a received
+.Sy START
+character
+restarts output.
+The
+.Sy STOP
+and
+.Sy START
+characters will not be read,
+but will merely perform flow control functions.
+If
+.Dv IXANY
+is set, any
+input character restarts output that has been suspended.
+.Pp
+If
+.Dv IXOFF
+is set, the system transmits a
+.Sy STOP
+character when the
+input queue is nearly full, and a
+.Sy START
+character when enough input has
+been read so that the input queue is nearly empty again.
+.Pp
+If
+.Dv IMAXBEL
+is set, the
+.Sy ASCII BEL
+character is echoed if the input stream overflows.
+Further input is not stored, but any input already present in
+the input stream is not disturbed.
+If
+.Dv IMAXBEL
+is not set, no
+.Sy BEL
+character is echoed, and all input present in the input queue is discarded if
+the input stream overflows.
+.Ss "Output Modes"
+The
+.Fa c_oflag
+field specifies the system treatment of output:
+.Pp
+.Bl -tag -width ONLRET -offset 2n -compact
+.It Dv OPOST
+Post-process output.
+.It Dv OLCUC
+Map lower case to upper on output.
+.It Dv ONLCR
+Map NL to CR-NL on output.
+.It Dv OCRNL
+Map CR to NL on output.
+.It Dv ONOCR
+No
+.Sy CR
+output at column 0.
+.It Dv ONLRET
+.Sy NL
+performs
+.Sy CR
+function.
+.It Dv OFILL
+Use fill characters for delay.
+.It Dv OFDEL
+Fill is
+.Sy DEL ,
+else
+.Sy INULL .
+.It Dv NLDLY
+Select newline delays:
+.Bl -tag -width NL0 -compact -offset 2n
+.It Sy NL0
+.It Sy NL1
+.El
+.It Dv CRDLY
+Select carriage-return delays:
+.Bl -tag -width CR0 -compact -offset 2n
+.It Dv CR0
+.It Dv CR1
+.It Dv CR2
+.It Dv CR3
+.El
+.It Dv TABDLY
+Select horizontal tab delays or tab expansion:
+.Bl -tag -width XTABS -compact -offset 2n
+.It Dv TAB0
+.It Dv TAB1
+.It Dv TAB2
+.It Dv TAB3
+Expand tabs to spaces
+.It Dv XTABS
+Expand tabs to spaces
+.El
+.It Dv BSDLY
+Select backspace delays:
+.Bl -tag -width BS0 -offset 2n -compact
+.It Dv BS0
+.It Dv BS1
+.El
+.It Dv VTDLY
+Select vertical tab delays:
+.Bl -tag -width VT0 -offset 2n -compact
+.It Dv VT0
+.It Dv VT1
+.El
+.It Dv FFDLY
+Select form feed delays:
+.Bl -tag -width FF0 -offset 2n -compact
+.It Dv FF0
+.It Dv FF1
+.El
+.El
+.Pp
+If
+.Dv OPOST
+is set, output characters are post-processed as indicated by the
+remaining flags; otherwise, characters are transmitted without change.
+.Pp
+If
+.Dv OLCUC
+is set, a lower case alphabetic character is transmitted as the
+corresponding upper case character.
+This function is often used in conjunction
+with
+.Dv IUCLC .
+.Pp
+If
+.Dv ONLCR
+is set, the
+.Sy NL
+character is transmitted as the
+.Sy CR-NL
+character pair.
+If
+.Dv OCRNL
+is set, the
+.Sy CR
+character is transmitted as the
+.Sy NL
+character.
+If
+.Dv ONOCR
+is set, no
+.Sy CR
+character is transmitted when at column 0 (first position).
+If
+.Dv ONRET
+is set, the
+.Sy NL
+character is assumed to do the carriage-return function; the column
+pointer is set to 0 and the delays specified for
+.Sy CR
+are used.
+Otherwise, the
+.Sy NL
+character is assumed to do just the line-feed function; the column
+pointer remains unchanged.
+The column pointer is also set to 0 if the
+.Sy CR
+character is actually transmitted.
+.Pp
+The delay bits specify how long transmission stops to allow for mechanical or
+other movement when certain characters are sent to the terminal.
+In all cases, a value of 0 indicates no delay.
+If
+.Dv OFILL
+is set, fill characters are transmitted for delay instead of a timed delay.
+This is useful for high baud rate terminals that need only a minimal delay.
+If
+.Dv OFDEL
+is set, the
+fill character is
+.Sy DEL ;
+otherwise it is
+.Sy NULL .
+.Pp
+If a form-feed or vertical-tab delay is specified, it lasts for about 2
+seconds.
+.Pp
+Newline delay lasts about 0\&.10 seconds.
+If
+.Dv ONLRET
+is set, the carriage-return delays are used instead of the newline delays.
+If
+.Dv OFILL
+is set, two fill characters are transmitted.
+.Pp
+Carriage-return delay type 1 is dependent on the current column position, type
+2 is about 0\&.10 seconds, and type 3 is about 0\&.15 seconds.
+If
+.Dv OFILL
+is set, delay type 1 transmits two fill characters, and type 2 transmits four
+fill characters.
+.Pp
+Horizontal-tab delay type 1 is dependent on the current column position.
+Type 2 is about 0\&.10 seconds.
+Type 3 specifies that tabs are to be expanded into spaces.
+If
+.Dv OFILL
+is set, two fill characters are transmitted for any delay.
+.Pp
+Backspace delay lasts about 0\&.05 seconds.
+If
+.Dv OFILL
+is set, one fill character is transmitted.
+.Pp
+The actual delays depend on line speed and system load.
+.Ss "Control Modes"
+The
+.Fa c_cflag
+field describes the hardware control of the terminal:
+.Bl -tag -width CIBAUDEXT -offset 2n
+.It Dv CBAUD
+Baud rate:
+.Bl -tag -width B4000000 -compact
+.It Dv B0
+Hang up
+.It Dv B50
+50 baud
+.It Dv B75
+75 baud
+.It Dv B110
+110 baud
+.It Dv B134
+134 baud
+.It Dv B150
+150 baud
+.It Dv B200
+200 baud
+.It Dv B300
+300 baud
+.It Dv B600
+600 baud
+.It Dv B1200
+1200 baud
+.It Dv B1800
+1800 baud
+.It Dv B2400
+2400 baud
+.It Dv B4800
+4800 baud
+.It Dv B9600
+9600 baud
+.It Dv B19200
+19200 baud
+.It Dv B38400
+38400 baud
+.It Dv B57600
+57600 baud
+.It Dv B76800
+76800 baud
+.It Dv B115200
+115200 baud
+.It Dv B153600
+153600 baud
+.It Dv B230400
+230400 baud
+.It Dv B307200
+307200 baud
+.It Dv B460800
+460800 baud
+.It Dv B921600
+921600 baud
+.It Dv B1000000
+1000000 baud
+.It Dv B1152000
+1152000 baud
+.It Dv B1500000
+1500000 baud
+.It Dv B2000000
+2000000 baud
+.It Dv B2500000
+2500000 baud
+.It Dv B3000000
+3000000 baud
+.It Dv B3500000
+3500000 baud
+.It Dv B4000000
+4000000 baud
+.El
+.It Dv CSIZE
+Character size:
+.Bl -tag -width CIBAUDEXT -compact
+.It Dv CS5
+5 bits
+.It Dv CS6
+6 bits
+.It Dv CS7
+7 bits
+.It Dv CS8
+8 bits
+.It Dv CSTOPB
+Send two stop bits, else one
+.It Dv CREAD
+Enable receiver
+.It Dv PARENB
+Parity enable
+.It Dv PARODD
+Odd parity, else even
+.It Dv HUPCL
+Hang up on last close
+.It Dv CLOCAL
+Local line, else dial-up
+.It Dv CIBAUD
+Input baud rate, if different from output rate
+.It Dv PAREXT
+Extended parity for mark and space parity
+.It Dv CRTSXOFF
+Enable inbound hardware flow control
+.It Dv CRTSCTS
+Enable outbound hardware flow control
+.It Dv CBAUDEXT
+Bit to indicate output speed > B38400
+.It Dv CIBAUDEXT
+Bit to indicate input speed > B38400
+.El
+.El
+.Pp
+The
+.Dv CBAUD
+bits together with the
+.Dv CBAUDEXT
+bit specify the output baud rate.
+To retrieve the output speed from the
+.Vt termios
+structure pointed to by
+.Fa termios_p
+see the following code segment.
+.Bd -literal -offset 2n
+speed_t ospeed;
+if (termios_p->c_cflag & CBAUDEXT)
+ ospeed = (termios_p->c_cflag & CBAUD) + CBAUD + 1;
+else
+ ospeed = termios_p->c_cflag & CBAUD;
+.Ed
+.Pp
+To store the output speed in the termios structure pointed to by
+.Fa termios_p
+see the following code segment.
+.Bd -literal -offset 2n
+speed_t ospeed;
+if (ospeed > CBAUD) {
+ termios_p->c_cflag |= CBAUDEXT;
+ ospeed -= (CBAUD + 1);
+} else {
+ termios_p->c_cflag &= ~CBAUDEXT;
+}
+termios_p->c_cflag =
+ (termios_p->c_cflag & ~CBAUD) | (ospeed & CBAUD);
+.Ed
+.Pp
+The zero baud rate,
+.Dv B0 ,
+is used to hang up the connection.
+If
+.Dv B0
+is specified, the data-terminal-ready signal is not asserted.
+Normally, this disconnects the line.
+.Pp
+If the
+.Dv CIBAUDEXT
+or
+.Dv CIBAUD
+bits are not zero, they specify the input baud rate, with the
+.Dv CBAUDEXT
+and
+.Dv CBAUD
+bits specifying the output baud rate; otherwise, the output and input baud
+rates are both specified by the
+.Dv CBAUDEXT
+and
+.Dv CBAUD
+bits.
+The values for the
+.Dv CIBAUD
+bits are the same as the values for the
+.Dv CBAUD
+bits, shifted left
+.Dv IBSHIFT
+bits.
+For any particular hardware, impossible speed changes are
+ignored.
+To retrieve the input speed in the
+.Vt termios
+structure pointed to
+by
+.Fa termios_p
+see the following code segment.
+.Bd -literal -offset 2n
+speed_t ispeed;
+if (termios_p->c_cflag & CIBAUDEXT) {
+ ispeed = ((termios_p->c_cflag & CIBAUD) >> IBSHIFT)
+ + (CIBAUD >> IBSHIFT) + 1;
+} else {
+ ispeed = (termios_p->c_cflag & CIBAUD) >> IBSHIFT;
+}
+.Ed
+.Pp
+To store the input speed in the
+.Vt termios
+structure pointed to by
+.Fa termios_p
+see the following code segment.
+.Bd -literal -offset 2n
+speed_t ispeed;
+if (ispeed == 0) {
+ ispeed = termios_p->c_cflag & CBAUD;
+ if (termios_p->c_cflag & CBAUDEXT)
+ ispeed += (CBAUD + 1);
+}
+if ((ispeed << IBSHIFT) > CIBAUD) {
+ termios_p->c_cflag |= CIBAUDEXT;
+ ispeed -= ((CIBAUD >> IBSHIFT) + 1);
+} else {
+ termios_p->c_cflag &= ~CIBAUDEXT;
+}
+termios_p->c_cflag =
+ (termios_p->c_cflag & ~CIBAUD) | ((ispeed << IBSHIFT) & CIBAUD);
+.Ed
+.Pp
+The
+.Dv CSIZE
+bits specify the character size in bits for both transmission and reception.
+This size does not include the parity bit, if any.
+If
+.Dv CSTOPB
+is set, two stop bits are used; otherwise, one stop bit is used.
+For example, at 110 baud, two stops bits are required.
+.Pp
+If
+.Dv PARENB
+is set, parity generation and detection is enabled, and a
+parity bit is added to each character.
+If parity is enabled, the
+.Dv PARODD
+flag specifies odd parity if set; otherwise, even parity is used.
+.Pp
+If
+.Dv CREAD
+is set, the receiver is enabled.
+Otherwise, no characters are received.
+.Pp
+If
+.Dv HUPCL
+is set, the line is disconnected when the last process with the
+line open closes it or terminates.
+That is, the data-terminal-ready signal is not asserted.
+.Pp
+If
+.Dv CLOCAL
+is set, the line is assumed to be a local, direct connection
+with no modem control; otherwise, modem control is assumed.
+.Pp
+If
+.Dv CRTSXOFF
+is set, inbound hardware flow control is enabled.
+.Pp
+If
+.Dv CRTSCTS
+is set, outbound hardware flow control is enabled.
+.Pp
+The four possible combinations for the state of
+.Dv CRTSCTS
+and
+.Dv CRTSXOFF
+bits and their interactions are described below.
+.Bl -tag -width "Case C:"
+.It Sy Case A :
+.Dv CRTSCTS
+off,
+.Dv CRTSXOFF
+off.
+In this case the hardware flow control is disabled.
+.It Sy Case B :
+.Dv CRTSCTS
+on,
+.Dv CRTSXOFF
+off.
+In this case only outbound hardware flow control is enabled.
+The state of CTS signal is used to do outbound flow control.
+It is expected that output will be suspended if CTS is low and resumed
+when CTS is high.
+.It Sy Case C :
+.Dv CRTSCTS
+off,
+.Dv CRTSXOFF
+on.
+In this case only inbound hardware flow control is enabled.
+The state of RTS signal is used to do inbound flow control.
+It is expected that input will be suspended if RTS is low and resumed when RTS
+is high.
+.It Sy Case D :
+.Dv CRTSCTS
+on,
+.Dv CRTSXOFF
+on.
+In this case both inbound and outbound hardware flow control are enabled.
+Uses the state of CTS signal to do outbound
+flow control and RTS signal to do inbound flow control.
+.El
+.Ss "Local Modes"
+The
+.Fa c_lflag
+field of the argument structure is used by the line
+discipline to control terminal functions.
+The basic line discipline provides the following:
+.Pp
+.Bl -tag -offset 2n -width SIGTTOU -compact
+.It Dv ISIG
+Enable signals.
+.It Dv ICANON
+Canonical input (erase and kill processing).
+.It Dv XCASE
+Canonical upper/lower presentation.
+.It Dv ECHO
+Enable echo.
+.It Dv ECHOE
+Echo erase character as
+.Sy BS Ns - Ns Sy SP Ns - Ns Sy BS
+&.
+.It Dv ECHOK
+Echo
+.Sy NL
+after kill character.
+.It Dv ECHONL
+Echo
+.Sy NL .
+.It Dv NOFLSH
+Disable flush after interrupt or quit.
+.It Dv TOSTOP
+Send
+.It Dv SIGTTOU
+for background output.
+.It Dv ECHOCTL
+Echo control characters as
+.Em char ,
+delete as ^?.
+.It Dv ECHOPRT
+Echo erase character as character erased.
+.It Dv ECHOKE
+.Sy BS Ns - Ns Sy SP Ns - Ns Sy BS
+erase entire line on line kill.
+.It Dv FLUSHO
+Output is being flushed.
+.It Dv PENDIN
+Retype pending input at next read or input character.
+.It Dv IEXTEN
+Enable extended (implementation-defined) functions.
+.El
+.Pp
+If
+.Dv ISIG
+is set, each input character is checked against the special
+control characters
+.Sy INTR ,
+.Sy QUIT ,
+.Sy SWTCH ,
+.Sy SUSP ,
+.Sy STATUS ,
+and
+.Sy DSUSP .
+If an input character matches one of these control characters, the function
+associated with that character is performed.
+.Po
+Note: If
+.Sy SWTCH
+is set and the character matches, the character is simply discarded.
+No other action is taken.
+.Pc
+If
+.Dv ISIG
+is not set, no checking is done.
+Thus, these special
+input functions are possible only if
+.Dv ISIG
+is set.
+.Pp
+If
+.Dv ICANON
+is set, canonical processing is enabled.
+This enables the erase
+and kill edit functions, and the assembly of input characters into lines
+delimited by
+.Sy NL-c ,
+.Sy EOF ,
+.Sy EOL ,
+and
+.Sy EOL .
+If
+.Dv ICANON
+is not set, read requests are satisfied directly from the input queue.
+A read is not satisfied until at least
+.Sy MIN
+characters have been received or the timeout value
+.Sy TIME
+has expired between characters.
+This allows fast bursts of input to be read efficiently while still allowing
+single character input.
+The time value represents tenths of seconds.
+.Pp
+If
+.Dv XCASE
+is set and
+.Dv ICANON
+is set, an upper case letter is
+accepted on input if preceded by a backslash
+.Ql \e
+character, and is output preceded by a backslash
+.Ql \e
+character.
+In this mode, the
+following escape sequences are generated on output and accepted on input:
+.Bl -column "FOR:" "USE:" -offset 2n
+.It FOR: Ta USE:
+.It ` Ta \e'
+.It | Ta \e!
+.It \(ap Ta \e^
+.It { Ta \e(
+.It } Ta \e)
+.It \e Ta \e\e
+.El
+.Pp
+For example, input A as \ea, \en as \e\en, and \eN as \e\e\en.
+.Pp
+If
+.Dv ECHO
+is set, characters are echoed as received.
+.Pp
+When
+.Dv ICANON
+is set, the following echo functions are possible.
+.Bl -bullet -offset indent
+.It
+If
+.Dv ECHO
+and
+.Dv ECHOE
+are set, and
+.Dv ECHOPRT
+is not set, the
+.Sy ERASE ,
+.Sy ERASE2 ,
+and
+.Sy WERASE
+characters are echoed as one or
+more ASCII BS SP BS, which clears the last character(s) from a
+.Sy CRT
+screen.
+.It
+If
+.Dv ECHO ,
+.Dv ECHOPRT ,
+and
+.Dv IEXTEN
+are set, the first
+.Sy ERASE ,
+.Sy ERASE2 ,
+and
+.Sy WERASE
+character in a sequence echoes as a backslash
+.Ql \e ,
+followed by the characters being erased.
+Subsequent
+.Sy ERASE
+and
+.Sy WERASE
+characters echo the characters being erased, in reverse order.
+The
+next non-erase character causes a
+.Ql /
+(slash) to be typed before it is echoed.
+.Dv ECHOPRT
+should be used for hard copy terminals.
+.It
+If
+.Dv ECHOKE
+and
+.Dv IEXTEN
+are set, the kill character is echoed by
+erasing each character on the line from the screen (using the mechanism
+selected by
+.Dv ECHOE
+and
+.Dv ECHOPR ) .
+.It
+If
+.Dv ECHOK
+is set, and
+.Dv ECHOKE
+is not set, the
+.Sy NL
+character is
+echoed after the kill character to emphasize that the line is deleted.
+Note
+that a
+.Ql \e
+(escape) character or an
+.Sy LNEXT
+character preceding the erase
+or kill character removes any special function.
+.It
+If
+.Dv ECHONL
+is set, the
+.Sy NL
+character is echoed even if
+.Dv ECHO
+is not set.
+This is useful for terminals set to local echo (so called
+half-duplex).
+.El
+.Pp
+If
+.Dv ECHOCTL
+and
+.Dv IEXTEN
+are set, all control characters (characters
+with codes between 0 and 37 octal) other than
+.Sy ASCII TAB ,
+.Sy ASCII NL ,
+the
+.Sy START
+character, and the
+.Sy STOP
+character,
+.Sy ASCII CR ,
+and
+.Sy ASCII BS
+are echoed as
+.No ^ Ns Em X ,
+where
+.Em X
+is the character given by adding
+.Ql 100
+octal to the code of the control character (so
+that the character with octal code
+.Ql 1
+is echoed as
+.No ^ Ns Sy A ) ,
+and the
+.Sy ASCII DEL
+character,
+with code
+.Ql 177
+octal, is echoed as
+.No ^ Ns Sy \&? .
+.Pp
+If
+.Dv NOFLSH
+is set, the normal flush of the input and output queues
+associated with the
+.Sy INTR ,
+.Sy QUIT ,
+.Sy STATUS ,
+and
+.Sy SUSP
+characters is not done.
+This bit should be set when restarting system calls
+that read from or write to a terminal
+.Po
+see
+.Xr sigaction 2
+.Pc .
+.Pp
+If
+.Dv TOSTOP
+and
+.Dv IEXTEN
+are set, the signal
+.Dv SIGTTOU
+is sent to
+a process that tries to write to its controlling terminal if it is not in the
+foreground process group for that terminal.
+This signal normally stops the process.
+Otherwise, the output generated by that process is output to the
+current output stream.
+Processes that are blocking or ignoring
+.Dv SIGTTOU
+signals are excepted and allowed to produce output, if any.
+.Pp
+If
+.Dv FLUSHO
+and
+.Dv IEXTEN
+are set, data written to the terminal is
+discarded.
+This bit is set when the
+.Sy FLUSH
+character is typed.
+A program can cancel the effect of typing the
+.Sy FLUSH
+character by clearing
+.Dv FLUSHO .
+.Pp
+If
+.Dv PENDIN
+and
+.Dv IEXTEN
+are set, any input that has not yet been read
+is reprinted when the next character arrives as input.
+.Dv PENDIN
+is then
+automatically cleared.
+.Pp
+If
+.Dv IEXTEN
+is set, the following implementation-defined functions are
+enabled: special characters (
+.Sy WERASE ,
+.Sy REPRINT ,
+.Sy DISCARD ,
+and
+.Sy LNEXT )
+and local flags (
+.Dv TOSTOP ,
+.Dv ECHOCTL ,
+.Dv ECHOPRT ,
+.Dv ECHOKE ,
+.Dv FLUSHO ,
+and
+.Dv PENDIN ) .
+.Ss "Minimum and Timeout"
+The
+.Sy MIN
+and
+.Sy TIME
+values were described previously, in the
+subsection,
+.Sy Non-canonical Mode Input Processing .
+The initial value of
+.Sy MIN
+is 1, and the initial value of
+.Sy TIME
+is 0.
+.Ss "Terminal Size"
+The number of lines and columns on the terminal's display is specified in the
+.Vt winsize
+structure defined by
+.In sys/termios.h
+and includes the following members:
+.Bd -literal -offset 2n
+unsigned short ws_row; /* rows, in characters */
+unsigned short ws_col; /* columns, in characters */
+unsigned short ws_xpixel; /* horizontal size, in pixels */
+unsigned short ws_ypixel; /* vertical size, in pixels */
+.Ed
+.Ss "Termio Structure"
+The SunOS/SVR4
+.Vt termio
+structure is used by some
+.Fn ioctl Ns s ;
+it is defined by
+.In sys/termio.h
+and includes the following members:
+.Bd -literal -offset 2n
+unsigned short c_iflag; /* input modes */
+unsigned short c_oflag; /* output modes */
+unsigned short c_cflag; /* control modes */
+unsigned short c_lflag; /* local modes */
+char c_line; /* line discipline */
+unsigned char c_cc[NCC]; /* control chars */
+.Ed
+.Pp
+The special control characters are defined by the array
+.Fa c_cc .
+The symbolic name
+.Dv NCC
+is the size of the Control-character array and is also
+defined by
+.In termio.h .
+The relative positions, subscript names, and typical
+default values for each function are as follows:
+.Bl -column "Relative Positions" "Subscript Names" "Typical Default Values"
+.It Relative Positions Ta Subscript Names Ta Typical Default Values
+.It 0 Ta VINTR Ta EXT
+.It 1 Ta VQUIT Ta FS
+.It 2 Ta VERASE Ta DEL
+.It 3 Ta VKILL Ta NAK
+.It 4 Ta VEOF Ta EOT
+.It 5 Ta VEOL Ta NUL
+.It 6 Ta VEOL2 Ta NUL
+.It 7 Ta Reserved Ta
+.El
+.Pp
+The
+.Sy MIN
+values is stored in the
+.Dv VMIN
+element of the
+.Fa c_cc
+array; the
+.Sy TIME
+value is stored in the
+.Dv VTIME
+element of the
+.Fa c_cc
+array.
+The
+.Dv VMIN
+element is the same element as the
+.Dv VEOF
+element; the
+.Dv VTIME
+element is the same element as the
+.Dv VEOL
+element.
+.Pp
+The calls that use the
+.Va termio
+structure only affect the flags and control
+characters that can be stored in the
+.Vt termio
+structure; all other flags and control characters are unaffected.
+.Ss "Modem Lines"
+On special files representing serial ports, modem control lines can be read.
+Control lines (if the underlying hardware supports it) may also be changed.
+Status lines are read-only.
+The following modem control and status lines may be
+supported by a device; they are defined by
+.In sys/termios.h :
+.Pp
+.Bl -tag -width "TIOCM_DTR" -compact -offset 2n
+.It Dv TIOCM_LE
+line enable
+.It Dv TIOCM_DTR
+data terminal ready
+.It Dv TIOCM_RTS
+request to send
+.It Dv TIOCM_ST
+secondary transmit
+.It Dv TIOCM_SR
+secondary receive
+.It Dv TIOCM_CTS
+clear to send
+.It Dv TIOCM_CAR
+carrier detect
+.It Dv TIOCM_RNG
+ring
+.It Dv TIOCM_DSR
+data set ready
+.El
+.Pp
+.Dv TIOCM_CD
+is a synonym for
+.Dv TIOCM_CAR ,
+and
+.Dv TIOCM_RI
+is a synonym for
+.Dv TIOCM_RNG .
+Not all of these are necessarily supported by any
+particular device; check the manual page for the device in question.
+.Pp
+The software carrier mode can be enabled or disabled using the
+.Dv TIOCSSOFTCAR
+.Fn ioctl .
+If the software carrier flag for a line is off,
+the line pays attention to the hardware carrier detect (DCD) signal.
+The
+.Sy tty
+device associated with the line cannot be opened until
+.Sy DCD
+is asserted.
+If the software carrier flag is on, the line behaves as if
+.Sy DCD
+is always asserted.
+.Pp
+The software carrier flag is usually turned on for locally connected terminals
+or other devices, and is off for lines with modems.
+.Pp
+To be able to issue the
+.Dv TIOCGSOFTCAR
+and
+.Dv TIOCSSOFTCAR
+.Fn ioctl
+calls, the
+.Sy tty
+line should be opened with
+.Dv O_NDELAY
+so that the
+.Xr open 2
+will not wait for the carrier.
+.Ss "Default Values"
+The initial
+.Vt termios
+values upon driver open is configurable.
+This is accomplished by setting the "ttymodes" property in the file
+.Pa /kernel/drv/options.conf .
+Since this property is assigned during system
+initialization, any change to the "ttymodes" property will not take effect
+until the next reboot.
+The string value assigned to this property should be in
+the same format as the output of the
+.Xr stty 1
+command with the -g option.
+.Pp
+If this property is undefined, the following
+.Vt termios
+modes are in effect.
+The initial input control value is
+.Dv BRKINT ,
+.Dv ICRNL ,
+.Dv IXON ,
+.Dv IMAXBEL .
+The initial output control value is
+.Dv OPOST ,
+.Dv ONLCR ,
+.Dv TAB3 .
+The initial hardware control value is
+.Dv B9600 ,
+.Dv CS8 ,
+.Dv CREAD .
+The initial line-discipline control value is
+.Dv ISIG ,
+.Dv ICANON ,
+.Dv IEXTEN ,
+.Dv ECHO ,
+.Dv ECHOK ,
+.Dv ECHOE ,
+.Dv ECHOKE ,
+.Dv ECHOCTL .
+.Sh IOCTLS
+The
+.Fn ioctl Ns s
+supported by devices and
+.Sy STREAMS
+modules providing the
+.Xr termios 3C
+interface are listed below.
+Some calls may not be supported by all devices or modules.
+The functionality provided by these calls is also
+available through the preferred function call interface specified on
+.Nm termios .
+.Bl -tag -width TIOCSSOFTCAR
+.It Dv TCGETS
+The argument is a pointer to a
+.Vt termios
+structure.
+The current terminal parameters are fetched and stored into that structure.
+.It Dv TCSETS
+The argument is a pointer to a
+.Vt termios
+structure.
+The current terminal parameters are set from the values stored in that structure.
+The change is immediate.
+.It Dv TCSETSW
+The argument is a pointer to a
+.Vt termios
+structure.
+The current terminal parameters are set from the values stored in that structure.
+The change occurs after all characters queued for output have been transmitted.
+This form should be used when changing parameters that affect output.
+.It Dv TCSETSF
+The argument is a pointer to a
+.Vt termios
+structure.
+The current terminal parameters are set from the values stored in that structure.
+The change occurs after all characters queued for output have been transmitted;
+all characters queued for input are discarded and then the change occurs.
+.It Dv TCGETA
+The argument is a pointer to a
+.Vt termio
+structure.
+The current terminal parameters are fetched, and those parameters that can be
+stored in a
+.Vt termio
+structure are stored into that structure.
+.It Dv TCSETA
+The argument is a pointer to a
+.Vt termio
+structure.
+Those terminal parameters that can be stored in a
+.Vt termio
+structure are set from the values stored in that structure.
+The change is immediate.
+.It Dv TCSETAW
+The argument is a pointer to a
+.Vt termio
+structure.
+Those terminal parameters that can be stored in a
+.Vt termio
+structure are set from
+the values stored in that structure.
+The change occurs after all characters queued for output have been transmitted.
+This form should be used when changing parameters that affect output.
+.It Dv TCSETAF
+The argument is a pointer to a
+.Vt termio
+structure.
+Those terminal parameters that can be stored in a
+.Vt termio
+structure are set from the values stored in that structure.
+The change occurs after all characters queued
+for output have been transmitted; all characters queued for input are discarded
+and then the change occurs.
+.It Dv TCSBRK
+The argument is an
+.Vt int
+value.
+Wait for the output to drain.
+If the argument is
+.Sy 0 ,
+then send a break (zero valued bits for 0\&.25 seconds).
+.It Dv TCXONC
+Start/stop control.
+The argument is an
+.Vt int
+value.
+If the argument is
+.Sy 0 ,
+suspend output; if
+.Sy 1 ,
+restart suspended output; if
+.Sy 2 ,
+suspend input; if
+.Sy 3 ,
+restart suspended input.
+.It Dv TCFLSH
+The argument is an
+.Vt int
+value.
+If the argument is
+.Sy 0 ,
+flush the input queue; if
+.Sy 1 ,
+flush the output queue; if
+.Sy 2 ,
+flush both the input and output queues.
+.It Dv TIOCGPGRP
+The argument is a pointer to a
+.Vt pid_t .
+Set the value of that
+.Vt pid_t
+to the process group
+.Sy ID
+of the foreground process group associated with the terminal.
+See
+.Xr termios 3C
+for a description of
+.Dv TCGETPGRP .
+.It Dv TIOCSPGRP
+The argument is a pointer to a
+.Vt pid_t .
+Associate the process group whose
+process group
+.Sy ID
+is specified by the value of that
+.Vt pid_t
+with the terminal.
+The new process group value must be in the range of valid process
+group
+.Sy ID
+values.
+Otherwise, the error
+.Er EPERM
+is returned.
+.It Dv TIOCGSID
+The argument is a pointer to a
+.Vt pid_t .
+The session ID of the terminal is fetched and stored in the
+.Vt pid_t .
+.It Dv TIOCGWINSZ
+The argument is a pointer to a
+.Vt winsize
+structure.
+The terminal driver's
+notion of the terminal size is stored into that structure.
+.It Dv TIOCSWINSZ
+The argument is a pointer to a
+.Vt winsize
+structure.
+The terminal driver's
+notion of the terminal size is set from the values specified in that structure.
+If the new sizes are different from the old sizes, a
+.Dv SIGWINCH
+signal is set to the process group of the terminal.
+.It Dv TIOCMBIS
+The argument is a pointer to an
+.Vt int
+whose value is a mask containing modem control lines to be turned on.
+The control lines whose bits are set in
+the argument are turned on; no other control lines are affected.
+.It Dv TIOCMBIC
+The argument is a pointer to an
+.Vt int
+whose value is a mask containing modem control lines to be turned off.
+The control lines whose bits are set in
+the argument are turned off; no other control lines are affected.
+.It Dv TIOCMGET
+The argument is a pointer to an
+.Vt int .
+The current state of the modem
+status lines is fetched and stored in the
+.Vt int
+pointed to by the argument.
+.It Dv TIOCMSET
+The argument is a pointer to an
+.Vt int
+containing a new set of modem control lines.
+The modem control lines are turned on or off, depending on
+whether the bit for that mode is set or clear.
+.It Dv TIOCSPPS
+The argument is a pointer to an
+.Vt int
+that determines whether pulse-per-second event handling is to be enabled
+(non-zero) or disabled (zero).
+If a one-pulse-per-second reference clock is attached to the serial line's data
+carrier detect input, the local system clock will be calibrated to it.
+A clock with a high error, that is, a deviation of more than 25 microseconds
+per tick, is ignored.
+.It Dv TIOCGPPS
+The argument is a pointer to an
+.Vt int ,
+in which the state of the even handling is returned.
+The
+.Vt int
+is set to a non-zero value if pulse-per-second (PPS) handling has been enabled.
+Otherwise, it is set to zero.
+.It Dv TIOCGSOFTCAR
+The argument is a pointer to an
+.Vt int
+whose value is
+.Sy 1
+or
+.Sy 0 ,
+depending on whether the software carrier detect is turned on or off.
+.It Dv TIOCSSOFTCAR
+The argument is a pointer to an
+.Vt int
+whose value is
+.Sy 1
+or
+.Sy 0 .
+The value of the integer should be
+.Sy 0
+to turn off software carrier, or
+.Sy 1
+to turn it on.
+.It Dv TIOCGPPSEV
+The argument is a pointer to a
+.Vt "struct ppsclockev" .
+This structure contains the following members:
+.Bd -literal -offset 2n
+struct timeval tv;
+uint32_t serial;
+.Ed
+.Pp
+.Fa tv
+is the system clock timestamp when the event (pulse on the
+.Sy DCD
+pin) occurred.
+.Fa serial
+is the ordinal of the event, which each consecutive event
+being assigned the next ordinal.
+The first event registered gets a
+.Fa serial
+value of
+.Sy 1 .
+The
+.Dv TIOCGPPSEV
+returns the last event registered; multiple calls will persistently return the
+same event until a new one is registered.
+In addition to time stamping and saving the event, if it is of
+one-second period and of consistently high accuracy, the local system clock
+will automatically calibrate to it.
+.El
+.Sh FILES
+Files in or under
+.Pa /dev
+.Sh SEE ALSO
+.Xr stty 1 ,
+.Xr fork 2 ,
+.Xr getpgid 2 ,
+.Xr getsid 2 ,
+.Xr ioctl 2 ,
+.Xr setsid 2 ,
+.Xr sigaction 2 ,
+.Xr signal 3C ,
+.Xr tcsetpgrp 3C ,
+.Xr termios 3C ,
+.Xr signal.h 3HEAD ,
+.Xr streamio 4I
diff --git a/usr/src/man/man4i/termiox.4i b/usr/src/man/man4i/termiox.4i
new file mode 100644
index 0000000000..b25ba1940b
--- /dev/null
+++ b/usr/src/man/man4i/termiox.4i
@@ -0,0 +1,413 @@
+.\" Copyright 1989 AT&T
+.\" Copyright (C) 1999, Sun Microsystems, Inc. All Rights Reserved
+.\" Copyright (c) 2017, Joyent, Inc.
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd October 29, 2017
+.Dt TERMIOX 4I
+.Os
+.Sh NAME
+.Nm termiox
+.Nd extended general terminal interface
+.Sh DESCRIPTION
+The extended general terminal interface supplements the
+.Xr termio 4I
+general terminal interface by adding support for asynchronous hardware flow
+control, isochronous flow control and clock modes, and local implementations of
+additional asynchronous features.
+Some systems may not support all of these
+capabilities because of either hardware or software limitations.
+Other systems may not permit certain functions to be disabled.
+In these cases the appropriate bits will be ignored.
+See
+.In sys/termiox.h
+for your system to find out which capabilities are supported.
+.Ss "Hardware Flow Control Modes"
+Hardware flow control supplements the
+.Xr termio 4I
+.Dv IXON ,
+.Dv IXOFF ,
+and
+.Dv IXANY
+character flow control.
+Character flow control occurs when one
+device controls the data transfer of another device by the insertion of control
+characters in the data stream between devices.
+Hardware flow control occurs
+when one device controls the data transfer of another device using electrical
+control signals on wires (circuits) of the asynchronous interface.
+Isochronous
+hardware flow control occurs when one device controls the data transfer of
+another device by asserting or removing the transmit clock signals of that
+device.
+Character flow control and hardware flow control may be simultaneously
+set.
+.Pp
+In asynchronous, full duplex applications, the use of the Electronic Industries
+Association's EIA-232-D Request To Send (RTS) and Clear To Send (CTS) circuits
+is the preferred method of hardware flow control.
+An interface to other
+hardware flow control methods is included to provide a standard interface to
+these existing methods.
+.Pp
+The EIA-232-D standard specified only unidirectional hardware flow control \(em
+the Data Circuit-terminating Equipment or Data Communications Equipment (DCE)
+indicates to the Data Terminal Equipment (DTE) to stop transmitting data.
+The
+.Nm
+interface allows both unidirectional and bidirectional hardware
+flow control; when bidirectional flow control is enabled, either the DCE or DTE
+can indicate to each other to stop transmitting data across the interface.
+Note: It is assumed that the asynchronous port is configured as a DTE.
+If the
+connected device is also a DTE and not a DCE, then DTE to DTE (for example,
+terminal or printer connected to computer) hardware flow control is possible by
+using a null modem to interconnect the appropriate data and control circuits.
+.Ss "Clock Modes"
+Isochronous communication is a variation of asynchronous communication whereby
+two communicating devices may provide transmit and/or receive clock signals to
+one another.
+Incoming clock signals can be taken from the baud rate generator
+on the local isochronous port controller, from CCITT V\.24 circuit 114,
+Transmitter Signal Element Timing - DCE source (EIA-232-D pin 15), or from
+CITT V\.24 circuit 115, Receiver Signal Element Timing - DCE source (EIA-232-D
+pin 17).
+Outgoing clock signals can be sent on CCITT V\.24 circuit 113,
+Transmitter Signal Element Timing - DTE source (EIA-232-D pin 24), on CCITT
+V\.24 circuit 128, Receiver Signal Element Timing - DTE source (no EIA-232-D
+pin), or not sent at all.
+.Pp
+In terms of clock modes, traditional asynchronous communication is implemented
+simply by using the local baud rate generator as the incoming transmit and
+receive clock source and not outputting any clock signals.
+.Ss "Terminal Parameters"
+The parameters that control the behavior of devices providing the
+.Nm
+interface are specified by the
+.Vt termiox
+structure defined in the
+.In sys/termiox.h
+header.
+Several
+.Xr ioctl 2
+system calls that fetch
+or change these parameters use this structure:
+.Bd -literal -offset 2n
+#define NFF 5
+struct termiox {
+ unsigned short x_hflag; /* hardware flow control modes */
+ unsigned short x_cflag; /* clock modes */
+ unsigned short x_rflag[NFF]; /* reserved modes */
+ unsigned short x_sflag; /* spare local modes */
+};
+.Ed
+.Pp
+The
+.Fa x_hflag
+field describes hardware flow control modes:
+.Bl -column xxxxxxx xxxxxxx x
+.It Dv RTSXOFF Ta 0000001 Ta "Enable RTS hardware flow control on input."
+.It Dv CTSXON Ta 0000002 Ta "Enable CTS hardware flow control on output."
+.It Dv DTRXOFF Ta 0000004 Ta "Enable DTR hardware flow control on input."
+.It Dv CDXON Ta 0000010 Ta "Enable CD hardware flow control on output."
+.It Dv ISXOFF Ta 0000020 Ta "Enable isochronous hardware flow control on input."
+.El
+.Pp
+The EIA-232-D DTR and CD circuits are used to establish a connection between
+two systems.
+The RTS circuit is also used to establish a connection with a modem.
+Thus, both DTR and RTS are activated when an asynchronous port is opened.
+If DTR is used for hardware flow control, then RTS must be used for
+connectivity.
+If CD is used for hardware flow control, then CTS must be used
+for connectivity.
+Thus, RTS and DTR (or CTS and CD) cannot both be used for
+hardware flow control at the same time.
+Other mutual exclusions may apply, such as the simultaneous setting of the
+.Xr termio 4I
+.Dv HUPCL
+and the
+.Vt termiox
+.Dv DTRXOFF
+bits, which use the DTE ready line for different functions.
+.Pp
+Variations of different hardware flow control methods may be selected by
+setting the appropriate bits.
+For example, bidirectional RTS/CTS flow control is selected by setting both the
+.Dv RTSXOFF
+and
+.Dv CTSXON
+bits and bidirectional DTR/CTS flow control is selected by setting both the
+.Dv DTRXOFF
+and
+.Dv CTSXON .
+Modem control or unidirectional CTS hardware
+flow control is selected by setting only the
+.Dv CTSXON
+bit.
+.Pp
+As previously mentioned, it is assumed that the local asynchronous port (for
+example, computer) is configured as a DTE.
+If the connected device (for example, printer) is also a DTE, it is assumed
+that the device is connected to the computer's asynchronous port using a null
+modem that swaps control circuits (typically RTS and CTS).
+The connected DTE drives RTS and the null modem swaps
+RTS and CTS so that the remote RTS is received as CTS by the local DTE.
+In the case that
+.Dv CTSXON
+is set for hardware flow control, printer's lowering
+of its RTS would cause CTS seen by the computer to be lowered.
+Output to the printer is suspended until the printer's raising of its RTS,
+which would cause CTS seen by the computer to be raised.
+.Pp
+If
+.Dv RTSXOFF
+is set, the Request To Send (RTS) circuit (line) will be
+raised, and if the asynchronous port needs to have its input stopped, it will
+lower the Request To Send (RTS) line.
+If the RTS line is lowered, it is assumed
+that the connected device will stop its output until RTS is raised.
+.Pp
+If
+.Dv CTSXON
+is set, output will occur only if the Clear To Send (CTS)
+circuit (line) is raised by the connected device.
+If the CTS line is lowered by
+the connected device, output is suspended until CTS is raised.
+.Pp
+If
+.Dv DTRXOFF
+is set, the DTE Ready (DTR) circuit (line) will be raised, and
+if the asynchronous port needs to have its input stopped, it will lower the DTE
+Ready (DTR) line.
+If the DTR line is lowered, it is assumed that the connected
+device will stop its output until DTR is raised.
+.Pp
+If
+.Dv CDXON
+is set, output will occur only if the Received Line Signal
+Detector (CD) circuit (line) is raised by the connected device.
+If the CD line
+is lowered by the connected device, output is suspended until CD is raised.
+.Pp
+If
+.Dv ISXOFF
+is set, and if the isochronous port needs to have its input
+stopped, it will stop the outgoing clock signal.
+It is assumed that the
+connected device is using this clock signal to create its output.
+Transit and receive clock sources are programmed using the
+.Fa x_cflag
+fields.
+If the port is not programmed for external clock generation,
+.Dv ISXOFF
+is ignored.
+Output isochronous flow control is supported by appropriate clock source
+programming using the
+.Fa x_cflag
+field and enabled at the remote connected device.
+.Pp
+The
+.Fa x_cflag
+field specifies the system treatment of clock modes.
+.Bl -column xxxxxxxxx xxxxxxxx l
+.It Dv XMTCLK Ta 0000007 Ta "Transmit clock source:"
+.It Dv XCIBRG Ta 0000000 Ta "Get transmit clock from internal baud rate generator."
+.It Dv XCTSET Ta 0000001 Ta "Get transmit clock from transmitter signal element timing (DCE source) lead, CCITT V\.24 circuit 114, EIA-232-D pin 15."
+.It Dv XCRSET Ta 0000002 Ta Get transmit clock from receiver signal element timing (DCE source) lead, CCITT V\.4 circuit 115, EIA-232-D pin 17."
+.It Dv RCVCLK Ta 0000070 Ta "Receive clock source:"
+.It Dv RCIBRG Ta 0000000 Ta "Get receive clock from internal baud rate generator."
+.It Dv RCTSET Ta 0000010 Ta "Get receive clock from transmitter signal element timing (DCE source) lead, CCITT V\.24 circuit 114, EIA-232-D pin 15."
+.It Dv RCRSET Ta 0000020 Ta "Get receive clock from receiver signal element timing (DCE source) lead, CCITT V\.24 circuit 115, EIA-232-D pin 17."
+.It Dv TSETCLK Ta 0000700 Ta "Transmitter signal element timing (DTE source) lead, CCITT V\.24 circuit 113, EIA-232-D pin 24, clock source:"
+.It Dv TSETCOFF Ta 0000000 Ta "TSET clock not provided."
+.It Dv TSETCRBRG Ta 0000100 Ta "Output receive baud rate generator on circuit 113."
+.It Dv TSETCTBRG Ta 0000200 Ta "Output transmit baud rate generator on circuit 113"
+.It Dv TSETCTSET Ta 0000300 Ta "Output transmitter signal element timing (DCE source) on circuit 113."
+.It Dv TSETCRSET Ta 0000400 Ta "Output receiver signal element timing (DCE source) on circuit 113."
+.It Dv RSETCLK Ta 0007000 Ta "Receiver signal element timing (DTE source) lead, CCITT V\.24 circuit 128, no EIA-232-D pin, clock source:"
+.It Dv RSETCOFF Ta 0000000 Ta "RSET clock not provided."
+.It Dv RSETCRBRG Ta 0001000 Ta "Output receive baud rate generator on circuit 128."
+.It Dv RSETCTBRG Ta 0002000 Ta "Output transmit baud rate generator on circuit 128."
+.It Dv RSETCTSET Ta 0003000 Ta "Output transmitter signal element timing (DCE source) on circuit 128."
+.It Dv RSETCRSET Ta 0004000 Ta "Output receiver signal element timing (DCE) on circuit 128."
+.El
+.Pp
+If the
+.Fa XMTCLK
+field has a value of
+.Dv XCIBRG
+the transmit clock is taken from the hardware internal baud rate generator, as
+in normal asynchronous transmission.
+If
+.Fa XMTCLK
+=
+.Dv XCTSET
+the transmit clock is taken from
+the Transmitter Signal Element Timing (DCE source) circuit.
+If
+.Fa XMTCLK
+=
+.Dv XCRSET
+the transmit clock is taken from the Receiver Signal Element
+Timing (DCE source) circuit.
+.Pp
+If the
+.Fa RCVCLK
+field has a value of
+.Dv RCIBRG ,
+the receive clock is
+taken from the hardware Internal Baud Rate Generator, as in normal asynchronous
+transmission.
+If
+.Fa RCVCLK
+=
+.Dv RCTSET
+the receive clock is taken from
+the Transmitter Signal Element Timing (DCE source) circuit.
+If
+.Fa RCVCLK
+=
+.Dv RCRSET
+the receive clock is taken from the Receiver Signal Element Timing
+(DCE source) circuit.
+.Pp
+If the
+.Fa TSETCLK
+field has a value of
+.Dv TSETCOFF
+the Transmitter Signal Element Timing (DTE source) circuit is not driven.
+If
+.Fa TSETCLK
+=
+.Dv TSETCRBRG
+the Transmitter Signal Element Timing (DTE source) circuit is
+driven by the Receive Baud Rate Generator.
+If
+.Fa TSETCLK
+=
+.Dv TSETCTBRG
+the Transmitter Signal Element Timing (DTE source) circuit is driven by the
+Transmit Baud Rate Generator.
+If
+.Fa TSETCLK
+=
+.Dv TSETCTSET
+the Transmitter Signal Element Timing (DTE source) circuit is driven by the
+Transmitter Signal Element Timing (DCE source).
+If
+.Fa TSETCLK
+=
+.Dv TSETCRBRG
+the Transmitter Signal Element Timing (DTE source) circuit is
+driven by the Receiver Signal Element Timing (DCE source).
+.Pp
+If the
+.Fa RSETCLK
+field has a value of
+.Dv RSETCOFF
+the Receiver Signal Element Timing (DTE source) circuit is not driven.
+If
+.Fa RSETCLK
+=
+.Dv RSETCRBRG
+the Receiver Signal Element Timing (DTE source) circuit is
+driven by the Receive Baud Rate Generator.
+If
+.Fa RSETCLK
+=
+.Dv RSETCTBRG
+the Receiver Signal Element Timing (DTE source) circuit is driven by the
+Transmit Baud Rate Generator.
+If
+.Fa RSETCLK
+=
+.Dv RSETCTSET
+the Receiver
+Signal Element Timing (DTE source) circuit is driven by the Transmitter Signal
+Element Timing (DCE source).
+If
+.Fa RSETCLK
+=
+.Dv RSETCRBRG
+the Receiver
+Signal Element Timing (DTE source) circuit is driven by the Receiver Signal
+Element Timing (DCE source).
+.Pp
+The
+.Fa x_rflag
+is reserved for future interface definitions and should not
+be used by any implementations.
+The
+.Fa x_sflag
+may be used by local
+implementations wishing to customize their terminal interface using the
+.Nm
+ioctl system calls.
+.Sh IOCTLS
+The
+.Xr ioctl 2
+system calls have the form:
+.Bd -literal -offset 2n
+struct termiox *arg;
+ioctl(fildes, command, arg);
+.Ed
+.Pp
+The commands using this form are:
+.Bl -tag -width TCSETXW
+.It Dv TCGETX
+The argument is a pointer to a
+.Vt termiox
+structure.
+The current terminal parameters are fetched and stored into that structure.
+.It Dv TCSETX
+The argument is a pointer to a
+.Vt termiox
+structure.
+The current terminal parameters are set from the values stored in that structure.
+The change is immediate.
+.It Dv TCSETXW
+The argument is a pointer to a
+.Vt termiox
+structure.
+The current terminal parameters are set from the values stored in that structure.
+The change occurs after all characters queued for output have been transmitted.
+This form should be used when changing parameters that will affect output.
+.It Dv TCSETXF
+The argument is a pointer to a
+.Vt termiox
+structure.
+The current terminal parameters are set from the values stored in that structure.
+The change occurs
+after all characters queued for output have been transmitted; all characters
+queued for input are discarded and then the change occurs.
+.El
+.Sh FILES
+.Pa /dev/*
+.Sh SEE ALSO
+.Xr stty 1 ,
+.Xr ioctl 2 ,
+.Xr termio 4I
+.Sh NOTES
+The
+.Nm termiox Ns Pq 4I
+system call is provided for compatibility with previous
+releases and its use is discouraged.
+Instead, the
+.Xr termio 4I
+system call is recommended.
+See
+.Xr termio 4I
+for usage information.
diff --git a/usr/src/man/man4i/uscsi.4i b/usr/src/man/man4i/uscsi.4i
new file mode 100644
index 0000000000..bd8b384c9b
--- /dev/null
+++ b/usr/src/man/man4i/uscsi.4i
@@ -0,0 +1,395 @@
+.\" Copyright (c) 2007 by Sun Microsystems, Inc. All rights reserved.
+.\" Copyright 2017 Joyent, Inc.
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd October 23, 2017
+.Dt USCSI 4I
+.Os
+.Sh NAME
+.Nm uscsi
+.Nd user SCSI command interface
+.Sh SYNOPSIS
+.In sys/scsi/impl/uscsi.h
+.Fo ioctl
+.Fa "int filedes"
+.Fa "int request"
+.Fa "struct uscsi_cmd *cmd"
+.Fc
+.Sh DESCRIPTION
+The
+.Nm
+command is very powerful and somewhat dangerous; therefore it
+has some permission restrictions.
+See
+.Sx WARNINGS
+for more details.
+.Pp
+Drivers supporting this
+.Xr ioctl 2
+provide a general interface allowing user-level applications to cause individual
+.Sy SCSI
+commands to be directed to a particular
+.Sy SCSI
+or
+.Sy ATAPI
+device under control of that driver.
+The
+.Nm
+command is supported by the
+.Xr sd 4D
+driver for
+.Sy SCSI
+disks and
+.Sy ATAPI
+CD-ROM drives, and by the
+.Xr st 4D
+driver for
+.Sy SCSI
+tape drives.
+.Nm
+may also be supported by other device drivers; see the
+specific device driver manual page for complete information.
+.Pp
+Applications must not assume that all Solaris disk device drivers support the
+.Nm
+ioctl command.
+The
+.Sy SCSI
+command may include a data transfer
+to or from that device, if appropriate for that command.
+Upon completion of the command, the user application can determine how many
+bytes were transferred and the status returned by the device.
+Also, optionally, if the command returns a
+Check Condition status, the driver will automatically issue a Request Sense
+command and return the sense data along with the original status.
+See the
+.Sy USCSI_RQENABLE
+flag below for this Request Sense processing.
+The
+.Vt uscsi_cmd
+structure is defined in
+.In sys/scsi/impl/uscsi.h
+and includes the following members:
+.Bd -literal -offset 2n
+int uscsi_flags; /* read, write, etc. see below */
+short uscsi_status; /* resulting status */
+short uscsi_timeout; /* Command Timeout */
+caddr_t uscsi_cdb /* CDB to send to target */
+caddr_t uscsi_bufaddr; /* i/o source/destination */
+size_t uscsi_buflen; /* size of i/o to take place*/
+size_t uscsi_resid; /* resid from i/o operation */
+uchar_t uscsi_cdblen; /* # of valid CDB bytes */
+uchar_t uscsi_rqlen; /* size of uscsi_rqbuf */
+uchar_t uscsi_rqstatus; /* status of request sense cmd */
+uchar_t uscsi_rqresid; /* resid of request sense cmd */
+caddr_t uscsi_rqbuf; /* request sense buffer */
+void *uscsi_reserved_5; /* Reserved for future use */
+.Ed
+.Pp
+The fields of the
+.Vt uscsi_cmd
+structure have the following meanings:
+.Bl -tag -width uscsi_reserved_5
+.It Sy uscsi_flags
+The
+.Sy I/O
+direction and other details of how to carry out the
+.Sy SCSI
+command.
+Possible values are described below.
+.It Fa uscsi_status
+The
+.Sy SCSI
+status byte returned by the device is returned in this field.
+.It Fa uscsi_timeout
+Time in seconds to allow for completion of the command.
+.It Fa uscsi_cdb
+A pointer to the
+.Sy SCSI
+CDB (command descriptor block) to be transferred to the device in command phase.
+.It Fa uscsi_bufaddr
+The user buffer containing the data to be read from or written to the device.
+.It Sy uscsi_buflen
+The length of
+.Fa uscsi_bufaddr .
+.It Fa uscsi_resid
+If a data transfer terminates without transferring the entire requested amount,
+the remainder, or residue, is returned in this field.
+.It Fa uscsi_cdblen
+The length of the
+.Sy SCSI
+CDB to be transferred to the device in command phase.
+.It Fa uscsi_rqlen
+The length of
+.Fa uscsi_rqbuf ,
+the application's Request Sense buffer.
+.It Fa uscsi_rqstatus
+The
+.Sy SCSI
+status byte returned for the Request Sense command executed
+automatically by the driver in response to a Check Condition status return.
+.It Fa uscsi_rqresid
+The residue, or untransferred data length, of the Request Sense data transfer
+(the number of bytes, less than or equal to
+.Fa uscsi_rqlen ,
+which were not filled with sense data).
+.It Fa uscsi_rqbuf
+Points to a buffer in application address space to which the results of an
+automatic Request Sense command are written.
+.It Fa uscsi_reserved_5
+Reserved for future use.
+.El
+.Pp
+The
+.Fa uscsi_flags
+field defines the following:
+.Bd -literal -offset 2n
+USCSI_WRITE /* send data to device */
+USCSI_SILENT /* no error messages */
+USCSI_DIAGNOSE /* fail if any error occurs */
+USCSI_ISOLATE /* isolate from normal commands */
+USCSI_READ /* get data from device */
+USCSI_ASYNC /* set bus to asynchronous mode */
+USCSI_SYNC /* return bus to sync mode if possible */
+USCSI_RESET /* reset target */
+USCSI_RESET_TARGET /* reset target */
+USCSI_RESET_LUN /* reset logical unit */
+USCSI_RESET_ALL /* reset all targets */
+USCSI_RQENABLE /* enable request sense extensions */
+USCSI_RENEGOT /* renegotiate wide/sync on next I/O */
+.Ed
+.Pp
+The
+.Fa uscsi_flags
+bits have the following interpretation:
+.Bl -tag -width USCSI_RESET_TARGET
+.It Dv USCSI_WRITE
+Data will be written from the initiator to the target.
+.It Dv USCSI_SILENT
+The driver should not print any console error messages or warnings regarding
+failures associated with this
+.Sy SCSI
+command.
+.It Dv USCSI_DIAGNOSE
+The driver should not attempt any retries or other recovery mechanisms if this
+.Sy SCSI
+command terminates abnormally in any way.
+.It Dv USCSI_ISOLATE
+This
+.Sy SCSI
+command should not be executed with other commands.
+.It Dv USCSI_READ
+Data will be read from the target to the initiator.
+.It Dv USCSI_ASYNC
+Set the
+.Sy SCSI
+bus to asynchronous mode before running this command.
+.It Dv USCSI_SYNC
+Set the
+.Sy SCSI
+bus to synchronous mode before running this command.
+.It Dv USCSI_RESET
+Send a
+.Sy SCSI
+bus device reset message to this target.
+.It Dv USCSI_RESET_TARGET
+Same as USCSI_RESET.
+Use this flag to request TARGET RESET.
+.Po
+.Dv USCSI_RESET
+is maintained only for compatibility with old applications
+.Pc .
+.It Dv USCSI_RESET_LUN
+Send a
+.Sy SCSI
+logical unit reset message to this target.
+.It Dv USCSI_RESET_ALL
+.Dv USCSI_RESET_ALL ,
+.Dv USCSI_RESET/USCSI_RESET_TARGET ,
+and
+.Dv USCSI_RESET_LUN
+are
+mutually exclusive options and issuing them in any simultaneous combination
+will result in implementation-dependent behavior
+When a USCSI reset request is combined with other
+.Sy SCSI
+commands, the following semantics take effect:
+If the
+.Dv USCSI RESET
+flag is specified, the other fields (other than
+.Fa uscsi_flags )
+in the
+.Vt uscsi_cmd
+are ignored.
+The
+.Fa uscsi_cdblen
+field
+.Em must
+be set to zero.
+.It Dv USCSI_RQENABLE
+Enable Request Sense extensions.
+If the user application is prepared to receive
+sense data, this bit must be set, the fields
+.Fa uscsi_rqbuf
+and
+.Fa uscsi_rqbuflen
+must be non-zero, and the
+.Fa uscsi_rqbuf
+must point to memory writable by the application.
+.It Dv USCSI_RENEGOT
+Tells USCSI to renegotiate wide mode and synchronous transfer speed before the
+transmitted SCSI command is executed.
+This flag in effects tells the target driver to pass the
+.Dv FLAG_RENEGOTIATE_WIDE_SYNC
+flag in the SCSI packet
+before passing the command to an adapter driver for transport.
+See the
+.Xr scsi_pkt 9S
+flag
+.Dv FLAG_RENEGOTIATE_WIDE_SYNC
+for more information.
+.El
+.Pp
+The
+.Vt uscsi_xfer_t
+is a type definition that corresponds to a 64-bit unsigned integer.
+It should be used for the
+.Dv USCSIMAXXFER
+ioctls.
+This is
+used for determining the maximum transfer size that can be performed in a single
+.Dv USCSICMD
+ioctl.
+If the SCSI request is larger than the specified size,
+then it may not work, depending on the hardware platform.
+.Sh IOCTLS
+The
+.Fn ioctl
+supported by drivers providing the
+.Nm
+interface is:
+.Bl -tag -width USCSIMAXXFER
+.It Dv USCSICMD
+The argument is a pointer to a
+.Vt uscsi_cmd
+structure.
+The
+.Sy SCSI
+device addressed by that driver is selected, and given the
+.Sy SCSI
+command addressed by
+.Fa uscsi_cdb .
+If this command requires a data phase, the
+.Fa uscsi_buflen
+and
+.Fa uscsi_bufaddr
+fields must be set appropriately; if data phase occurs, the
+.Fa uscsi_resid
+is returned as the number of bytes not transferred.
+The status of the command, as returned by the device, is returned in the
+.Fa uscsi_status
+field.
+If the command terminates with Check Condition
+status, and Request Sense is enabled, the sense data itself is returned in
+.Fa uscsi_rqbuf .
+The
+.Fa uscsi_rqresid
+provides the residue of the Request Sense data transfer.
+.It Dv USCSIMAXXFER
+The argument is a pointer to a
+.Vt uscsi_xfer_t
+value.
+The maximum transfer size that can be used with the
+.Dv USCSICMD
+ioctl for the current device will be returned in the
+.Vt uscsi_xfer_t .
+.Pp
+Not all devices which support the
+.Dv USCSICMD
+ioctl also support the
+.Dv USCSIMAXXFER
+ioctl.
+.El
+.Sh ERRORS
+.Bl -tag -width EINVAL
+.It Er EINVAL
+A parameter has an incorrect, or unsupported, value.
+.It Er EIO
+An error occurred during the execution of the command.
+.It Er EPERM
+A process without root credentials tried to execute the
+.Dv USCSICMD
+or
+.Dv USCSIMAXXFER
+ioctl.
+.It Er EFAULT
+The
+.Vt uscsi_cmd
+itself, the
+.Fa uscsi_cdb ,
+the
+.Fa uscsi_buf ,
+the
+.Fa uscsi_rqbuf ,
+or the
+.Vt uscsi_xfer_t
+point to an invalid address.
+.El
+.Sh STABILITY
+Committed
+.Sh SEE ALSO
+.Xr ioctl 2 ,
+.Xr sd 4D ,
+.Xr st 4D ,
+.Xr attributes 7
+.Rs
+.%T ANSI Small Computer System Interface-2 (SCSI-2)
+.Re
+.Sh WARNINGS
+The
+.Nm
+command is very powerful, but somewhat dangerous, and so its
+use is restricted to processes running as root, regardless of the file
+permissions on the device node.
+The device driver code expects to own the device state, and
+.Nm
+commands can change the state of the device and confuse the device driver.
+It is best to use
+.Nm
+commands only with no side effects, and avoid commands such as Mode Select, as
+they may cause damage to data stored on the drive or system panics.
+Also, as the commands are not checked in any way by the device driver, any block
+may be overwritten, and the block numbers are absolute block numbers on the
+drive regardless of which slice number is used to send the command.
+.Pp
+The
+.Nm
+interface is not recommended for very large data transfers
+(typically more than 16MB).
+If the requested transfer size exceeds the maximum transfer size of the DMA
+engine, it will not be broken up into multiple transfers and DMA errors may
+result.
+The
+.Dv USCSIMAXXFER
+ioctl can be used to determine the maximum transfer size.
+.Pp
+The
+.Dv USCSICMD
+ioctl associates a
+.Vt struct uscsi_cmd
+with a device by using an open file descriptor to the device.
+Other APIs might provide the same
+.Vt struct uscsi_cmd
+programming interface, but perform device association in some other manner.
diff --git a/usr/src/man/man4i/visual_io.4i b/usr/src/man/man4i/visual_io.4i
new file mode 100644
index 0000000000..91975c625c
--- /dev/null
+++ b/usr/src/man/man4i/visual_io.4i
@@ -0,0 +1,738 @@
+.\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved
+.\" Copyright 2018, Joyent, Inc.
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd August 31, 2018
+.Dt VISUAL_IO 4I
+.Os
+.Sh NAME
+.Nm visual_io
+.Nd illumos VISUAL I/O control operations
+.Sh SYNOPSIS
+.In sys/visual_io.h
+.Sh DESCRIPTION
+The illumos VISUAL environment defines a small set of ioctls for controlling
+graphics and imaging devices.
+.Pp
+The
+.Dv VIS_GETIDENTIFIER
+ioctl is mandatory and must be implemented in
+device drivers for graphics devices using the illumos VISUAL environment.
+The
+.Dv VIS_GETIDENTIFIER
+ioctl is defined to return a device identifier from the device driver.
+This identifier must be a uniquely-defined string.
+.Pp
+There are two additional sets of ioctls.
+One supports mouse tracking via hardware cursor operations.
+Use of this set is optional, however, if a graphics
+device has hardware cursor support and implements these ioctls, the mouse
+tracking performance is improved.
+The remaining set supports the device acting
+as the system console device.
+Use of this set is optional, but if a graphics device is to be used as the
+system console device, it must implement these ioctls.
+.Pp
+The VISUAL environment also defines interfaces for non-ioctl entry points into
+the driver that the illumos operating environment calls when it is running in
+standalone mode (for example, when using a stand-alone debugger, entering
+the PROM monitor, or when the system panicking).
+These are also known as
+.Dq Polled I/O
+entry points, which operate under an an explicit set of restrictions, described below.
+.Sh IOCTLS
+.Bl -tag -width VIS_GETIDENTIFIER -compact
+.It Dv VIS_GETIDENTIFIER
+This
+.Xr ioctl 2
+returns an identifier string to uniquely identify a device
+used in the illumos VISUAL environment.
+This is a mandatory ioctl and must return a unique string.
+We suggest that the name be formed as
+.Ao companysymbol Ac Ns Ao devicetype Ac .
+For example, the
+.Xr cgsix 4D
+driver
+returns
+.Sy SUNWcg6 .
+.Pp
+.Dv VIS_GETIDENTIFIER
+takes a
+.Vt vis_identifier
+structure as its parameter.
+This structure has the form:
+.Bd -literal -offset 2n
+#define VIS_MAXNAMELEN 128
+struct vis_identifier {
+ char name[VIS_MAXNAMELEN];
+};
+.Ed
+.Pp
+.It Dv VIS_GETCURSOR
+.It Dv VIS_SETCURSOR
+These ioctls fetch and set various cursor attributes, using the
+.Vt vis_cursor
+structure.
+.Bd -literal -offset 2n
+struct vis_cursorpos {
+ short x; /* cursor x coordinate */
+ short y; /* cursor y coordinate */
+};
+
+struct vis_cursorcmap {
+ int version; /* version */
+ int reserved;
+ /* red color map elements */
+ unsigned char *red;
+ /* green color map elements */
+ unsigned char *green;
+ /* blue color map elements */
+ unsigned char *blue;
+};
+
+#define VIS_CURSOR_SETCURSOR 0x01 /* set cursor */
+ /* set cursor position */
+#define VIS_CURSOR_SETPOSITION 0x02
+ /* set cursur hot spot */
+#define VIS_CURSOR_SETHOTSPOT 0x04
+ /* set cursor colormap */
+#define VIS_CURSOR_SETCOLORMAP 0x08
+ /* set cursor shape */
+#define VIS_CURSOR_SETSHAPE 0x10
+#define VIS_CURSOR_SETALL \e
+ (VIS_CURSOR_SETCURSOR | VIS_CURSOR_SETPOSITION | \e
+ VIS_CURSOR_SETHOTSPOT | VIS_CURSOR_SETCOLORMAP | \e
+ VIS_CURSOR_SETSHAPE)
+
+struct vis_cursor {
+ short set; /* what to set */
+ short enable; /* cursor on/off */
+ struct vis_cursorpos pos; /* cursor position */
+ struct vis_cursorpos hot; /* cursor hot spot */
+ struct vis_cursorcmap cmap; /* color map info */
+ /* cursor bitmap size */
+ struct vis_cursorpos size;
+ char *image; /* cursor image bits */
+ char *mask; /* cursor mask bits */
+};
+.Ed
+.Pp
+The
+.Vt vis_cursorcmap
+structure should contain pointers to two elements,
+specifying the red, green, and blue values for foreground and background.
+.Pp
+.It Dv VIS_SETCURSORPOS
+.It Dv VIS_MOVECURSOR
+These ioctls fetch and move the current cursor position, using the
+.Vt vis_cursorpos
+structure.
+.El
+.Ss "Console Optional Ioctls"
+The following ioctl sets are used by graphics drivers that are part of the
+system console device.
+All of the ioctls must be implemented to be a console device.
+In addition, if the system does not have a prom or the prom goes away
+during boot, the special standalone ioctls (listed below) must also be
+implemented.
+.Pp
+The coordinate system for the console device places 0,0 at the upper left
+corner of the device, with rows increasing toward the bottom of the device and
+columns increasing from left to right.
+.Pp
+.Bl -tag -width VIS_CONSDISPLAY -compact -offset 2n
+.It Dv VIS_PUTCMAP
+.It Dv VIS_GETCMAP
+Set or get color map entries.
+.Pp
+The argument is a pointer to a
+.Vt vis_cmap
+structure, which contains the
+following fields:
+.Bd -literal -offset 2n
+struct vis_cmap {
+ int index;
+ int count;
+ uchar_t *red;
+ uchar_t *green;
+ uchar_t *blue;
+}
+.Ed
+.Pp
+.Fa index
+is the starting index in the color map where you want to start
+setting or getting color map entries.
+.Pp
+.Fa count
+is the number of color map entries to set or get.
+It also is the
+size of the
+.Fa red ,
+.Fa green ,
+and
+.Fa blue
+color arrays.
+.Pp
+.Fa *red ,
+.Fa *green ,
+and
+.Fa *blue
+are pointers to unsigned character arrays which contain the color map info to
+set or where the color map info is placed on a get.
+.Pp
+.It Dv VIS_DEVINIT
+Initializes the graphics driver as a console device.
+.Pp
+The argument is a pointer to a
+.Vt vis_devinit
+structure.
+The graphics driver
+is expected to allocate any local state information needed to be a console
+device and fill in this structure.
+.Bd -literal -offset 2n
+struct vis_devinit {
+ int version;
+ screen_size_t width;
+ screen_size_t height;
+ screen_size_t linebytes;
+ unit_t size;
+ int depth;
+ short mode;
+ struct vis_polledio *polledio;
+ vis_modechg_cb_t modechg_cb;
+ struct vis_modechg_arg *modechg_arg;
+};
+.Ed
+.Pp
+.Fa version
+is the version of this structure and should be set to
+.Dv VIS_CONS_REV .
+.Pp
+.Fa width
+and
+.Fa height
+are the width and height of the device.
+If
+.Fa mode
+(see below) is
+.Dv VIS_TEXT
+then
+.Fa width
+and
+.Fa height
+are the number of characters wide and high of the device.
+If
+.Fa mode
+is
+.Dv VIS_PIXEL
+then
+.Fa width
+and
+.Fa height
+are the number of pixels wide and high of the device.
+.Pp
+.Fa linebytes
+is the number of bytes per line of the device.
+.Pp
+.Fa size
+is the total size of the device in pixels.
+.Pp
+.Fa depth
+is the pixel depth in device bits.
+Currently supported depths are:
+.Sy 1 ,
+.Sy 4 ,
+.Sy 8
+and
+.Sy 24 .
+.Pp
+.Fa mode
+is the mode of the device.
+Either
+.Dv VIS_PIXEL
+(data to be displayed is in bitmap format) or
+.Dv VIS_TEXT
+(data to be displayed is in ascii format).
+.Pp
+.Fa polledio
+is used to pass the address of the structure containing the
+standalone mode polled I/O entry points to the device driver back to the
+terminal emulator.
+The
+.Vt vis_polledio
+interfaces are described in the
+Console Standalone Entry Points section of this manpage.
+These entry points are where the operating system enters the driver when the
+system is running in standalone mode.
+These functions perform identically to the
+.Dv VIS_CONSDISPLAY ,
+.Dv VIS_CONSCURSOR ,
+and
+.Dv VIS_CONSCOPY
+ioctls, but are called directly by the illumos
+operating environment and must operate under a very strict set of assumptions.
+.Pp
+.Fa modechg_cb
+is a callback function passed from the terminal emulator to
+the framebuffer driver which the frame-buffer driver must call whenever a video
+mode change event occurs that changes the screen height, width or depth.
+The callback takes two arguments, an opaque handle,
+.Fa modechg_arg ,
+and the address of a
+.Vt vis_devinit
+struct containing the new video mode information.
+.Pp
+.Fa modechg_arg
+is an opaque handle passed from the terminal emulator to the
+driver, which the driver must pass back to the terminal emulator as an argument
+to the
+.Fa modechg_cb
+function when the driver notifies the terminal emulator of a video mode change.
+.Pp
+.It Dv VIS_DEVFINI
+Tells the graphics driver that it is no longer the system console device.
+There is no argument to this ioctl.
+The driver is expected to free any locally kept
+state information related to the console.
+.Pp
+.It Dv VIS_CONSCURSOR
+Describes the size and placement of the cursor on the screen.
+The graphics
+driver is expected to display or hide the cursor at the indicated position.
+.Pp
+The argument is a pointer to a
+.Vt vis_conscursor
+structure which contains
+the following fields:
+.Bd -literal -offset 2n
+struct vis_conscursor {
+ screen_pos_t row;
+ screen_pos_t col;
+ screen_size_t width;
+ screen_size_t height
+ color_t fg_color;
+ color_t bg_color;
+ short action;
+};
+.Ed
+.Pp
+.Fa row
+and
+.Fa col
+are the first row and column (upper left corner of the cursor).
+.Pp
+.Fa width
+and
+.Fa height
+are the width and height of the cursor.
+.Pp
+If
+.Fa mode
+in the
+.Dv VIS_DEVINIT
+ioctl is set to
+.Dv VIS_PIXEL ,
+then
+.Fa col ,
+.Fa row ,
+.Fa width
+and
+.Fa height
+are in pixels.
+If
+.Fa mode
+in the
+.Dv VIS_DEVINIT
+ioctl was set to
+.Dv VIS_TEXT ,
+then
+.Fa col ,
+.Fa row ,
+.Fa width
+and
+.Fa height
+are in characters.
+.Pp
+.Fa fg_color
+and
+.Fa bg_color
+are the foreground and background color map
+indexes to use when the
+.Fa action
+(see below) is set to
+.Dv VIS_DISPLAY_CURSOR .
+.Pp
+.Fa action
+indicates whether to display or hide the cursor.
+It is set to either
+.Dv VIS_HIDE_CURSOR
+or
+.Dv VIS_DISPLAY_CURSOR .
+.Pp
+.It Dv VIS_CONSDISPLAY
+Display data on the graphics device.
+The graphics driver is expected to display the data contained in the
+.Vt vis_display
+structure at the specified position on the console.
+.Pp
+The
+.Vt vis_display
+structure contains the following fields:
+.Bd -literal -offset 2n
+struct vis_display {
+ screen_pos_t row;
+ screen_pos_t col;
+ screen_size_t width;
+ screen_size_t height;
+ uchar_t *data;
+ color_t fg_color;
+ color_t bg_color;
+};
+.Ed
+.Pp
+.Fa row
+and
+.Fa col
+specify at which starting row and column the date is to be displayed.
+If
+.Fa mode
+in the
+.Dv VIS_DEVINIT
+ioctl was set to
+.Dv VIS_TEXT ,
+.Fa row
+and
+.Fa col
+are defined to be a character offset
+from the starting position of the console device.
+If
+.Fa mode
+in the
+.Dv VIS_DEVINIT
+ioctl was set to
+.Dv VIS_PIXEL ,
+.Fa row
+and
+.Fa col
+are defined to be a pixel offset from the starting position of the console
+device.
+.Pp
+.Fa width
+and
+.Fa height
+specify the size of the
+.Fa data
+to be displayed.
+If
+.Fa mode
+in the
+.Dv VIS_DEVINIT
+ioctl was set to
+.Dv VIS_TEXT ,
+.Fa width
+and
+.Fa height
+define the size of
+.Fa data
+as rectangle that is
+.Fa width
+characters wide and
+.Fa height
+characters high.
+If
+.Fa mode
+in the
+.Dv VIS_DEVINIT
+ioctl was set to
+.Dv VIS_PIXEL ,
+.Fa width
+and
+.Fa height
+define the size of
+.Fa data
+as a rectangle that is
+.Fa width
+pixels wide and
+.Fa height
+pixels high.
+.Pp
+.Fa *data
+is a pointer to the data to be displayed on the console device.
+If
+.Fa mode
+in the
+.Dv VIS_DEVINIT
+ioctl was set to
+.Dv VIS_TEXT ,
+.Fa data
+is an array of
+.Sy ASCII
+characters to be displayed on the console device.
+The driver must break these characters up appropriately and display it in the
+rectangle defined by
+.Fa row ,
+.Fa col ,
+.Fa width ,
+and
+.Fa height .
+If
+.Fa mode
+in the
+.Dv VIS_DEVINIT
+ioctl was set to
+.Dv VIS_PIXEL ,
+.Fa data
+is an array of bitmap data to be displayed on the console device.
+The driver must break this data up appropriately and display it in the retangle
+defined by
+.Fa row ,
+.Fa col ,
+.Fa width ,
+and
+.Fa height .
+.Pp
+The
+.Fa fg_color
+and
+.Fa bg_color
+fields define the foreground and
+background color map indexes to use when displaying the data.
+.Fa fb_color
+is used for
+.Dq on
+pixels and
+.Fa bg_color
+is used for
+.Dq off
+pixels.
+.Pp
+.It Dv VIS_CONSCOPY
+Copy data from one location on the device to another.
+The driver is expected to copy the specified data.
+The source data should not be modified.
+Any modifications to the source data should be as a side effect of the copy
+destination overlapping the copy source.
+.Pp
+The argument is a pointer to a
+.Vt vis_copy
+structure which contains the following fields:
+.Bd -literal -offset 2n
+struct vis_copy {
+ screen_pos_t s_row;
+ screen_pos_t s_col;
+ screen_pos_t e_row;
+ screen_pos_t e_col;
+ screen_pos_t t_row;
+ screen_pos_t t_col;
+ short direction;
+};
+.Ed
+.Pp
+.Fa s_row ,
+.Fa s_col ,
+.Fa e_row ,
+and
+.Fa e_col
+define the source rectangle of the copy.
+.Fa s_row
+and
+.Fa s_col
+are the upper left corner of the source rectangle.
+.Fa e_row
+and
+.Fa e_col
+are the lower right corner of the source rectangle.
+If
+.Fa mode
+in the
+.Dv VIS_DEVINIT
+.Fn ioctl
+was set to
+.Dv VIS_TEXT ,
+.Fa s_row ,
+.Fa s_col ,
+.Fa e_row ,
+and
+.Fa e_col
+are defined to be character offsets from the starting position of the console
+device.
+If
+.Fa mode
+in the
+.Dv VIS_DEVINIT
+.Fn ioctl
+was set to
+.Dv VIS_PIXEL ,
+.Fa s_row ,
+.Fa s_col ,
+.Fa e_row ,
+and
+.Fa e_col
+are
+defined to be pixel offsets from the starting position of the console device.
+.Pp
+.Fa t_row
+and
+.Fa t_col
+define the upper left corner of the destination rectangle of the copy.
+The entire rectangle is copied to this location.
+If
+.Fa mode
+in the
+.Dv VIS_DEVINIT
+ioctl was set to
+.Dv VIS_TEXT ,
+.Fa t_row ,
+and
+.Fa t_col
+are defined to be character offsets from the
+starting position of the console device.
+If
+.Fa mode
+in the
+.Dv VIS_DEVINIT
+ioctl was set to
+.Dv VIS_PIXEL ,
+.Fa t_row ,
+and
+.Fa t_col
+are defined to be pixel offsets from the starting position of the
+onssole device.
+.Pp
+.Fa direction
+specifies which way to do the copy.
+If direction is
+.Dv VIS_COPY_FORWARD
+the graphics driver should copy data from position
+.Po
+.Fa s_row ,
+.Fa s_col
+.Pc
+in the source rectangle to position
+.Po
+.Fa t_row ,
+.Fa t_col
+.Pc
+in the destination rectangle.
+If direction is
+.Dv VIS_COPY_BACKWARDS
+the graphics driver should copy data from position
+.Po
+.Fa e_row ,
+.Fa e_col
+.Pc
+in the source rectangle to position
+.Po
+.Fa t_row Ns + Ns
+.Po
+.Fa e_row Ns \- Ns
+.Fa s_row
+.Pc ,
+.Fa t_col Ns + Ns
+.Po
+.Fa e_col Ns \- Ns
+.Fa s_col
+.Pc
+.Pc
+in the destination rectangle.
+.El
+.Ss "Console Standalone Entry Points (Polled I/O Interfaces)"
+Console standalone entry points are necessary only if the driver is
+implementing console-compatible extensions.
+All console vectored standalone
+entry points must be implemented along with all console-related ioctls if the
+console extension is implemented.
+.Bd -literal -offset 2n
+struct vis_polledio {
+ struct vis_polledio_arg *arg;
+ void (*display)(vis_polledio_arg *, struct vis_consdisplay *);
+ void (*copy)(vis_polledio_arg *, struct vis_conscopy *);
+ void (*cursor)(vis_polledio_arg *, struct vis_conscursor *);
+};
+.Ed
+.Pp
+The
+.Vt vis_polledio
+structure is passed from the driver to the illumos
+operating environment, conveying the entry point addresses of three functions
+which perform the same operations of their similarly named ioctl counterparts.
+The rendering parameters for each entry point are derived from the same
+structure passed as the respective ioctl.
+See the
+.Sx "Console Optional Ioctls"
+section of this manpage for an explanation of the specific function each of the
+entry points,
+.Fn display ,
+.Fn copy ,
+and
+.Fn cursor
+are required to implement.
+In
+addition to performing the prescribed function of their ioctl counterparts, the
+standalone vectors operate in a special context and must adhere to a strict set
+of rules.
+The polled I/O vectors are called directly whenever the system is
+quisced (running in a limited context) and must send output to the display.
+Standalone mode describes the state in which the system is running in
+single-threaded mode and only one processor is active.
+illumos operating
+environment services are stopped, along with all other threads on the system,
+prior to entering any of the polled I/O interfaces.
+The polled I/O vectors are
+called when the system is running in a standalone debugger, when executing the
+PROM monitor (OBP) or when panicking.
+.Pp
+The following restrictions must be observed in the polled I/O functions:
+.Bl -enum -offset indent
+.It
+The driver must not allocate memory.
+.It
+The driver must not wait on mutexes.
+.It
+The driver must not wait for interrupts.
+.It
+The driver must not call any DDI or LDI services.
+.It
+The driver must not call any system services.
+.El
+.Pp
+The system is single-threaded when calling these functions, meaning that all
+other threads are effectively halted.
+Single-threading makes mutexes (which
+cannot be held) easier to deal with, so long as the driver does not disturb any
+shared state.
+See
+.%T Writing Device Drivers
+for more information about implementing polled I/O entry points.
+.Sh SEE ALSO
+.Xr ioctl 2
+.Rs
+.%T Writing Device Drivers
+.Re
+.Sh NOTES
+On SPARC systems, compatible drivers supporting the kernel terminal emulator
+should export the
+.Sy tem-support
+DDI property.
+.Sy tem-support
+indicates that the driver supports the kernel terminal emulator.
+By exporting
+.Sy tem-support
+it's possible to avoid premature handling of an incompatible driver.
+.Bl -tag -width tem-support
+.It Sy tem-support
+This DDI property, set to 1, means driver is compatible with the console
+kernel framebuffer interface.
+.El
diff --git a/usr/src/man/man4i/vt.4i b/usr/src/man/man4i/vt.4i
new file mode 100644
index 0000000000..0684aa44ff
--- /dev/null
+++ b/usr/src/man/man4i/vt.4i
@@ -0,0 +1,329 @@
+.\" Copyright (c) 2017, Joyent, Inc.
+.\" Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.Dd December 28, 2020
+.Dt VT 4I
+.Os
+.Sh NAME
+.Nm vt
+.Nd Solaris virtual console interface
+.Sh SYNOPSIS
+.In sys/kd.h
+.In sys/vt.h
+.Sh DESCRIPTION
+The virtual console device driver \(em also known as virtual terminal
+.Pq Sy VT
+\(em is a layer of management functions that provides facilities to
+support and switch between multiple screen faces on a single physical device.
+.Pp
+VT's are accessed in the same way as other devices.
+The
+.Xr open 2
+system
+call is used to open the virtual console and
+.Xr read 2 ,
+.Xr write 2
+and
+.Xr ioctl 2
+are used in the normal way and support the functionality of the
+underlying device.
+In addition, some virtual console-specific ioctls are
+provided and described below.
+.Pp
+The VT provides a link between different screen faces and the device.
+The
+.Sy "active virtual console"
+corresponds to the currently visible screen face.
+Device input is directed to the active console and any device-specific modes
+that change on a per virtual terminal basis are set to the characteristics
+associated with the active console.
+.Pp
+You manage VT's by intercepting keyboard sequences
+.Pq Dq "hot key" .
+To maintain consistency with Xserver, the virtual console device driver
+supports the Ctrl, Alt, F# and arrow keys.
+.Pp
+The sequence
+.Sy "AltL + F#"
+(where AltL represents the left Alt key and F# represents function keys 1
+through 12) is used to select virtual console 1-12.
+The sequence
+.Sy "AltGraph + F#"
+(where AltGraph represents the right Alt key and F# represent function keys 1
+through 12) is for virtual console 13-24.
+.Sy "Alt + F1"
+chooses the system console (also known as virtual console 1).
+The sequence
+.Sy "Alt + \(->"
+(where "\(->" represents the right directional arrow)
+selects the next VT in a circular ring fashion and
+.Sy "Alt + \(<-"
+(where "\(<-" represents the left directional arrow) changes to the previous
+console in a circular fashion.
+The sequence
+.Sy "Alt + \(ua"
+(where "\(ua" represents the up directional arrow) is for the last used console.
+.Pp
+Virtual console switching can be done automatically
+.Pq Dv VT_AUTO
+on receipt of a
+.Dq hot-key
+or by the process owning the VT
+.Pq Dv VT_PROCESS .
+When performed automatically, the process associated with the virtual console is
+unaware of the switch.
+Saving and restoring the device are handled by the
+underlying device driver and the virtual console manager.
+Note that automatic switching is the default mode.
+.Pp
+When a
+.Dq hot-key
+is sent when in process-controlled switch mode, the process
+owning the VT is sent a signal (relsig) it has specified to the virtual console
+manager (see
+.Xr signal 3C )
+requesting the process to release the physical device.
+At this point, the virtual console manager awaits the
+.Dv VT_RELDISP
+ioctl from the process.
+If the process refuses to release the device (meaning
+the switch does not occur), it performs a
+.Dv VT_RELDISP
+ioctl with an argument of 0 (zero).
+If the process desires to release the device, it saves
+the device state (keyboard, display, and I/O registers) and then performs a
+.Dv VT_RELDISP
+with an argument of 1 to complete the switch.
+.Pp
+A ring of VT's can contain intermixed auto mode and process control mode
+consoles.
+When an auto mode process becomes active, the underlying device
+driver and the virtual console manager handle the restoring of the device.
+Process control mode processes are sent a specified signal (acqsig) when they
+become the active console.
+The process then restores the device state
+(keyboard, display, and I/O registers) and performs
+.Dv VT_RELDISP
+ioctl with an argument of
+.Dv VT_ACKACQ
+to complete the switching protocol.
+.Pp
+The modify-operations ioctls
+.Po
+.Dv VT_SETMODE ,
+.Dv VT_RELDISP ,
+.Dv VT_WAITACTIVE ,
+.Dv KDSETMODE
+.Pc
+check if the VT is the controlling tty of
+the calling process.
+If not, the sys_devices privilege is enforced.
+.Dv VT_ACTIVATE
+requires the sys_devices privilege.
+Note that there is no
+controlling tty and privilege check for query/view operations.
+.Sh IOCTLS
+The following ioctls apply to devices that support virtual consoles:
+.Bl -tag -width VT_ENABLED
+.It Dv VT_ENABLED
+Queries to determine if VT functionality is available on the system.
+The argument is a pointer to an integer.
+If VT functionality is available, the
+integer is 1, otherwise it is 0.
+.It Dv VT_OPENQRY
+Finds an available VT.
+The argument is a pointer to an integer.
+The integer is
+filled in with the number of the first available console that no other process
+has open (and hence, is available to be opened).
+If there are no available
+VT's, -1 is filled in.
+.It Dv VT_GETMODE
+Determines the VT's current mode, either
+.Dv VT_AUTO
+or
+.Dv VT_PROCESS .
+The
+argument is the address of the following structure, as defined in
+.In sys/vt.h
+.Bd -literal -offset 2n
+struct vt_mode {
+ char mode; /* VT mode */
+ char waitv; /* not used */
+ short relsig; /* signal to use for release request */
+ short acqsig; /* signal to use for display acquired */
+ short frsig; /* not used */
+}
+
+/* Virtual console Modes */
+#define VT_AUTO 0 /* automatic VT switching */
+#define VT_PROCESS 1 /* process controls switching */
+.Ed
+.Pp
+The structure will be filled in with the current value for each field.
+.It Dv VT_SETMODE
+Sets the VT mode.
+The argument is a pointer to a vt_mode structure as defined above.
+The structure should be filled in with the desired mode.
+If process-control mode is specified, the signals used to communicate with the
+process should be specified.
+If any signals are not specified (value is zero), the signal default is
+.Dv SIGUSR1
+(for relsig and acqsig).
+.It Dv VT_RELDISP
+Tells the VT manager if the process releases (or refuses to release) the
+display.
+An argument of 1 indicates the VT is released.
+An argument of 0 indicates refusal to release.
+The
+.Dv VT_ACKACQ
+argument indicates if acquisition of the VT has been completed.
+.It Dv VT_ACTIVATE
+Makes the VT specified in the argument the active VT (in the same manner as if
+a hotkey initiated the switch).
+If the specified VT is not open or does not exist, the call fails and errno is
+set to
+.Er ENXIO .
+.It Dv VT_WAITACTIVE
+If the specified VT is currently active, this call returns immediately.
+Otherwise, it sleeps until the specified VT becomes active, at which point it
+returns.
+.It Dv VT_GETSTATE
+Obtains the active VT number and a list of open VTs.
+The argument is an address to the following structure:
+.Bd -literal -offset 2n
+struct vt_stat {
+ unsigned short v_active, /* number of the active VT */
+ v_signal, /* not used */
+ /*
+ * count of open VTs. For every 1 in this
+ * field, there is an open VT
+ */
+ v_state;
+}
+.Ed
+.Pp
+With
+.Dv VT_GETSTATE ,
+the VT manager first gets the number of the active VT,
+then determines the number of open VTs in the system and sets a 1 for each open
+VT in v_state.
+Next, the VT manager transfers the information in structure
+.Vt vt_stat
+passed by the user process.
+.It Dv KDGETMODE
+Obtains the text/graphics mode associated with the VT.
+.Bd -literal -offset 2n
+#define KD_TEXT 0
+#define KD_GRAPHICS 1
+.Ed
+.It Dv KDSETMODE
+Sets the text/graphics mode to the VT.
+.It Dv KD_TEXT
+indicates that console text is displayed on the screen.
+Normally
+.Dv KD_TEXT
+is combined with
+.Dv VT_AUTO
+mode for text console terminals,
+so that the console text display automatically is saved and restored on the hot
+key screen switches.
+.Pp
+.Dv KD_GRAPHICS
+indicates that the user/application (usually Xserver) has
+direct control of the display for this VT in graphics mode.
+Normally
+.Dv KD_GRAPHICS
+is combined with
+.Dv VT_PROCESS
+mode for this VT indicating
+direct control of the display in graphics mode.
+In this mode, all writes to the
+VT using the write system call are ignored, and you must save and restore the
+display on the hot key screen switches.
+.Pp
+When the mode of the active VT is changed from
+.Dv KD_TEXT
+to
+.Dv KD_GRAPHICS
+or a VT of
+.Dv KD_GRAPHICS
+mode is made active from a
+previous active VT of
+.Dv KD_TEXT
+mode, the virtual console manager initiates a
+.Dv KDSETMODE
+ioctl with
+.Dv KD_GRAPHICS
+as the argument to the underlying console frame buffer device indicating that
+current display is running into graphics mode.
+.Pp
+When the mode of the active VT is changed from
+.Dv KD_GRAPHICS
+to
+.Dv KD_TEXT
+or a VT of
+.Dv KD_TEXT
+mode is activated from a previous active VT of
+.Dv KD_GRAPHICS
+mode, the virtual console manager initiates a
+.Dv KDSETMODE
+ioctl with
+.Dv KD_TEXT
+as the argument to the underlying console frame buffer device indicating that
+current display is running into console text mode.
+.El
+.Sh FILES
+.Bl -tag -width xxxxxxxxx
+.It Pa /dev/vt/#
+VT devices.
+.El
+.Sh SEE ALSO
+.Xr ioctl 2 ,
+.Xr signal 3C ,
+.Xr wscons 4D
+.Sh NOTES
+By default, there are only five virtual console instance login prompts running
+on
+.Pa /dev/vt/#
+(where "#" represents 2 to 6) in addition to the system
+console running on
+.Pa /dev/console .
+Normally Xorg uses the seventh virtual console
+.Pq Pa /dev/vt/7 .
+To switch from consoles to Xserver (which normally
+picks up the first available virtual console), use [ Ctrl + ] Alt + F7 .
+.Bd -literal -offset indent
+# svcs | grep login
+online 17:49:11 svc:/system/console-login:default
+online 17:49:11 svc:/system/console-login:vt2
+online 17:49:11 svc:/system/console-login:vt3
+online 17:49:11 svc:/system/console-login:vt4
+online 17:49:11 svc:/system/console-login:vt5
+online 17:49:11 svc:/system/console-login:vt6
+.Ed
+.Pp
+.Sy console-login:default
+is for the system console, others for virtual consoles.
+.Pp
+You can modify properties/disable/enable and remove/add virtual consoles using
+.Xr smf 7 :
+.Bd -literal -offset indent
+# svccfg -s console-login add vt8
+# svccfg -s console-login:vt8 setprop \e
+ ttymon/device=astring: "/dev/vt/8"
+# svcadm enable console-login:vt8
+.Ed