Annotation of sys/arch/alpha/alpha/dec_eb164.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: dec_eb164.c,v 1.14 2006/11/28 16:56:50 dlg Exp $ */
! 2: /* $NetBSD: dec_eb164.c,v 1.33 2000/05/22 20:13:32 thorpej Exp $ */
! 3:
! 4: /*
! 5: * Copyright (c) 1995, 1996, 1997 Carnegie-Mellon University.
! 6: * All rights reserved.
! 7: *
! 8: * Author: Chris G. Demetriou
! 9: *
! 10: * Permission to use, copy, modify and distribute this software and
! 11: * its documentation is hereby granted, provided that both the copyright
! 12: * notice and this permission notice appear in all copies of the
! 13: * software, derivative works or modified versions, and any portions
! 14: * thereof, and that both notices appear in supporting documentation.
! 15: *
! 16: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
! 17: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
! 18: * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
! 19: *
! 20: * Carnegie Mellon requests users of this software to return to
! 21: *
! 22: * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
! 23: * School of Computer Science
! 24: * Carnegie Mellon University
! 25: * Pittsburgh PA 15213-3890
! 26: *
! 27: * any improvements or extensions that they make and grant Carnegie the
! 28: * rights to redistribute these changes.
! 29: */
! 30: /*
! 31: * Additional Copyright (c) 1997 by Matthew Jacob for NASA/Ames Research Center
! 32: */
! 33:
! 34: #include <sys/param.h>
! 35: #include <sys/systm.h>
! 36: #include <sys/device.h>
! 37: #include <sys/termios.h>
! 38: #include <dev/cons.h>
! 39: #include <sys/conf.h>
! 40:
! 41: #include <machine/rpb.h>
! 42: #include <machine/autoconf.h>
! 43: #include <machine/cpuconf.h>
! 44: #include <machine/bus.h>
! 45:
! 46: #include <dev/ic/comreg.h>
! 47: #include <dev/ic/comvar.h>
! 48:
! 49: #include <dev/isa/isareg.h>
! 50: #include <dev/isa/isavar.h>
! 51: #include <dev/ic/i8042reg.h>
! 52: #include <dev/ic/pckbcvar.h>
! 53: #include <dev/pci/pcireg.h>
! 54: #include <dev/pci/pcivar.h>
! 55:
! 56: #include <alpha/pci/ciareg.h>
! 57: #include <alpha/pci/ciavar.h>
! 58:
! 59: #include <scsi/scsi_all.h>
! 60: #include <scsi/scsiconf.h>
! 61: #include <dev/ata/atavar.h>
! 62:
! 63: #include "pckbd.h"
! 64:
! 65: #ifndef CONSPEED
! 66: #define CONSPEED TTYDEF_SPEED
! 67: #endif
! 68: static int comcnrate = CONSPEED;
! 69:
! 70: #define DR_VERBOSE(f) while (0)
! 71:
! 72: void dec_eb164_init(void);
! 73: static void dec_eb164_cons_init(void);
! 74: static void dec_eb164_device_register(struct device *, void *);
! 75:
! 76: void
! 77: dec_eb164_init()
! 78: {
! 79:
! 80: platform.family = "EB164";
! 81:
! 82: if ((platform.model = alpha_dsr_sysname()) == NULL) {
! 83: /* XXX Don't know the system variations, yet. */
! 84: platform.model = alpha_unknown_sysname();
! 85: }
! 86:
! 87: platform.iobus = "cia";
! 88: platform.cons_init = dec_eb164_cons_init;
! 89: platform.device_register = dec_eb164_device_register;
! 90: }
! 91:
! 92: static void
! 93: dec_eb164_cons_init()
! 94: {
! 95: struct ctb *ctb;
! 96: struct cia_config *ccp;
! 97: extern struct cia_config cia_configuration;
! 98:
! 99: ccp = &cia_configuration;
! 100: cia_init(ccp, 0);
! 101:
! 102: ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off);
! 103:
! 104: switch (ctb->ctb_term_type) {
! 105: case CTB_PRINTERPORT:
! 106: /* serial console ... */
! 107: /* XXX */
! 108: {
! 109: /*
! 110: * Delay to allow PROM putchars to complete.
! 111: * FIFO depth * character time,
! 112: * character time = (1000000 / (defaultrate / 10))
! 113: */
! 114: DELAY(160000000 / comcnrate);
! 115:
! 116: if(comcnattach(&ccp->cc_iot, 0x3f8, comcnrate,
! 117: COM_FREQ,
! 118: (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8))
! 119: panic("can't init serial console");
! 120:
! 121: break;
! 122: }
! 123:
! 124: case CTB_GRAPHICS:
! 125: #if NPCKBD > 0
! 126: /* display console ... */
! 127: /* XXX */
! 128: (void) pckbc_cnattach(&ccp->cc_iot, IO_KBD, KBCMDP,
! 129: PCKBC_KBD_SLOT);
! 130:
! 131: /*
! 132: * On at least LX164, SRM reports an isa video board
! 133: * as a pci slot with 0xff as the bus and slot numbers.
! 134: * Since these values are not plausible from a pci point
! 135: * of view, it is safe to check for them.
! 136: */
! 137: if (CTB_TURBOSLOT_TYPE(ctb->ctb_turboslot) ==
! 138: CTB_TURBOSLOT_TYPE_ISA ||
! 139: (CTB_TURBOSLOT_BUS(ctb->ctb_turboslot) == 0xff &&
! 140: CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot) == 0xff))
! 141: isa_display_console(&ccp->cc_iot, &ccp->cc_memt);
! 142: else
! 143: pci_display_console(&ccp->cc_iot, &ccp->cc_memt,
! 144: &ccp->cc_pc, CTB_TURBOSLOT_BUS(ctb->ctb_turboslot),
! 145: CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot), 0);
! 146: #else
! 147: panic("not configured to use display && keyboard console");
! 148: #endif
! 149: break;
! 150:
! 151: default:
! 152: printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type);
! 153: printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot);
! 154:
! 155: panic("consinit: unknown console type %ld",
! 156: ctb->ctb_term_type);
! 157: }
! 158: }
! 159:
! 160: static void
! 161: dec_eb164_device_register(dev, aux)
! 162: struct device *dev;
! 163: void *aux;
! 164: {
! 165: static int found, initted, diskboot, netboot;
! 166: static struct device *pcidev, *ctrlrdev;
! 167: struct bootdev_data *b = bootdev_data;
! 168: struct device *parent = dev->dv_parent;
! 169: struct cfdata *cf = dev->dv_cfdata;
! 170: struct cfdriver *cd = cf->cf_driver;
! 171:
! 172: if (found)
! 173: return;
! 174:
! 175: if (!initted) {
! 176: diskboot = (strncasecmp(b->protocol, "SCSI", 4) == 0) ||
! 177: (strncasecmp(b->protocol, "IDE", 3) == 0);
! 178: netboot = (strncasecmp(b->protocol, "BOOTP", 5) == 0) ||
! 179: (strncasecmp(b->protocol, "MOP", 3) == 0);
! 180: DR_VERBOSE(printf("diskboot = %d, netboot = %d\n", diskboot,
! 181: netboot));
! 182: initted = 1;
! 183: }
! 184:
! 185: if (pcidev == NULL) {
! 186: if (strcmp(cd->cd_name, "pci"))
! 187: return;
! 188: else {
! 189: struct pcibus_attach_args *pba = aux;
! 190:
! 191: if ((b->slot / 1000) != pba->pba_bus)
! 192: return;
! 193:
! 194: pcidev = dev;
! 195: DR_VERBOSE(printf("\npcidev = %s\n", dev->dv_xname));
! 196: return;
! 197: }
! 198: }
! 199:
! 200: if (ctrlrdev == NULL) {
! 201: if (parent != pcidev)
! 202: return;
! 203: else {
! 204: struct pci_attach_args *pa = aux;
! 205: int slot;
! 206:
! 207: slot = pa->pa_bus * 1000 + pa->pa_function * 100 +
! 208: pa->pa_device;
! 209: if (b->slot != slot)
! 210: return;
! 211:
! 212: if (netboot) {
! 213: booted_device = dev;
! 214: DR_VERBOSE(printf("\nbooted_device = %s\n",
! 215: dev->dv_xname));
! 216: found = 1;
! 217: } else {
! 218: ctrlrdev = dev;
! 219: DR_VERBOSE(printf("\nctrlrdev = %s\n",
! 220: dev->dv_xname));
! 221: }
! 222: return;
! 223: }
! 224: }
! 225:
! 226: if (!diskboot)
! 227: return;
! 228:
! 229: if (!strcmp(cd->cd_name, "sd") || !strcmp(cd->cd_name, "st") ||
! 230: !strcmp(cd->cd_name, "cd")) {
! 231: struct scsi_attach_args *sa = aux;
! 232: struct scsi_link *periph = sa->sa_sc_link;
! 233: int unit;
! 234:
! 235: if (parent->dv_parent != ctrlrdev)
! 236: return;
! 237:
! 238: unit = periph->target * 100 + periph->lun;
! 239: if (b->unit != unit)
! 240: return;
! 241:
! 242: /* we've found it! */
! 243: booted_device = dev;
! 244: DR_VERBOSE(printf("\nbooted_device = %s\n", dev->dv_xname));
! 245: found = 1;
! 246: }
! 247:
! 248: /*
! 249: * Support to boot from IDE drives.
! 250: */
! 251: if (!strcmp(cd->cd_name, "wd")) {
! 252: struct ata_atapi_attach *aa_link = aux;
! 253:
! 254: if ((strncmp("pciide", parent->dv_xname, 6) != 0))
! 255: return;
! 256: if (parent != ctrlrdev)
! 257: return;
! 258:
! 259: DR_VERBOSE(printf("\nAtapi info: drive: %d, channel %d\n",
! 260: aa_link->aa_drv_data->drive, aa_link->aa_channel));
! 261: DR_VERBOSE(printf("Bootdev info: unit: %d, channel: %d\n",
! 262: b->unit, b->channel));
! 263: if (b->unit != aa_link->aa_drv_data->drive ||
! 264: b->channel != aa_link->aa_channel)
! 265: return;
! 266:
! 267: /* we've found it! */
! 268: booted_device = dev;
! 269: DR_VERBOSE(printf("booted_device = %s\n", dev->dv_xname));
! 270: found = 1;
! 271: }
! 272: }
CVSweb