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

Annotation of sys/arch/alpha/alpha/dec_1000a.c, Revision 1.1.1.1

1.1       nbrk        1: /* $OpenBSD: dec_1000a.c,v 1.4 2006/11/28 16:56:50 dlg Exp $ */
                      2: /* $NetBSD: dec_1000a.c,v 1.14 2001/06/05 04:53:11 thorpej Exp $ */
                      3:
                      4: /*
                      5:  * Copyright (c) 1998 The NetBSD Foundation, Inc.
                      6:  * All rights reserved.
                      7:  *
                      8:  * This code is based on dec_kn20aa.c, written by Chris G. Demetriou at
                      9:  * Carnegie-Mellon University. Platform support for Noritake, Pintake, and
                     10:  * Corelle by Ross Harvey with copyright assignment by permission of Avalon
                     11:  * Computer Systems, Inc.
                     12:  *
                     13:  * Redistribution and use in source and binary forms, with or without
                     14:  * modification, are permitted provided that the following conditions
                     15:  * are met:
                     16:  * 1. Redistributions of source code must retain the above copyright
                     17:  *    notice, this list of conditions and the following disclaimer.
                     18:  * 2. Redistributions in binary form must reproduce the above copyright
                     19:  *    notice, this list of conditions and the following disclaimer in the
                     20:  *    documentation and/or other materials provided with the distribution.
                     21:  * 3. All advertising materials mentioning features or use of this software
                     22:  *    must display the following acknowledgement:
                     23:  *     This product includes software developed by the NetBSD
                     24:  *     Foundation, Inc. and its contributors.
                     25:  * 4. Neither the name of The NetBSD Foundation nor the names of its
                     26:  *    contributors may be used to endorse or promote products derived
                     27:  *    from this software without specific prior written permission.
                     28:  *
                     29:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     30:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     31:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     32:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     33:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     34:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     35:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     36:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     37:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     38:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     39:  * POSSIBILITY OF SUCH DAMAGE.
                     40:  */
                     41:
                     42: /*
                     43:  * Copyright (c) 1995, 1996, 1997 Carnegie-Mellon University.
                     44:  * All rights reserved.
                     45:  *
                     46:  * Author: Chris G. Demetriou
                     47:  *
                     48:  * Permission to use, copy, modify and distribute this software and
                     49:  * its documentation is hereby granted, provided that both the copyright
                     50:  * notice and this permission notice appear in all copies of the
                     51:  * software, derivative works or modified versions, and any portions
                     52:  * thereof, and that both notices appear in supporting documentation.
                     53:  *
                     54:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
                     55:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
                     56:  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
                     57:  *
                     58:  * Carnegie Mellon requests users of this software to return to
                     59:  *
                     60:  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
                     61:  *  School of Computer Science
                     62:  *  Carnegie Mellon University
                     63:  *  Pittsburgh PA 15213-3890
                     64:  *
                     65:  * any improvements or extensions that they make and grant Carnegie the
                     66:  * rights to redistribute these changes.
                     67:  */
                     68: /*
                     69:  * Additional Copyright (c) 1997 by Matthew Jacob for NASA/Ames Research Center
                     70:  */
                     71:
                     72: #include <sys/param.h>
                     73: #include <sys/systm.h>
                     74: #include <sys/device.h>
                     75: #include <sys/termios.h>
                     76: #include <dev/cons.h>
                     77:
                     78: #include <machine/rpb.h>
                     79: #include <machine/autoconf.h>
                     80: #include <machine/cpuconf.h>
                     81: #include <machine/conf.h>
                     82: #include <machine/bus.h>
                     83:
                     84: #include <dev/ic/comreg.h>
                     85: #include <dev/ic/comvar.h>
                     86:
                     87: #include <dev/isa/isareg.h>
                     88: #include <dev/isa/isavar.h>
                     89: #include <dev/ic/i8042reg.h>
                     90: #include <dev/ic/pckbcvar.h>
                     91: #include <dev/pci/pcireg.h>
                     92: #include <dev/pci/pcivar.h>
                     93:
                     94: #include <alpha/pci/apecsreg.h>
                     95: #include <alpha/pci/apecsvar.h>
                     96: #include <alpha/pci/ciareg.h>
                     97: #include <alpha/pci/ciavar.h>
                     98:
                     99: #include <scsi/scsi_all.h>
                    100: #include <scsi/scsiconf.h>
                    101:
                    102: #include "pckbd.h"
                    103:
                    104: #ifndef CONSPEED
                    105: #define CONSPEED TTYDEF_SPEED
                    106: #endif
                    107: static int comcnrate = CONSPEED;
                    108:
                    109: void _dec_1000a_init(void);
                    110: void dec_1000a_cons_init(void);
                    111: void dec_1000a_device_register(struct device *, void *);
                    112:
                    113: #ifdef KGDB
                    114: #include <machine/db_machdep.h>
                    115:
                    116: const char *kgdb_devlist[] = {
                    117:        "com",
                    118:        NULL,
                    119: };
                    120: #endif /* KGDB */
                    121:
                    122: const struct alpha_variation_table dec_1000_variations[] = {
                    123:        { 0, "AlphaServer 1000" },
                    124:        { 0, NULL },
                    125: };
                    126:
                    127: const struct alpha_variation_table dec_1000a_variations[] = {
                    128:        { 0, "AlphaServer 1000A" },
                    129:        { 0, NULL },
                    130: };
                    131:
                    132: void
                    133: _dec_1000a_init()
                    134: {
                    135:        u_int64_t variation;
                    136:
                    137:        platform.family = "AlphaServer 1000/1000A";
                    138:
                    139:        if ((platform.model = alpha_dsr_sysname()) == NULL) {
                    140:                variation = hwrpb->rpb_variation & SV_ST_MASK;
                    141:                if ((platform.model = alpha_variation_name(variation,
                    142:                    cputype == ST_DEC_1000 ? dec_1000_variations
                    143:                                           : dec_1000a_variations)) == NULL)
                    144:                        platform.model = alpha_unknown_sysname();
                    145:        }
                    146:
                    147:        switch(PCS_CPU_MAJORTYPE(LOCATE_PCS(hwrpb, 0))) {
                    148:            case PCS_PROC_EV4:
                    149:            case PCS_PROC_EV45:
                    150:                platform.iobus = "apecs";
                    151:                break;
                    152:            default:
                    153:                platform.iobus = "cia";
                    154:                break;
                    155:        }
                    156:        platform.cons_init = dec_1000a_cons_init;
                    157:        platform.device_register = dec_1000a_device_register;
                    158: }
                    159:
                    160: void
                    161: dec_1000a_cons_init()
                    162: {
                    163:        struct ctb *ctb;
                    164:        struct cia_config *ccp;
                    165:        struct apecs_config *acp;
                    166:        extern struct cia_config cia_configuration;
                    167:        extern struct apecs_config apecs_configuration;
                    168:        bus_space_tag_t iot, memt;
                    169:        struct alpha_pci_chipset *pcichipset;
                    170:
                    171:        if(strcmp(platform.iobus, "cia") == 0) {
                    172:                ccp = &cia_configuration;
                    173:                cia_init(ccp, 0);
                    174:                iot = &ccp->cc_iot;
                    175:                memt = &ccp->cc_memt;
                    176:                pcichipset = &ccp->cc_pc;
                    177:        } else {
                    178:                acp = &apecs_configuration;
                    179:                apecs_init(acp, 0);
                    180:                iot = &acp->ac_iot;
                    181:                memt = &acp->ac_memt;
                    182:                pcichipset = &acp->ac_pc;
                    183:        }
                    184:
                    185:        ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off);
                    186:
                    187:        switch (ctb->ctb_term_type) {
                    188:        case CTB_PRINTERPORT:
                    189:                /* serial console ... */
                    190:                /* XXX */
                    191:                {
                    192:                        /*
                    193:                         * Delay to allow PROM putchars to complete.
                    194:                         * FIFO depth * character time,
                    195:                         * character time = (1000000 / (defaultrate / 10))
                    196:                         */
                    197:                        DELAY(160000000 / comcnrate);
                    198:
                    199:                        if(comcnattach(iot, 0x3f8, comcnrate,
                    200:                            COM_FREQ,
                    201:                            (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8))
                    202:                                panic("can't init serial console");
                    203:
                    204:                        break;
                    205:                }
                    206:
                    207:        case CTB_GRAPHICS:
                    208: #if NPCKBD > 0
                    209:                /* display console ... */
                    210:                /* XXX */
                    211:                (void) pckbc_cnattach(iot, IO_KBD, KBCMDP, PCKBC_KBD_SLOT);
                    212:
                    213:                /*
                    214:                 * AlphaServer 1000s have a firmware bug whereby the
                    215:                 * built-in ISA VGA is reported incorrectly -- ctb_turboslot
                    216:                 * is mostly 0.
                    217:                 */
                    218:                switch (CTB_TURBOSLOT_TYPE(ctb->ctb_turboslot)) {
                    219:                case CTB_TURBOSLOT_TYPE_PCI:
                    220:                        pci_display_console(iot, memt, pcichipset,
                    221:                            CTB_TURBOSLOT_BUS(ctb->ctb_turboslot),
                    222:                            CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot), 0);
                    223:                        break;
                    224:
                    225:                default:
                    226:                        isa_display_console(iot, memt);
                    227:                        break;
                    228:                }
                    229: #else
                    230:                panic("not configured to use display && keyboard console");
                    231: #endif
                    232:                break;
                    233:
                    234:        default:
                    235:                printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type);
                    236:                printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot);
                    237:
                    238:                panic("consinit: unknown console type %ld",
                    239:                    ctb->ctb_term_type);
                    240:        }
                    241: #ifdef KGDB
                    242:        /* Attach the KGDB device. */
                    243:        alpha_kgdb_init(kgdb_devlist, iot);
                    244: #endif /* KGDB */
                    245: }
                    246:
                    247: void
                    248: dec_1000a_device_register(dev, aux)
                    249:        struct device *dev;
                    250:        void *aux;
                    251: {
                    252:        static int found, initted, diskboot, netboot;
                    253:        static struct device *pcidev, *ctrlrdev;
                    254:        struct bootdev_data *b = bootdev_data;
                    255:        struct device *parent = dev->dv_parent;
                    256:        struct cfdata *cf = dev->dv_cfdata;
                    257:        struct cfdriver *cd = cf->cf_driver;
                    258:
                    259:        if (found)
                    260:                return;
                    261:
                    262:        if (!initted) {
                    263:                diskboot = (strncasecmp(b->protocol, "SCSI", 4) == 0);
                    264:                netboot = (strncasecmp(b->protocol, "BOOTP", 5) == 0) ||
                    265:                    (strncasecmp(b->protocol, "MOP", 3) == 0);
                    266: #if 0
                    267:                printf("diskboot = %d, netboot = %d\n", diskboot, netboot);
                    268: #endif
                    269:                initted =1;
                    270:        }
                    271:
                    272:        if (pcidev == NULL) {
                    273:                if (strcmp(cd->cd_name, "pci"))
                    274:                        return;
                    275:                else {
                    276:                        struct pcibus_attach_args *pba = aux;
                    277:
                    278:                        if ((b->slot / 1000) != pba->pba_bus)
                    279:                                return;
                    280:
                    281:                        pcidev = dev;
                    282: #if 0
                    283:                        printf("\npcidev = %s\n", dev->dv_xname);
                    284: #endif
                    285:                        return;
                    286:                }
                    287:        }
                    288:
                    289:        if (ctrlrdev == NULL) {
                    290:                if (parent != pcidev)
                    291:                        return;
                    292:                else {
                    293:                        struct pci_attach_args *pa = aux;
                    294:                        int slot;
                    295:
                    296:                        slot = pa->pa_bus * 1000 + pa->pa_function * 100 +
                    297:                            pa->pa_device;
                    298:                        if (b->slot != slot)
                    299:                                return;
                    300:
                    301:                        if (netboot) {
                    302:                                booted_device = dev;
                    303: #if 0
                    304:                                printf("\nbooted_device = %s\n", dev->dv_xname);
                    305: #endif
                    306:                                found = 1;
                    307:                        } else {
                    308:                                ctrlrdev = dev;
                    309: #if 0
                    310:                                printf("\nctrlrdev = %s\n", dev->dv_xname);
                    311: #endif
                    312:                        }
                    313:                        return;
                    314:                }
                    315:        }
                    316:
                    317:        if (!diskboot)
                    318:                return;
                    319:
                    320:        if (!strcmp(cd->cd_name, "sd") || !strcmp(cd->cd_name, "st") ||
                    321:            !strcmp(cd->cd_name, "cd")) {
                    322:                struct scsi_attach_args *sa = aux;
                    323:                struct scsi_link *periph = sa->sa_sc_link;
                    324:                int unit;
                    325:
                    326:                if (parent->dv_parent != ctrlrdev)
                    327:                        return;
                    328:
                    329:                unit = periph->target * 100 + periph->lun;
                    330:                if (b->unit != unit)
                    331:                        return;
                    332:
                    333:                /* we've found it! */
                    334:                booted_device = dev;
                    335: #if 0
                    336:                printf("\nbooted_device = %s\n", dev->dv_xname);
                    337: #endif
                    338:                found = 1;
                    339:        }
                    340: }

CVSweb