diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1996-10-23 09:02:55 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1996-10-23 09:02:55 +0000 |
commit | 1694f084732e3fd41b2594922184771d8217f4b8 (patch) | |
tree | cb1d608eaa5f091da1732a65977c39c74ad4af7e /sys/lib/libsa | |
parent | 8828bb30112279b5b23ddfdbd09842da6451e73e (diff) |
introduce multiconsoles.
add btochs macro.
Diffstat (limited to 'sys/lib/libsa')
-rw-r--r-- | sys/lib/libsa/cons.c | 57 | ||||
-rw-r--r-- | sys/lib/libsa/stand.h | 20 |
2 files changed, 75 insertions, 2 deletions
diff --git a/sys/lib/libsa/cons.c b/sys/lib/libsa/cons.c new file mode 100644 index 00000000000..3dc3a10a3c8 --- /dev/null +++ b/sys/lib/libsa/cons.c @@ -0,0 +1,57 @@ +/* $OpenBSD: cons.c,v 1.1 1996/10/23 09:02:53 mickey Exp $ */ + +/* + * Copyright (c) 1996 Michael Shalayeff + * 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 Michael Shalayeff. + * 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 REGENTS 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. + * + */ + +#include <stand.h> + +struct consw *console = &consw[0]; + +void +putc(c) + int c; +{ + (*console->cn_putc)(c); +} + +int +getc() +{ + return (*console->cn_getc)(); +} + +int +ischar() +{ + return (*console->cn_ischar)(); +} + diff --git a/sys/lib/libsa/stand.h b/sys/lib/libsa/stand.h index 9e3e105af8a..ccdb0d2f184 100644 --- a/sys/lib/libsa/stand.h +++ b/sys/lib/libsa/stand.h @@ -1,4 +1,4 @@ -/* $OpenBSD: stand.h,v 1.11 1996/10/17 06:49:58 mickey Exp $ */ +/* $OpenBSD: stand.h,v 1.12 1996/10/23 09:02:54 mickey Exp $ */ /* $NetBSD: stand.h,v 1.13 1996/01/13 22:25:42 leo Exp $ */ /*- @@ -94,6 +94,17 @@ struct devsw { extern struct devsw devsw[]; /* device array */ extern int ndevs; /* number of elements in devsw[] */ +struct consw { + char *name; /* console driver name */ + int (*cn_probe) __P((void)); /* probe device for presence */ + void (*cn_putc) __P((int c)); /* print char */ + int (*cn_getc) __P((void)); /* read char */ + int (*cn_ischar) __P((void)); /* check input */ +}; + +extern struct consw consw[]; +extern int ncons; + struct open_file { int f_flags; /* see F_* below */ struct devsw *f_dev; /* pointer to device operations */ @@ -119,7 +130,11 @@ extern struct open_file files[]; #define isspace(c) ((c) == ' ' || (c) == '\t') #define isdigit(c) ((c) >= '0' && (c) <= '9') -int devopen __P((struct open_file *, const char *, char **)); +#define btochs(b,c,h,s,nh,ns) \ + c = (b) / ((nh) * (ns)); \ + h = ((b) % ((nh) * (ns))) / (ns); \ + s = ((b) % ((nh) * (ns))) % (ns); + void *alloc __P((unsigned int)); void free __P((void *, unsigned int)); struct disklabel; @@ -167,6 +182,7 @@ int null_stat __P((struct open_file *f, struct stat *sb)); int null_readdir __P((struct open_file *f, char *name)); /* Machine dependent functions */ +int devopen __P((struct open_file *, const char *, char **)); void machdep_start __P((char *, int, char *, char *, char *)); int getchar __P((void)); void putchar __P((int)); |