[BACK]Return to apci.c CVS log [TXT][DIR] Up to [local] / sys / arch / hp300 / stand / common

Annotation of sys/arch/hp300/stand/common/apci.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: apci.c,v 1.8 2006/08/17 06:31:10 miod Exp $   */
                      2: /*     $NetBSD: apci.c,v 1.2 1997/10/04 17:20:15 thorpej Exp $ */
                      3:
                      4: /*-
                      5:  * Copyright (c) 1997, 1999 The NetBSD Foundation, Inc.
                      6:  * All rights reserved.
                      7:  *
                      8:  * This code is derived from software contributed to The NetBSD Foundation
                      9:  * by Jason R. Thorpe.
                     10:  *
                     11:  * Redistribution and use in source and binary forms, with or without
                     12:  * modification, are permitted provided that the following conditions
                     13:  * are met:
                     14:  * 1. Redistributions of source code must retain the above copyright
                     15:  *    notice, this list of conditions and the following disclaimer.
                     16:  * 2. Redistributions in binary form must reproduce the above copyright
                     17:  *    notice, this list of conditions and the following disclaimer in the
                     18:  *    documentation and/or other materials provided with the distribution.
                     19:  * 3. All advertising materials mentioning features or use of this software
                     20:  *    must display the following acknowledgement:
                     21:  *     This product includes software developed by the NetBSD
                     22:  *     Foundation, Inc. and its contributors.
                     23:  * 4. Neither the name of The NetBSD Foundation nor the names of its
                     24:  *    contributors may be used to endorse or promote products derived
                     25:  *    from this software without specific prior written permission.
                     26:  *
                     27:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     28:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     29:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     30:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     31:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     32:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     33:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     34:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     35:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     36:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     37:  * POSSIBILITY OF SUCH DAMAGE.
                     38:  */
                     39:
                     40: /*
                     41:  * Copyright (c) 1988 University of Utah.
                     42:  * Copyright (c) 1990, 1993
                     43:  *     The Regents of the University of California.  All rights reserved.
                     44:  *
                     45:  * This code is derived from software contributed to Berkeley by
                     46:  * the Systems Programming Group of the University of Utah Computer
                     47:  * Science Department.
                     48:  *
                     49:  * Redistribution and use in source and binary forms, with or without
                     50:  * modification, are permitted provided that the following conditions
                     51:  * are met:
                     52:  * 1. Redistributions of source code must retain the above copyright
                     53:  *    notice, this list of conditions and the following disclaimer.
                     54:  * 2. Redistributions in binary form must reproduce the above copyright
                     55:  *    notice, this list of conditions and the following disclaimer in the
                     56:  *    documentation and/or other materials provided with the distribution.
                     57:  * 3. Neither the name of the University nor the names of its contributors
                     58:  *    may be used to endorse or promote products derived from this software
                     59:  *    without specific prior written permission.
                     60:  *
                     61:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     62:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     63:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     64:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     65:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     66:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     67:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     68:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     69:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     70:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     71:  * SUCH DAMAGE.
                     72:  *
                     73:  *     @(#)dca.c       8.1 (Berkeley) 6/10/93
                     74:  */
                     75:
                     76: #ifdef APCICONSOLE
                     77: #include <sys/param.h>
                     78:
                     79: #include <hp300/dev/frodoreg.h>                /* for APCI offsets */
                     80: #include <hp300/dev/apcireg.h>         /* for register map */
                     81: #include <hp300/dev/dcareg.h>          /* for register bits */
                     82:
                     83: #include "samachdep.h"
                     84: #include "consdefs.h"
                     85:
                     86: struct apciregs *apcicnaddr = 0;
                     87:
                     88: void
                     89: apciprobe(struct consdev *cp)
                     90: {
                     91:        volatile u_int8_t *frodoregs;
                     92:
                     93:        /*
                     94:         * Only a 425e can have an APCI console.  On all other 4xx models,
                     95:         * the "first" serial port is mapped to the DCA at select code 9.
                     96:         */
                     97:        if (machineid != HP_425 || mmuid != MMUID_425_E)
                     98:                return;
                     99:
                    100:        /*
                    101:         * Check the service switch. On the 425e, this is a physical
                    102:         * switch, unlike other frodo-based machines, so we can use it
                    103:         * as a serial vs internal video selector, since the PROM can not
                    104:         * be configured for serial console.
                    105:         */
                    106:        frodoregs = (volatile u_int8_t *)IIOV(FRODO_BASE);
                    107:        if (badaddr((caddr_t)frodoregs) == 0 &&
                    108:            (frodoregs[FRODO_IISR] & FRODO_IISR_SERVICE) == 0)
                    109:                cp->cn_pri = CN_REMOTE;
                    110:        else
                    111:                cp->cn_pri = CN_NORMAL;
                    112: }
                    113:
                    114: void
                    115: apciinit(struct consdev *cp)
                    116: {
                    117:        struct apciregs *apci = (struct apciregs *)apcicnaddr;
                    118:
                    119:        apci->ap_cfcr = CFCR_DLAB;
                    120:        apci->ap_data = APCIBRD(9600) & 0xff;
                    121:        apci->ap_ier  = (APCIBRD(9600) >> 8) & 0xff;
                    122:        apci->ap_cfcr = CFCR_8BITS;
                    123:        apci->ap_fifo =
                    124:            FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_1;
                    125:        apci->ap_mcr = MCR_DTR | MCR_RTS;
                    126: }
                    127:
                    128: /* ARGSUSED */
                    129: int
                    130: apcigetchar(dev_t dev)
                    131: {
                    132: #ifndef SMALL
                    133:        struct apciregs *apci = apcicnaddr;
                    134:        short stat;
                    135:        int c;
                    136:
                    137:        if (((stat = apci->ap_lsr) & LSR_RXRDY) == 0)
                    138:                return (0);
                    139:        c = apci->ap_data;
                    140:        return (c);
                    141: #else
                    142:        return (0);
                    143: #endif
                    144: }
                    145:
                    146: /* ARGSUSED */
                    147: void
                    148: apciputchar(dev_t dev, int c)
                    149: {
                    150:        struct apciregs *apci = apcicnaddr;
                    151:        int timo;
                    152:        short stat;
                    153:
                    154:        /* wait a reasonable time for the transmitter to come ready */
                    155:        timo = 50000;
                    156:        while (((stat = apci->ap_lsr) & LSR_TXRDY) == 0 && --timo)
                    157:                ;
                    158:        apci->ap_data = c;
                    159:        /* wait for this transmission to complete */
                    160:        timo = 1000000;
                    161:        while (((stat = apci->ap_lsr) & LSR_TXRDY) == 0 && --timo)
                    162:                ;
                    163: }
                    164: #endif

CVSweb