Set it so you can add and remove line disciplines without replicating

code for looking for open slots in table (and you could hide the table
if you wanted to).
This commit is contained in:
Peter Dufault 1995-03-21 11:24:05 +00:00
parent e8d9ff42ce
commit 3749fcff67
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=7218
3 changed files with 72 additions and 3 deletions

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)tty_conf.c 8.4 (Berkeley) 1/21/94
* $Id: tty_conf.c,v 1.3 1994/08/02 07:42:50 davidg Exp $
* $Id: tty_conf.c,v 1.4 1994/10/05 21:22:24 wollman Exp $
*/
#include <sys/param.h>
@ -89,6 +89,67 @@ struct linesw linesw[MAXLDISC] =
int nlinesw = sizeof (linesw) / sizeof (linesw[0]);
static struct linesw nodisc =
{
ttynodisc,
ttyerrclose,
ttyerrio,
ttyerrio,
nullioctl,
ttyerrinput,
ttyerrstart,
nullmodem
};
#define LOADABLE_LDISC 6
/*
* ldisc_register: Register a line discipline.
*
* discipline: Index for discipline to load, or LDISC_LOAD for us to choose.
* linesw_p: Pointer to linesw_p.
*
* Returns: Index used or -1 on failure.
*/
int
ldisc_register(discipline, linesw_p)
int discipline;
struct linesw *linesw_p;
{
int slot = -1;
if (discipline == LDISC_LOAD) {
int i;
for (i = LOADABLE_LDISC; i < MAXLDISC; i++)
if (bcmp(linesw + i, &nodisc, sizeof(nodisc)) == 0) {
slot = i;
}
}
else if (discipline >= 0 && discipline < MAXLDISC) {
slot = discipline;
}
if (slot != -1 && linesw_p)
linesw[slot] = *linesw_p;
return slot;
}
/*
* ldisc_deregister: Deregister a line discipline obtained with
* ldisc_register. Can only deregister "loadable" ones now.
*
* discipline: Index for discipline to unload.
*/
void
ldisc_deregister(discipline)
int discipline;
{
if (discipline >= LOADABLE_LDISC && discipline < MAXLDISC) {
linesw[discipline] = nodisc;
}
}
/*
* Do nothing specific version of line
* discipline specific ioctl command.

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)conf.h 8.3 (Berkeley) 1/21/94
* $Id: conf.h,v 1.9 1995/02/25 20:09:36 pst Exp $
* $Id: conf.h,v 1.10 1995/03/16 18:16:13 bde Exp $
*/
#ifndef _SYS_CONF_H_
@ -121,6 +121,10 @@ struct linesw {
#ifdef KERNEL
extern struct linesw linesw[];
extern int nlinesw;
int ldisc_register __P((int , struct linesw *));
void ldisc_deregister __P((int));
#define LDISC_LOAD -1 /* Loadable line discipline */
#endif
struct swdevt {

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)conf.h 8.3 (Berkeley) 1/21/94
* $Id: conf.h,v 1.9 1995/02/25 20:09:36 pst Exp $
* $Id: conf.h,v 1.10 1995/03/16 18:16:13 bde Exp $
*/
#ifndef _SYS_CONF_H_
@ -121,6 +121,10 @@ struct linesw {
#ifdef KERNEL
extern struct linesw linesw[];
extern int nlinesw;
int ldisc_register __P((int , struct linesw *));
void ldisc_deregister __P((int));
#define LDISC_LOAD -1 /* Loadable line discipline */
#endif
struct swdevt {