1 /* $NetBSD: consinit.c,v 1.9 2009/03/18 10:22:36 cegger Exp $ */ 2 3 /* 4 * Copyright (c) 1998 5 * Matthias Drochner. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * 27 */ 28 29 #include <sys/cdefs.h> 30 __KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.9 2009/03/18 10:22:36 cegger Exp $"); 31 32 #include <sys/param.h> 33 #include <sys/systm.h> 34 #include <sys/device.h> 35 #include <dev/cons.h> 36 #include <machine/bus.h> 37 #include <dev/isa/isavar.h> 38 39 #include "vga.h" 40 #if (NVGA > 0) 41 #include <dev/ic/mc6845reg.h> 42 #include <dev/ic/pcdisplayvar.h> 43 #include <dev/ic/vgareg.h> 44 #include <dev/ic/vgavar.h> 45 #endif 46 #include "vga_ofbus.h" 47 #if (NVGA_OFBUS > 0) 48 #include <shark/ofw/vga_ofbusvar.h> 49 #endif 50 51 #include "pckbc.h" 52 #if (NPCKBC > 0) 53 #include <dev/isa/isareg.h> 54 #include <dev/ic/i8042reg.h> 55 #include <dev/ic/pckbcvar.h> 56 #include <dev/pckbport/pckbportvar.h> 57 #endif 58 #include "pckbd.h" /* for pckbc_machdep_cnattach */ 59 60 #include "com.h" 61 #if (NCOM > 0) 62 #include <sys/termios.h> 63 #include <dev/ic/comreg.h> 64 #include <dev/ic/comvar.h> 65 #endif 66 67 #include "ofcons.h" 68 #if (NOFCONS > 0) 69 cons_decl(ofcons_) 70 static struct consdev ofcons = cons_init(ofcons_); 71 #endif 72 73 #include "igsfb_ofbus.h" 74 #include <shark/ofw/igsfb_ofbusvar.h> 75 76 #if (NCOM > 0) 77 #ifndef CONADDR 78 #define CONADDR 0x3f8 79 #endif 80 #ifndef CONSPEED 81 #define CONSPEED TTYDEF_SPEED 82 #endif 83 #ifndef CONMODE 84 #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */ 85 #endif 86 int comcnmode = CONMODE; 87 #endif /* NCOM */ 88 #ifdef COMCONSOLE 89 int comconsole = 1; 90 #else 91 int comconsole = 0; 92 #endif 93 94 /* 95 * consinit: 96 * initialize the system console. 97 */ 98 void 99 consinit(void) 100 { 101 struct consdev *cp; 102 static int initted; 103 104 if (initted) 105 return; 106 initted = 1; 107 cp = NULL; 108 109 #if (NVGA > 0) 110 /* The font built into the VGA ROM is broken: all the characters 111 * above the 127th do not match the standard set expected by the 112 * console. E.g. boxes drawn using the ACS are incorrect. */ 113 vga_no_builtinfont = 1; 114 #endif 115 116 if (!comconsole) { 117 #if (NVGA > 0) || (NIGSFB_OFBUS > 0) 118 #if (NIGSFB_OFBUS > 0) 119 if (!igsfb_ofbus_cnattach(&isa_io_bs_tag, &isa_mem_bs_tag)) { 120 #if (NPCKBC > 0) 121 pckbc_cnattach(&isa_io_bs_tag, IO_KBD, KBCMDP, 122 PCKBC_KBD_SLOT); 123 #endif /* NPCKBC */ 124 return; 125 } 126 #endif /* NIGSFB_OFBUS */ 127 #if (NVGA_OFBUS > 0) 128 if (!vga_ofbus_cnattach(&isa_io_bs_tag, &isa_mem_bs_tag)) { 129 #if (NPCKBC > 0) 130 pckbc_cnattach(&isa_io_bs_tag, IO_KBD, KBCMDP, 131 PCKBC_KBD_SLOT); 132 #endif /* NPCKBC */ 133 return; 134 } 135 #endif /* NVGA_OFBUS */ 136 #else /* NVGA */ 137 #if (NOFCONS > 0) 138 cp = &ofcons; 139 ofcons_cnprobe(cp); 140 if (cp->cn_pri == CN_INTERNAL) { 141 ofcons_cninit(cp); 142 cn_tab = cp; 143 return; 144 } 145 #endif /* NOFCONS */ 146 #endif /* NVGA */ 147 } 148 #if (NCOM > 0) 149 if (comcnattach(&isa_io_bs_tag, CONADDR, CONSPEED, COM_FREQ, 150 COM_TYPE_NORMAL, comcnmode)) 151 panic("can't init serial console"); 152 #endif 153 } 154