Annotation of sys/arch/hp300/stand/common/dca.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: dca.c,v 1.6 2006/08/17 06:31:10 miod Exp $ */
! 2: /* $NetBSD: dca.c,v 1.10 1996/10/06 01:42:48 mycroft Exp $ */
! 3:
! 4: /*
! 5: * Copyright (c) 1988 University of Utah.
! 6: * Copyright (c) 1990, 1993
! 7: * The Regents of the University of California. All rights reserved.
! 8: *
! 9: * This code is derived from software contributed to Berkeley by
! 10: * the Systems Programming Group of the University of Utah Computer
! 11: * Science Department.
! 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. Neither the name of the University nor the names of its contributors
! 22: * may be used to endorse or promote products derived from this software
! 23: * without specific prior written permission.
! 24: *
! 25: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
! 26: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 27: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 28: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
! 29: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 30: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 31: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 32: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 33: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 34: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 35: * SUCH DAMAGE.
! 36: *
! 37: * @(#)dca.c 8.1 (Berkeley) 6/10/93
! 38: */
! 39:
! 40: #ifdef DCACONSOLE
! 41: #include <sys/param.h>
! 42:
! 43: #include <hp300/dev/dcareg.h>
! 44:
! 45: #include "samachdep.h"
! 46: #include "consdefs.h"
! 47:
! 48: struct dcadevice *dcacnaddr = 0;
! 49:
! 50: #define DCACONSCODE 9 /* XXX */
! 51:
! 52: void
! 53: dcaprobe(struct consdev *cp)
! 54: {
! 55: struct dcadevice *dca;
! 56:
! 57: dcacnaddr = (struct dcadevice *) sctoaddr(DCACONSCODE);
! 58: if (badaddr((char *)dcacnaddr))
! 59: return;
! 60:
! 61: dca = dcacnaddr;
! 62: switch (dca->dca_id) {
! 63: case DCAID0:
! 64: case DCAID1:
! 65: cp->cn_pri = CN_NORMAL;
! 66: break;
! 67: case DCAID0 | DCACON:
! 68: case DCAID1 | DCACON:
! 69: cp->cn_pri = CN_REMOTE;
! 70: break;
! 71: default:
! 72: break;
! 73: }
! 74: }
! 75:
! 76: void
! 77: dcainit(struct consdev *cp)
! 78: {
! 79: struct dcadevice *dca = dcacnaddr;
! 80:
! 81: dca->dca_reset = 0xFF;
! 82: DELAY(100);
! 83: dca->dca_ic = 0;
! 84: dca->dca_cfcr = CFCR_DLAB;
! 85: dca->dca_data = DCABRD(9600) & 0xFF;
! 86: dca->dca_ier = DCABRD(9600) >> 8;
! 87: dca->dca_cfcr = CFCR_8BITS;
! 88: dca->dca_fifo =
! 89: FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_1;
! 90: dca->dca_mcr = MCR_DTR | MCR_RTS;
! 91: }
! 92:
! 93: /* ARGSUSED */
! 94: int
! 95: dcagetchar(dev_t dev)
! 96: {
! 97: #ifndef SMALL
! 98: struct dcadevice *dca = dcacnaddr;
! 99: short stat;
! 100: int c;
! 101:
! 102: if (((stat = dca->dca_lsr) & LSR_RXRDY) == 0)
! 103: return(0);
! 104: c = dca->dca_data;
! 105: return(c);
! 106: #else
! 107: return(0);
! 108: #endif
! 109: }
! 110:
! 111: /* ARGSUSED */
! 112: void
! 113: dcaputchar(dev_t dev, int c)
! 114: {
! 115: struct dcadevice *dca = dcacnaddr;
! 116: int timo;
! 117: short stat;
! 118:
! 119: /* wait a reasonable time for the transmitter to come ready */
! 120: timo = 50000;
! 121: while (((stat = dca->dca_lsr) & LSR_TXRDY) == 0 && --timo)
! 122: ;
! 123: dca->dca_data = c;
! 124: /* wait for this transmission to complete */
! 125: timo = 1000000;
! 126: while (((stat = dca->dca_lsr) & LSR_TXRDY) == 0 && --timo)
! 127: ;
! 128: }
! 129: #endif
CVSweb