[BACK]Return to dec_kn20aa.c CVS log [TXT][DIR] Up to [local] / sys / arch / alpha / alpha

Annotation of sys/arch/alpha/alpha/dec_kn20aa.c, Revision 1.1

1.1     ! nbrk        1: /* $OpenBSD: dec_kn20aa.c,v 1.17 2006/11/28 16:56:50 dlg Exp $ */
        !             2: /* $NetBSD: dec_kn20aa.c,v 1.42 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:
        !            62: #include "pckbd.h"
        !            63:
        !            64: #ifndef CONSPEED
        !            65: #define CONSPEED TTYDEF_SPEED
        !            66: #endif
        !            67: static int comcnrate = CONSPEED;
        !            68:
        !            69: void dec_kn20aa_init(void);
        !            70: static void dec_kn20aa_cons_init(void);
        !            71: static void dec_kn20aa_device_register(struct device *, void *);
        !            72:
        !            73: const struct alpha_variation_table dec_kn20aa_variations[] = {
        !            74:        { 0, "AlphaStation 500 or 600 (KN20AA)" },
        !            75:        { 0, NULL },
        !            76: };
        !            77:
        !            78: void
        !            79: dec_kn20aa_init()
        !            80: {
        !            81:        u_int64_t variation;
        !            82:
        !            83:        platform.family = "AlphaStation 500 or 600 (KN20AA)";
        !            84:
        !            85:        if ((platform.model = alpha_dsr_sysname()) == NULL) {
        !            86:                variation = hwrpb->rpb_variation & SV_ST_MASK;
        !            87:                if ((platform.model = alpha_variation_name(variation,
        !            88:                    dec_kn20aa_variations)) == NULL)
        !            89:                        platform.model = alpha_unknown_sysname();
        !            90:        }
        !            91:
        !            92:        platform.iobus = "cia";
        !            93:        platform.cons_init = dec_kn20aa_cons_init;
        !            94:        platform.device_register = dec_kn20aa_device_register;
        !            95: }
        !            96:
        !            97: static void
        !            98: dec_kn20aa_cons_init()
        !            99: {
        !           100:        struct ctb *ctb;
        !           101:        struct cia_config *ccp;
        !           102:        extern struct cia_config cia_configuration;
        !           103:
        !           104:        ccp = &cia_configuration;
        !           105:        cia_init(ccp, 0);
        !           106:
        !           107:        ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off);
        !           108:
        !           109:        switch (ctb->ctb_term_type) {
        !           110:        case CTB_PRINTERPORT:
        !           111:                /* serial console ... */
        !           112:                /* XXX */
        !           113:                {
        !           114:                        /*
        !           115:                         * Delay to allow PROM putchars to complete.
        !           116:                         * FIFO depth * character time,
        !           117:                         * character time = (1000000 / (defaultrate / 10))
        !           118:                         */
        !           119:                        DELAY(160000000 / comcnrate);
        !           120:
        !           121:                        if(comcnattach(&ccp->cc_iot, 0x3f8, comcnrate,
        !           122:                            COM_FREQ,
        !           123:                            (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8))
        !           124:                                panic("can't init serial console");
        !           125:
        !           126:                        break;
        !           127:                }
        !           128:
        !           129:        case CTB_GRAPHICS:
        !           130: #if NPCKBD > 0
        !           131:                /* display console ... */
        !           132:                /* XXX */
        !           133:                (void) pckbc_cnattach(&ccp->cc_iot, IO_KBD, KBCMDP,
        !           134:                    PCKBC_KBD_SLOT);
        !           135:
        !           136:                if (CTB_TURBOSLOT_TYPE(ctb->ctb_turboslot) ==
        !           137:                    CTB_TURBOSLOT_TYPE_ISA)
        !           138:                        isa_display_console(&ccp->cc_iot, &ccp->cc_memt);
        !           139:                else
        !           140:                        pci_display_console(&ccp->cc_iot, &ccp->cc_memt,
        !           141:                            &ccp->cc_pc, CTB_TURBOSLOT_BUS(ctb->ctb_turboslot),
        !           142:                            CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot), 0);
        !           143: #else
        !           144:                panic("not configured to use display && keyboard console");
        !           145: #endif
        !           146:                break;
        !           147:
        !           148:        default:
        !           149:                printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type);
        !           150:                printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot);
        !           151:
        !           152:                panic("consinit: unknown console type %ld",
        !           153:                    ctb->ctb_term_type);
        !           154:        }
        !           155: }
        !           156:
        !           157: static void
        !           158: dec_kn20aa_device_register(dev, aux)
        !           159:        struct device *dev;
        !           160:        void *aux;
        !           161: {
        !           162:        static int found, initted, diskboot, netboot;
        !           163:        static struct device *pcidev, *ctrlrdev;
        !           164:        struct bootdev_data *b = bootdev_data;
        !           165:        struct device *parent = dev->dv_parent;
        !           166:        struct cfdata *cf = dev->dv_cfdata;
        !           167:        struct cfdriver *cd = cf->cf_driver;
        !           168:
        !           169:        if (found)
        !           170:                return;
        !           171:
        !           172:        if (!initted) {
        !           173:                diskboot = (strncasecmp(b->protocol, "SCSI", 4) == 0);
        !           174:                netboot = (strncasecmp(b->protocol, "BOOTP", 5) == 0) ||
        !           175:                    (strncasecmp(b->protocol, "MOP", 3) == 0);
        !           176: #if 0
        !           177:                printf("diskboot = %d, netboot = %d\n", diskboot, netboot);
        !           178: #endif
        !           179:                initted =1;
        !           180:        }
        !           181:
        !           182:        if (pcidev == NULL) {
        !           183:                if (strcmp(cd->cd_name, "pci"))
        !           184:                        return;
        !           185:                else {
        !           186:                        struct pcibus_attach_args *pba = aux;
        !           187:
        !           188:                        if ((b->slot / 1000) != pba->pba_bus)
        !           189:                                return;
        !           190:
        !           191:                        pcidev = dev;
        !           192: #if 0
        !           193:                        printf("\npcidev = %s\n", dev->dv_xname);
        !           194: #endif
        !           195:                        return;
        !           196:                }
        !           197:        }
        !           198:
        !           199:        if (ctrlrdev == NULL) {
        !           200:                if (parent != pcidev)
        !           201:                        return;
        !           202:                else {
        !           203:                        struct pci_attach_args *pa = aux;
        !           204:                        int slot;
        !           205:
        !           206:                        slot = pa->pa_bus * 1000 + pa->pa_function * 100 +
        !           207:                            pa->pa_device;
        !           208:                        if (b->slot != slot)
        !           209:                                return;
        !           210:
        !           211:                        if (netboot) {
        !           212:                                booted_device = dev;
        !           213: #if 0
        !           214:                                printf("\nbooted_device = %s\n", dev->dv_xname);
        !           215: #endif
        !           216:                                found = 1;
        !           217:                        } else {
        !           218:                                ctrlrdev = dev;
        !           219: #if 0
        !           220:                                printf("\nctrlrdev = %s\n", dev->dv_xname);
        !           221: #endif
        !           222:                        }
        !           223:                        return;
        !           224:                }
        !           225:        }
        !           226:
        !           227:        if (!diskboot)
        !           228:                return;
        !           229:
        !           230:        if (!strcmp(cd->cd_name, "sd") || !strcmp(cd->cd_name, "st") ||
        !           231:            !strcmp(cd->cd_name, "cd")) {
        !           232:                struct scsi_attach_args *sa = aux;
        !           233:                struct scsi_link *periph = sa->sa_sc_link;
        !           234:                int unit;
        !           235:
        !           236:                if (parent->dv_parent != ctrlrdev)
        !           237:                        return;
        !           238:
        !           239:                unit = periph->target * 100 + periph->lun;
        !           240:                if (b->unit != unit)
        !           241:                        return;
        !           242:
        !           243:                /* we've found it! */
        !           244:                booted_device = dev;
        !           245: #if 0
        !           246:                printf("\nbooted_device = %s\n", dev->dv_xname);
        !           247: #endif
        !           248:                found = 1;
        !           249:        }
        !           250: }

CVSweb