Document cnbell(), cngetc(), cngetsn(), cnpollc(), cnputc().
This commit is contained in:
parent
7089595665
commit
d005e2321e
@ -1,4 +1,4 @@
|
||||
# $NetBSD: mi,v 1.345 2001/05/31 21:56:23 tron Exp $
|
||||
# $NetBSD: mi,v 1.346 2001/06/02 19:12:59 jdolecek Exp $
|
||||
./sys comp-sysutil-root
|
||||
./usr/bin/addr2line comp-debug-bin
|
||||
./usr/bin/ar comp-util-bin
|
||||
@ -2965,7 +2965,13 @@
|
||||
./usr/share/man/cat9/clock_secs_to_ymdhms.0 comp-sys-catman
|
||||
./usr/share/man/cat9/clock_ymdhms_to_secs.0 comp-sys-catman
|
||||
./usr/share/man/cat9/cltom.0 comp-sys-catman
|
||||
./usr/share/man/cat9/cnbell.0 comp-sys-catman
|
||||
./usr/share/man/cat9/cngetc.0 comp-sys-catman
|
||||
./usr/share/man/cat9/cngetsn.0 comp-sys-catman
|
||||
./usr/share/man/cat9/cnmagic.0 comp-sys-catman
|
||||
./usr/share/man/cat9/cnpollc.0 comp-sys-catman
|
||||
./usr/share/man/cat9/cnputc.0 comp-sys-catman
|
||||
./usr/share/man/cat9/cons.0 comp-sys-catman
|
||||
./usr/share/man/cat9/copy.0 comp-sys-catman
|
||||
./usr/share/man/cat9/copyin.0 comp-sys-catman
|
||||
./usr/share/man/cat9/copyinstr.0 comp-sys-catman
|
||||
@ -4938,7 +4944,13 @@
|
||||
./usr/share/man/man9/clock_secs_to_ymdhms.9 comp-sys-man
|
||||
./usr/share/man/man9/clock_ymdhms_to_secs.9 comp-sys-man
|
||||
./usr/share/man/man9/cltom.9 comp-sys-man
|
||||
./usr/share/man/man9/cnbell.9 comp-sys-man
|
||||
./usr/share/man/man9/cngetc.9 comp-sys-man
|
||||
./usr/share/man/man9/cngetsn.9 comp-sys-man
|
||||
./usr/share/man/man9/cnmagic.9 comp-sys-man
|
||||
./usr/share/man/man9/cnpollc.9 comp-sys-man
|
||||
./usr/share/man/man9/cnputc.9 comp-sys-man
|
||||
./usr/share/man/man9/cons.9 comp-sys-man
|
||||
./usr/share/man/man9/copy.9 comp-sys-man
|
||||
./usr/share/man/man9/copyin.9 comp-sys-man
|
||||
./usr/share/man/man9/copyinstr.9 comp-sys-man
|
||||
|
@ -1,9 +1,10 @@
|
||||
# $NetBSD: Makefile,v 1.80 2001/05/24 14:04:41 sommerfeld Exp $
|
||||
# $NetBSD: Makefile,v 1.81 2001/06/02 19:12:59 jdolecek Exp $
|
||||
|
||||
# Makefile for section 9 (kernel function and variable) manual pages.
|
||||
|
||||
MAN= access.9 arp.9 audio.9 bitmask_snprintf.9 bus_dma.9 bus_space.9 \
|
||||
callout.9 cnmagic.9 copy.9 cpu_reboot.9 ctxsw.9 disk.9 disklabel.9 \
|
||||
callout.9 cnmagic.9 cons.9 copy.9 cpu_reboot.9 ctxsw.9 disk.9 \
|
||||
disklabel.9 \
|
||||
dopowerhooks.9 doshutdownhooks.9 ethersubr.9 evcnt.9 \
|
||||
extent.9 fetch.9 fork1.9 humanize_number.9 in4_cksum.9 inittodr.9 \
|
||||
intro.9 ioctl.9 kprintf.9 linedisc.9 lock.9 log.9 malloc.9 mbuf.9 \
|
||||
@ -57,6 +58,8 @@ MLINKS+=callout.9 callout_init.9 callout.9 callout_reset.9 \
|
||||
callout.9 callout_stop.9 callout.9 callout_active.9 \
|
||||
callout.9 callout_pending.9 callout.9 callout_deactivate.9 \
|
||||
callout.9 timeout.9 callout.9 untimeout.9
|
||||
MLINKS+=cons.9 cnbell.9 cons.9 cngetc.9 cons.9 cngetsn.9 cons.9 cnpollc.9 \
|
||||
cons.9 cnputc.9
|
||||
MLINKS+=copy.9 copyin.9 copy.9 copyout.9 copy.9 copystr.9 \
|
||||
copy.9 copyinstr.9 copy.9 copyoutstr.9
|
||||
MLINKS+=ctxsw.9 cpu_switch.9 ctxsw.9 mi_switch.9
|
||||
|
158
share/man/man9/cons.9
Normal file
158
share/man/man9/cons.9
Normal file
@ -0,0 +1,158 @@
|
||||
.\" $NetBSD: cons.9,v 1.1 2001/06/02 19:13:00 jdolecek Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" This product includes software developed by the NetBSD
|
||||
.\" Foundation, Inc. and its contributors.
|
||||
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
.\" contributors may be used to endorse or promote products derived
|
||||
.\" from this software without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd June 2, 2001
|
||||
.Dt CONS 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm cnbell ,
|
||||
.Nm cngetc ,
|
||||
.Nm cngetsn ,
|
||||
.Nm cnpollc ,
|
||||
.Nm cnputc
|
||||
.Nd console access interface
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <dev/cons.h>
|
||||
.Ft void
|
||||
.Fn cnbell "u_int pitch" "u_int period" "u_int volume"
|
||||
.Ft int
|
||||
.Fn cngetc "void"
|
||||
.Ft int
|
||||
.Fn cngetsn "char *cp" "int size"
|
||||
.Ft void
|
||||
.Fn cnpollc "int on"
|
||||
.Ft void
|
||||
.Fn cnputc "int c"
|
||||
.Sh DESCRIPTION
|
||||
These functions operate over current console device. The console has
|
||||
to be initialized first, before these functions could be used.
|
||||
.Pp
|
||||
Keyboard polling functions
|
||||
.Fn cngetc ,
|
||||
.Fn cngetsn
|
||||
and
|
||||
.Fn cnpollc
|
||||
are only to be used during initial system
|
||||
boot, e.g. when asking for root and dump device or to get
|
||||
necessary user input within mountroothooks. Once the system
|
||||
boots, user input is read via standard
|
||||
.Xr tty 4
|
||||
facilities.
|
||||
.Pp
|
||||
The following is a brief description of each function:
|
||||
.Bl -tag -width "cngetsn()"
|
||||
.It Fn cnbell
|
||||
Ring a bell at appropriate
|
||||
.Fa pitch ,
|
||||
for duration of
|
||||
.Fa period
|
||||
miliseconds at given
|
||||
.Fa volume.
|
||||
Note that the
|
||||
.Fa volume
|
||||
value is ignored commonly.
|
||||
.It Fn cngetc
|
||||
Poll (busy wait) for a input and return the input key.
|
||||
.Fn cnpollc
|
||||
.Em must
|
||||
be called before
|
||||
.Fn cngetc
|
||||
could be used.
|
||||
.Fn cngetc
|
||||
should be used during kernel startup only.
|
||||
.It Fn cngetsn
|
||||
Read one line of user input, stop reading once the newline
|
||||
key is input. Input is echoed back. This
|
||||
uses
|
||||
.Fn cnpollc
|
||||
and
|
||||
.Fn cngetc .
|
||||
Number of read characters is
|
||||
.Fa size
|
||||
at maximum, user is notified by keyboard bell when the end
|
||||
of input buffer is reached. Standard <Baskspace> key
|
||||
work as expected. <@> key makes
|
||||
.Fn cngetsn
|
||||
discard input read so far, print newline and
|
||||
wait for next input.
|
||||
.Fn cngetsn
|
||||
returns number of characters actually read, exluding
|
||||
the final newline.
|
||||
.Fa cp
|
||||
is
|
||||
.Em not
|
||||
zero-ended before return.
|
||||
.Fn cngetsn
|
||||
should be used during kernel startup only.
|
||||
.It Fn cnpollc
|
||||
Switch the console driver to polling mode if
|
||||
.Fa on
|
||||
is nonzero, or back to interrupt driven mode if
|
||||
.Fa on
|
||||
is zero. The system priority level has to be raised to splhigh before
|
||||
the polling mode could be switched on, so that the polled console device would
|
||||
not be disturbed by interrupts. The system priority level has to be
|
||||
restored to previous level once the polling mode is switched back off.
|
||||
.Fn cnpollc
|
||||
should be used during kernel startup only.
|
||||
.It Fn cnputc
|
||||
Console kernel output character routine. Commonly, kernel code uses
|
||||
.Xr printf 9
|
||||
rather than using this low-level interface.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
This waits until a <Enter> key is pressed:
|
||||
.Pp
|
||||
.Bd -literal -compact
|
||||
int s, c;
|
||||
|
||||
s = splhigh();
|
||||
cnpollc(1);
|
||||
for(;;) {
|
||||
c = cngetc();
|
||||
if ((c == '\\r' || (c == '\\n')) {
|
||||
printf("\\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
cnpollc(0);
|
||||
splx(s);
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr pckbd 4 ,
|
||||
.Xr pcppi 4 ,
|
||||
.Xr tty 4 ,
|
||||
.Xr wscons 4 ,
|
||||
.Xr wskbd 4 ,
|
||||
.Xr printf 9 ,
|
||||
.Xr spl 9
|
Loading…
Reference in New Issue
Block a user