1/* $NetBSD: dec_2000_300.c,v 1.17 2011/06/14 15:34:21 matt Exp $ */ 2 3/*- 4 * Copyright (c) 2000 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Jason R. Thorpe. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32/* 33 * Copyright (c) 1995, 1996 Carnegie-Mellon University. 34 * All rights reserved. 35 * 36 * Author: Chris G. Demetriou 37 * 38 * Permission to use, copy, modify and distribute this software and 39 * its documentation is hereby granted, provided that both the copyright 40 * notice and this permission notice appear in all copies of the 41 * software, derivative works or modified versions, and any portions 42 * thereof, and that both notices appear in supporting documentation. 43 * 44 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 45 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 46 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 47 * 48 * Carnegie Mellon requests users of this software to return to 49 * 50 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 51 * School of Computer Science 52 * Carnegie Mellon University 53 * Pittsburgh PA 15213-3890 54 * 55 * any improvements or extensions that they make and grant Carnegie the 56 * rights to redistribute these changes. 57 */ 58 59#include "opt_kgdb.h" 60 61#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 62 63__KERNEL_RCSID(0, "$NetBSD: dec_2000_300.c,v 1.17 2011/06/14 15:34:21 matt Exp $"); 64 65#include <sys/param.h> 66#include <sys/systm.h> 67#include <sys/device.h> 68#include <sys/termios.h> 69#include <sys/conf.h> 70 71#include <machine/rpb.h> 72#include <machine/autoconf.h> 73#include <machine/cpuconf.h> 74 75#include <dev/eisa/eisavar.h> 76#include <dev/isa/isareg.h> 77#include <dev/isa/isavar.h> 78#include <dev/ic/i8042reg.h> 79 80#include <dev/ic/comvar.h> 81#include <dev/ic/comreg.h> 82#include <dev/ic/pckbcvar.h> 83 84#include <alpha/jensenio/jenseniovar.h> 85 86#include <dev/scsipi/scsi_all.h> 87#include <dev/scsipi/scsipi_all.h> 88#include <dev/scsipi/scsiconf.h> 89 90#include "pckbd.h" 91 92void dec_2000_300_init(void); 93static void dec_2000_300_cons_init(void); 94static void dec_2000_300_device_register(device_t, void *); 95 96#ifdef KGDB 97#include <machine/db_machdep.h> 98 99static const char *kgdb_devlist[] = { 100 "com", 101 NULL, 102}; 103#endif /* KGDB */ 104 105void 106dec_2000_300_init(void) 107{ 108 109 platform.family = "DECpc AXP 150 (\"Jensen\")"; 110 111 if ((platform.model = alpha_dsr_sysname()) == NULL) { 112 /* XXX Don't know the system variations, yet. */ 113 platform.model = alpha_unknown_sysname(); 114 } 115 116 platform.iobus = "jensenio"; 117 platform.cons_init = dec_2000_300_cons_init; 118 platform.device_register = dec_2000_300_device_register; 119} 120 121static void 122dec_2000_300_cons_init(void) 123{ 124 struct ctb_tt *ctb; 125 struct jensenio_config *jcp; 126 extern struct jensenio_config jensenio_configuration; 127 128 jcp = &jensenio_configuration; 129 jensenio_init(jcp, 0); 130 131 ctb = (struct ctb_tt *)(((char *)hwrpb) + hwrpb->rpb_ctb_off); 132 133 /* 134 * The Jensen uses an older (pre-Type 4) CTB format. The 135 * console type is specified directly by ctb_type, and only 136 * minimal info is given, only for the serial console. 137 * 138 * Thankfully, the only graphics device we can have is 139 * ISA/EISA, so it really doesn't matter too much. 140 */ 141 142 switch (ctb->ctb_type) { 143 case CTB_PRINTERPORT: 144 /* serial console... */ 145 /* XXX */ 146 { 147#if 0 148 printf("CTB CSR = 0x%08lx\n", ctb->ctb_csr); 149 printf("CTB BAUD = %lu\n", ctb->ctb_baud); 150#endif 151 /* 152 * Delay to allow PROM putchars to complete. 153 * FIFO depth * character time, 154 * character time = (1000000 / (defaultrate / 10)) 155 */ 156 DELAY(160000000 / ctb->ctb_baud); 157 158 if (comcnattach(&jcp->jc_internal_iot, 0x3f8, 159 ctb->ctb_baud, COM_FREQ, COM_TYPE_NORMAL, 160 (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8)) 161 panic("can't init serial console"); 162 163 break; 164 } 165 166 case CTB_GRAPHICS: 167#if NPCKBD > 0 168 /* display console... */ 169 /* XXX */ 170 (void) pckbc_cnattach(&jcp->jc_internal_iot, IO_KBD, KBCMDP, 171 PCKBC_KBD_SLOT); 172 173 isa_display_console(&jcp->jc_eisa_iot, &jcp->jc_eisa_memt); 174#else 175 panic("not configured to use display && keyboard console"); 176#endif 177 break; 178 179 180 default: 181 goto badconsole; 182 } 183#ifdef KGDB 184 /* Attach the KGDB device. */ 185 alpha_kgdb_init(kgdb_devlist, &jcp->jc_internal_iot); 186#endif /* KGDB */ 187 188 return; 189 badconsole: 190 printf("ctb->ctb_type = 0x%lx\n", ctb->ctb_type); 191 printf("ctb->ctb_csr = 0x%lx\n", ctb->ctb_csr); 192 printf("ctb->ctb_baud = %lu\n", ctb->ctb_baud); 193 194 panic("consinit: unknown console type %lu", 195 ctb->ctb_type); 196} 197 198static void 199dec_2000_300_device_register(device_t dev, void *aux) 200{ 201 static int found, initted, scsiboot, netboot; 202 static device_t eisadev, isadev, scsidev; 203 struct bootdev_data *b = bootdev_data; 204 device_t parent = device_parent(dev); 205 206 if (found) 207 return; 208 209 if (!initted) { 210 scsiboot = (strcmp(b->protocol, "SCSI") == 0); 211 netboot = (strcmp(b->protocol, "BOOTP") == 0); 212#if 0 213 printf("scsiboot = %d, netboot = %d\n", scsiboot, netboot); 214#endif 215 initted = 1; 216 } 217 218 if (eisadev == NULL && device_is_a(dev, "eisa")) 219 eisadev = dev; 220 221 if (isadev == NULL && device_is_a(dev, "isa")) 222 isadev = dev; 223 224 if (scsiboot && (scsidev == NULL)) { 225 if (eisadev == NULL || parent != eisadev) 226 return; 227 else { 228 struct eisa_attach_args *ea = aux; 229 230 if (b->slot != ea->ea_slot) 231 return; 232 233 scsidev = dev; 234#if 0 235 printf("\nscsidev = %s\n", device_xname(scsidev)); 236#endif 237 return; 238 } 239 } 240 241 if (scsiboot && 242 (device_is_a(dev, "sd") || 243 device_is_a(dev, "st") || 244 device_is_a(dev, "cd"))) { 245 struct scsipibus_attach_args *sa = aux; 246 247 if (device_parent(parent) != scsidev) 248 return; 249 250 if (b->unit / 100 != sa->sa_periph->periph_target) 251 return; 252 253 /* XXX LUN! */ 254 255 switch (b->boot_dev_type) { 256 case 0: 257 if (!device_is_a(dev, "sd") && 258 !device_is_a(dev, "cd")) 259 return; 260 break; 261 case 1: 262 if (!device_is_a(dev, "st")) 263 return; 264 break; 265 default: 266 return; 267 } 268 269 /* we've found it! */ 270 booted_device = dev; 271#if 0 272 printf("\nbooted_device = %s\n", device_xname(booted_device)); 273#endif 274 found = 1; 275 return; 276 } 277 278 if (netboot) { 279 /* 280 * XXX WHAT ABOUT ISA NETWORK CARDS? 281 */ 282 if (eisadev == NULL || parent != eisadev) 283 return; 284 else { 285 struct eisa_attach_args *ea = aux; 286 287 if (b->slot != ea->ea_slot) 288 return; 289 290 booted_device = dev; 291#if 0 292 printf("\nbooted_device = %s\n", device_xname(booted_device)); 293#endif 294 found = 1; 295 return; 296 } 297 } 298} 299