[BACK]Return to cnmagic.9 CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / share / man / man9

File: [cvs.NetBSD.org] / src / share / man / man9 / cnmagic.9 (download)

Revision 1.13, Wed Oct 6 05:57:33 2004 UTC (19 years, 6 months ago) by dbj
Branch: MAIN
CVS Tags: yamt-pf42-baseX, yamt-pf42-base4, yamt-pf42-base3, yamt-pf42-base2, yamt-pf42-base, yamt-pf42, wrstuden-revivesa-base-3, wrstuden-revivesa-base-2, wrstuden-revivesa-base-1, wrstuden-revivesa-base, wrstuden-revivesa, wrstuden-fixsa-newbase, wrstuden-fixsa-base-1, wrstuden-fixsa-base, wrstuden-fixsa, uebayasi-xip-base1, netbsd-5-base, netbsd-5-2-RELEASE, netbsd-5-2-RC1, netbsd-5-2-3-RELEASE, netbsd-5-2-2-RELEASE, netbsd-5-2-1-RELEASE, netbsd-5-2, netbsd-5-1-RELEASE, netbsd-5-1-RC4, netbsd-5-1-RC3, netbsd-5-1-RC2, netbsd-5-1-RC1, netbsd-5-1-5-RELEASE, netbsd-5-1-4-RELEASE, netbsd-5-1-3-RELEASE, netbsd-5-1-2-RELEASE, netbsd-5-1-1-RELEASE, netbsd-5-1, netbsd-5-0-RELEASE, netbsd-5-0-RC4, netbsd-5-0-RC3, netbsd-5-0-RC2, netbsd-5-0-RC1, netbsd-5-0-2-RELEASE, netbsd-5-0-1-RELEASE, netbsd-5-0, netbsd-5, netbsd-4-base, netbsd-4-0-RELEASE, netbsd-4-0-RC5, netbsd-4-0-RC4, netbsd-4-0-RC3, netbsd-4-0-RC2, netbsd-4-0-RC1, netbsd-4-0-1-RELEASE, netbsd-4-0, netbsd-4, netbsd-3-base, netbsd-3-1-RELEASE, netbsd-3-1-RC4, netbsd-3-1-RC3, netbsd-3-1-RC2, netbsd-3-1-RC1, netbsd-3-1-1-RELEASE, netbsd-3-1, netbsd-3-0-RELEASE, netbsd-3-0-RC6, netbsd-3-0-RC5, netbsd-3-0-RC4, netbsd-3-0-RC3, netbsd-3-0-RC2, netbsd-3-0-RC1, netbsd-3-0-3-RELEASE, netbsd-3-0-2-RELEASE, netbsd-3-0-1-RELEASE, netbsd-3-0, netbsd-3, mjf-devfs2-base, mjf-devfs2, matt-premerge-20091211, matt-nb5-pq3-base, matt-nb5-pq3, matt-nb5-mips64-u2-k2-k4-k7-k8-k9, matt-nb5-mips64-u1-k1-k5, matt-nb5-mips64-premerge-20101231, matt-nb5-mips64-premerge-20091211, matt-nb5-mips64-k15, matt-nb5-mips64, matt-nb4-mips64-k7-u2a-k9b, matt-mips64-base2, matt-mips64-base, matt-mips64, matt-armv6-prevmlocking, matt-armv6-nbase, matt-armv6-base, matt-armv6, keiichi-mipv6-nbase, keiichi-mipv6-base, keiichi-mipv6, jym-xensuspend-nbase, jym-xensuspend-base, jym-xensuspend, hpcarm-cleanup-nbase, hpcarm-cleanup-base, hpcarm-cleanup, cube-autoconf-base, cube-autoconf, chap-midi-nbase, chap-midi-base, chap-midi, abandoned-netbsd-4-base, abandoned-netbsd-4
Branch point for: uebayasi-xip
Changes since 1.12: +2 -2 lines

fix typo: s/sate/state/

