|
|
1.1.1.2 root 1: /*
1.1 root 2: * Copyright (c) 1995-1994 The University of Utah and
3: * the Computer Systems Laboratory at the University of Utah (CSL).
4: * All rights reserved.
5: *
6: * Permission to use, copy, modify and distribute this software is hereby
7: * granted provided that (1) source code retains these copyright, permission,
8: * and disclaimer notices, and (2) redistributions including binaries
9: * reproduce the notices in supporting documentation, and (3) all advertising
10: * materials mentioning features or use of this software display the following
11: * acknowledgement: ``This product includes software developed by the
12: * Computer Systems Laboratory at the University of Utah.''
13: *
14: * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
15: * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
16: * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17: *
18: * CSL requests users of this software to return to [email protected] any
19: * improvements that they make and grant CSL redistribution rights.
20: *
21: * Author: Bryan Ford, University of Utah CSL
22: */
23:
1.1.1.5 ! root 24: #if ENABLE_IMMEDIATE_CONSOLE
1.1 root 25:
1.1.1.5 ! root 26: #include <device/cons.h>
! 27: #include <mach/boolean.h>
! 28: #include <i386/vm_param.h>
1.1.1.3 root 29: #include <string.h>
30:
1.1 root 31: /* This is a special "feature" (read: kludge)
32: intended for use only for kernel debugging.
33: It enables an extremely simple console output mechanism
34: that sends text straight to CGA/EGA/VGA video memory.
35: It has the nice property of being functional right from the start,
36: so it can be used to debug things that happen very early
37: before any devices are initialized. */
38:
1.1.1.4 root 39: boolean_t immediate_console_enable = TRUE;
1.1 root 40:
1.1.1.5 ! root 41: /*
! 42: * XXX we assume that pcs *always* have a console
! 43: */
! 44: int
! 45: immc_cnprobe(struct consdev *cp)
! 46: {
! 47: int maj, unit, pri;
! 48:
! 49: maj = 0;
! 50: unit = 0;
! 51: pri = CN_INTERNAL;
! 52:
! 53: cp->cn_dev = makedev(maj, unit);
! 54: cp->cn_pri = pri;
! 55: return 0;
! 56: }
! 57:
! 58: int
! 59: immc_cninit(struct consdev *cp)
! 60: {
! 61: return 0;
! 62: }
! 63:
! 64: int immc_cnmaygetc(void)
! 65: {
! 66: return -1;
! 67: }
! 68:
! 69: int
! 70: immc_cngetc(dev_t dev, int wait)
! 71: {
! 72: if (wait) {
! 73: int c;
! 74: while ((c = immc_cnmaygetc()) < 0)
! 75: continue;
! 76: return c;
! 77: }
! 78: else
! 79: return immc_cnmaygetc();
! 80: }
! 81:
! 82: int
! 83: immc_cnputc(dev_t dev, int c)
1.1 root 84: {
85: static int ofs = -1;
86:
87: if (!immediate_console_enable)
1.1.1.5 ! root 88: return -1;
! 89: if (ofs < 0 || ofs >= 80)
1.1 root 90: {
91: ofs = 0;
1.1.1.5 ! root 92: immc_cnputc(dev, '\n');
1.1 root 93: }
1.1.1.5 ! root 94:
! 95: if (c == '\n')
1.1 root 96: {
1.1.1.5 ! root 97: memmove((void *) phystokv(0xb8000),
! 98: (void *) phystokv(0xb8000+80*2), 80*2*24);
! 99: memset((void *) phystokv((0xb8000+80*2*24)), 0, 80*2);
1.1 root 100: ofs = 0;
101: }
102: else
103: {
104: volatile unsigned char *p;
105:
106: if (ofs >= 80)
107: {
1.1.1.5 ! root 108: immc_cnputc(dev, '\r');
! 109: immc_cnputc(dev, '\n');
1.1 root 110: }
111:
1.1.1.5 ! root 112: p = (void *) phystokv(0xb8000 + 80*2*24 + ofs*2);
1.1 root 113: p[0] = c;
114: p[1] = 0x0f;
115: ofs++;
116: }
1.1.1.5 ! root 117: return 0;
1.1 root 118: }
119:
1.1.1.5 ! root 120: void
! 121: immc_romputc(char c)
1.1 root 122: {
1.1.1.5 ! root 123: immc_cnputc (0, c);
1.1 root 124: }
125:
1.1.1.2 root 126: #endif /* ENABLE_IMMEDIATE_CONSOLE */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.