diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1997-08-13 14:18:11 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1997-08-13 14:18:11 +0000 |
commit | f33c6e50002d716df12f9116355332e01891bfd4 (patch) | |
tree | 24dbb4c0ce047a3698e7d73fe629a346a3c523a7 | |
parent | 0bb25ed72ac18b1d2e5dda0ea93d18c216606c97 (diff) |
Add console switching logic
-rw-r--r-- | sys/lib/libsa/cons.c | 29 | ||||
-rw-r--r-- | sys/lib/libsa/stand.h | 5 |
2 files changed, 31 insertions, 3 deletions
diff --git a/sys/lib/libsa/cons.c b/sys/lib/libsa/cons.c index 8afa19c5979..ae0a84f6a9a 100644 --- a/sys/lib/libsa/cons.c +++ b/sys/lib/libsa/cons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cons.c,v 1.8 1997/08/12 21:28:39 mickey Exp $ */ +/* $OpenBSD: cons.c,v 1.9 1997/08/13 14:18:09 niklas Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -75,6 +75,33 @@ cninit() } int +cnset(dev) + dev_t dev; +{ + struct consdev *cp; + + /* + * Look for the specified console device and use it. + */ + for (cp = constab; cp->cn_probe; cp++) { + if (major(cp->cn_dev) == major(dev)) { + /* short-circuit noop */ + if (cp == cn_tab && cp->cn_dev == dev) + return (0); + if (cp->cn_pri > CN_DEAD) { + cn_tab = cp; + cp->cn_dev = dev; + /* Turn it on. */ + (cp->cn_init)(cp); + return (0); + } + break; + } + } + return (1); +} + +int cngetc() { if (cn_tab == NULL) diff --git a/sys/lib/libsa/stand.h b/sys/lib/libsa/stand.h index 0fa92e53b7c..0fd9ca0cc8f 100644 --- a/sys/lib/libsa/stand.h +++ b/sys/lib/libsa/stand.h @@ -1,4 +1,4 @@ -/* $OpenBSD: stand.h,v 1.28 1997/08/12 21:28:39 mickey Exp $ */ +/* $OpenBSD: stand.h,v 1.29 1997/08/13 14:18:10 niklas Exp $ */ /* $NetBSD: stand.h,v 1.18 1996/11/30 04:35:51 gwr Exp $ */ /*- @@ -179,9 +179,10 @@ ssize_t null_write __P((struct open_file *f, void *buf, off_t null_seek __P((struct open_file *f, off_t offset, int where)); int null_stat __P((struct open_file *f, struct stat *sb)); int null_readdir __P((struct open_file *f, char *name)); -int cons_probe __P((void)); char *ttyname __P((int)); /* match userland decl, but ignore !0 */ +dev_t ttydev __P((char *)); void cninit __P((void)); +int cnset __P((dev_t)); void cnputc __P((int)); int cngetc __P((void)); int cnischar __P((void)); |