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

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

1.1     ! nbrk        1: /* $OpenBSD: dec_kn300.c,v 1.2 2007/03/21 22:10:57 martin Exp $ */
        !             2: /* $NetBSD: dec_kn300.c,v 1.34 2007/03/04 15:18:10 yamt Exp $ */
        !             3:
        !             4: /*
        !             5:  * Copyright (c) 1998 by Matthew Jacob
        !             6:  * NASA AMES Research Center.
        !             7:  * All rights reserved.
        !             8:  *
        !             9:  * Redistribution and use in source and binary forms, with or without
        !            10:  * modification, are permitted provided that the following conditions
        !            11:  * are met:
        !            12:  * 1. Redistributions of source code must retain the above copyright
        !            13:  *    notice immediately at the beginning of the file, without modification,
        !            14:  *    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:  * 3. The name of the author may not be used to endorse or promote products
        !            19:  *    derived from this software without specific prior written permission.
        !            20:  *
        !            21:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
        !            22:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            23:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            24:  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
        !            25:  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            26:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            27:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            28:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            29:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            30:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            31:  * SUCH DAMAGE.
        !            32:  */
        !            33:
        !            34: #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
        !            35: #include <sys/param.h>
        !            36: #include <sys/systm.h>
        !            37: #include <sys/device.h>
        !            38: #include <sys/termios.h>
        !            39: #include <sys/conf.h>
        !            40: #include <dev/cons.h>
        !            41:
        !            42: #include <machine/rpb.h>
        !            43: #include <machine/autoconf.h>
        !            44: #include <machine/frame.h>
        !            45: #include <machine/cpuconf.h>
        !            46:
        !            47: #include <dev/ic/comreg.h>
        !            48: #include <dev/ic/comvar.h>
        !            49:
        !            50: #include <dev/isa/isareg.h>
        !            51: #include <dev/isa/isavar.h>
        !            52: #include <dev/ic/i8042reg.h>
        !            53: #include <dev/ic/pckbcvar.h>
        !            54: #include <dev/pci/pcireg.h>
        !            55: #include <dev/pci/pcivar.h>
        !            56:
        !            57: #include <alpha/mcbus/mcbusreg.h>
        !            58: #include <alpha/mcbus/mcbusvar.h>
        !            59: #include <alpha/pci/mcpciareg.h>
        !            60: #include <alpha/pci/mcpciavar.h>
        !            61: #include <alpha/pci/pci_kn300.h>
        !            62:
        !            63: #include <scsi/scsi_all.h>
        !            64: #include <scsi/scsiconf.h>
        !            65:
        !            66: #include "pckbd.h"
        !            67:
        !            68: #ifndef        CONSPEED
        !            69: #define        CONSPEED        TTYDEF_SPEED
        !            70: #endif
        !            71: static int comcnrate = CONSPEED;
        !            72:
        !            73: #ifdef DEBUG
        !            74: int bootdev_debug;
        !            75: #define DPRINTF(x)     if (bootdev_debug) printf x
        !            76: #else
        !            77: #define DPRINTF(x)
        !            78: #endif
        !            79:
        !            80: void dec_kn300_init (void);
        !            81: void dec_kn300_cons_init (void);
        !            82: static void dec_kn300_device_register (struct device *, void *);
        !            83:
        !            84: #ifdef KGDB
        !            85: #include <machine/db_machdep.h>
        !            86:
        !            87: static const char *kgdb_devlist[] = {
        !            88:        "com",
        !            89:        NULL,
        !            90: };
        !            91: #endif /* KGDB */
        !            92:
        !            93: #define        ALPHASERVER_4100        "AlphaServer 4100"
        !            94:
        !            95: const struct alpha_variation_table dec_kn300_variations[] = {
        !            96:        { 0, ALPHASERVER_4100 },
        !            97:        { 0, NULL },
        !            98: };
        !            99:
        !           100: void
        !           101: dec_kn300_init()
        !           102: {
        !           103:        u_int64_t variation;
        !           104:        int cachesize;
        !           105:
        !           106:        platform.family = ALPHASERVER_4100;
        !           107:
        !           108:        if ((platform.model = alpha_dsr_sysname()) == NULL) {
        !           109:                variation = hwrpb->rpb_variation & SV_ST_MASK;
        !           110:                if ((platform.model = alpha_variation_name(variation,
        !           111:                    dec_kn300_variations)) == NULL)
        !           112:                        platform.model = alpha_unknown_sysname();
        !           113:        }
        !           114:
        !           115:        platform.iobus = "mcbus";
        !           116:        platform.cons_init = dec_kn300_cons_init;
        !           117:        platform.device_register = dec_kn300_device_register;
        !           118:
        !           119:        /*
        !           120:         * Determine B-cache size by looking at the primary (console)
        !           121:         * MCPCIA's WHOAMI register.
        !           122:         */
        !           123:        mcpcia_init();
        !           124:
        !           125:        if (mcbus_primary.mcbus_valid) {
        !           126:                switch (mcbus_primary.mcbus_bcache) {
        !           127:                default:
        !           128:                case CPU_BCache_0MB:
        !           129:                        /* No B-cache or invalid; default to 1MB. */
        !           130:                        /* FALLTHROUGH */
        !           131:
        !           132:                case CPU_BCache_1MB:
        !           133:                        cachesize = (1 * 1024 * 1024);
        !           134:                        break;
        !           135:
        !           136:                case CPU_BCache_2MB:
        !           137:                        cachesize = (2 * 1024 * 1024);
        !           138:                        break;
        !           139:
        !           140:                case CPU_BCache_4MB:
        !           141:                        cachesize = (4 * 1024 * 1024);
        !           142:                        break;
        !           143:                }
        !           144:        } else {
        !           145:                /* Default to 1MB. */
        !           146:                cachesize = (1 * 1024 * 1024);
        !           147:        }
        !           148: }
        !           149:
        !           150: void
        !           151: dec_kn300_cons_init()
        !           152: {
        !           153:        struct ctb *ctb;
        !           154:        struct mcpcia_config *ccp;
        !           155:        extern struct mcpcia_config mcpcia_console_configuration;
        !           156:
        !           157:        ccp = &mcpcia_console_configuration;
        !           158:        /* It's already initialized. */
        !           159:
        !           160:        ctb = (struct ctb *)(((char *)hwrpb) + hwrpb->rpb_ctb_off);
        !           161:
        !           162:        switch (ctb->ctb_term_type) {
        !           163:        case CTB_PRINTERPORT:
        !           164:                /* serial console ... */
        !           165:                /*
        !           166:                 * Delay to allow PROM putchars to complete.
        !           167:                 * FIFO depth * character time,
        !           168:                 * character time = (1000000 / (defaultrate / 10))
        !           169:                 */
        !           170:                DELAY(160000000 / comcnrate);
        !           171:                if (comcnattach(&ccp->cc_iot, 0x3f8, comcnrate,
        !           172:                    COM_FREQ,
        !           173:                    (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8)) {
        !           174:                        panic("can't init serial console");
        !           175:
        !           176:                }
        !           177:                break;
        !           178:
        !           179:        case CTB_GRAPHICS:
        !           180: #if NPCKBD > 0
        !           181:                /* display console ... */
        !           182:                /* XXX */
        !           183:                (void) pckbc_cnattach(&ccp->cc_iot, IO_KBD, KBCMDP,
        !           184:                    PCKBC_KBD_SLOT);
        !           185:
        !           186:                if (CTB_TURBOSLOT_TYPE(ctb->ctb_turboslot) ==
        !           187:                    CTB_TURBOSLOT_TYPE_ISA)
        !           188:                        isa_display_console(&ccp->cc_iot, &ccp->cc_memt);
        !           189:                else
        !           190:                        pci_display_console(&ccp->cc_iot, &ccp->cc_memt,
        !           191:                            &ccp->cc_pc, CTB_TURBOSLOT_BUS(ctb->ctb_turboslot),
        !           192:                            CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot), 0);
        !           193: #else
        !           194:                panic("not configured to use display && keyboard console");
        !           195: #endif
        !           196:                break;
        !           197:
        !           198:        default:
        !           199:                printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type);
        !           200:                printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot);
        !           201:
        !           202:                panic("consinit: unknown console type %ld",
        !           203:                    ctb->ctb_term_type);
        !           204:        }
        !           205: #ifdef KGDB
        !           206:        /* Attach the KGDB device. */
        !           207:        alpha_kgdb_init(kgdb_devlist, &ccp->cc_iot);
        !           208: #endif /* KGDB */
        !           209: }
        !           210:
        !           211: static void
        !           212: dec_kn300_device_register(dev, aux)
        !           213:        struct device *dev;
        !           214:        void *aux;
        !           215: {
        !           216:        static int found, initted, diskboot, netboot;
        !           217:        static struct device *primarydev, *pcidev, *ctrlrdev;
        !           218:        struct bootdev_data *b = bootdev_data;
        !           219:        struct device *parent = dev->dv_parent;
        !           220:        struct cfdata *cf = dev->dv_cfdata;
        !           221:        struct cfdriver *cd = cf->cf_driver;
        !           222:
        !           223:        if (found)
        !           224:                return;
        !           225:
        !           226:        if (!initted) {
        !           227:                diskboot = (strncasecmp(b->protocol, "SCSI", 4) == 0);
        !           228:                netboot = (strncasecmp(b->protocol, "BOOTP", 5) == 0) ||
        !           229:                    (strncasecmp(b->protocol, "MOP", 3) == 0);
        !           230:
        !           231:                DPRINTF(("proto:%s bus:%d slot:%d chan:%d", b->protocol,
        !           232:                    b->bus, b->slot, b->channel));
        !           233:                if (b->remote_address)
        !           234:                        printf(" remote_addr:%s", b->remote_address);
        !           235:                DPRINTF((" un:%d bdt:%d", b->unit, b->boot_dev_type));
        !           236:                if (b->ctrl_dev_type)
        !           237:                        DPRINTF((" cdt:%s\n", b->ctrl_dev_type));
        !           238:                else
        !           239:                        DPRINTF(("\n"));
        !           240:                DPRINTF(("diskboot = %d, netboot = %d\n", diskboot, netboot));
        !           241:                initted = 1;
        !           242:        }
        !           243:
        !           244:        if (primarydev == NULL) {
        !           245:                if (strcmp(cd->cd_name, "mcpcia"))
        !           246:                        return;
        !           247:                else {
        !           248:                        struct mcbus_dev_attach_args *ma = aux;
        !           249:
        !           250:                        if (b->bus != ma->ma_mid - 4)
        !           251:                                return;
        !           252:                        primarydev = dev;
        !           253:                        DPRINTF(("\nprimarydev = %s\n", dev->dv_xname));
        !           254:                        return;
        !           255:                }
        !           256:        }
        !           257:
        !           258:        if (pcidev == NULL) {
        !           259:                if (strcmp(cd->cd_name, "pci"))
        !           260:                        return;
        !           261:                /*
        !           262:                 * Try to find primarydev anywhere in the ancestry.  This is
        !           263:                 * necessary if the PCI bus is hidden behind a bridge.
        !           264:                 */
        !           265:                else {
        !           266:                        struct pcibus_attach_args *pba = aux;
        !           267:
        !           268:                        if ((b->slot / 1000) != pba->pba_bus)
        !           269:                                return;
        !           270:
        !           271:                        pcidev = dev;
        !           272:                        DPRINTF(("\npcidev = %s\n", dev->dv_xname));
        !           273:                        return;
        !           274:                }
        !           275:        }
        !           276:
        !           277:        if (ctrlrdev == NULL) {
        !           278:                if (parent != pcidev)
        !           279:                        return;
        !           280:                else {
        !           281:                        struct pci_attach_args *pa = aux;
        !           282:                        int slot;
        !           283:
        !           284:                        slot = pa->pa_bus * 1000 + pa->pa_function * 100 +
        !           285:                            pa->pa_device;
        !           286:                        if (b->slot != slot)
        !           287:                                return;
        !           288:
        !           289:                        if (netboot) {
        !           290:                                booted_device = dev;
        !           291:                                DPRINTF(("\nbooted_device = %s\n", dev->dv_xname));
        !           292:                                found = 1;
        !           293:                        } else {
        !           294:                                ctrlrdev = dev;
        !           295:                                DPRINTF(("\nctrlrdev = %s\n", dev->dv_xname));
        !           296:                        }
        !           297:                        return;
        !           298:                }
        !           299:        }
        !           300:
        !           301:        if (!diskboot)
        !           302:                return;
        !           303:
        !           304:        if (strcmp(cd->cd_name, "sd") ||
        !           305:            strcmp(cd->cd_name, "st") ||
        !           306:            strcmp(cd->cd_name, "cd")) {
        !           307:                struct scsi_attach_args *sa = aux;
        !           308:                struct scsi_link *periph = sa->sa_sc_link;
        !           309:                int unit;
        !           310:
        !           311:                if (parent->dv_parent != ctrlrdev)
        !           312:                        return;
        !           313:
        !           314:                unit = periph->target * 100 + periph->lun;
        !           315:                if (b->unit != unit)
        !           316:                        return;
        !           317:
        !           318:                /* we've found it! */
        !           319:                booted_device = dev;
        !           320:                DPRINTF(("\nbooted_device = %s\n", dev->dv_xname));
        !           321:                found = 1;
        !           322:        }
        !           323: }

CVSweb