Home | History | Annotate | Line # | Download | only in alpha
      1 /* $NetBSD: dec_2000_300.c,v 1.23 2025/03/09 01:06:41 thorpej 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 (at) 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.23 2025/03/09 01:06:41 thorpej 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 
     92 void dec_2000_300_init(void);
     93 static void dec_2000_300_cons_init(void);
     94 static void dec_2000_300_device_register(device_t, void *);
     95 
     96 #ifdef KGDB
     97 #include <machine/db_machdep.h>
     98 
     99 static const char *kgdb_devlist[] = {
    100 	"com",
    101 	NULL,
    102 };
    103 #endif /* KGDB */
    104 
    105 void
    106 dec_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 	platform.page_physload = jensenio_page_physload;
    120 }
    121 
    122 static void
    123 dec_2000_300_cons_init(void)
    124 {
    125 	struct ctb_tt *ctb;
    126 	struct jensenio_config *jcp;
    127 	extern struct jensenio_config jensenio_configuration;
    128 
    129 	jcp = &jensenio_configuration;
    130 	jensenio_init(jcp);
    131 
    132 	ctb = (struct ctb_tt *)(((char *)hwrpb) + hwrpb->rpb_ctb_off);
    133 
    134 	/*
    135 	 * The Jensen uses an older (pre-Type 4) CTB format.  The
    136 	 * console type is specified directly by ctb_type, and only
    137 	 * minimal info is given, only for the serial console.
    138 	 *
    139 	 * Thankfully, the only graphics device we can have is
    140 	 * ISA/EISA, so it really doesn't matter too much.
    141 	 */
    142 
    143 	switch (ctb->ctb_type) {
    144 	case CTB_PRINTERPORT:
    145 		/* serial console... */
    146 		/* XXX */
    147 		{
    148 #if 0
    149 			printf("CTB CSR = 0x%08lx\n", ctb->ctb_csr);
    150 			printf("CTB BAUD = %lu\n", ctb->ctb_baud);
    151 #endif
    152 			/*
    153 			 * Delay to allow PROM putchars to complete.
    154 			 * FIFO depth * character time,
    155 			 * character time = (1000000 / (defaultrate / 10))
    156 			 */
    157 			DELAY(160000000 / ctb->ctb_baud);
    158 
    159 			if (comcnattach(&jcp->jc_internal_iot, 0x3f8,
    160 			    ctb->ctb_baud, COM_FREQ, COM_TYPE_NORMAL,
    161 			    (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8))
    162 				panic("can't init serial console");
    163 
    164 			break;
    165 		}
    166 
    167 	case CTB_GRAPHICS:
    168 #if NPCKBD > 0
    169 		/* display console... */
    170 		/* XXX */
    171 		(void) pckbc_cnattach(&jcp->jc_internal_iot, IO_KBD, KBCMDP,
    172 		    PCKBC_KBD_SLOT, 0);
    173 
    174 		isa_display_console(&jcp->jc_eisa_iot, &jcp->jc_eisa_memt);
    175 #else
    176 		panic("not configured to use display && keyboard console");
    177 #endif
    178 		break;
    179 
    180 
    181 	default:
    182 		goto badconsole;
    183 	}
    184 #ifdef KGDB
    185 	/* Attach the KGDB device. */
    186 	alpha_kgdb_init(kgdb_devlist, &jcp->jc_internal_iot);
    187 #endif /* KGDB */
    188 
    189 	return;
    190  badconsole:
    191 	printf("ctb->ctb_type = 0x%lx\n", ctb->ctb_type);
    192 	printf("ctb->ctb_csr = 0x%lx\n", ctb->ctb_csr);
    193 	printf("ctb->ctb_baud = %lu\n", ctb->ctb_baud);
    194 
    195 	panic("consinit: unknown console type %lu",
    196 	    ctb->ctb_type);
    197 }
    198 
    199 static void
    200 dec_2000_300_device_register(device_t dev, void *aux)
    201 {
    202 	static device_t eisadev, isadev, scsidev;
    203 	struct bootdev_data *b = bootdev_data;
    204 	device_t parent = device_parent(dev);
    205 
    206 	if (booted_device != NULL || b == NULL) {
    207 		return;
    208 	}
    209 
    210 	if (eisadev == NULL && device_is_a(dev, "eisa")) {
    211 		eisadev = dev;
    212 	}
    213 
    214 	if (isadev == NULL && device_is_a(dev, "isa")) {
    215 		isadev = dev;
    216 	}
    217 
    218 	if (bootdev_is_disk && scsidev == NULL) {
    219 		if (eisadev != NULL && parent == eisadev) {
    220 			struct eisa_attach_args *ea = aux;
    221 
    222 			if (b->slot == ea->ea_slot) {
    223 				scsidev = dev;
    224 #if 0
    225 				printf("\nscsidev = %s\n",
    226 				    device_xname(scsidev));
    227 #endif
    228 			}
    229 		}
    230 		return;
    231 	}
    232 
    233 	if (bootdev_is_disk &&
    234 	    (device_is_a(dev, "sd") ||
    235 	     device_is_a(dev, "st") ||
    236 	     device_is_a(dev, "cd"))) {
    237 		struct scsipibus_attach_args *sa = aux;
    238 
    239 		if (device_parent(parent) != scsidev)
    240 			return;
    241 
    242 		if (b->unit / 100 != sa->sa_periph->periph_target)
    243 			return;
    244 
    245 		/* XXX LUN! */
    246 
    247 		switch (b->boot_dev_type) {
    248 		case 0:
    249 			if (!device_is_a(dev, "sd") &&
    250 			    !device_is_a(dev, "cd"))
    251 				return;
    252 			break;
    253 		case 1:
    254 			if (!device_is_a(dev, "st"))
    255 				return;
    256 			break;
    257 		default:
    258 			return;
    259 		}
    260 
    261 		goto foundit;
    262 	}
    263 
    264 	if (bootdev_is_net) {
    265 		/*
    266 		 * XXX WHAT ABOUT ISA NETWORK CARDS?
    267 		 */
    268 		if (eisadev != NULL && parent == eisadev) {
    269 			struct eisa_attach_args *ea = aux;
    270 
    271 			if (b->slot == ea->ea_slot) {
    272 				goto foundit;
    273 			}
    274 		}
    275 	}
    276 
    277 	return;
    278 
    279  foundit:
    280 	booted_device = dev;
    281 #if 0
    282 	printf("\nbooted_device = %s\n", device_xname(booted_device));
    283 #endif
    284 }
    285