.\" $NetBSD: cnmagic.9,v 1.13 2004/10/06 05:57:33 dbj Exp $
.\"
.\" Copyright (c) 2000 Eduardo Horvath
.\" 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 for the
.\"          NetBSD Project.  See http://www.NetBSD.org/ for
.\"          information about NetBSD.
.\" 4. The name of the author may not be used to endorse or promote products
.\"    derived from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
.\"
.\" --(license Id: LICENSE.proto,v 1.1 2000/06/13 21:40:26 cgd Exp )--
.\"
.Dd November 11, 2000
.Dt CNMAGIC 9
.Os
.Sh NAME
.Nm cn_trap ,
.Nm cn_isconsole ,
.Nm cn_check_magic ,
.Nm cn_init_magic ,
.Nm cn_set_magic ,
.Nm cn_get_magic ,
.Nm cn_destroy_magic
.Nd console magic key sequence management
.Sh SYNOPSIS
.In sys/systm.h
.Va typedef struct cnm_state cnm_state_t;
.Ft void
.Fn cn_trap
.Ft int
.Fn cn_isconsole "dev_t dev"
.Ft void
.Fn cn_check_magic "dev_t dev" "int k" "cnm_state_t *cnms"
.Ft void
.Fn cn_init_magic "cnm_state_t *cnms"
.Ft int
.Fn cn_set_magic "char *magic"
.Ft int
.Fn cn_get_magic "char *magic" "int len"
.Ft void
.Fn cn_destroy_magic "cnm_state_t *cnms"
.Sh DESCRIPTION
The
.Nx
console magic key sequence management framework is designed to provide
flexible methods to set, change, and detect magic key sequences on console
devices and break into the debugger or ROM monitor with a minimum of interrupt
latency.
.Pp
Drivers that generate console input should make use of these routines.
A different
.Va cnm_state_t
should be used for each separate input stream.
Multiple devices that share the same input stream, such as USB
keyboards can share the same
.Va cnm_state_t .
Once a
.Va cnm_state_t
is allocated, it should be initialized with
.Fn cn_init_magic
so it can be used by
.Fn cn_check_magic .
If a driver thinks it might be the console input device it can set the
magic sequence with
.Fn cn_set_magic
to any arbitrary string.
Whenever the driver receives input, it should call
.Fn cn_check_magic
to process the data and determine whether the magic sequence has
been hit.
.Pp
The magic key sequence can be accessed through the
.Va hw.cnmagic
.Ic sysctl
variable.
This is the raw data and may be keycodes rather than
processed characters, depending on the console device.
.Pp
Here is a description of the console magic interface:
.Bl -tag -width indent
.It Fn "void cn_init_magic" "cnm_state_t *cnm"
.Pp
Initialize the console magic state pointed to by
.Fa cnm
to a usable state.
.It Fn "void cnm_trap"
.Pp
Trap into the kernel debugger or ROM monitor.
By default this routine is defined to be
.Fn console_debugger
but can be overridden in MI header files.
.It Fn "int cn_isconsole" "dev_t dev"
.Pp
Determine whether a given
.Fa dev
is the system console.
This macro tests to see if
.Fa dev
is the same as
.Va cn_tab-\*[Gt]cn_dev
but can be overridden in MI header files.
.It Fn "void cn_check_magic" "dev_t dev" "int k" "cnm_state_t *cnms"
.Pp
All input should be passed through
.Fn cn_check_magic
so the state machine remains in a consistent state.
.Fn cn_check_magic
calls
.Fn cn_isconsole
with
.Fa dev
to determine if this is the console.
If that returns true then it runs the input value
.Fa k
through the state machine.
If the state machine completes a match of the current console magic sequence
.Fn cn_trap
is called.
Some input may need to be translated to state machine
values such as the serial line
.Li BREAK
sequence.
.It Fn "void cn_destroy_magic" "cnm_state_t *cnms"
.Pp
This should be called once what
.Fa cnms
points to is no longer needed.
.It Fn "int cn_set_magic" "char *magic"
.Fn cn_set_magic
encodes a
.Li nul
terminated string arbitrary string into values that can be used by
the state machine and installs it as the global magic sequence.
The escape sequence is character value
.Li 0x27
and can be used to encode special values:
.Pp
.Bl -tag -width "0x001" -compact -offset indent
.It 0x27
The literal value
.Li 0x27 .
.It 0x01
Serial
.Li BREAK
sequence.
.It 0x02
.Li Nul
character.
.El
Returns
.Li 0
on success or a non-zero error value.
.It Fn "int cn_get_magic" "char *magic" "int len"
Extract the current magic sequence from the state machine and return
up to
.Fa len
bytes of it in the buffer pointed to by
.Fa magic .
It uses the same encoding accepted by
.Fn cn_set_magic .
Returns
.Li 0
on success or a non-zero error value.
.El
.Sh SEE ALSO
.Xr sysctl 8
.Sh HISTORY
The
.Nx
console magic key sequence management framework
first appeared in
.Nx 1.6 .
.Sh AUTHORS
The
.Nx
console magic key sequence management framework was designed and
implemented by
.An Eduardo Horvath
.Aq eeh@NetBSD.org .