/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/*
* Copyright 2012 Milan Jurik. All rights reserved.
*/
/*
* Serial I/O driver for 8250/16450/16550A/16650/16750 chips.
*/
#ifdef DEBUG
#endif
/*
* set the RX FIFO trigger_level to half the RX FIFO size for now
* we may want to make this configurable later.
*/
/*
* Just in case someone has a chip with broken loopback mode, we provide a
* means to disable the loopback test. By default, we only loopback test
* UARTs which look like they have FIFOs bigger than 16 bytes.
* Set to 0 to suppress test, or to 2 to enable test on any size FIFO.
*/
/*
* Allow ability to switch off testing of the scratch register.
* Some UART emulators might not have it. This will also disable the test
*/
/*
* As we don't yet support on-chip flow control, it's a bad idea to put a
* large number of characters in the TX FIFO, since if other end tells us
* to stop transmitting, we can only stop filling the TX FIFO, but it will
* still carry on draining by itself, so remote end still gets what's left
* in the FIFO.
*/
#define ASY_NOINIT 0
/* enum value for sw and hw flow control action */
typedef enum {
#ifdef DEBUG
static int debug = 0;
#else
#endif
/* pnpISA compressed device ids */
/*
* PPS (Pulse Per Second) support.
*/
void ddi_hardpps(struct timeval *, int);
/*
* This is protected by the asy_excl_hi of the port on which PPS event
* handling is enabled. Note that only one port should have this enabled at
* any one time. Enabling PPS handling on multiple ports will result in
* unpredictable (but benign) results.
*/
#ifdef PPSCLOCKLED
/* XXX Use these to observe PPS latencies and jitter on a scope */
#define LED_ON
#define LED_OFF
#else
#define LED_ON
#define LED_OFF
#endif
/* The async interrupt entry points */
static void async_reioctl(void *unit);
static void async_restart(void *arg);
static int asygetchar(cons_polledio_arg_t);
static int asytodm(int, int);
static int dmtoasy(int);
/*PRINTFLIKE2*/
static void asy_soft_state_free(struct asycom *);
static void async_hold_utbrk(void *arg);
const char *property);
void *asy_soft_state;
/* Standard COM port I/O addresses */
static const int standard_com_ports[] = {
};
static int *com_ports;
#ifdef DEBUG
/*
* Set this to true to make the driver pretend to do a suspend. Useful
*/
#endif
/*
*/
0, /* 0 baud rate */
0x900, /* 50 baud rate */
0x600, /* 75 baud rate */
0x417, /* 110 baud rate (%0.026) */
0x359, /* 134 baud rate (%0.058) */
0x300, /* 150 baud rate */
0x240, /* 200 baud rate */
0x180, /* 300 baud rate */
0x0c0, /* 600 baud rate */
0x060, /* 1200 baud rate */
0x040, /* 1800 baud rate */
0x030, /* 2400 baud rate */
0x018, /* 4800 baud rate */
0x00c, /* 9600 baud rate */
0x006, /* 19200 baud rate */
0x003, /* 38400 baud rate */
0x002, /* 57600 baud rate */
0x0, /* 76800 baud rate not supported */
0x001, /* 115200 baud rate */
0x0, /* 153600 baud rate not supported */
0x0, /* 0x8002 (SMC chip) 230400 baud rate not supported */
0x0, /* 307200 baud rate not supported */
0x0, /* 0x8001 (SMC chip) 460800 baud rate not supported */
0x0, /* unused */
0x0, /* unused */
0x0, /* unused */
0x0, /* unused */
0x0, /* unused */
0x0, /* unused */
0x0, /* unused */
0x0, /* unused */
0x0, /* unused */
};
0,
"asy",
0,
4096,
128
};
putq,
NULL,
&asy_info,
};
NULL,
NULL,
NULL,
NULL,
&asy_info,
};
&asy_rint,
&asy_wint,
NULL,
};
void **result);
static int asyprobe(dev_info_t *);
static int asyquiesce(dev_info_t *);
nodev, /* cb_open */
nodev, /* cb_close */
nodev, /* cb_strategy */
nodev, /* cb_print */
nodev, /* cb_dump */
nodev, /* cb_read */
nodev, /* cb_write */
nodev, /* cb_ioctl */
nodev, /* cb_devmap */
nodev, /* cb_mmap */
nodev, /* cb_segmap */
nochpoll, /* cb_chpoll */
ddi_prop_op, /* cb_prop_op */
&asy_str_info, /* cb_stream */
D_MP /* cb_flag */
};
DEVO_REV, /* devo_rev */
0, /* devo_refcnt */
asyinfo, /* devo_getinfo */
nulldev, /* devo_identify */
asyprobe, /* devo_probe */
asyattach, /* devo_attach */
asydetach, /* devo_detach */
nodev, /* devo_reset */
&cb_asy_ops, /* devo_cb_ops */
NULL, /* devo_bus_ops */
NULL, /* power */
asyquiesce, /* quiesce */
};
&mod_driverops, /* Type of module. This one is a driver */
"ASY driver",
&asy_ops, /* driver ops */
};
(void *)&modldrv,
};
int
_init(void)
{
int i;
if (i == 0) {
if ((i = mod_install(&modlinkage)) != 0) {
} else {
}
}
return (i);
}
int
_fini(void)
{
int i;
if ((i = mod_remove(&modlinkage)) == 0) {
/* free "motherboard-serial-ports" property if allocated */
}
return (i);
}
int
{
}
void
{
else
}
static mblk_t *
{
} else {
}
return (mp);
}
static void
{
queue_t *q;
}
}
static int
{
int parentlen;
parentlen = sizeof (parent_type);
&parentlen) != DDI_PROP_SUCCESS) {
"asy: can't figure out device type for"
" parent \"%s\"",
return (ASY_BUS_UNKNOWN);
}
return (ASY_BUS_ISA);
return (ASY_BUS_PCI);
else
return (ASY_BUS_UNKNOWN);
}
static int
{
int regnum, i;
" not found in devices property list");
return (-1);
}
/*
* PCI devices are assumed to not have broken FIFOs;
*/
if (asy)
regnum = -1;
for (i = 0; i < nregs; i++) {
case PCI_ADDR_IO: /* I/O bus reg property */
regnum = i;
break;
default:
break;
}
}
/* check for valid count of registers */
if (regnum >= 0) {
if (size < 8)
regnum = -1;
}
return (regnum);
}
static int
{
int regnum, i;
struct {
int base;
int size;
} *reglist;
"in devices property list");
return (-1);
}
regnum = -1;
for (i = 0; i < nregs; i++) {
case 1: /* I/O bus reg property */
regnum = i;
break;
case pnpMTS0219: /* Multitech MT5634ZTX modem */
/* Venus chipset can't do loopback test */
if (asy)
break;
default:
break;
}
}
/* check for valid count of registers */
regnum = -1;
return (regnum);
}
static int
{
switch (asy_get_bus_type(devinfo)) {
case ASY_BUS_ISA:
case ASY_BUS_PCI:
default:
return (-1);
}
}
static int
{
int instance;
return (DDI_FAILURE);
switch (cmd) {
case DDI_DETACH:
/* cancel DTR hold timeout */
if (async->async_dtrtid != 0) {
async->async_dtrtid = 0;
}
/* remove all minor device node(s) for this device */
instance);
break;
case DDI_SUSPEND:
{
unsigned i;
#ifdef DEBUG
if (asy_nosuspend)
return (DDI_SUCCESS);
#endif
/* Wait for timed break and delay to complete */
== 0) {
return (DDI_FAILURE);
}
}
/* Clear untimed break */
if (async->async_wbufcid != 0) {
async->async_wbufcid = 0;
}
/* Disable interrupts from chip */
/*
* Hardware interrupts are disabled we can drop our high level
* lock and proceed.
*/
/* Process remaining RX characters and RX errors, if any */
/* Wait for TX to drain */
for (i = 1000; i > 0; i--) {
break;
}
if (i == 0)
"asy: transmitter wasn't drained before "
"driver was suspended");
break;
}
default:
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
* asyprobe
* We don't bother probing for the hardware, as since Solaris 2.6, device
* nodes are only created for auto-detected hardware or nodes explicitly
* created by the user, e.g. via the DCA. However, we should check the
* device node is at least vaguely usable, i.e. we have a block of 8 i/o
* ports. This prevents attempting to attach to bogus serial ports which
* some BIOSs still partially report when they are disabled in the BIOS.
*/
static int
{
}
static int
{
int instance;
int mcr;
int ret;
int regnum = 0;
int i;
int status;
};
switch (cmd) {
case DDI_ATTACH:
break;
case DDI_RESUME:
{
#ifdef DEBUG
if (asy_nosuspend)
return (DDI_SUCCESS);
#endif
return (DDI_FAILURE);
/* Disable interrupts */
(void *)asy->asy_ioaddr);
return (DDI_FAILURE);
}
/* Kick off output */
if (async->async_ocnt > 0) {
} else {
if (async->async_xmitblk)
}
}
BPRI_HI, (void (*)(void *)) async_reioctl,
}
return (DDI_SUCCESS);
}
default:
return (DDI_FAILURE);
}
if (ret != DDI_SUCCESS)
return (DDI_FAILURE);
if (instance > max_asy_instance)
if (regnum < 0 ||
!= DDI_SUCCESS) {
return (DDI_FAILURE);
}
/* Use our built-in COM[1234] values */
com_ports = (int *)standard_com_ports;
num_com_ports = sizeof (standard_com_ports) /
sizeof (standard_com_ports[0]);
}
if (num_com_ports > 10) {
/* We run out of single digits for device properties */
num_com_ports = 10;
"More than %d motherboard-serial-ports",
}
}
/*
* Lookup the i/o address to see if this is a standard COM port
* in which case we assign it the correct tty[a-d] to match the
* COM port number, or some other i/o address in which case it
* fashion.
*/
for (i = 0; i < num_com_ports; i++) {
break;
}
}
/*
* It appears that there was async hardware that on reset
* did not clear ICR. Hence when we get to
* ddi_get_iblock_cookie below, this hardware would cause
* the system to hang if there was input available.
*/
/* establish default usage */
#ifdef DEBUG
#endif
mcr = 0; /* don't enable until open */
if (asy->asy_com_port != 0) {
/*
* For motherboard ports, emulate tty eeprom properties.
* Actually, we can't tell if a port is motherboard or not,
* so for "motherboard ports", read standard DOS COM ports.
*/
case 0: /* *-ignore-cd=False */
"asy%dattach: clear ASY_IGNORE_CD\n", instance);
break;
case 1: /* *-ignore-cd=True */
/*FALLTHRU*/
default: /* *-ignore-cd not defined */
/*
* We set rather silly defaults of soft carrier on
* one of the motherboard ports is the system console.
*/
"asy%dattach: set ASY_IGNORE_CD, set RTS & DTR\n",
instance);
break;
}
case 0: /* *-rts-dtr-off=False */
"ASY_RTS_DTR_OFF set and DTR & RTS set\n",
instance);
break;
case 1: /* *-rts-dtr-off=True */
/*FALLTHRU*/
default: /* *-rts-dtr-off undefined */
break;
}
/* Parse property for tty modes */
} else {
"asy%dattach: clear ASY_IGNORE_CD, clear RTS & DTR\n",
instance);
}
/*
* Initialize the port with default settings.
*/
/*
* Get icookie for mutexes initialization
*/
DDI_SUCCESS) ||
"asy%d: could not hook interrupt for UART @ %p\n",
return (DDI_FAILURE);
}
/*
* Initialize mutexes before accessing the hardware
*/
(void *)asy->asy_soft_iblock);
(void *)asy->asy_iblock);
(void *)asy->asy_soft_iblock);
(void *)asy->asy_ioaddr);
return (DDI_FAILURE);
}
/* disable all interrupts */
/* select baud rate generator */
/* Set the baud rate to 9600 */
/*
* Set up the other components of the asycom structure for this port.
*/
/*
* Install per instance software interrupt handler.
*/
"Can not set soft interrupt for ASY driver\n");
return (DDI_FAILURE);
}
/*
* Install interrupt handler for this device.
*/
"Can not set device interrupt for ASY driver\n");
return (DDI_FAILURE);
}
/* create minor device nodes for this device */
if (asy->asy_com_port != 0) {
/*
* For DOS COM ports, add letter suffix so
* devfsadm can create correct link names.
*/
} else {
/*
* asy port which isn't a standard DOS COM
* port gets a numeric name based on instance
*/
}
if (status == DDI_SUCCESS) {
}
if (status != DDI_SUCCESS) {
return (DDI_FAILURE);
}
/*
* Fill in the polled I/O structure.
*/
return (DDI_SUCCESS);
}
/*ARGSUSED*/
static int
void **result)
{
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
error = DDI_FAILURE;
else {
error = DDI_SUCCESS;
}
break;
case DDI_INFO_DEVT2INSTANCE:
error = DDI_SUCCESS;
break;
default:
error = DDI_FAILURE;
}
return (error);
}
/* asy_getproperty -- walk through all name variants until we find a match */
static int
{
int len;
int ret;
/* Property for ignoring DCD */
if (ret != DDI_PROP_SUCCESS) {
}
if (ret != DDI_PROP_SUCCESS) {
}
if (ret != DDI_PROP_SUCCESS) {
}
if (ret != DDI_PROP_SUCCESS)
return (-1); /* property non-existant */
return (0); /* property false/0 */
return (1); /* property true/!0 */
}
/* asy_soft_state_free - local wrapper for ddi_soft_state_free(9F) */
static void
{
/* If we were the max_asy_instance, work out new value */
while (--max_asy_instance >= 0) {
max_asy_instance) != NULL)
break;
}
}
}
}
static char *
{
switch (asy->asy_hwtype) {
case ASY8250A:
return ("8250A/16450");
case ASY16550:
return ("16550");
case ASY16550A:
return ("16550A");
case ASY16650:
return ("16650");
case ASY16750:
return ("16750");
default:
"asy%d: asy_hw_name: unknown asy_hwtype: %d",
return ("?");
}
}
static int
{
int ret;
int mcr;
if (asy_scr_test) {
/* Check scratch register works. */
/* write to scratch register */
/* make sure that pattern doesn't just linger on the bus */
/* read data back from scratch register */
/*
* Scratch register not working.
* Probably not an async chip.
* 8250 and 8250B don't have scratch registers,
* but only worked in ancient PC XT's anyway.
*/
"scratch register: expected 0x5a, got 0x%02x\n",
return (DDI_FAILURE);
}
}
/*
* Use 16550 fifo reset sequence specified in NS application
* note. Disable fifos until chip is initialized.
*/
/* reset */
/*
* Reset 16650 enhanced regs also, in case we have one of these
*/
0);
}
/*
* See what sort of FIFO we have.
* Try enabling it and see what chip makes of this.
*/
if (asymaxchip >= ASY16550A)
if (asymaxchip >= ASY16650)
"asy%d: probe fifo FIFOR=0x%02x ISR=0x%02x MCR=0x%02x\n",
switch (ret & 0xf0) {
case 0x40:
break;
case 0xc0:
break;
case 0xe0:
break;
case 0xf0:
/*
* Note we get 0xff if chip didn't return us anything,
* e.g. if there's no chip there.
*/
if (ret == 0xff) {
"interrupt register: got 0xff\n",
return (DDI_FAILURE);
}
/*FALLTHRU*/
case 0xd0:
break;
default:
}
if (hwtype > asymaxchip) {
"unexpected probe result: "
"FIFOR=0x%02x ISR=0x%02x MCR=0x%02x\n",
return (DDI_FAILURE);
}
/*
* Now reset the FIFO operation appropriate for the chip type.
* Note we must call asy_reset_fifo() before any possible
* downgrade of the asy->asy_hwtype, or it may not disable
* the more advanced features we specifically want downgraded.
*/
asy_reset_fifo(asy, 0);
/*
* 16550A until we enable its enhanced mode.
*/
asy_scr_test) {
/* Enable enhanced mode register access */
/* zero scratch register (not scratch register if enhanced) */
/* Disable enhanced mode register access */
/* read back scratch register */
/* looks like we have an ST16650 -- enable it */
asy_reset_fifo(asy, 0);
}
}
/*
* If we think we might have a FIFO larger than 16 characters,
* measure FIFO size and check it against expected.
*/
if (asy_fifo_test > 0 &&
ASY_DEBUG(ASY_DEBUG_CHIP))) {
int i;
/* Set baud rate to 57600 (fairly arbitrary choice) */
DLAB);
/* Set 8 bits, 1 stop bit */
/* Set loopback mode */
/* Overfill fifo */
}
/*
* Now there's an interesting question here about which
* FIFO we're testing the size of, RX or TX. We just
* filled the TX FIFO much faster than it can empty,
* although it is possible one or two characters may
* have gone from it to the TX shift register.
* We wait for enough time for all the characters to
* move into the RX FIFO and any excess characters to
* have been lost, and then read all the RX FIFO. So
* the answer we finally get will be the size which is
* the MIN(RX FIFO,(TX FIFO + 1 or 2)). The critical
* one is actually the TX FIFO, because if we overfill
* it in normal operation, the excess characters are
* lost with no warning.
*/
/*
* Wait for characters to move into RX FIFO.
* In theory, 200 * asy->asy_fifo_buf * 2 should be
* enough. However, in practice it isn't always, so we
* increase to 400 so some slow 16550A's finish, and we
* increase to 3 so we spot more characters coming back
* than we sent, in case that should ever happen.
*/
/* Now see how many characters we can read back */
break; /* FIFO emptied */
}
"asy%d FIFO size: expected=%d, measured=%d\n",
if (i < asy->asy_fifo_buf) {
/*
* FIFO is somewhat smaller than we anticipated.
* If we have 16 characters usable, then this
* UART will probably work well enough in
* 16550A mode. If less than 16 characters,
* then we'd better not use it at all.
* UARTs with busted FIFOs do crop up.
*/
/* fall back to a 16550A */
} else {
/* fall back to no FIFO at all */
}
}
/*
* We will need to reprogram the FIFO if we changed
* our mind about how to drive it above, and in any
* case, it would be a good idea to flush any garbage
* out incase the loopback test left anything behind.
* Again as earlier above, we must call asy_reset_fifo()
* before any possible downgrade of asy->asy_hwtype.
*/
/* Disable 16650 enhanced mode */
0);
}
}
/* Make UART type visible in device tree for prtconf, etc */
return (DDI_SUCCESS);
}
/*
* asyinit() initializes the TTY protocol-private data for this channel
* before enabling the interrupts.
*/
static void
{
}
/*ARGSUSED3*/
static int
{
int mcr;
int unit;
int len;
return (ENXIO); /* unit not configured */
/*
* Block waiting for carrier to come up, unless this is a no-delay open.
*/
/*
* Set the default termios settings (cflag).
* Others are set in ldterm.
*/
0, "ttymodes",
} else
"asy: couldn't get ttymodes property!");
/* eeprom mode support - respect properties */
async->async_wbufcid = 0;
} else
secpolicy_excl_open(cr) != 0) {
return (EBUSY);
return (EBUSY);
}
/* Raise DTR on every open, but delay if it was just lowered. */
"asy%dopen: waiting for the ASYNC_DTR_DELAY to be clear\n",
unit);
"asy%dopen: interrupted by signal, exiting\n",
unit);
return (EINTR);
}
}
"asy%dopen: \"Raise DTR on every open\": make mcr = %x, "
"make TS_SOFTCAR = %s\n",
"asy%dopen: ASY_IGNORE_CD set, set TS_SOFTCAR\n",
unit);
}
else
/*
* Check carrier.
*/
"MSR & DCD is %s\n",
unit,
else
/*
* If FNDELAY and FNONBLOCK are clear, block until carrier up.
* Quit on interrupt.
*/
return (EINTR);
}
goto again;
}
return (EBUSY);
}
/*
* Caution here -- qprocson sets the pointers that are used by canput
* called by async_softint. ASYNC_ISOPEN must *not* be set until those
* pointers are valid.
*/
async->async_polltid = 0;
return (0);
}
static void
{
/*
* We define "progress" as either waiting on a timed break or delay, or
* having had at least one transmitter interrupt. If none of these are
* true, then just terminate the output and wake up that close thread.
*/
async->async_ocnt = 0;
async->async_timer = 0;
/*
* Since this timer is running, we know that we're in exit(2).
* That means that the user can't possibly be waiting on any
* valid ioctl(2) completion anymore, and we should just flush
* everything.
*/
} else {
}
}
/*
* Release DTR so that asyopen() can raise it.
*/
static void
{
"async_dtr_free, clearing ASYNC_DTR_DELAY\n");
async->async_dtrtid = 0;
}
/*
* Close routine.
*/
/*ARGSUSED2*/
static int
{
#ifdef DEBUG
int instance;
#endif
#ifdef DEBUG
#endif
/*
* Turn off PPS handling early to avoid events occuring during
* close. Also reset the DCD edge monitoring bit.
*/
/*
* There are two flavors of break -- timed (M_BREAK or TCSBRK) and
* untimed (TIOCSBRK). For the timed case, these are enqueued on our
* write queue and there's a timer running, so we don't have to worry
* about them. For the untimed case, though, the user obviously made a
* mistake, because these are handled immediately. We'll terminate the
* break now and honor his implicit request by discarding the rest of
* the data.
*/
if (async->async_utbrktid != 0) {
async->async_utbrktid = 0;
}
goto nodrain;
}
/*
* If the user told us not to delay the close ("non-blocking"), then
* don't bother trying to drain.
*
* If the user did M_STOP (ASYNC_STOPPED), there's no hope of ever
* getting an M_START (since these messages aren't enqueued), and the
* only other way to clear the stop condition is by loss of DCD, which
* would discard the queue data. Thus, we drop the output data if
* ASYNC_STOPPED is set.
*/
goto nodrain;
}
/*
* If there's any pending output, then we have to try to drain it.
* There are two main cases to be handled:
* - called by close(2): need to drain until done or until
* a signal is received. No timeout.
* - called by exit(2): need to drain while making progress
* or until a timeout occurs. No signals.
*
* If we can't rely on receiving a signal to get us out of a hung
* session, then we have to use a timer. In this case, we set a timer
* to check for progress in sending the output data -- all that we ask
* (at each interval) is that there's been some progress made. Since
* the interrupt routine grabs buffers from the write queue, we can't
* trust changes in async_ocnt. Instead, we use a progress flag.
*
* Note that loss of carrier will cause the output queue to be flushed,
* and we'll wake up again and finish normally.
*/
if (!ddi_can_receive_sig() && asy_drain_check != 0) {
}
while (async->async_ocnt > 0 ||
break;
}
if (async->async_timer != 0) {
async->async_timer = 0;
}
async->async_ocnt = 0;
/*
* If line has HUPCL set or is incompletely opened fix up the modem
* lines.
*/
instance);
"asy%dclose: HUPCL flag = %x, ASYNC_WOPEN flag = %x\n",
/* turn off DTR, RTS but NOT interrupt to 386 */
"asy%dclose: ASY_IGNORE_CD flag = %x, "
"ASY_RTS_DTR_OFF flag = %x\n",
} else {
"asy%dclose: Dropping DTR and RTS\n", instance);
OUT2);
}
timeout((void (*)())async_dtr_free,
}
/*
* If nobody's using it now, turn off receiver interrupts.
*/
}
out:
/*
* Cancel outstanding "bufcall" request.
*/
if (async->async_wbufcid != 0) {
async->async_wbufcid = 0;
}
/* Note that qprocsoff can't be done until after interrupts are off */
qprocsoff(q);
/*
* Clear out device state, except persistant device property flags.
*/
return (0);
}
static boolean_t
{
/*
* XXXX this should be recoded
*/
return ((async->async_ocnt > 0) ||
}
static void
{
/*
* Wait for the current transmission block and the
* current fifo data to transmit. Once this is done
* we may go on.
*/
while (asy_isbusy(asy)) {
}
}
/* asy_reset_fifo -- flush fifos and [re]program fifo control register */
static void
{
/* On a 16750, we have to set DLAB in order to set FIFOEXTRA. */
}
/* Clear DLAB */
}
}
/*
* Program the ASY port. Most of the async operation is based on the values
* of 'c_iflag' and 'c_cflag'.
*/
static void
{
int flush_reg;
int ocflags;
#ifdef DEBUG
int instance;
#endif
#ifdef DEBUG
#endif
} else {
}
/* disable interrupts */
/*
* The device is programmed in the open sequence, if we
* have to hardware handshake, then this is a good time
* to check if the device can receive any data.
*/
} else {
/*
* We can not use async_flowcontrol_hw_output(asy, FLOW_START)
* here, because if CRTSCTS is clear, we need clear
* ASYNC_HW_OUT_FLW bit.
*/
}
/*
* If IXON is not set, clear ASYNC_SW_OUT_FLW;
* If IXON is set, no matter what IXON flag is before this
* function call to asy_program,
* we will use the old ASYNC_SW_OUT_FLW status.
* Because of handling IXON in the driver, we also should re-calculate
* the value of ASYNC_OUT_FLW_RESUME bit, but in fact,
* the TCSET* commands which call asy_program
* are put into the write queue, so there is no output needed to
* be resumed at this point.
*/
/* manually flush receive buffer or fifo (workaround for buggy fifos) */
}
} else {
}
/* Set line control */
case CS5:
break;
case CS6:
break;
case CS7:
break;
case CS8:
break;
}
/* set the baud rate, unless it is "0" */
if (baudrate != 0) {
}
/* set the line control modes */
/*
* at intialize time, flush if transitioning from
* CREAD off to CREAD on.
*/
/* remember the new cflags */
}
if (baudrate == 0)
else
/*
* Call the modem status interrupt handler to check for the carrier
* in case CLOCAL was turned off after the carrier came on.
* (Note: Modem status interrupt is not enabled if CLOCAL is ON.)
*/
/* Set interrupt control */
"asy%d_program: c_flag & CLOCAL = %x t_cflag & CRTSCTS = %x\n",
/*
* direct-wired line ignores DCD, so we don't enable modem
* status interrupts.
*/
else
}
static boolean_t
{
int baudrate;
return (0);
}
/*
* asyintr() is the High Level Interrupt Handler.
*
* There are four different interrupt types indexed by ISR register values:
* 0: modem
* 1: Tx holding register is empty, ready for next char
* 2: Rx register now holds a char to be picked up
* 3: error or break on line
* This routine checks the Bit 0 (interrupt-not-pending) to determine if
* the interrupt is from this port.
*/
{
if (interrupt_id & NOINTERRUPT)
return (DDI_INTR_UNCLAIMED);
else {
/*
* reset the device by:
* reading line status
* reading any data from data status register
* reading modem status
*/
return (DDI_INTR_CLAIMED);
}
}
return (DDI_INTR_CLAIMED);
}
/*
* We will loop until the interrupt line is pulled low. asy
* interrupt is edge triggered.
*/
/* CSTYLED */
for (;; interrupt_id =
if (interrupt_id & NOINTERRUPT)
break;
switch (interrupt_id) {
case RxRDY:
case RSTATUS:
case FFTMOUT:
/* receiver interrupt or receiver errors */
break;
case TxRDY:
/* transmit interrupt */
continue;
case MSTATUS:
/* modem status interrupt */
break;
}
(async->async_ocnt > 0))
}
return (ret_status);
}
/*
* Transmitter interrupt service routine.
* If there is more data to transmit in the current pseudo-DMA block,
* send the next character if output is not stopped or draining.
* Otherwise, queue up a soft interrupt.
*
* XXX - Needs review for HW FIFOs.
*/
static void
{
int fifo_len;
/*
* If ASYNC_BREAK or ASYNC_OUT_SUSPEND has been set, return to
* asyintr()'s context to claim the interrupt without performing
* timed or untimed break is removed
*/
return;
if (fifo_len > asy_max_tx_fifo)
fifo_len--;
!(async->async_flags &
}
}
if (fifo_len <= 0)
return;
}
/*
* Interrupt on port: handle PPS event. This function is only called
* for a port on which PPS event handling has been enabled.
*/
static void
{
/* Have seen leading edge, now look for and record drop */
/*
* Waiting for leading edge, look for rise; stamp event and
* calibrate kernel clock.
*/
/*
* This code captures a timestamp at the designated
* transition of the PPS signal (DCD asserted). The
* code provides a pointer to the timestamp, as well
* as the hardware counter value at the capture.
*
* Note: the kernel has nano based time values while
* NTP requires micro based, an in-line fast algorithm
* to convert nsec to usec is used here -- see hrt2ts()
*/
gethrestime(&ts);
/*
* Because the kernel keeps a high-resolution time,
* pass the current highres timestamp in tvp and zero
* in usec.
*/
ddi_hardpps(tvp, 0);
}
}
/*
* Receiver interrupt: RxRDY interrupt, FIFO timeout interrupt or receive
* error interrupt.
* Try to put the character into the circular buffer for this line; if it
* overflows, indicate a circular buffer overrun. If this port is always
* to be serviced immediately, or the character is a STOP character, or
* more than 15 characters have arrived, queue up a soft interrupt to
* drain the circular buffer.
* XXX - needs review for hw FIFOs support.
*/
static void
{
uchar_t c;
if (looplim-- < 0) /* limit loop */
break;
}
return; /* line is not open for read? */
}
c = 0;
s = 0; /* reset error status */
/*
* but if received char is _POSIX_VDISABLE,
* we left it to the up level module.
*/
if ((c == async->async_stopc) &&
(c != _POSIX_VDISABLE)) {
goto check_looplim;
} else if ((c == async->async_startc) &&
(c != _POSIX_VDISABLE)) {
needsoft = 1;
goto check_looplim;
}
needsoft = 1;
}
}
}
/*
* Check for character break sequence
*/
if ((abort_enable == KIOCABORTALTERNATE) &&
if (abort_charseq_recognize(c))
abort_sequence_enter((char *)NULL);
}
/* Handle framing errors */
s |= PERROR;
}
s |= FRERROR;
s |= OVERRUN;
}
}
if (s == 0)
(c == 0377))
} else
else
else
else
if (s & FRERROR) /* Handle framing errors */
if (c == 0)
(abort_enable !=
abort_sequence_enter((char *)0);
else
async->async_break++;
else
else
else /* Parity errors are handled by ldterm */
else
if (looplim-- < 0) /* limit loop */
break;
}
}
}
/*
* Modem status interrupt.
*
* (Note: It is assumed that the MSR hasn't been read by asyintr().)
*/
static void
{
#ifdef DEBUG
#endif
/* this resets the interrupt */
"async%d_msint call #%d:\n"
" transition: %3s %3s %3s %3s\n"
"current state: %3s %3s %3s %3s\n",
++(asy->asy_msint_cnt),
/* If CTS status is changed, do H/W output flow control */
/*
* Reading MSR resets the interrupt, we save the
* value of msr so that other functions could examine MSR by
* looking at asy_msr.
*/
/* Handle PPS event */
/*
* We will make sure that the modem status presented to us
* during the previous read has not changed. If the chip samples
* the modem status on the falling edge of the interrupt line,
* and uses this state as the base for detecting change of modem
* status, we would miss a change of modem status event that occured
* after we initiated a read MSR operation.
*/
goto async_msint_retry;
}
/*
* Handle a second-stage interrupt.
*/
/*ARGSUSED*/
{
int rv;
/*
* Test and clear soft interrupt.
*/
if (rv != 0)
asy->asysoftpend = 0;
if (rv) {
}
/*
* There are some instances where the softintr is not
* scheduled and hence not called. It so happens that
* causes the last few characters to be stuck in the
* ringbuffer. Hence, call the handler once again so
* the last few characters are cleared.
*/
if (cc > 0)
(void) async_softint(asy);
}
}
/*
* Handle a software interrupt.
*/
static void
{
queue_t *q;
uchar_t c;
int nb;
return;
}
if (async->async_ocnt > 0) {
} else {
if (async->async_xmitblk)
}
}
/* check for carrier up */
"async%d_softint: asy_msr & DCD = %x, "
"tp->t_flags & TS_SOFTCAR = %x\n",
/* carrier present */
"async%d_softint: set ASYNC_CARR_ON\n",
instance);
(void) putctl(q, M_UNHANGUP);
}
}
} else {
int flushflag;
"async%d_softint: carrier dropped, "
"so drop DTR\n",
instance);
/*
* Carrier went away.
* Drop DTR, abort any output in
* progress, indicate that output is
* not stopped, and send a hangup
* notification upstream.
*/
"async_softint: "
"Carrier dropped. "
"Clearing async_ocnt\n");
async->async_ocnt = 0;
} /* if */
"async%d_softint: "
"putctl(q, M_HANGUP)\n",
instance);
/*
* Flush FIFO buffers
* Any data left in there is invalid now
*/
/*
* Flush our write queue if we have one.
* If we're in the midst of close, then
* flush everything. Don't leave stale
* ioctls lying about.
*/
ASYNC_CLOSING) ? FLUSHALL :
/* active msg */
}
/*
* This message warns of Carrier loss
* with data left to transmit can hang
* the system.
*/
"async_softint: Flushing to "
"prevent HUPCL hanging\n");
} /* if (ASYNC_ISOPEN) */
} /* if (ASYNC_CARR_ON && CLOCAL) */
} /* else */
} /* if (async->async_ext) */
/*
* If data has been added to the circular buffer, remove
* it from the buffer, and send it up the stream if there's
* somebody listening. Try to do it 16 bytes at a time. If we
* have more than 16 bytes to move, move 16 byte chunks and
* leave the rest for next time around (maybe it will grow).
*/
goto rv;
}
goto rv;
if (!canput(q)) {
}
goto rv;
}
}
goto rv;
}
do {
break;
} else
} while (--cc);
if (!canput(q)) {
instance);
} else
} else
/*
* If we have a parity error, then send
* up an M_BREAK with the "bad"
* character as an argument. Let ldterm
* figure out what to do with the error.
*/
if (cc) {
}
rv:
}
/*
* If a transmission has finished, indicate that it's finished,
* and start that line up again.
*/
if (async->async_break > 0) {
async->async_break = 0;
}
}
"async%d_softint: Clearing ASYNC_BUSY. async_ocnt=%d\n",
async->async_ocnt);
if (async->async_xmitblk)
/*
* If the flag isn't set after doing the async_start above, we
* may have finished all the queued output. Signal any thread
* stuck in close.
*/
}
/*
* A note about these overrun bits: all they do is *tell* someone
* about an error- They do not track multiple errors. In fact,
* you could consider them latched register bits if you like.
* We are only interested in printing the error message once for
* any cluster of overrun errrors.
*/
if (async->async_hw_overrun) {
}
async->async_hw_overrun = 0;
}
if (async->async_sw_overrun) {
instance);
}
async->async_sw_overrun = 0;
}
goto begin;
}
}
/*
* Restart output on a line after a delay or break timer expired.
*/
static void
{
/*
* If break timer expired, turn off the break bit.
*/
#ifdef DEBUG
#endif
/*
* If ASYNC_OUT_SUSPEND is also set, we don't really
* clean the HW break, TIOCCBRK is responsible for this.
*/
}
}
static void
{
async_nstart(async, 0);
}
/*
* Start output on a line, unless it's busy, frozen, or otherwise.
*/
/*ARGSUSED*/
static void
{
int cc;
queue_t *q;
#ifdef DEBUG
#endif
if (fifo_len > asy_max_tx_fifo)
}
/*
* If the chip is busy (i.e., we're waiting for a break timeout
* to expire, or for the current transmission to finish, or for
* output to finish draining from chip), don't grab anything new.
*/
"async%d_nstart: start %s.\n",
return;
}
/*
* Check only pended sw input flow control.
*/
fifo_len--;
/*
* If we're waiting for a delay timeout to expire, don't grab
* anything new.
*/
"async%d_nstart: start ASYNC_DELAY.\n", instance);
return;
}
"async%d_nstart: start writeq is null.\n", instance);
return; /* not attached to a stream */
}
for (;;) {
return; /* no data to transmit */
/*
* We have a message block to work on.
* Check whether it's a break, a delay, or an ioctl (the latter
* occurs if the ioctl in question was waiting for the output
* to drain). If it's one of those, process it immediately.
*/
case M_BREAK:
/*
* Set the break bit, and arrange for "async_restart"
* to be called in 1/4 second; it will turn the
* break bit off, and call "async_start" to grab
* the next message.
*/
return; /* wait for this to finish */
case M_DELAY:
/*
* Arrange for "async_restart" to be called when the
* delay expires; it will turn ASYNC_DELAY off,
* and call "async_start" to grab the next message.
*/
return; /* wait for this to finish */
case M_IOCTL:
/*
* This ioctl was waiting for the output ahead of
* it to drain; obviously, it has. Do it, and
* then grab the next message after it.
*/
continue;
}
}
break;
}
/*
* We have data to transmit. If output is stopped, put
* it back and try again later.
*/
return;
}
/*
* In 5-bit mode, the high order bits are used
* to indicate character sizes less than five,
* so we need to explicitly mask before transmitting
*/
unsigned char *p = xmit_addr;
while (cnt--)
*p++ &= (unsigned char) 0x1f;
}
/*
* Set up this block for pseudo-DMA.
*/
/*
* If the transmitter is ready, shove the first
* character out.
*/
XHRE))
break;
*xmit_addr++);
cc--;
}
if (didsome)
"async%d_nstart: Set ASYNC_BUSY. async_ocnt=%d\n",
}
/*
* Resume output by poking the transmitter.
*/
static void
{
#ifdef DEBUG
int instance;
#endif
#ifdef DEBUG
#endif
return;
if (async->async_ocnt > 0 &&
!(async->async_flags &
async->async_ocnt--;
}
}
}
/*
* Hold the untimed break to last the minimum time.
*/
static void
{
async->async_utbrktid = 0;
}
/*
* Resume the untimed break.
*/
static void
{
/*
* Because the wait time is very short,
* so we use uninterruptably wait.
*/
}
/*
* Timed break and untimed break can exist simultaneously,
* if ASYNC_BREAK is also set at here, we don't
* really clean the HW break.
*/
}
if (async->async_ocnt > 0) {
} else {
}
}
}
/*
* Process an "ioctl" message sent down to us.
* Note that we don't need to get any locks until we are ready to access
* the hardware. Nothing we access until then is going to be altered
* outside of the STREAMS framework, so we should be safe.
*/
static void
{
unsigned datasize;
int error = 0;
unsigned int index;
#ifdef DEBUG
#endif
/*
* We were holding an "ioctl" response pending the
* availability of an "mblk" to hold data to be passed up;
* another "ioctl" came through, which means that "ioctl"
* must have timed out or been aborted.
*/
}
/*
* For TIOCMGET and the PPS ioctls, do NOT call ttycommon_ioctl()
* because this function frees up the message block (mp->b_cont) that
* contains the user location where we pass back the results.
*
* Similarly, CONSOPENPOLLEDIO needs ioc_count, which ttycommon_ioctl
* zaps. We know that ttycommon_ioctl doesn't know any CONS*
* ioctls, so keep the others safe too.
*/
"other");
case TIOCMGET:
case TIOCGPPS:
case TIOCSPPS:
case TIOCGPPSEV:
case CONSOPENPOLLEDIO:
case CONSCLOSEPOLLEDIO:
case CONSSETABORTENABLE:
case CONSGETABORTENABLE:
break;
default:
/*
* The only way in which "ttycommon_ioctl" can fail is if the
* "ioctl" requires a response containing data to be returned
* to the user, and no mblk could be allocated for the data.
* No such "ioctl" alters our state. Thus, we always go ahead
* and do any state-changes the "ioctl" calls for. If we
* couldn't allocate the data, "ttycommon_ioctl" has stashed
* the "ioctl" away safely, so we just call "bufcall" to
* request that we be called back when we stand a better
* chance of allocating the data.
*/
if (async->async_wbufcid)
(void (*)(void *)) async_reioctl,
return;
}
}
if (error == 0) {
/*
* "ttycommon_ioctl" did most of the work; we just use the
* data it set up.
*/
case TCSETS:
if (asy_baudok(asy))
else
break;
case TCSETSF:
case TCSETSW:
case TCSETA:
case TCSETAW:
case TCSETAF:
if (!asy_baudok(asy))
else {
if (asy_isbusy(asy))
}
break;
}
} else if (error < 0) {
/*
* "ttycommon_ioctl" didn't do anything; we process it here.
*/
error = 0;
case TIOCGPPS:
/*
*/
break;
}
else
break;
case TIOCSPPS:
/*
*/
if (error != 0)
break;
else
/* Reset edge sense */
break;
case TIOCGPPSEV:
{
/*
* Get PPS event data.
*/
void *buf;
#ifdef _SYSCALL32_IMPL
#endif
}
break;
}
/* Protect from incomplete asy_ppsev */
#ifdef _SYSCALL32_IMPL
} else
#endif
{
buf = &ppsclockev;
}
break;
}
break;
}
case TCSBRK:
if (error != 0)
break;
/*
* XXX Arrangements to ensure that a break
* isn't in progress should be sufficient.
* This ugly delay() is the only thing
* that seems to work on the NCR Worldmark.
* It should be replaced. Note that an
* asy_waiteot() also does not work.
*/
if (asydelay)
}
/*
* We loop until the TSR is empty and then
* set the break. ASYNC_BREAK has been set
* to ensure that no characters are
* transmitted while the TSR is being
* flushed and SOUT is being used for the
* break signal.
*
* The wait period is equal to
* clock / (baud * 16) * 16 * 2.
*/
}
/*
* Arrange for "async_restart"
* to be called in 1/4 second;
* it will turn the break bit off, and call
* "async_start" to grab the next message.
*/
} else {
"async%d_ioctl: wait for flush.\n",
instance);
"async%d_ioctl: ldterm satisfied.\n",
instance);
}
break;
case TIOCSBRK:
}
/* wait for 100ms to hold BREAK */
timeout((void (*)())async_hold_utbrk,
}
break;
case TIOCCBRK:
break;
case TIOCMSET:
case TIOCMBIS:
case TIOCMBIC:
"non-transparent\n", instance);
if (error != 0)
break;
} else {
"transparent\n", instance);
}
break;
case TIOCMGET:
break;
}
"transparent\n", instance);
} else {
"non-transparent\n", instance);
}
break;
case CONSOPENPOLLEDIO:
if (error != 0)
break;
break;
case CONSCLOSEPOLLEDIO:
break;
case CONSSETABORTENABLE:
if (error != 0)
break;
break;
}
else
break;
case CONSGETABORTENABLE:
/*CONSTANTCONDITION*/
/*
* Store the return value right in the payload
* we were passed. Crude.
*/
break;
default:
/*
* If we don't understand it, it's an error. NAK it.
*/
break;
}
}
if (error != 0) {
}
}
static int
{
async->async_polltid = 0;
return (0);
}
/*
* The ASYWPUTDO_NOT_SUSP macro indicates to asywputdo() whether it should
* handle messages as though the driver is operating normally or is
* suspended. In the suspended case, some or all of the processing may have
* to be delayed until the driver is resumed.
*/
/*
* Processing for write queue put procedure.
* Respond to M_STOP, M_START, M_IOCTL, and M_FLUSH messages here;
* set the flow control character for M_STOPI and M_STARTI messages;
* queue up M_BREAK, M_DELAY, and M_DATA messages for processing
* by the start routine, and then call the start routine; discard
* everything else. Note that this driver does not incorporate any
* mechanism to negotiate to handle the canonicalization process.
* It expects that these functions are handled in upper module(s),
* as we do in ldterm.
*/
static int
{
#ifdef DEBUG
int instance;
#endif
int error;
#ifdef DEBUG
#endif
case M_STOP:
/*
* Since we don't do real DMA, we can just let the
* chip coast to a stop after applying the brakes.
*/
break;
case M_START:
/*
* If an output operation is in progress,
* resume it. Otherwise, prod the start
* routine.
*/
if (async->async_ocnt > 0) {
} else {
}
}
}
break;
case M_IOCTL:
case TCSBRK:
if (error != 0) {
return (0);
}
"async%d_ioctl: flush request.\n",
instance);
/*
* If an TIOCSBRK is in progress,
* clean it as TIOCCBRK does,
* then kick off output.
* If TIOCSBRK is not in progress,
* just kick off output.
*/
}
break;
}
/*FALLTHROUGH*/
case TCSETSW:
case TCSETSF:
case TCSETAW:
case TCSETAF:
/*
* The changes do not take effect until all
* output queued before them is drained.
* Put this message on the queue, so that
* "async_start" will see it when it's done
* with the output before it. Poke the
* start routine, just in case.
*/
/*
* If an TIOCSBRK is in progress,
* clean it as TIOCCBRK does.
* then kick off output.
* If TIOCSBRK is not in progress,
* just kick off output.
*/
}
break;
default:
/*
* Do it now.
*/
break;
}
break;
}
break;
case M_FLUSH:
/*
* Abort any output in progress.
*/
"Clearing async_ocnt, "
"leaving ASYNC_BUSY set\n",
instance);
async->async_ocnt = 0;
} /* if */
/* Flush FIFO buffers */
}
}
/* Flush FIFO buffers */
}
/*
* Flush our write queue.
*/
}
}
/* Flush FIFO buffers */
}
}
} else {
}
/*
* We must make sure we process messages that survive the
* write-side flush.
*/
}
break;
case M_BREAK:
case M_DELAY:
case M_DATA:
/*
* Queue the message up to be transmitted,
* and poke the start routine.
*/
}
break;
case M_STOPI:
(void) async_flowcontrol_sw_input(asy,
}
break;
}
break;
case M_STARTI:
(void) async_flowcontrol_sw_input(asy,
}
break;
}
break;
case M_CTL:
break;
} else {
}
} else {
/*
* These MC_SERVICE type messages are used by upper
* modules to tell this driver to send input up
* immediately, or that it can wait for normal
* processing that may or may not be done. Sun
* requires these for the mouse module.
* (XXX - for x86?)
*/
case MC_SERVICEIMM:
break;
case MC_SERVICEDEF:
break;
}
}
break;
case M_IOCDATA:
async_iocdata(q, mp);
break;
}
break;
default:
break;
}
return (0);
}
static int
{
}
/*
* Retry an "ioctl", now that "bufcall" claims we may be able to allocate
* the buffer we need.
*/
static void
{
queue_t *q;
/*
* The bufcall is no longer pending.
*/
async->async_wbufcid = 0;
return;
}
/* not pending any more */
} else
}
static void
{
#ifdef DEBUG
#endif
if (csp->cp_private)
return;
}
"TIOCMBIC");
case TIOCMGET:
}
break;
case TIOCMSET:
case TIOCMBIS:
case TIOCMBIC:
break;
default:
break;
}
}
/*
*/
/*
* put a character out
* Do not use interrupts. If char is LF, put out CR, LF.
*/
static void
{
if (c == '\n')
/* wait for xmit to finish */
drv_usecwait(10);
}
/* put the character out */
}
/*
* See if there's a character available. If no character is
* available, return 0. Run in polled mode, no interrupts.
*/
static boolean_t
{
!= 0);
}
/*
* Get a character. Run in polled mode, no interrupts.
*/
static int
{
drv_usecwait(10);
}
/*
* Set or get the modem control status.
*/
static int
{
/* Read Modem Control Registers */
switch (how) {
case TIOCMSET:
break;
case TIOCMBIS:
break;
case TIOCMBIC:
break;
case TIOCMGET:
/* Read Modem Status Registers */
/*
* If modem interrupts are enabled, we return the
* saved value of msr. We read MSR only in async_msint()
*/
"asy%dmctl: TIOCMGET, read msr_r = %x\n",
} else {
"asy%dmctl: TIOCMGET, read MSR = %x\n",
}
}
return (mcr_r);
}
static int
{
int b = 0;
/* MCR registers */
b |= TIOCM_RTS;
b |= TIOCM_DTR;
/* MSR registers */
b |= TIOCM_CAR;
b |= TIOCM_CTS;
b |= TIOCM_DSR;
b |= TIOCM_RNG;
return (b);
}
static int
{
int b = 0;
#ifdef CAN_NOT_SET /* only DTR and RTS can be set */
b |= DCD;
b |= CTS;
b |= DSR;
b |= RI;
#endif
b |= RTS;
}
b |= DTR;
}
return (b);
}
static void
{
static const char *lastfmt;
/*
* Don't print the same error message too often.
* Print the message only if we have not printed the
* message within the last second.
* Note: that fmt cannot be a pointer to a string
* stored on the stack. The fmt pointer
* must be in the data segment otherwise lastfmt would point
* to non-sense.
*/
now = gethrestime_sec();
return;
}
/*
* asy_parse_mode(dev_info_t *devi, struct asycom *asy)
* The value of this property is in the form of "9600,8,n,1,-"
* 1) speed: 9600, 4800, ...
* 2) data bits
* 3) parity: n(none), e(even), o(odd)
* 4) stop bits
*
* This parsing came from a SPARCstation eeprom.
*/
static void
{
int len;
int ret;
char *p;
char *p1;
/*
* Parse the ttyx-mode property
*/
if (ret != DDI_PROP_SUCCESS) {
}
/* no property to parse */
if (ret != DDI_PROP_SUCCESS)
return;
p = val;
/* ---- baud rate ---- */
*p1++ = '\0';
} else {
return;
}
if (strcmp(p, "110") == 0)
else if (strcmp(p, "150") == 0)
else if (strcmp(p, "300") == 0)
else if (strcmp(p, "600") == 0)
else if (strcmp(p, "1200") == 0)
else if (strcmp(p, "2400") == 0)
else if (strcmp(p, "4800") == 0)
else if (strcmp(p, "9600") == 0)
else if (strcmp(p, "19200") == 0)
else if (strcmp(p, "38400") == 0)
else if (strcmp(p, "57600") == 0)
else if (strcmp(p, "115200") == 0)
else
} else {
}
/* ---- Next item is data bits ---- */
p = p1;
*p1++ = '\0';
} else {
return;
}
switch (*p) {
default:
case '8':
break;
case '7':
break;
case '6':
break;
case '5':
/* LINTED: CS5 is currently zero (but might change) */
break;
}
/* ---- Parity info ---- */
p = p1;
*p1++ = '\0';
} else {
return;
}
switch (*p) {
default:
case 'n':
break;
case 'e':
case 'o':
break;
}
/* ---- Find stop bits ---- */
p = p1;
*p1++ = '\0';
} else {
return;
}
if (*p == '2') {
}
/* ---- handshake is next ---- */
p = p1;
if (p) {
*p1++ = '\0';
if (*p == 'h')
else if (*p == 's')
}
}
/*
* Check for abort character sequence
*/
static boolean_t
{
static int state = 0;
state = 0;
return (B_TRUE);
}
} else {
}
return (B_FALSE);
}
/*
* Flow control functions
*/
/*
* Software input flow control
* This function can execute software input flow control sucessfully
* at most of situations except that the line is in BREAK status
* (timed and untimed break).
* INPUT VALUE of onoff:
* FLOW_START means to send out a XON char
* and clear SW input flow control flag.
* FLOW_STOP means to send out a XOFF char
* and set SW input flow control flag.
* if it is true, send it out.
* INPUT VALUE of type:
* IN_FLOW_RINGBUFF means flow control is due to RING BUFFER
* IN_FLOW_STREAMS means flow control is due to STREAMS
* IN_FLOW_USER means flow control is due to user's commands
* RETURN VALUE: B_FALSE means no flow control char is sent
* B_TRUE means one flow control char is sent
*/
static boolean_t
int type)
{
return (rval);
/*
* If we get this far, then we know IXOFF is set.
*/
switch (onoff) {
case FLOW_STOP:
/*
* We'll send an XOFF character for each of up to
* three different input flow control attempts to stop input.
* If we already send out one XOFF, but FLOW_STOP comes again,
* it seems that input flow control becomes more serious,
* then send XOFF again.
*/
break;
case FLOW_START:
if (async->async_inflow_source == 0) {
"input sflow start\n", instance);
}
break;
default:
break;
}
ASYNC_OUT_SUSPEND)) == ASYNC_SW_IN_NEEDED) &&
/*
* If we get this far, then we know we need to send out
* XON or XOFF char.
*/
}
return (rval);
}
/*
* Software output flow control
* This function can be executed sucessfully at any situation.
* It does not handle HW, and just change the SW output flow control flag.
* INPUT VALUE of onoff:
* FLOW_START means to clear SW output flow control flag,
* also combine with HW output flow control status to
* determine if we need to set ASYNC_OUT_FLW_RESUME.
* FLOW_STOP means to set SW output flow control flag,
* also clear ASYNC_OUT_FLW_RESUME.
*/
static void
{
return;
switch (onoff) {
case FLOW_STOP:
instance);
break;
case FLOW_START:
instance);
break;
default:
break;
}
}
/*
* Hardware input flow control
* This function can be executed sucessfully at any situation.
* It directly changes RTS depending on input parameter onoff.
* INPUT VALUE of onoff:
* FLOW_START means to clear HW input flow control flag,
* and pull up RTS if it is low.
* FLOW_STOP means to set HW input flow control flag,
* and low RTS if it is high.
* INPUT VALUE of type:
* IN_FLOW_RINGBUFF means flow control is due to RING BUFFER
* IN_FLOW_STREAMS means flow control is due to STREAMS
* IN_FLOW_USER means flow control is due to user's commands
*/
static void
int type)
{
return;
switch (onoff) {
case FLOW_STOP:
break;
case FLOW_START:
if (async->async_inflow_source == 0) {
"input hflow start\n", instance);
}
break;
default:
break;
}
}
}
/*
* Hardware output flow control
* This function can execute HW output flow control sucessfully
* at any situation.
* It doesn't really change RTS, and just change
* HW output flow control flag depending on CTS status.
* INPUT VALUE of onoff:
* FLOW_START means to clear HW output flow control flag.
* also combine with SW output flow control status to
* determine if we need to set ASYNC_OUT_FLW_RESUME.
* FLOW_STOP means to set HW output flow control flag.
* also clear ASYNC_OUT_FLW_RESUME.
*/
static void
{
return;
switch (onoff) {
case FLOW_STOP:
instance);
break;
case FLOW_START:
instance);
break;
default:
break;
}
}
/*
* quiesce(9E) entry point.
*
* This function is called when the system is single-threaded at high
* PIL with preemption disabled. Therefore, this function must not be
* blocked.
*
* This function returns DDI_SUCCESS on success, or DDI_FAILURE on failure.
* DDI_FAILURE indicates an error condition and should almost never happen.
*/
static int
{
int instance;
return (DDI_FAILURE);
/* disable all interrupts */
/* reset the FIFO */
return (DDI_SUCCESS);
}