?? dmb.c
字號:
#ifndef lintstatic char *sccsid = "@(#)dmb.c 4.5 ULTRIX 4/30/91";#endif lint/************************************************************************ * * * Copyright (c) 1986-1988 by * * Digital Equipment Corporation, Maynard, MA * * All rights reserved. * * * * This software is furnished under a license and may be used and * * copied only in accordance with the terms of such license and * * with the inclusion of the above copyright notice. This * * software or any other copies thereof may not be provided or * * otherwise made available to any other person. No title to and * * ownership of the software is hereby transferred. * * * * This software is derived from software received from the * * University of California, Berkeley, and from Bell * * Laboratories. Use, duplication, or disclosure is subject to * * restrictions under license agreements with University of * * California and with AT&T. * * * * The information in this software is subject to change without * * notice and should not be construed as a commitment by Digital * * Equipment Corporation. * * * * Digital assumes no responsibility for the use or reliability * * of its software on equipment which is not supplied by Digital. * * * ************************************************************************//* * dmb.c * * Modification history * * DMB32 terminal driver * * 25-Apr-91 - R. Craig Peterson * * Don't generate a formfeed when closing a dmb parallel port * unless the device is currently on-line and ready to print. * * Don't allow a minor number for dmb printer that is out of * the range of the number of dmb's on the system. * * 28-Jan-91 - Stuart Hollander * Replaced code with functionally equivalent code to avoid * bug in C optimizer. in dmbxint() * * 08-Aug-90 - Kuo-Hsiung Hsieh * * Added a missing case for a break condition. If neither * IGNBRK or BRKINT is set, and PARMRK is set, a break condition * is read as '\377', '\0' , '\0'. * * 31-Oct-89 - Randall Brown * * Added the support to allow the device to determine if baudrate is * supported before it is set in the tty data structures. * * 11-Oct-89 - Randall Brown * * Added support for MIPS based machines. Converted the DMA to be done * in physical mode. * * 15-Aug-89 - Randall Brown * * Changed all references of TCSADFLUSH to TCSAFLUSH * * 11-Aug-89 - dws * * Release dmb lock after trusted path processing in dmbrintr(). * * 21-Jul-89 - Randall Brown * * Moved default open and default close code to tty.c and call it * using tty_def_open() and tty_def_close(). In the close routine, * don't clear the baudrate so that subsequent opens will keep the * present attributes. This only applies to a Berkeley environment. * * 30-Jun-89 - Tim Burke * * Keep dmb lock held while examining dmb_tbuffct in dmbxint. This * is needed to keep the line number in acsr fixed to determine an * accurate transfer count. Also in dmbxint, don't mask off the error * bits in tbuf before examining them. * * 19-Jun-89 - Randall Brown * Change to dmblopen to not allow open of the printer on DHB. * * 15-Jun-89 - darrell * Removed cpup as function arg. * * 12-Jun-89 - dws * * Added trusted path support. * * 02-Sep-88 - Tim Burke * * Return EINVAL instead of ENOTTY for POSIX programs on invalid ioctls. * * 18-Aug-88 - Tim Burke * * If PARMRK is set and a BREAK occurs, return '\0377','\0','\0'. * * 5-Aug-88 - Tim Burke * * Return the 2 character sequence 0377, 0377 upon receipt of a valid * 0377 character only when PARMRK is set under the termio line disc. * * 07-Jul-88 - Tim Burke * Use address of post_wakeup when calling dmb_start_tty. * * 16-May-88 - Tim Burke * * Call param routine for setting of local mode word because it can * affect bit size and parity. * * 22-Mar-88 - Tim Burke * Added initial version of locking for SMP. Locks are used on the * individual tty line as well as one lock per dmb board. * * 09-Mar-88 - Tim Burke * Changed flow control mechanism to enable support for the DHB32. * Previously if a stop char was received the dmbstop routine would do * a dma abort, the start routine would resetup for the resumption. * Now in dmbstop, simply turn off transmit enable, and make note of the * fact in the state (TS_OABORT). Dmbstart now will turn on transmit * enable to resume a previously stopped transmission. * * 20-Feb-88 - Tim Burke * Changed most softCAR[unit&LINEMASK] references to use the CLOCAL * bit of the control flags to determine if the line is set to be a * modem line or a direct connect. The setting of softCAR[] remains * to allow one to set default settings for device open. * * Provide Support for the DHB32. This device is a 16 line terminal * multiplexer. It does not have a printer port or sync port. Modem * control is not provided on all lines, only the first two lines if * configured for modem control. * * 3-Feb-88 - Tim Burke * Only examine O_NONBLOCK for POSIX mode. * A valid character of 0377 is returned as 0377,0377 in TERMIODISC only. * * 1-Dec-87 - Tim Burke * * Added support for both System V termio(7) and POSIX termios(7). These * changes also include support for 8-bit canonical processing. Changes * involve: * * - Default settings on first open depend on mode of open. For termio * opens the defaults are "RAW" style, while non-termio opens default * to the traditional "cooked" style. * - The driver now represents its terminal attributes and special * characters in the POSIX termios data structure. This contrasts the * original approach of storing attributes and special chars in the * t_flags, ltchars and tchars. * - New termio ioctls: TCSANOW, TCSADRAIN, TCSADFLUSH, TCSETA, TESETAW, * TCSETAF. * - Addition of LPASS8 to local mode word for 8-bit canonical support. * * 8-Sep-87 - Ricky Palmer (rsp) * * Defined LINEMASK for this driver and replaced references where * appropriate. Also fixed DEVIOCGET code to use LINEMASK. * * 2-Sept-87 - Tim Burke * * Added support for hardware auto flow control on the outgoing side. This * will provide quick response to start/stop characters which will reduce * buffer overflow on the receiving device. * * 1-Sept-87 - Tim Burke * * Put a timer in dmbstart to prevent possible system hang if the DMA * start bit doesn't clear due to hardware failure. * 19-Mar-87 - Tim Burke * * Added full TERMIO functionality to terminal subsystem. * * * 28-Jan-87 - Tim Burke * * Added the capability to ignore the "DSR" modem signal. This is being * done to allow modems that do not follow DEC Standard 52 to still * function as they would have prior to the addition of DECSTD52 code * into the drivers. If the driver is setup to ignore "DSR" then it will * not be following DECSTD52. To follow DECSTD52 set dmbdsr to "1", to * ignore "DSR" set dmbdsr to be "0"; * * Removed unnecessary return values from dmblint, dmb_dsr_check, * dmb_cd_drop, dmb_tty_drop. A few other lint cleanups with Jim * Woodward. * * 9-Jan-87 - Tim Burke * * Bug fix to TIOCMODEM to clear modem flags if signals are not up. * * 15-Dec-86 - Tim Burke * * When a break occurs, (interpreted as a framing error) set the variable * c to be the interrupt character. There was a problem here due to the * fact that sign extension is done which causes unwanted side affects. To * solve this bug, the character is stripped to 8 bits. * * Fix DEVIOGET to return propper modem status information. * * 4-Dec-86 - Tim Burke * * Bug fix to modem control. In dmb_tty_drop routine, clear the stopped * state to prevent modem lines from hanging on close. * * 26-Sep-86 - afd (Al Delorey) * * Enable external vector in the User Interface Interrupt Control * Register (a BIIC reg). Original DMB32 always had this bit set, but * that violated BI standard. So driver does it in dmbinit() & dmbreset(). * * 26-Aug-86 - rsp (Ricky Palmer) * * Cleaned up devioctl code to (1) zero out devget structure * upon entry and (2) use strlen instead of fixed storage * for bcopy's. * * 25-Aug-86 - Tim Burke * * Insure that a modem will drop and restart line on a flase call. Also * set state to ~TS_CARR_ON on line drop to terminate associated processes. * * 05-Aug-86 - Tim Burke * * In dmbrint, record the present timestamp in the event of a * carrier drop. * * 11-Jul-86 - ricky palmer * * Added adpt and nexus fields to DEVIOCGET code. * * 29-May-86 - afd & tim burke * Enable DTR & RTS in open routine for both hardwired and modem lines. * This was being done only for modem lines. * * 26-Apr-86 - ricky palmer * Added new DEVIOCGET ioctl request code. V2.0 * * 4-Apr-86 - afd * Call "bidev_vec()" form dmbinit() to set up interrupt vector handlers. * */#include "dmb.h"#if NDMB > 0 || defined (BINARY)#include "../data/dmb_data.c"/* * The line printer on dmbx is indicated by a minor device code of 128+x * The flags field of the config file is interpreted as follows: * * bits meaning * ---- ------- * 0-7 soft carrier bits for the 8 async tty lines on DMB32 * 0-15 soft carrier bits for the 16 async tty lines on DHB32 * 8-15 number of cols/line on the line printer (if 0, 132 will be used) * 16-23 number of lines/page on the line printer (if 0, 66 will be used) * */#ifdef DEBUGint dmbdebug = 0;#define printd if (dmbdebug) mprintf#define printd10 if (dmbdebug >= 10) mprintf#endifextern struct bidata bidata[];/* * Definition of the driver for the auto-configuration program. */int dmbinit(), dmbattach(), dmbaint(), dmbsint(), dmblint(), dmbbaudrate();struct uba_device *dmbinfo[NDMB];u_short dmbstd[] = { 0 };struct uba_driver dmbdriver = { dmbinit, 0, dmbattach, 0, dmbstd, "dmb", dmbinfo };/* function type definitions */int dmbstart(), ttrstrt();int wakeup();/* For for DEC std 52, modem control */int dmb_cd_drop(), dmb_dsr_check_timeout(), dmb_cd_down(), dmb_tty_drop();struct timeval dmbzerotime = {0,0};int dmbcdtime = 2;#ifndef MODEM_CD#define MODEM_CD 0x01#define MODEM_DSR 0x02#define MODEM_CTS 0x04#define MODEM_DSR_START 0x08#endif#define LINEMASK 0xF /* line number mask */#define LINEBITS 0x4 /* 4 bits are needed to represent line number *//* * Local variables for the driver */int dmb_timeout = 10; /* receive fifo timeout, in ms */char dmb_speeds[] = { 0, 0, 01, 02, 03, 04, 0, 05, 06, 07, 010, 012, 013, 015, 016, 017 }; /* 50 75 110 134 150 300 600 1200 1800 2400 4800 9600 19.2 38.4 */short dmb_valid_speeds = 0xffbf; /* 1,1,1,1, 1,1,1,1, 1,0,1,1, 1,1,1,1 */#define ASLP 1 /* waiting for interrupt from dmb for printer port */#define OPEN 2 /* line printer is open */#define ERROR 4 /* error while printing, driver refuses to do anything till closed *//* * Macros used for smp locking. *//* * Macro: DMB_TTY_LOCK(tp,saveipl) * * Description: * Raise ipl to level 15 and save off old * value in "saveipl". * Lock the tty structure pointed * to by "tp". */#define DMB_TTY_LOCK(tp,saveipl) { \ saveipl = spltty();\ smp_lock(&tp->t_lk_tty, LK_RETRY);\ }/* * Macro: DMB_TTY_UNLOCK * * Description: * Unlock tty structure pointed to by * "tp". Restore IPL to "saveipl". */#define DMB_TTY_UNLOCK(tp,saveipl) {\ smp_unlock(&tp->t_lk_tty);\ splx(saveipl);\ }/* * Macro: DMB_LOCK * * Description: * Lock dmb device. */#define DMB_LOCK(dmb) \ smp_lock(&lk_dmb[dmb],LK_RETRY);/* * Macro: DMB_UNLOCK * * Description: * Unlock dmb device. */#define DMB_UNLOCK(dmb) \ smp_unlock(&lk_dmb[dmb]);/* * Define which address to do a wakeup on. These are used to insure that * wakeups are not called while locks are held. */#define WAKEUP_RAWQ 0x1 /* wakeup on raw queue */#define WAKEUP_DEV 0x2 /* wakeup on device address */#define WAKEUP_OUTQ 0x4 /* wakeup on output queue */#define WAKEUP_STATE 0x8 /* wakeup on line printer state */#define WAKEUP_BUF 0x10 /* wakeup on line printer buffer */#define WAKEUP_SELECT 0x20 /* select wakeup */ /* * Routine for configuration to see if the DMB32 is functional *//*ARGSUSED*/dmbinit(nxv,nxp,binumber,binode,ui) caddr_t nxv; /* virt addr of device */ caddr_t nxp; /* phys addr of device */ int binumber; /* this bi number on the system */ int binode; /* the node number on this bi */ struct uba_device *ui;{ register struct dmb_device *addr; addr = (struct dmb_device *)nxv;# ifdef DEBUG printd("dmbinit: addr = 0x%x, devtype = 0x%x, revcode = 0x%x, nodeid = %d\n", addr, addr->dmb_biic.biic_typ & 0xFFFF, (addr->dmb_biic.biic_typ >> 16) & 0xFFFF, addr->dmb_biic.biic_ctrl & 0xF);# endif /* * Determine the number of asynchronous lines on the device: * DMB has 8 lines * DHB has 16 lines */ dmb_lines[ui->ui_unit] = addr->dmb_config & DMB_ASYNC_MASK; /* * Check for device malfunction. Distribution cable is connected. */ if ((addr->dmb_mainthigh & DMB_ALP) == 0) { printf("dmbinit: async lines unavailable\n"); return(0); } /* * Only the DMB has a printer port. (The DHB doesn't) */ if ((dmb_lines[ui->ui_unit]==DMB_8_LINES) && ((addr->dmb_mainthigh & DMB_PP) == 0)) { printf("dmbinit: printer port unavailable\n"); return(0); } /* * Check results of powerup self tests (if they've completed). */ if ((addr->dmb_maintlow & DMB_RESET) == 0) { if (addr->dmb_mainthigh & DMB_DFAIL) printf("dmbinit: warning, self test diagnostic failure\n");# ifdef DEBUG /* * See if the 6 ribbon cables are correctly connected to pannel. * This was being printed on functional systems (DMB) ?? */ if (((addr->dmb_mainthigh & DMB_CABLE) == 0) && dmbdebug) printf("dmbinit: CABLE error, check ribbon cables, reg=%x\n", addr->dmb_mainthigh);# endif } /* * Enable external vector */ addr->dmb_biic.biic_int_ctrl |= BIIC_EXVEC; /* * Set up interrupt vectors for DMB32. It has 4. * BIIC (14), sync (15), async (16), & printer (17). * There are 4 interrupt vectors for a dmb. They are LEVEL14,15,16,17. * These levels do not correspond to ipl levels, for example LEVEL15 on * the async lines cause interrupts at ipl14. */ bidev_vec(binumber,binode,LEVEL15,ui); return(1);}dmbattach(ui) struct uba_device *ui;{ register int cols; register int lines, i; register struct dmb_device *addr; register struct tty *tp; addr = (struct dmb_device *)ui->ui_addr;# ifdef DEBUG
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -