1/* 2 * Copyright (c) 1988 University of Utah. 3 * Copyright (c) 1991 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * the Systems Programming Group of the University of Utah Computer 8 * Science Department. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * from: @(#)cons.c 7.2 (Berkeley) 5/9/91 |
39 * $FreeBSD: head/sys/kern/tty_cons.c 51654 1999-09-25 16:21:39Z phk $ |
40 */ 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/conf.h> 45#include <sys/kernel.h> 46#include <sys/reboot.h> 47#include <sys/sysctl.h> --- 47 unchanged lines hidden (view full) --- 95 */ 96 97static u_char cn_is_open; /* nonzero if logical console is open */ 98static int openmode, openflag; /* how /dev/console was openned */ 99static u_char cn_phys_is_open; /* nonzero if physical device is open */ 100static d_close_t *cn_phys_close; /* physical device close function */ 101static d_open_t *cn_phys_open; /* physical device open function */ 102struct consdev *cn_tab; /* physical console device info */ |
103static dev_t condev_t; /* represents the device private info */ 104 105CONS_DRIVER(cons, NULL, NULL, NULL, NULL, NULL, NULL); 106 107void 108cninit() 109{ 110 struct consdev **list, *best_cp, *cp; --- 58 unchanged lines hidden (view full) --- 169 /* 170 * Hook the open and close functions. 171 */ 172 cdp = devsw(cn_tab->cn_dev); 173 cn_phys_close = cdp->d_close; 174 cdp->d_close = cnclose; 175 cn_phys_open = cdp->d_open; 176 cdp->d_open = cnopen; |
177 cn_dev_t = cn_tab->cn_dev; 178 cn_udev_t = dev2udev(cn_dev_t); 179} 180 181static void 182cnuninit(void) 183{ 184 struct cdevsw *cdp; --- 4 unchanged lines hidden (view full) --- 189 /* 190 * Unhook the open and close functions. 191 */ 192 cdp = devsw(cn_tab->cn_dev); 193 cdp->d_close = cn_phys_close; 194 cn_phys_close = NULL; 195 cdp->d_open = cn_phys_open; 196 cn_phys_open = NULL; |
197 cn_dev_t = NODEV; 198 cn_udev_t = NOUDEV; 199} 200 201/* 202 * User has changed the state of the console muting. 203 * This may require us to open or close the device in question. 204 */ --- 68 unchanged lines hidden (view full) --- 273 */ 274 if (dev == cndev) 275 cn_phys_is_open = 1; 276 else if (physdev == cndev) { 277 openmode = mode; 278 openflag = flag; 279 cn_is_open = 1; 280 } |
281 dev->si_tty = physdev->si_tty; |
282 } 283 return (retval); 284} 285 286static int 287cnclose(dev, flag, mode, p) 288 dev_t dev; 289 int flag, mode; 290 struct proc *p; 291{ 292 dev_t cndev; |
293 struct tty *cn_tp; |
294 295 if (cn_tab == NULL) 296 return (0); 297 cndev = cn_tab->cn_dev; |
298 cn_tp = cndev->si_tty; |
299 /* 300 * act appropriatly depending on whether it's /dev/console 301 * or the pysical device (e.g. /dev/sio) that's being closed. 302 * in either case, don't actually close the device unless 303 * both are closed. 304 */ 305 if (dev == cndev) { 306 /* the physical device is about to be closed */ --- 136 unchanged lines hidden --- |