cons.h revision 1.24
11.24Schristos/* $NetBSD: cons.h,v 1.24 2005/12/11 12:20:53 christos Exp $ */ 21.6Scgd 31.1Scgd/* 41.5Scgd * Copyright (c) 1990, 1993 51.5Scgd * The Regents of the University of California. All rights reserved. 61.21Sagc * 71.21Sagc * This code is derived from software contributed to Berkeley by 81.21Sagc * the Systems Programming Group of the University of Utah Computer 91.21Sagc * Science Department. 101.21Sagc * 111.21Sagc * Redistribution and use in source and binary forms, with or without 121.21Sagc * modification, are permitted provided that the following conditions 131.21Sagc * are met: 141.21Sagc * 1. Redistributions of source code must retain the above copyright 151.21Sagc * notice, this list of conditions and the following disclaimer. 161.21Sagc * 2. Redistributions in binary form must reproduce the above copyright 171.21Sagc * notice, this list of conditions and the following disclaimer in the 181.21Sagc * documentation and/or other materials provided with the distribution. 191.21Sagc * 3. Neither the name of the University nor the names of its contributors 201.21Sagc * may be used to endorse or promote products derived from this software 211.21Sagc * without specific prior written permission. 221.21Sagc * 231.21Sagc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 241.21Sagc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 251.21Sagc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 261.21Sagc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 271.21Sagc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 281.21Sagc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 291.21Sagc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 301.21Sagc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 311.21Sagc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 321.21Sagc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 331.21Sagc * SUCH DAMAGE. 341.21Sagc * 351.21Sagc * from: Utah $Hdr: cons.h 1.6 92/01/21$ 361.21Sagc * 371.21Sagc * @(#)cons.h 8.1 (Berkeley) 6/10/93 381.21Sagc */ 391.21Sagc 401.21Sagc/* 411.21Sagc * Copyright (c) 1988 University of Utah. 421.1Scgd * 431.1Scgd * This code is derived from software contributed to Berkeley by 441.1Scgd * the Systems Programming Group of the University of Utah Computer 451.1Scgd * Science Department. 461.1Scgd * 471.1Scgd * Redistribution and use in source and binary forms, with or without 481.1Scgd * modification, are permitted provided that the following conditions 491.1Scgd * are met: 501.1Scgd * 1. Redistributions of source code must retain the above copyright 511.1Scgd * notice, this list of conditions and the following disclaimer. 521.1Scgd * 2. Redistributions in binary form must reproduce the above copyright 531.1Scgd * notice, this list of conditions and the following disclaimer in the 541.1Scgd * documentation and/or other materials provided with the distribution. 551.1Scgd * 3. All advertising materials mentioning features or use of this software 561.1Scgd * must display the following acknowledgement: 571.1Scgd * This product includes software developed by the University of 581.1Scgd * California, Berkeley and its contributors. 591.1Scgd * 4. Neither the name of the University nor the names of its contributors 601.1Scgd * may be used to endorse or promote products derived from this software 611.1Scgd * without specific prior written permission. 621.1Scgd * 631.1Scgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 641.1Scgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 651.1Scgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 661.1Scgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 671.1Scgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 681.1Scgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 691.1Scgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 701.1Scgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 711.1Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 721.1Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 731.1Scgd * SUCH DAMAGE. 741.1Scgd * 751.5Scgd * from: Utah $Hdr: cons.h 1.6 92/01/21$ 761.5Scgd * 771.5Scgd * @(#)cons.h 8.1 (Berkeley) 6/10/93 781.1Scgd */ 791.1Scgd 801.16Ssimonb#ifndef _SYS_DEV_CONS_H_ 811.16Ssimonb#define _SYS_DEV_CONS_H_ 821.16Ssimonb 831.1Scgdstruct consdev { 841.10Smycroft void (*cn_probe) /* probe hardware and fill in consdev info */ 851.23Sperry (struct consdev *); 861.10Smycroft void (*cn_init) /* turn on as console */ 871.23Sperry (struct consdev *); 881.10Smycroft int (*cn_getc) /* kernel getchar interface */ 891.23Sperry (dev_t); 901.10Smycroft void (*cn_putc) /* kernel putchar interface */ 911.23Sperry (dev_t, int); 921.10Smycroft void (*cn_pollc) /* turn on and off polling */ 931.23Sperry (dev_t, int); 941.17Sthorpej void (*cn_bell) /* ring bell */ 951.23Sperry (dev_t, u_int, u_int, u_int); 961.20Smatt void (*cn_halt) /* stop device */ 971.23Sperry (dev_t); 981.20Smatt void (*cn_flush) /* flush output */ 991.23Sperry (dev_t); 1001.1Scgd dev_t cn_dev; /* major/minor of device */ 1011.11Sgwr int cn_pri; /* pecking order; the higher the better */ 1021.1Scgd}; 1031.1Scgd 1041.1Scgd/* values for cn_pri - reflect our policy for console selection */ 1051.1Scgd#define CN_DEAD 0 /* device doesn't exist */ 1061.22Scdi#define CN_NULL 1 /* noop console */ 1071.22Scdi#define CN_NORMAL 2 /* device exists but is nothing special */ 1081.22Scdi#define CN_INTERNAL 3 /* "internal" bit-mapped display */ 1091.22Scdi#define CN_REMOTE 4 /* serial interface with remote bit set */ 1101.1Scgd 1111.9Sjtc#ifdef _KERNEL 1121.10Smycroft 1131.1Scgdextern struct consdev constab[]; 1141.1Scgdextern struct consdev *cn_tab; 1151.8Scgd 1161.23Sperryvoid cninit(void); 1171.23Sperryint cngetc(void); 1181.23Sperryint cngetsn(char *, int); 1191.23Sperryvoid cnputc(int); 1201.23Sperryvoid cnpollc(int); 1211.23Sperryvoid cnbell(u_int, u_int, u_int); 1221.23Sperryvoid cnflush(void); 1231.23Sperryvoid cnhalt(void); 1241.23Sperryvoid cnrint(void); 1251.23Sperryvoid nullcnprobe(struct consdev *); 1261.23Sperryvoid nullcninit(struct consdev *); 1271.23Sperryvoid nullcnpollc(dev_t, int); 1281.23Sperryvoid nullconsattach(int); 1291.10Smycroft 1301.10Smycroft/* console-specific types */ 1311.23Sperry#define dev_type_cnprobe(n) void n(struct consdev *) 1321.23Sperry#define dev_type_cninit(n) void n(struct consdev *) 1331.23Sperry#define dev_type_cngetc(n) int n(dev_t) 1341.23Sperry#define dev_type_cnputc(n) void n(dev_t, int) 1351.23Sperry#define dev_type_cnpollc(n) void n(dev_t, int) 1361.23Sperry#define dev_type_cnbell(n) void n(dev_t, u_int, u_int, u_int); 1371.23Sperry#define dev_type_cnhalt(n) void n(dev_t) 1381.23Sperry#define dev_type_cnflush(n) void n(dev_t) 1391.10Smycroft 1401.19Sgehenna#define dev_decl(n,t) __CONCAT(dev_type_,t)(__CONCAT(n,t)) 1411.19Sgehenna#define dev_init(n,t) __CONCAT(n,t) 1421.19Sgehenna 1431.10Smycroft#define cons_decl(n) \ 1441.10Smycroft dev_decl(n,cnprobe); dev_decl(n,cninit); dev_decl(n,cngetc); \ 1451.20Smatt dev_decl(n,cnputc); dev_decl(n,cnpollc); dev_decl(n,cnbell); \ 1461.20Smatt dev_decl(n,cnflush); dev_decl(n,cnhalt); 1471.10Smycroft 1481.10Smycroft#define cons_init(n) { \ 1491.19Sgehenna dev_init(n,cnprobe), dev_init(n,cninit), dev_init(n,cngetc), \ 1501.19Sgehenna dev_init(n,cnputc), dev_init(n,cnpollc) } 1511.17Sthorpej 1521.17Sthorpej#define cons_init_bell(n) { \ 1531.19Sgehenna dev_init(n,cnprobe), dev_init(n,cninit), dev_init(n,cngetc), \ 1541.19Sgehenna dev_init(n,cnputc), dev_init(n,cnpollc), dev_init(n,cnbell) } 1551.20Smatt 1561.20Smatt#define cons_init_halt(n) { \ 1571.20Smatt dev_init(n,cnprobe), dev_init(n,cninit), dev_init(n,cngetc), \ 1581.20Smatt dev_init(n,cnputc), dev_init(n,cnpollc), 0, \ 1591.20Smatt dev_init(n,cnhalt) } 1601.10Smycroft 1611.1Scgd#endif 1621.16Ssimonb 1631.16Ssimonb#endif /* _SYS_DEV_CONS_H_ */ 164