Index: stable/10/sys/dev/ppbus/ppb_1284.c =================================================================== --- stable/10/sys/dev/ppbus/ppb_1284.c (revision 305554) +++ stable/10/sys/dev/ppbus/ppb_1284.c (revision 305555) @@ -1,865 +1,865 @@ /*- * Copyright (c) 1997 Nicolas Souchu * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * */ #include __FBSDID("$FreeBSD$"); /* * General purpose routines for the IEEE1284-1994 Standard */ #include "opt_ppb_1284.h" #include #include #include #include #include #include #include #include "ppbus_if.h" #include #define DEVTOSOFTC(dev) ((struct ppb_data *)device_get_softc(dev)) /* * do_1284_wait() * * Wait for the peripherial up to 40ms */ static int -do_1284_wait(device_t bus, char mask, char status) +do_1284_wait(device_t bus, uint8_t mask, uint8_t status) { return (ppb_poll_bus(bus, 4, mask, status, PPB_NOINTR | PPB_POLL)); } static int -do_peripheral_wait(device_t bus, char mask, char status) +do_peripheral_wait(device_t bus, uint8_t mask, uint8_t status) { return (ppb_poll_bus(bus, 100, mask, status, PPB_NOINTR | PPB_POLL)); } #define nibble2char(s) (((s & ~nACK) >> 3) | (~s & nBUSY) >> 4) /* * ppb_1284_reset_error() * * Unconditionaly reset the error field */ static int ppb_1284_reset_error(device_t bus, int state) { struct ppb_data *ppb = DEVTOSOFTC(bus); ppb->error = PPB_NO_ERROR; ppb->state = state; return (0); } /* * ppb_1284_get_state() * * Get IEEE1284 state */ int ppb_1284_get_state(device_t bus) { struct ppb_data *ppb = DEVTOSOFTC(bus); mtx_assert(ppb->ppc_lock, MA_OWNED); return (ppb->state); } /* * ppb_1284_set_state() * * Change IEEE1284 state if no error occured */ int ppb_1284_set_state(device_t bus, int state) { struct ppb_data *ppb = DEVTOSOFTC(bus); /* call ppb_1284_reset_error() if you absolutly want to change * the state from PPB_ERROR to another */ mtx_assert(ppb->ppc_lock, MA_OWNED); if ((ppb->state != PPB_ERROR) && (ppb->error == PPB_NO_ERROR)) { ppb->state = state; ppb->error = PPB_NO_ERROR; } return (0); } static int ppb_1284_set_error(device_t bus, int error, int event) { struct ppb_data *ppb = DEVTOSOFTC(bus); /* do not accumulate errors */ if ((ppb->error == PPB_NO_ERROR) && (ppb->state != PPB_ERROR)) { ppb->error = error; ppb->state = PPB_ERROR; } #ifdef DEBUG_1284 printf("ppb1284: error=%d status=0x%x event=%d\n", error, ppb_rstr(bus) & 0xff, event); #endif return (0); } /* * ppb_request_mode() * * Converts mode+options into ext. value */ static int ppb_request_mode(int mode, int options) { int request_mode = 0; if (options & PPB_EXTENSIBILITY_LINK) { request_mode = EXT_LINK_1284_NORMAL; } else { switch (mode) { case PPB_NIBBLE: request_mode = (options & PPB_REQUEST_ID) ? NIBBLE_1284_REQUEST_ID : NIBBLE_1284_NORMAL; break; case PPB_PS2: request_mode = (options & PPB_REQUEST_ID) ? BYTE_1284_REQUEST_ID : BYTE_1284_NORMAL; break; case PPB_ECP: if (options & PPB_USE_RLE) request_mode = (options & PPB_REQUEST_ID) ? ECP_1284_RLE_REQUEST_ID : ECP_1284_RLE; else request_mode = (options & PPB_REQUEST_ID) ? ECP_1284_REQUEST_ID : ECP_1284_NORMAL; break; case PPB_EPP: request_mode = EPP_1284_NORMAL; break; default: panic("%s: unsupported mode %d\n", __func__, mode); } } return (request_mode); } /* * ppb_peripheral_negociate() * * Negociate the peripheral side */ int ppb_peripheral_negociate(device_t bus, int mode, int options) { int spin, request_mode, error = 0; char r; ppb_set_mode(bus, PPB_COMPATIBLE); ppb_1284_set_state(bus, PPB_PERIPHERAL_NEGOCIATION); /* compute ext. value */ request_mode = ppb_request_mode(mode, options); /* wait host */ spin = 10; while (spin-- && (ppb_rstr(bus) & nBUSY)) DELAY(1); /* check termination */ if (!(ppb_rstr(bus) & SELECT) || !spin) { error = ENODEV; goto error; } /* Event 4 - read ext. value */ r = ppb_rdtr(bus); /* nibble mode is not supported */ if ((r == (char)request_mode) || (r == NIBBLE_1284_NORMAL)) { /* Event 5 - restore direction bit, no data avail */ ppb_wctr(bus, (STROBE | nINIT) & ~(SELECTIN)); DELAY(1); /* Event 6 */ ppb_wctr(bus, (nINIT) & ~(SELECTIN | STROBE)); if (r == NIBBLE_1284_NORMAL) { #ifdef DEBUG_1284 printf("R"); #endif ppb_1284_set_error(bus, PPB_MODE_UNSUPPORTED, 4); error = EINVAL; goto error; } else { ppb_1284_set_state(bus, PPB_PERIPHERAL_IDLE); switch (r) { case BYTE_1284_NORMAL: ppb_set_mode(bus, PPB_BYTE); break; default: break; } #ifdef DEBUG_1284 printf("A"); #endif /* negociation succeeds */ } } else { /* Event 5 - mode not supported */ ppb_wctr(bus, SELECTIN); DELAY(1); /* Event 6 */ ppb_wctr(bus, (SELECTIN) & ~(STROBE | nINIT)); ppb_1284_set_error(bus, PPB_MODE_UNSUPPORTED, 4); #ifdef DEBUG_1284 printf("r"); #endif error = EINVAL; goto error; } return (0); error: ppb_peripheral_terminate(bus, PPB_WAIT); return (error); } /* * ppb_peripheral_terminate() * * Terminate peripheral transfer side * * Always return 0 in compatible mode */ int ppb_peripheral_terminate(device_t bus, int how) { int error = 0; #ifdef DEBUG_1284 printf("t"); #endif ppb_1284_set_state(bus, PPB_PERIPHERAL_TERMINATION); /* Event 22 - wait up to host response time (1s) */ if ((error = do_peripheral_wait(bus, SELECT | nBUSY, 0))) { ppb_1284_set_error(bus, PPB_TIMEOUT, 22); goto error; } /* Event 24 */ ppb_wctr(bus, (nINIT | STROBE) & ~(AUTOFEED | SELECTIN)); /* Event 25 - wait up to host response time (1s) */ if ((error = do_peripheral_wait(bus, nBUSY, nBUSY))) { ppb_1284_set_error(bus, PPB_TIMEOUT, 25); goto error; } /* Event 26 */ ppb_wctr(bus, (SELECTIN | nINIT | STROBE) & ~(AUTOFEED)); DELAY(1); /* Event 27 */ ppb_wctr(bus, (SELECTIN | nINIT) & ~(STROBE | AUTOFEED)); /* Event 28 - wait up to host response time (1s) */ if ((error = do_peripheral_wait(bus, nBUSY, 0))) { ppb_1284_set_error(bus, PPB_TIMEOUT, 28); goto error; } error: ppb_set_mode(bus, PPB_COMPATIBLE); ppb_1284_set_state(bus, PPB_FORWARD_IDLE); return (0); } /* * byte_peripheral_outbyte() * * Write 1 byte in BYTE mode */ static int byte_peripheral_outbyte(device_t bus, char *buffer, int last) { int error = 0; /* Event 7 */ if ((error = do_1284_wait(bus, nBUSY, nBUSY))) { ppb_1284_set_error(bus, PPB_TIMEOUT, 7); goto error; } /* check termination */ if (!(ppb_rstr(bus) & SELECT)) { ppb_peripheral_terminate(bus, PPB_WAIT); goto error; } /* Event 15 - put byte on data lines */ #ifdef DEBUG_1284 printf("B"); #endif ppb_wdtr(bus, *buffer); /* Event 9 */ ppb_wctr(bus, (AUTOFEED | STROBE) & ~(nINIT | SELECTIN)); /* Event 10 - wait data read */ if ((error = do_peripheral_wait(bus, nBUSY, 0))) { ppb_1284_set_error(bus, PPB_TIMEOUT, 16); goto error; } /* Event 11 */ if (!last) { ppb_wctr(bus, (AUTOFEED) & ~(nINIT | STROBE | SELECTIN)); } else { ppb_wctr(bus, (nINIT) & ~(STROBE | SELECTIN | AUTOFEED)); } #if 0 /* Event 16 - wait strobe */ if ((error = do_peripheral_wait(bus, nACK | nBUSY, 0))) { ppb_1284_set_error(bus, PPB_TIMEOUT, 16); goto error; } #endif /* check termination */ if (!(ppb_rstr(bus) & SELECT)) { ppb_peripheral_terminate(bus, PPB_WAIT); goto error; } error: return (error); } /* * byte_peripheral_write() * * Write n bytes in BYTE mode */ int byte_peripheral_write(device_t bus, char *buffer, int len, int *sent) { int error = 0, i; char r; ppb_1284_set_state(bus, PPB_PERIPHERAL_TRANSFER); /* wait forever, the remote host is master and should initiate * termination */ for (i=0; i= PPB_PERIPHERAL_NEGOCIATION) ppb_peripheral_terminate(bus, PPB_WAIT); if (ppb_1284_get_state(bus) != PPB_FORWARD_IDLE) ppb_1284_terminate(bus); #ifdef DEBUG_1284 printf("%d", mode); #endif /* ensure the host is in compatible mode */ ppb_set_mode(bus, PPB_COMPATIBLE); /* reset error to catch the actual negociation error */ ppb_1284_reset_error(bus, PPB_FORWARD_IDLE); /* calculate ext. value */ request_mode = ppb_request_mode(mode, options); /* default state */ ppb_wctr(bus, (nINIT | SELECTIN) & ~(STROBE | AUTOFEED)); DELAY(1); /* enter negociation phase */ ppb_1284_set_state(bus, PPB_NEGOCIATION); /* Event 0 - put the exten. value on the data lines */ ppb_wdtr(bus, request_mode); #ifdef PERIPH_1284 /* request remote host attention */ ppb_wctr(bus, (nINIT | STROBE) & ~(AUTOFEED | SELECTIN)); DELAY(1); ppb_wctr(bus, (nINIT) & ~(STROBE | AUTOFEED | SELECTIN)); #else DELAY(1); #endif /* !PERIPH_1284 */ /* Event 1 - enter IEEE1284 mode */ ppb_wctr(bus, (nINIT | AUTOFEED) & ~(STROBE | SELECTIN)); #ifdef PERIPH_1284 /* ignore the PError line, wait a bit more, remote host's * interrupts don't respond fast enough */ if (ppb_poll_bus(bus, 40, nACK | SELECT | nFAULT, SELECT | nFAULT, PPB_NOINTR | PPB_POLL)) { ppb_1284_set_error(bus, PPB_NOT_IEEE1284, 2); error = ENODEV; goto error; } #else /* Event 2 - trying IEEE1284 dialog */ if (do_1284_wait(bus, nACK | PERROR | SELECT | nFAULT, PERROR | SELECT | nFAULT)) { ppb_1284_set_error(bus, PPB_NOT_IEEE1284, 2); error = ENODEV; goto error; } #endif /* !PERIPH_1284 */ /* Event 3 - latch the ext. value to the peripheral */ ppb_wctr(bus, (nINIT | STROBE | AUTOFEED) & ~SELECTIN); DELAY(1); /* Event 4 - IEEE1284 device recognized */ ppb_wctr(bus, nINIT & ~(SELECTIN | AUTOFEED | STROBE)); /* Event 6 - waiting for status lines */ if (do_1284_wait(bus, nACK, nACK)) { ppb_1284_set_error(bus, PPB_TIMEOUT, 6); error = EBUSY; goto error; } /* Event 7 - quering result consider nACK not to misunderstand * a remote computer terminate sequence */ if (options & PPB_EXTENSIBILITY_LINK) { /* XXX not fully supported yet */ ppb_1284_terminate(bus); return (0); } if (request_mode == NIBBLE_1284_NORMAL) { if (do_1284_wait(bus, nACK | SELECT, nACK)) { ppb_1284_set_error(bus, PPB_MODE_UNSUPPORTED, 7); error = ENODEV; goto error; } } else { if (do_1284_wait(bus, nACK | SELECT, SELECT | nACK)) { ppb_1284_set_error(bus, PPB_MODE_UNSUPPORTED, 7); error = ENODEV; goto error; } } switch (mode) { case PPB_NIBBLE: case PPB_PS2: /* enter reverse idle phase */ ppb_1284_set_state(bus, PPB_REVERSE_IDLE); break; case PPB_ECP: /* negociation ok, now setup the communication */ ppb_1284_set_state(bus, PPB_SETUP); ppb_wctr(bus, (nINIT | AUTOFEED) & ~(SELECTIN | STROBE)); #ifdef PERIPH_1284 /* ignore PError line */ if (do_1284_wait(bus, nACK | SELECT | nBUSY, nACK | SELECT | nBUSY)) { ppb_1284_set_error(bus, PPB_TIMEOUT, 30); error = ENODEV; goto error; } #else if (do_1284_wait(bus, nACK | SELECT | PERROR | nBUSY, nACK | SELECT | PERROR | nBUSY)) { ppb_1284_set_error(bus, PPB_TIMEOUT, 30); error = ENODEV; goto error; } #endif /* !PERIPH_1284 */ /* ok, the host enters the ForwardIdle state */ ppb_1284_set_state(bus, PPB_ECP_FORWARD_IDLE); break; case PPB_EPP: ppb_1284_set_state(bus, PPB_EPP_IDLE); break; default: panic("%s: unknown mode (%d)!", __func__, mode); } ppb_set_mode(bus, mode); return (0); error: ppb_1284_terminate(bus); return (error); } /* * ppb_1284_terminate() * * IEEE1284 termination phase, return code should ignored since the host * is _always_ in compatible mode after ppb_1284_terminate() */ int ppb_1284_terminate(device_t bus) { #ifdef DEBUG_1284 printf("T"); #endif /* do not reset error here to keep the error that * may occured before the ppb_1284_terminate() call */ ppb_1284_set_state(bus, PPB_TERMINATION); #ifdef PERIPH_1284 /* request remote host attention */ ppb_wctr(bus, (nINIT | STROBE | SELECTIN) & ~(AUTOFEED)); DELAY(1); #endif /* PERIPH_1284 */ /* Event 22 - set nSelectin low and nAutoFeed high */ ppb_wctr(bus, (nINIT | SELECTIN) & ~(STROBE | AUTOFEED)); /* Event 24 - waiting for peripheral, Xflag ignored */ if (do_1284_wait(bus, nACK | nBUSY | nFAULT, nFAULT)) { ppb_1284_set_error(bus, PPB_TIMEOUT, 24); goto error; } /* Event 25 - set nAutoFd low */ ppb_wctr(bus, (nINIT | SELECTIN | AUTOFEED) & ~STROBE); /* Event 26 - compatible mode status is set */ /* Event 27 - peripheral set nAck high */ if (do_1284_wait(bus, nACK, nACK)) { ppb_1284_set_error(bus, PPB_TIMEOUT, 27); } /* Event 28 - end termination, return to idle phase */ ppb_wctr(bus, (nINIT | SELECTIN) & ~(STROBE | AUTOFEED)); error: /* return to compatible mode */ ppb_set_mode(bus, PPB_COMPATIBLE); ppb_1284_set_state(bus, PPB_FORWARD_IDLE); return (0); } Index: stable/10/sys/dev/ppbus/ppb_base.c =================================================================== --- stable/10/sys/dev/ppbus/ppb_base.c (revision 305554) +++ stable/10/sys/dev/ppbus/ppb_base.c (revision 305555) @@ -1,242 +1,242 @@ /*- * Copyright (c) 1997, 1998, 1999 Nicolas Souchu * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include "ppbus_if.h" #include MODULE_VERSION(ppbus, 1); #define DEVTOSOFTC(dev) ((struct ppb_data *)device_get_softc(dev)) /* * ppb_poll_bus() * * Polls the bus * * max is a delay in 10-milliseconds */ int ppb_poll_bus(device_t bus, int max, - char mask, char status, int how) + uint8_t mask, uint8_t status, int how) { struct ppb_data *ppb = DEVTOSOFTC(bus); int i, j, error; - char r; + uint8_t r; ppb_assert_locked(bus); /* try at least up to 10ms */ for (j = 0; j < ((how & PPB_POLL) ? max : 1); j++) { for (i = 0; i < 10000; i++) { r = ppb_rstr(bus); DELAY(1); if ((r & mask) == status) return (0); } } if (!(how & PPB_POLL)) { for (i = 0; max == PPB_FOREVER || i < max-1; i++) { if ((ppb_rstr(bus) & mask) == status) return (0); /* wait 10 ms */ error = mtx_sleep((caddr_t)bus, ppb->ppc_lock, PPBPRI | (how == PPB_NOINTR ? 0 : PCATCH), "ppbpoll", hz/100); if (error != EWOULDBLOCK) return (error); } } return (EWOULDBLOCK); } /* * ppb_get_epp_protocol() * * Return the chipset EPP protocol */ int ppb_get_epp_protocol(device_t bus) { uintptr_t protocol; ppb_assert_locked(bus); BUS_READ_IVAR(device_get_parent(bus), bus, PPC_IVAR_EPP_PROTO, &protocol); return (protocol); } /* * ppb_get_mode() * */ int ppb_get_mode(device_t bus) { struct ppb_data *ppb = DEVTOSOFTC(bus); /* XXX yet device mode = ppbus mode = chipset mode */ ppb_assert_locked(bus); return (ppb->mode); } /* * ppb_set_mode() * * Set the operating mode of the chipset, return the previous mode */ int ppb_set_mode(device_t bus, int mode) { struct ppb_data *ppb = DEVTOSOFTC(bus); int old_mode = ppb_get_mode(bus); ppb_assert_locked(bus); if (PPBUS_SETMODE(device_get_parent(bus), mode)) return (-1); /* XXX yet device mode = ppbus mode = chipset mode */ ppb->mode = (mode & PPB_MASK); return (old_mode); } /* * ppb_write() * * Write charaters to the port */ int ppb_write(device_t bus, char *buf, int len, int how) { ppb_assert_locked(bus); return (PPBUS_WRITE(device_get_parent(bus), buf, len, how)); } /* * ppb_reset_epp_timeout() * * Reset the EPP timeout bit in the status register */ int ppb_reset_epp_timeout(device_t bus) { ppb_assert_locked(bus); return(PPBUS_RESET_EPP(device_get_parent(bus))); } /* * ppb_ecp_sync() * * Wait for the ECP FIFO to be empty */ int ppb_ecp_sync(device_t bus) { ppb_assert_locked(bus); return (PPBUS_ECP_SYNC(device_get_parent(bus))); } /* * ppb_get_status() * * Read the status register and update the status info */ int ppb_get_status(device_t bus, struct ppb_status *status) { - register char r; + uint8_t r; ppb_assert_locked(bus); r = status->status = ppb_rstr(bus); status->timeout = r & TIMEOUT; status->error = !(r & nFAULT); status->select = r & SELECT; status->paper_end = r & PERROR; status->ack = !(r & nACK); status->busy = !(r & nBUSY); return (0); } void ppb_lock(device_t bus) { struct ppb_data *ppb = DEVTOSOFTC(bus); mtx_lock(ppb->ppc_lock); } void ppb_unlock(device_t bus) { struct ppb_data *ppb = DEVTOSOFTC(bus); mtx_unlock(ppb->ppc_lock); } void _ppb_assert_locked(device_t bus, const char *file, int line) { mtx_assert_(DEVTOSOFTC(bus)->ppc_lock, MA_OWNED, file, line); } void ppb_init_callout(device_t bus, struct callout *c, int flags) { struct ppb_data *ppb = DEVTOSOFTC(bus); callout_init_mtx(c, ppb->ppc_lock, flags); } int ppb_sleep(device_t bus, void *wchan, int priority, const char *wmesg, int timo) { struct ppb_data *ppb = DEVTOSOFTC(bus); return (mtx_sleep(wchan, ppb->ppc_lock, priority, wmesg, timo)); } Index: stable/10/sys/dev/ppbus/ppbconf.h =================================================================== --- stable/10/sys/dev/ppbus/ppbconf.h (revision 305554) +++ stable/10/sys/dev/ppbus/ppbconf.h (revision 305555) @@ -1,281 +1,281 @@ /*- * Copyright (c) 1997, 1998, 1999 Nicolas Souchu * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ * */ #ifndef __PPBCONF_H #define __PPBCONF_H #define n(flags) (~(flags) & (flags)) /* * Parallel Port Chipset control bits. */ #define STROBE 0x01 #define AUTOFEED 0x02 #define nINIT 0x04 #define SELECTIN 0x08 #define IRQENABLE 0x10 #define PCD 0x20 #define nSTROBE n(STROBE) #define nAUTOFEED n(AUTOFEED) #define INIT n(nINIT) #define nSELECTIN n(SELECTIN) #define nPCD n(PCD) /* * Parallel Port Chipset status bits. */ #define TIMEOUT 0x01 #define nFAULT 0x08 #define SELECT 0x10 #define PERROR 0x20 #define nACK 0x40 #define nBUSY 0x80 #ifdef _KERNEL #include /* * Parallel Port Bus sleep/wakeup queue. */ #define PPBPRI (PZERO+8) /* * Parallel Port Chipset mode masks. * NIBBLE mode is supposed to be available under each other modes. */ #define PPB_COMPATIBLE 0x0 /* Centronics compatible mode */ #define PPB_NIBBLE 0x1 /* reverse 4 bit mode */ #define PPB_PS2 0x2 /* PS/2 byte mode */ #define PPB_EPP 0x4 /* EPP mode, 32 bit */ #define PPB_ECP 0x8 /* ECP mode */ /* mode aliases */ #define PPB_SPP PPB_NIBBLE|PPB_PS2 #define PPB_BYTE PPB_PS2 #define PPB_MASK 0x0f #define PPB_OPTIONS_MASK 0xf0 #define PPB_IS_EPP(mode) (mode & PPB_EPP) #define PPB_IN_EPP_MODE(bus) (PPB_IS_EPP (ppb_get_mode (bus))) #define PPB_IN_NIBBLE_MODE(bus) (ppb_get_mode (bus) & PPB_NIBBLE) #define PPB_IN_PS2_MODE(bus) (ppb_get_mode (bus) & PPB_PS2) /* * Structure to store status information. */ struct ppb_status { unsigned char status; unsigned int timeout:1; unsigned int error:1; unsigned int select:1; unsigned int paper_end:1; unsigned int ack:1; unsigned int busy:1; }; /* Parallel port bus I/O opcodes */ #define PPB_OUTSB_EPP 1 #define PPB_OUTSW_EPP 2 #define PPB_OUTSL_EPP 3 #define PPB_INSB_EPP 4 #define PPB_INSW_EPP 5 #define PPB_INSL_EPP 6 #define PPB_RDTR 7 #define PPB_RSTR 8 #define PPB_RCTR 9 #define PPB_REPP_A 10 #define PPB_REPP_D 11 #define PPB_RECR 12 #define PPB_RFIFO 13 #define PPB_WDTR 14 #define PPB_WSTR 15 #define PPB_WCTR 16 #define PPB_WEPP_A 17 #define PPB_WEPP_D 18 #define PPB_WECR 19 #define PPB_WFIFO 20 /* * How tsleep() is called in ppb_request_bus(). */ #define PPB_DONTWAIT 0 #define PPB_NOINTR 0 #define PPB_WAIT 0x1 #define PPB_INTR 0x2 #define PPB_POLL 0x4 #define PPB_FOREVER -1 /* * Microsequence stuff. */ #define PPB_MS_MAXLEN 64 /* XXX according to MS_INS_MASK */ #define PPB_MS_MAXARGS 3 /* according to MS_ARG_MASK */ /* maximum number of mode dependent * submicrosequences for in/out operations */ #define PPB_MAX_XFER 6 union ppb_insarg { int i; void *p; char *c; int (* f)(void *, char *); }; struct ppb_microseq { int opcode; /* microins. opcode */ union ppb_insarg arg[PPB_MS_MAXARGS]; /* arguments */ }; /* microseqences used for GET/PUT operations */ struct ppb_xfer { struct ppb_microseq *loop; /* the loop microsequence */ }; /* * Parallel Port Bus Device structure. */ struct ppb_data; /* see below */ struct ppb_context { int valid; /* 1 if the struct is valid */ int mode; /* XXX chipset operating mode */ struct microseq *curpc; /* pc in curmsq */ struct microseq *curmsq; /* currently executed microseqence */ }; /* * List of IVARS available to ppb device drivers */ #define PPBUS_IVAR_MODE 0 /* other fields are reserved to the ppbus internals */ struct ppb_device { const char *name; /* name of the device */ u_int flags; /* flags */ struct ppb_context ctx; /* context of the device */ /* mode dependent get msq. If NULL, * IEEE1284 code is used */ struct ppb_xfer get_xfer[PPB_MAX_XFER]; /* mode dependent put msq. If NULL, * IEEE1284 code is used */ struct ppb_xfer put_xfer[PPB_MAX_XFER]; driver_intr_t *intr_hook; void *intr_arg; }; /* EPP standards */ #define EPP_1_9 0x0 /* default */ #define EPP_1_7 0x1 /* Parallel Port Chipset IVARS */ /* elsewhere XXX */ #define PPC_IVAR_EPP_PROTO 0 #define PPC_IVAR_LOCK 1 #define PPC_IVAR_INTR_HANDLER 2 /* * Maximum size of the PnP info string */ #define PPB_PnP_STRING_SIZE 256 /* XXX */ /* * Parallel Port Bus structure. */ struct ppb_data { #define PPB_PnP_PRINTER 0 #define PPB_PnP_MODEM 1 #define PPB_PnP_NET 2 #define PPB_PnP_HDC 3 #define PPB_PnP_PCMCIA 4 #define PPB_PnP_MEDIA 5 #define PPB_PnP_FDC 6 #define PPB_PnP_PORTS 7 #define PPB_PnP_SCANNER 8 #define PPB_PnP_DIGICAM 9 #define PPB_PnP_UNKNOWN 10 int class_id; /* not a PnP device if class_id < 0 */ int state; /* current IEEE1284 state */ int error; /* last IEEE1284 error */ int mode; /* IEEE 1284-1994 mode * NIBBLE, PS2, EPP or ECP */ device_t ppb_owner; /* device which owns the bus */ struct mtx *ppc_lock; /* lock of parent device */ struct resource *ppc_irq_res; }; struct callout; typedef int (*ppc_intr_handler)(void *); extern int ppb_attach_device(device_t); extern int ppb_request_bus(device_t, device_t, int); extern int ppb_release_bus(device_t, device_t); /* bus related functions */ extern void ppb_lock(device_t); extern void ppb_unlock(device_t); extern void _ppb_assert_locked(device_t, const char *, int); extern void ppb_init_callout(device_t, struct callout *, int); extern int ppb_sleep(device_t, void *, int, const char *, int); extern int ppb_get_status(device_t, struct ppb_status *); -extern int ppb_poll_bus(device_t, int, char, char, int); +extern int ppb_poll_bus(device_t, int, uint8_t, uint8_t, int); extern int ppb_reset_epp_timeout(device_t); extern int ppb_ecp_sync(device_t); extern int ppb_get_epp_protocol(device_t); extern int ppb_set_mode(device_t, int); /* returns old mode */ extern int ppb_get_mode(device_t); /* returns current mode */ extern int ppb_write(device_t, char *, int, int); #ifdef INVARIANTS #define ppb_assert_locked(dev) _ppb_assert_locked(dev, __FILE__, __LINE__) #else #define ppb_assert_locked(dev) #endif #endif /* _KERNEL */ #endif /* !__PPBCONF_H */ Index: stable/10 =================================================================== --- stable/10 (revision 305554) +++ stable/10 (revision 305555) Property changes on: stable/10 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r305345 Index: stable/11/sys/dev/ppbus/ppb_1284.c =================================================================== --- stable/11/sys/dev/ppbus/ppb_1284.c (revision 305554) +++ stable/11/sys/dev/ppbus/ppb_1284.c (revision 305555) @@ -1,865 +1,865 @@ /*- * Copyright (c) 1997 Nicolas Souchu * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * */ #include __FBSDID("$FreeBSD$"); /* * General purpose routines for the IEEE1284-1994 Standard */ #include "opt_ppb_1284.h" #include #include #include #include #include #include #include #include "ppbus_if.h" #include #define DEVTOSOFTC(dev) ((struct ppb_data *)device_get_softc(dev)) /* * do_1284_wait() * * Wait for the peripherial up to 40ms */ static int -do_1284_wait(device_t bus, char mask, char status) +do_1284_wait(device_t bus, uint8_t mask, uint8_t status) { return (ppb_poll_bus(bus, 4, mask, status, PPB_NOINTR | PPB_POLL)); } static int -do_peripheral_wait(device_t bus, char mask, char status) +do_peripheral_wait(device_t bus, uint8_t mask, uint8_t status) { return (ppb_poll_bus(bus, 100, mask, status, PPB_NOINTR | PPB_POLL)); } #define nibble2char(s) (((s & ~nACK) >> 3) | (~s & nBUSY) >> 4) /* * ppb_1284_reset_error() * * Unconditionaly reset the error field */ static int ppb_1284_reset_error(device_t bus, int state) { struct ppb_data *ppb = DEVTOSOFTC(bus); ppb->error = PPB_NO_ERROR; ppb->state = state; return (0); } /* * ppb_1284_get_state() * * Get IEEE1284 state */ int ppb_1284_get_state(device_t bus) { struct ppb_data *ppb = DEVTOSOFTC(bus); mtx_assert(ppb->ppc_lock, MA_OWNED); return (ppb->state); } /* * ppb_1284_set_state() * * Change IEEE1284 state if no error occurred */ int ppb_1284_set_state(device_t bus, int state) { struct ppb_data *ppb = DEVTOSOFTC(bus); /* call ppb_1284_reset_error() if you absolutely want to change * the state from PPB_ERROR to another */ mtx_assert(ppb->ppc_lock, MA_OWNED); if ((ppb->state != PPB_ERROR) && (ppb->error == PPB_NO_ERROR)) { ppb->state = state; ppb->error = PPB_NO_ERROR; } return (0); } static int ppb_1284_set_error(device_t bus, int error, int event) { struct ppb_data *ppb = DEVTOSOFTC(bus); /* do not accumulate errors */ if ((ppb->error == PPB_NO_ERROR) && (ppb->state != PPB_ERROR)) { ppb->error = error; ppb->state = PPB_ERROR; } #ifdef DEBUG_1284 printf("ppb1284: error=%d status=0x%x event=%d\n", error, ppb_rstr(bus) & 0xff, event); #endif return (0); } /* * ppb_request_mode() * * Converts mode+options into ext. value */ static int ppb_request_mode(int mode, int options) { int request_mode = 0; if (options & PPB_EXTENSIBILITY_LINK) { request_mode = EXT_LINK_1284_NORMAL; } else { switch (mode) { case PPB_NIBBLE: request_mode = (options & PPB_REQUEST_ID) ? NIBBLE_1284_REQUEST_ID : NIBBLE_1284_NORMAL; break; case PPB_PS2: request_mode = (options & PPB_REQUEST_ID) ? BYTE_1284_REQUEST_ID : BYTE_1284_NORMAL; break; case PPB_ECP: if (options & PPB_USE_RLE) request_mode = (options & PPB_REQUEST_ID) ? ECP_1284_RLE_REQUEST_ID : ECP_1284_RLE; else request_mode = (options & PPB_REQUEST_ID) ? ECP_1284_REQUEST_ID : ECP_1284_NORMAL; break; case PPB_EPP: request_mode = EPP_1284_NORMAL; break; default: panic("%s: unsupported mode %d\n", __func__, mode); } } return (request_mode); } /* * ppb_peripheral_negociate() * * Negotiate the peripheral side */ int ppb_peripheral_negociate(device_t bus, int mode, int options) { int spin, request_mode, error = 0; char r; ppb_set_mode(bus, PPB_COMPATIBLE); ppb_1284_set_state(bus, PPB_PERIPHERAL_NEGOCIATION); /* compute ext. value */ request_mode = ppb_request_mode(mode, options); /* wait host */ spin = 10; while (spin-- && (ppb_rstr(bus) & nBUSY)) DELAY(1); /* check termination */ if (!(ppb_rstr(bus) & SELECT) || !spin) { error = ENODEV; goto error; } /* Event 4 - read ext. value */ r = ppb_rdtr(bus); /* nibble mode is not supported */ if ((r == (char)request_mode) || (r == NIBBLE_1284_NORMAL)) { /* Event 5 - restore direction bit, no data avail */ ppb_wctr(bus, (STROBE | nINIT) & ~(SELECTIN)); DELAY(1); /* Event 6 */ ppb_wctr(bus, (nINIT) & ~(SELECTIN | STROBE)); if (r == NIBBLE_1284_NORMAL) { #ifdef DEBUG_1284 printf("R"); #endif ppb_1284_set_error(bus, PPB_MODE_UNSUPPORTED, 4); error = EINVAL; goto error; } else { ppb_1284_set_state(bus, PPB_PERIPHERAL_IDLE); switch (r) { case BYTE_1284_NORMAL: ppb_set_mode(bus, PPB_BYTE); break; default: break; } #ifdef DEBUG_1284 printf("A"); #endif /* negotiation succeeds */ } } else { /* Event 5 - mode not supported */ ppb_wctr(bus, SELECTIN); DELAY(1); /* Event 6 */ ppb_wctr(bus, (SELECTIN) & ~(STROBE | nINIT)); ppb_1284_set_error(bus, PPB_MODE_UNSUPPORTED, 4); #ifdef DEBUG_1284 printf("r"); #endif error = EINVAL; goto error; } return (0); error: ppb_peripheral_terminate(bus, PPB_WAIT); return (error); } /* * ppb_peripheral_terminate() * * Terminate peripheral transfer side * * Always return 0 in compatible mode */ int ppb_peripheral_terminate(device_t bus, int how) { int error = 0; #ifdef DEBUG_1284 printf("t"); #endif ppb_1284_set_state(bus, PPB_PERIPHERAL_TERMINATION); /* Event 22 - wait up to host response time (1s) */ if ((error = do_peripheral_wait(bus, SELECT | nBUSY, 0))) { ppb_1284_set_error(bus, PPB_TIMEOUT, 22); goto error; } /* Event 24 */ ppb_wctr(bus, (nINIT | STROBE) & ~(AUTOFEED | SELECTIN)); /* Event 25 - wait up to host response time (1s) */ if ((error = do_peripheral_wait(bus, nBUSY, nBUSY))) { ppb_1284_set_error(bus, PPB_TIMEOUT, 25); goto error; } /* Event 26 */ ppb_wctr(bus, (SELECTIN | nINIT | STROBE) & ~(AUTOFEED)); DELAY(1); /* Event 27 */ ppb_wctr(bus, (SELECTIN | nINIT) & ~(STROBE | AUTOFEED)); /* Event 28 - wait up to host response time (1s) */ if ((error = do_peripheral_wait(bus, nBUSY, 0))) { ppb_1284_set_error(bus, PPB_TIMEOUT, 28); goto error; } error: ppb_set_mode(bus, PPB_COMPATIBLE); ppb_1284_set_state(bus, PPB_FORWARD_IDLE); return (0); } /* * byte_peripheral_outbyte() * * Write 1 byte in BYTE mode */ static int byte_peripheral_outbyte(device_t bus, char *buffer, int last) { int error = 0; /* Event 7 */ if ((error = do_1284_wait(bus, nBUSY, nBUSY))) { ppb_1284_set_error(bus, PPB_TIMEOUT, 7); goto error; } /* check termination */ if (!(ppb_rstr(bus) & SELECT)) { ppb_peripheral_terminate(bus, PPB_WAIT); goto error; } /* Event 15 - put byte on data lines */ #ifdef DEBUG_1284 printf("B"); #endif ppb_wdtr(bus, *buffer); /* Event 9 */ ppb_wctr(bus, (AUTOFEED | STROBE) & ~(nINIT | SELECTIN)); /* Event 10 - wait data read */ if ((error = do_peripheral_wait(bus, nBUSY, 0))) { ppb_1284_set_error(bus, PPB_TIMEOUT, 16); goto error; } /* Event 11 */ if (!last) { ppb_wctr(bus, (AUTOFEED) & ~(nINIT | STROBE | SELECTIN)); } else { ppb_wctr(bus, (nINIT) & ~(STROBE | SELECTIN | AUTOFEED)); } #if 0 /* Event 16 - wait strobe */ if ((error = do_peripheral_wait(bus, nACK | nBUSY, 0))) { ppb_1284_set_error(bus, PPB_TIMEOUT, 16); goto error; } #endif /* check termination */ if (!(ppb_rstr(bus) & SELECT)) { ppb_peripheral_terminate(bus, PPB_WAIT); goto error; } error: return (error); } /* * byte_peripheral_write() * * Write n bytes in BYTE mode */ int byte_peripheral_write(device_t bus, char *buffer, int len, int *sent) { int error = 0, i; char r; ppb_1284_set_state(bus, PPB_PERIPHERAL_TRANSFER); /* wait forever, the remote host is master and should initiate * termination */ for (i=0; i= PPB_PERIPHERAL_NEGOCIATION) ppb_peripheral_terminate(bus, PPB_WAIT); if (ppb_1284_get_state(bus) != PPB_FORWARD_IDLE) ppb_1284_terminate(bus); #ifdef DEBUG_1284 printf("%d", mode); #endif /* ensure the host is in compatible mode */ ppb_set_mode(bus, PPB_COMPATIBLE); /* reset error to catch the actual negotiation error */ ppb_1284_reset_error(bus, PPB_FORWARD_IDLE); /* calculate ext. value */ request_mode = ppb_request_mode(mode, options); /* default state */ ppb_wctr(bus, (nINIT | SELECTIN) & ~(STROBE | AUTOFEED)); DELAY(1); /* enter negotiation phase */ ppb_1284_set_state(bus, PPB_NEGOCIATION); /* Event 0 - put the exten. value on the data lines */ ppb_wdtr(bus, request_mode); #ifdef PERIPH_1284 /* request remote host attention */ ppb_wctr(bus, (nINIT | STROBE) & ~(AUTOFEED | SELECTIN)); DELAY(1); ppb_wctr(bus, (nINIT) & ~(STROBE | AUTOFEED | SELECTIN)); #else DELAY(1); #endif /* !PERIPH_1284 */ /* Event 1 - enter IEEE1284 mode */ ppb_wctr(bus, (nINIT | AUTOFEED) & ~(STROBE | SELECTIN)); #ifdef PERIPH_1284 /* ignore the PError line, wait a bit more, remote host's * interrupts don't respond fast enough */ if (ppb_poll_bus(bus, 40, nACK | SELECT | nFAULT, SELECT | nFAULT, PPB_NOINTR | PPB_POLL)) { ppb_1284_set_error(bus, PPB_NOT_IEEE1284, 2); error = ENODEV; goto error; } #else /* Event 2 - trying IEEE1284 dialog */ if (do_1284_wait(bus, nACK | PERROR | SELECT | nFAULT, PERROR | SELECT | nFAULT)) { ppb_1284_set_error(bus, PPB_NOT_IEEE1284, 2); error = ENODEV; goto error; } #endif /* !PERIPH_1284 */ /* Event 3 - latch the ext. value to the peripheral */ ppb_wctr(bus, (nINIT | STROBE | AUTOFEED) & ~SELECTIN); DELAY(1); /* Event 4 - IEEE1284 device recognized */ ppb_wctr(bus, nINIT & ~(SELECTIN | AUTOFEED | STROBE)); /* Event 6 - waiting for status lines */ if (do_1284_wait(bus, nACK, nACK)) { ppb_1284_set_error(bus, PPB_TIMEOUT, 6); error = EBUSY; goto error; } /* Event 7 - quering result consider nACK not to misunderstand * a remote computer terminate sequence */ if (options & PPB_EXTENSIBILITY_LINK) { /* XXX not fully supported yet */ ppb_1284_terminate(bus); return (0); } if (request_mode == NIBBLE_1284_NORMAL) { if (do_1284_wait(bus, nACK | SELECT, nACK)) { ppb_1284_set_error(bus, PPB_MODE_UNSUPPORTED, 7); error = ENODEV; goto error; } } else { if (do_1284_wait(bus, nACK | SELECT, SELECT | nACK)) { ppb_1284_set_error(bus, PPB_MODE_UNSUPPORTED, 7); error = ENODEV; goto error; } } switch (mode) { case PPB_NIBBLE: case PPB_PS2: /* enter reverse idle phase */ ppb_1284_set_state(bus, PPB_REVERSE_IDLE); break; case PPB_ECP: /* negotiation ok, now setup the communication */ ppb_1284_set_state(bus, PPB_SETUP); ppb_wctr(bus, (nINIT | AUTOFEED) & ~(SELECTIN | STROBE)); #ifdef PERIPH_1284 /* ignore PError line */ if (do_1284_wait(bus, nACK | SELECT | nBUSY, nACK | SELECT | nBUSY)) { ppb_1284_set_error(bus, PPB_TIMEOUT, 30); error = ENODEV; goto error; } #else if (do_1284_wait(bus, nACK | SELECT | PERROR | nBUSY, nACK | SELECT | PERROR | nBUSY)) { ppb_1284_set_error(bus, PPB_TIMEOUT, 30); error = ENODEV; goto error; } #endif /* !PERIPH_1284 */ /* ok, the host enters the ForwardIdle state */ ppb_1284_set_state(bus, PPB_ECP_FORWARD_IDLE); break; case PPB_EPP: ppb_1284_set_state(bus, PPB_EPP_IDLE); break; default: panic("%s: unknown mode (%d)!", __func__, mode); } ppb_set_mode(bus, mode); return (0); error: ppb_1284_terminate(bus); return (error); } /* * ppb_1284_terminate() * * IEEE1284 termination phase, return code should ignored since the host * is _always_ in compatible mode after ppb_1284_terminate() */ int ppb_1284_terminate(device_t bus) { #ifdef DEBUG_1284 printf("T"); #endif /* do not reset error here to keep the error that * may occurred before the ppb_1284_terminate() call */ ppb_1284_set_state(bus, PPB_TERMINATION); #ifdef PERIPH_1284 /* request remote host attention */ ppb_wctr(bus, (nINIT | STROBE | SELECTIN) & ~(AUTOFEED)); DELAY(1); #endif /* PERIPH_1284 */ /* Event 22 - set nSelectin low and nAutoFeed high */ ppb_wctr(bus, (nINIT | SELECTIN) & ~(STROBE | AUTOFEED)); /* Event 24 - waiting for peripheral, Xflag ignored */ if (do_1284_wait(bus, nACK | nBUSY | nFAULT, nFAULT)) { ppb_1284_set_error(bus, PPB_TIMEOUT, 24); goto error; } /* Event 25 - set nAutoFd low */ ppb_wctr(bus, (nINIT | SELECTIN | AUTOFEED) & ~STROBE); /* Event 26 - compatible mode status is set */ /* Event 27 - peripheral set nAck high */ if (do_1284_wait(bus, nACK, nACK)) { ppb_1284_set_error(bus, PPB_TIMEOUT, 27); } /* Event 28 - end termination, return to idle phase */ ppb_wctr(bus, (nINIT | SELECTIN) & ~(STROBE | AUTOFEED)); error: /* return to compatible mode */ ppb_set_mode(bus, PPB_COMPATIBLE); ppb_1284_set_state(bus, PPB_FORWARD_IDLE); return (0); } Index: stable/11/sys/dev/ppbus/ppb_base.c =================================================================== --- stable/11/sys/dev/ppbus/ppb_base.c (revision 305554) +++ stable/11/sys/dev/ppbus/ppb_base.c (revision 305555) @@ -1,242 +1,242 @@ /*- * Copyright (c) 1997, 1998, 1999 Nicolas Souchu * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include "ppbus_if.h" #include MODULE_VERSION(ppbus, 1); #define DEVTOSOFTC(dev) ((struct ppb_data *)device_get_softc(dev)) /* * ppb_poll_bus() * * Polls the bus * * max is a delay in 10-milliseconds */ int ppb_poll_bus(device_t bus, int max, - char mask, char status, int how) + uint8_t mask, uint8_t status, int how) { struct ppb_data *ppb = DEVTOSOFTC(bus); int i, j, error; - char r; + uint8_t r; ppb_assert_locked(bus); /* try at least up to 10ms */ for (j = 0; j < ((how & PPB_POLL) ? max : 1); j++) { for (i = 0; i < 10000; i++) { r = ppb_rstr(bus); DELAY(1); if ((r & mask) == status) return (0); } } if (!(how & PPB_POLL)) { for (i = 0; max == PPB_FOREVER || i < max-1; i++) { if ((ppb_rstr(bus) & mask) == status) return (0); /* wait 10 ms */ error = mtx_sleep((caddr_t)bus, ppb->ppc_lock, PPBPRI | (how == PPB_NOINTR ? 0 : PCATCH), "ppbpoll", hz/100); if (error != EWOULDBLOCK) return (error); } } return (EWOULDBLOCK); } /* * ppb_get_epp_protocol() * * Return the chipset EPP protocol */ int ppb_get_epp_protocol(device_t bus) { uintptr_t protocol; ppb_assert_locked(bus); BUS_READ_IVAR(device_get_parent(bus), bus, PPC_IVAR_EPP_PROTO, &protocol); return (protocol); } /* * ppb_get_mode() * */ int ppb_get_mode(device_t bus) { struct ppb_data *ppb = DEVTOSOFTC(bus); /* XXX yet device mode = ppbus mode = chipset mode */ ppb_assert_locked(bus); return (ppb->mode); } /* * ppb_set_mode() * * Set the operating mode of the chipset, return the previous mode */ int ppb_set_mode(device_t bus, int mode) { struct ppb_data *ppb = DEVTOSOFTC(bus); int old_mode = ppb_get_mode(bus); ppb_assert_locked(bus); if (PPBUS_SETMODE(device_get_parent(bus), mode)) return (-1); /* XXX yet device mode = ppbus mode = chipset mode */ ppb->mode = (mode & PPB_MASK); return (old_mode); } /* * ppb_write() * * Write charaters to the port */ int ppb_write(device_t bus, char *buf, int len, int how) { ppb_assert_locked(bus); return (PPBUS_WRITE(device_get_parent(bus), buf, len, how)); } /* * ppb_reset_epp_timeout() * * Reset the EPP timeout bit in the status register */ int ppb_reset_epp_timeout(device_t bus) { ppb_assert_locked(bus); return(PPBUS_RESET_EPP(device_get_parent(bus))); } /* * ppb_ecp_sync() * * Wait for the ECP FIFO to be empty */ int ppb_ecp_sync(device_t bus) { ppb_assert_locked(bus); return (PPBUS_ECP_SYNC(device_get_parent(bus))); } /* * ppb_get_status() * * Read the status register and update the status info */ int ppb_get_status(device_t bus, struct ppb_status *status) { - register char r; + uint8_t r; ppb_assert_locked(bus); r = status->status = ppb_rstr(bus); status->timeout = r & TIMEOUT; status->error = !(r & nFAULT); status->select = r & SELECT; status->paper_end = r & PERROR; status->ack = !(r & nACK); status->busy = !(r & nBUSY); return (0); } void ppb_lock(device_t bus) { struct ppb_data *ppb = DEVTOSOFTC(bus); mtx_lock(ppb->ppc_lock); } void ppb_unlock(device_t bus) { struct ppb_data *ppb = DEVTOSOFTC(bus); mtx_unlock(ppb->ppc_lock); } void _ppb_assert_locked(device_t bus, const char *file, int line) { mtx_assert_(DEVTOSOFTC(bus)->ppc_lock, MA_OWNED, file, line); } void ppb_init_callout(device_t bus, struct callout *c, int flags) { struct ppb_data *ppb = DEVTOSOFTC(bus); callout_init_mtx(c, ppb->ppc_lock, flags); } int ppb_sleep(device_t bus, void *wchan, int priority, const char *wmesg, int timo) { struct ppb_data *ppb = DEVTOSOFTC(bus); return (mtx_sleep(wchan, ppb->ppc_lock, priority, wmesg, timo)); } Index: stable/11/sys/dev/ppbus/ppbconf.h =================================================================== --- stable/11/sys/dev/ppbus/ppbconf.h (revision 305554) +++ stable/11/sys/dev/ppbus/ppbconf.h (revision 305555) @@ -1,281 +1,281 @@ /*- * Copyright (c) 1997, 1998, 1999 Nicolas Souchu * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ * */ #ifndef __PPBCONF_H #define __PPBCONF_H #define n(flags) (~(flags) & (flags)) /* * Parallel Port Chipset control bits. */ #define STROBE 0x01 #define AUTOFEED 0x02 #define nINIT 0x04 #define SELECTIN 0x08 #define IRQENABLE 0x10 #define PCD 0x20 #define nSTROBE n(STROBE) #define nAUTOFEED n(AUTOFEED) #define INIT n(nINIT) #define nSELECTIN n(SELECTIN) #define nPCD n(PCD) /* * Parallel Port Chipset status bits. */ #define TIMEOUT 0x01 #define nFAULT 0x08 #define SELECT 0x10 #define PERROR 0x20 #define nACK 0x40 #define nBUSY 0x80 #ifdef _KERNEL #include /* * Parallel Port Bus sleep/wakeup queue. */ #define PPBPRI (PZERO+8) /* * Parallel Port Chipset mode masks. * NIBBLE mode is supposed to be available under each other modes. */ #define PPB_COMPATIBLE 0x0 /* Centronics compatible mode */ #define PPB_NIBBLE 0x1 /* reverse 4 bit mode */ #define PPB_PS2 0x2 /* PS/2 byte mode */ #define PPB_EPP 0x4 /* EPP mode, 32 bit */ #define PPB_ECP 0x8 /* ECP mode */ /* mode aliases */ #define PPB_SPP PPB_NIBBLE|PPB_PS2 #define PPB_BYTE PPB_PS2 #define PPB_MASK 0x0f #define PPB_OPTIONS_MASK 0xf0 #define PPB_IS_EPP(mode) (mode & PPB_EPP) #define PPB_IN_EPP_MODE(bus) (PPB_IS_EPP (ppb_get_mode (bus))) #define PPB_IN_NIBBLE_MODE(bus) (ppb_get_mode (bus) & PPB_NIBBLE) #define PPB_IN_PS2_MODE(bus) (ppb_get_mode (bus) & PPB_PS2) /* * Structure to store status information. */ struct ppb_status { unsigned char status; unsigned int timeout:1; unsigned int error:1; unsigned int select:1; unsigned int paper_end:1; unsigned int ack:1; unsigned int busy:1; }; /* Parallel port bus I/O opcodes */ #define PPB_OUTSB_EPP 1 #define PPB_OUTSW_EPP 2 #define PPB_OUTSL_EPP 3 #define PPB_INSB_EPP 4 #define PPB_INSW_EPP 5 #define PPB_INSL_EPP 6 #define PPB_RDTR 7 #define PPB_RSTR 8 #define PPB_RCTR 9 #define PPB_REPP_A 10 #define PPB_REPP_D 11 #define PPB_RECR 12 #define PPB_RFIFO 13 #define PPB_WDTR 14 #define PPB_WSTR 15 #define PPB_WCTR 16 #define PPB_WEPP_A 17 #define PPB_WEPP_D 18 #define PPB_WECR 19 #define PPB_WFIFO 20 /* * How tsleep() is called in ppb_request_bus(). */ #define PPB_DONTWAIT 0 #define PPB_NOINTR 0 #define PPB_WAIT 0x1 #define PPB_INTR 0x2 #define PPB_POLL 0x4 #define PPB_FOREVER -1 /* * Microsequence stuff. */ #define PPB_MS_MAXLEN 64 /* XXX according to MS_INS_MASK */ #define PPB_MS_MAXARGS 3 /* according to MS_ARG_MASK */ /* maximum number of mode dependent * submicrosequences for in/out operations */ #define PPB_MAX_XFER 6 union ppb_insarg { int i; void *p; char *c; int (* f)(void *, char *); }; struct ppb_microseq { int opcode; /* microins. opcode */ union ppb_insarg arg[PPB_MS_MAXARGS]; /* arguments */ }; /* microseqences used for GET/PUT operations */ struct ppb_xfer { struct ppb_microseq *loop; /* the loop microsequence */ }; /* * Parallel Port Bus Device structure. */ struct ppb_data; /* see below */ struct ppb_context { int valid; /* 1 if the struct is valid */ int mode; /* XXX chipset operating mode */ struct microseq *curpc; /* pc in curmsq */ struct microseq *curmsq; /* currently executed microseqence */ }; /* * List of IVARS available to ppb device drivers */ #define PPBUS_IVAR_MODE 0 /* other fields are reserved to the ppbus internals */ struct ppb_device { const char *name; /* name of the device */ u_int flags; /* flags */ struct ppb_context ctx; /* context of the device */ /* mode dependent get msq. If NULL, * IEEE1284 code is used */ struct ppb_xfer get_xfer[PPB_MAX_XFER]; /* mode dependent put msq. If NULL, * IEEE1284 code is used */ struct ppb_xfer put_xfer[PPB_MAX_XFER]; driver_intr_t *intr_hook; void *intr_arg; }; /* EPP standards */ #define EPP_1_9 0x0 /* default */ #define EPP_1_7 0x1 /* Parallel Port Chipset IVARS */ /* elsewhere XXX */ #define PPC_IVAR_EPP_PROTO 0 #define PPC_IVAR_LOCK 1 #define PPC_IVAR_INTR_HANDLER 2 /* * Maximum size of the PnP info string */ #define PPB_PnP_STRING_SIZE 256 /* XXX */ /* * Parallel Port Bus structure. */ struct ppb_data { #define PPB_PnP_PRINTER 0 #define PPB_PnP_MODEM 1 #define PPB_PnP_NET 2 #define PPB_PnP_HDC 3 #define PPB_PnP_PCMCIA 4 #define PPB_PnP_MEDIA 5 #define PPB_PnP_FDC 6 #define PPB_PnP_PORTS 7 #define PPB_PnP_SCANNER 8 #define PPB_PnP_DIGICAM 9 #define PPB_PnP_UNKNOWN 10 int class_id; /* not a PnP device if class_id < 0 */ int state; /* current IEEE1284 state */ int error; /* last IEEE1284 error */ int mode; /* IEEE 1284-1994 mode * NIBBLE, PS2, EPP or ECP */ device_t ppb_owner; /* device which owns the bus */ struct mtx *ppc_lock; /* lock of parent device */ struct resource *ppc_irq_res; }; struct callout; typedef int (*ppc_intr_handler)(void *); extern int ppb_attach_device(device_t); extern int ppb_request_bus(device_t, device_t, int); extern int ppb_release_bus(device_t, device_t); /* bus related functions */ extern void ppb_lock(device_t); extern void ppb_unlock(device_t); extern void _ppb_assert_locked(device_t, const char *, int); extern void ppb_init_callout(device_t, struct callout *, int); extern int ppb_sleep(device_t, void *, int, const char *, int); extern int ppb_get_status(device_t, struct ppb_status *); -extern int ppb_poll_bus(device_t, int, char, char, int); +extern int ppb_poll_bus(device_t, int, uint8_t, uint8_t, int); extern int ppb_reset_epp_timeout(device_t); extern int ppb_ecp_sync(device_t); extern int ppb_get_epp_protocol(device_t); extern int ppb_set_mode(device_t, int); /* returns old mode */ extern int ppb_get_mode(device_t); /* returns current mode */ extern int ppb_write(device_t, char *, int, int); #ifdef INVARIANTS #define ppb_assert_locked(dev) _ppb_assert_locked(dev, __FILE__, __LINE__) #else #define ppb_assert_locked(dev) #endif #endif /* _KERNEL */ #endif /* !__PPBCONF_H */ Index: stable/11 =================================================================== --- stable/11 (revision 305554) +++ stable/11 (revision 305555) Property changes on: stable/11 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r305345 Index: stable/9/sys/dev/ppbus/ppb_1284.c =================================================================== --- stable/9/sys/dev/ppbus/ppb_1284.c (revision 305554) +++ stable/9/sys/dev/ppbus/ppb_1284.c (revision 305555) @@ -1,865 +1,865 @@ /*- * Copyright (c) 1997 Nicolas Souchu * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * */ #include __FBSDID("$FreeBSD$"); /* * General purpose routines for the IEEE1284-1994 Standard */ #include "opt_ppb_1284.h" #include #include #include #include #include #include #include #include "ppbus_if.h" #include #define DEVTOSOFTC(dev) ((struct ppb_data *)device_get_softc(dev)) /* * do_1284_wait() * * Wait for the peripherial up to 40ms */ static int -do_1284_wait(device_t bus, char mask, char status) +do_1284_wait(device_t bus, uint8_t mask, uint8_t status) { return (ppb_poll_bus(bus, 4, mask, status, PPB_NOINTR | PPB_POLL)); } static int -do_peripheral_wait(device_t bus, char mask, char status) +do_peripheral_wait(device_t bus, uint8_t mask, uint8_t status) { return (ppb_poll_bus(bus, 100, mask, status, PPB_NOINTR | PPB_POLL)); } #define nibble2char(s) (((s & ~nACK) >> 3) | (~s & nBUSY) >> 4) /* * ppb_1284_reset_error() * * Unconditionaly reset the error field */ static int ppb_1284_reset_error(device_t bus, int state) { struct ppb_data *ppb = DEVTOSOFTC(bus); ppb->error = PPB_NO_ERROR; ppb->state = state; return (0); } /* * ppb_1284_get_state() * * Get IEEE1284 state */ int ppb_1284_get_state(device_t bus) { struct ppb_data *ppb = DEVTOSOFTC(bus); mtx_assert(ppb->ppc_lock, MA_OWNED); return (ppb->state); } /* * ppb_1284_set_state() * * Change IEEE1284 state if no error occured */ int ppb_1284_set_state(device_t bus, int state) { struct ppb_data *ppb = DEVTOSOFTC(bus); /* call ppb_1284_reset_error() if you absolutly want to change * the state from PPB_ERROR to another */ mtx_assert(ppb->ppc_lock, MA_OWNED); if ((ppb->state != PPB_ERROR) && (ppb->error == PPB_NO_ERROR)) { ppb->state = state; ppb->error = PPB_NO_ERROR; } return (0); } static int ppb_1284_set_error(device_t bus, int error, int event) { struct ppb_data *ppb = DEVTOSOFTC(bus); /* do not accumulate errors */ if ((ppb->error == PPB_NO_ERROR) && (ppb->state != PPB_ERROR)) { ppb->error = error; ppb->state = PPB_ERROR; } #ifdef DEBUG_1284 printf("ppb1284: error=%d status=0x%x event=%d\n", error, ppb_rstr(bus) & 0xff, event); #endif return (0); } /* * ppb_request_mode() * * Converts mode+options into ext. value */ static int ppb_request_mode(int mode, int options) { int request_mode = 0; if (options & PPB_EXTENSIBILITY_LINK) { request_mode = EXT_LINK_1284_NORMAL; } else { switch (mode) { case PPB_NIBBLE: request_mode = (options & PPB_REQUEST_ID) ? NIBBLE_1284_REQUEST_ID : NIBBLE_1284_NORMAL; break; case PPB_PS2: request_mode = (options & PPB_REQUEST_ID) ? BYTE_1284_REQUEST_ID : BYTE_1284_NORMAL; break; case PPB_ECP: if (options & PPB_USE_RLE) request_mode = (options & PPB_REQUEST_ID) ? ECP_1284_RLE_REQUEST_ID : ECP_1284_RLE; else request_mode = (options & PPB_REQUEST_ID) ? ECP_1284_REQUEST_ID : ECP_1284_NORMAL; break; case PPB_EPP: request_mode = EPP_1284_NORMAL; break; default: panic("%s: unsupported mode %d\n", __func__, mode); } } return (request_mode); } /* * ppb_peripheral_negociate() * * Negociate the peripheral side */ int ppb_peripheral_negociate(device_t bus, int mode, int options) { int spin, request_mode, error = 0; char r; ppb_set_mode(bus, PPB_COMPATIBLE); ppb_1284_set_state(bus, PPB_PERIPHERAL_NEGOCIATION); /* compute ext. value */ request_mode = ppb_request_mode(mode, options); /* wait host */ spin = 10; while (spin-- && (ppb_rstr(bus) & nBUSY)) DELAY(1); /* check termination */ if (!(ppb_rstr(bus) & SELECT) || !spin) { error = ENODEV; goto error; } /* Event 4 - read ext. value */ r = ppb_rdtr(bus); /* nibble mode is not supported */ if ((r == (char)request_mode) || (r == NIBBLE_1284_NORMAL)) { /* Event 5 - restore direction bit, no data avail */ ppb_wctr(bus, (STROBE | nINIT) & ~(SELECTIN)); DELAY(1); /* Event 6 */ ppb_wctr(bus, (nINIT) & ~(SELECTIN | STROBE)); if (r == NIBBLE_1284_NORMAL) { #ifdef DEBUG_1284 printf("R"); #endif ppb_1284_set_error(bus, PPB_MODE_UNSUPPORTED, 4); error = EINVAL; goto error; } else { ppb_1284_set_state(bus, PPB_PERIPHERAL_IDLE); switch (r) { case BYTE_1284_NORMAL: ppb_set_mode(bus, PPB_BYTE); break; default: break; } #ifdef DEBUG_1284 printf("A"); #endif /* negociation succeeds */ } } else { /* Event 5 - mode not supported */ ppb_wctr(bus, SELECTIN); DELAY(1); /* Event 6 */ ppb_wctr(bus, (SELECTIN) & ~(STROBE | nINIT)); ppb_1284_set_error(bus, PPB_MODE_UNSUPPORTED, 4); #ifdef DEBUG_1284 printf("r"); #endif error = EINVAL; goto error; } return (0); error: ppb_peripheral_terminate(bus, PPB_WAIT); return (error); } /* * ppb_peripheral_terminate() * * Terminate peripheral transfer side * * Always return 0 in compatible mode */ int ppb_peripheral_terminate(device_t bus, int how) { int error = 0; #ifdef DEBUG_1284 printf("t"); #endif ppb_1284_set_state(bus, PPB_PERIPHERAL_TERMINATION); /* Event 22 - wait up to host response time (1s) */ if ((error = do_peripheral_wait(bus, SELECT | nBUSY, 0))) { ppb_1284_set_error(bus, PPB_TIMEOUT, 22); goto error; } /* Event 24 */ ppb_wctr(bus, (nINIT | STROBE) & ~(AUTOFEED | SELECTIN)); /* Event 25 - wait up to host response time (1s) */ if ((error = do_peripheral_wait(bus, nBUSY, nBUSY))) { ppb_1284_set_error(bus, PPB_TIMEOUT, 25); goto error; } /* Event 26 */ ppb_wctr(bus, (SELECTIN | nINIT | STROBE) & ~(AUTOFEED)); DELAY(1); /* Event 27 */ ppb_wctr(bus, (SELECTIN | nINIT) & ~(STROBE | AUTOFEED)); /* Event 28 - wait up to host response time (1s) */ if ((error = do_peripheral_wait(bus, nBUSY, 0))) { ppb_1284_set_error(bus, PPB_TIMEOUT, 28); goto error; } error: ppb_set_mode(bus, PPB_COMPATIBLE); ppb_1284_set_state(bus, PPB_FORWARD_IDLE); return (0); } /* * byte_peripheral_outbyte() * * Write 1 byte in BYTE mode */ static int byte_peripheral_outbyte(device_t bus, char *buffer, int last) { int error = 0; /* Event 7 */ if ((error = do_1284_wait(bus, nBUSY, nBUSY))) { ppb_1284_set_error(bus, PPB_TIMEOUT, 7); goto error; } /* check termination */ if (!(ppb_rstr(bus) & SELECT)) { ppb_peripheral_terminate(bus, PPB_WAIT); goto error; } /* Event 15 - put byte on data lines */ #ifdef DEBUG_1284 printf("B"); #endif ppb_wdtr(bus, *buffer); /* Event 9 */ ppb_wctr(bus, (AUTOFEED | STROBE) & ~(nINIT | SELECTIN)); /* Event 10 - wait data read */ if ((error = do_peripheral_wait(bus, nBUSY, 0))) { ppb_1284_set_error(bus, PPB_TIMEOUT, 16); goto error; } /* Event 11 */ if (!last) { ppb_wctr(bus, (AUTOFEED) & ~(nINIT | STROBE | SELECTIN)); } else { ppb_wctr(bus, (nINIT) & ~(STROBE | SELECTIN | AUTOFEED)); } #if 0 /* Event 16 - wait strobe */ if ((error = do_peripheral_wait(bus, nACK | nBUSY, 0))) { ppb_1284_set_error(bus, PPB_TIMEOUT, 16); goto error; } #endif /* check termination */ if (!(ppb_rstr(bus) & SELECT)) { ppb_peripheral_terminate(bus, PPB_WAIT); goto error; } error: return (error); } /* * byte_peripheral_write() * * Write n bytes in BYTE mode */ int byte_peripheral_write(device_t bus, char *buffer, int len, int *sent) { int error = 0, i; char r; ppb_1284_set_state(bus, PPB_PERIPHERAL_TRANSFER); /* wait forever, the remote host is master and should initiate * termination */ for (i=0; i= PPB_PERIPHERAL_NEGOCIATION) ppb_peripheral_terminate(bus, PPB_WAIT); if (ppb_1284_get_state(bus) != PPB_FORWARD_IDLE) ppb_1284_terminate(bus); #ifdef DEBUG_1284 printf("%d", mode); #endif /* ensure the host is in compatible mode */ ppb_set_mode(bus, PPB_COMPATIBLE); /* reset error to catch the actual negociation error */ ppb_1284_reset_error(bus, PPB_FORWARD_IDLE); /* calculate ext. value */ request_mode = ppb_request_mode(mode, options); /* default state */ ppb_wctr(bus, (nINIT | SELECTIN) & ~(STROBE | AUTOFEED)); DELAY(1); /* enter negociation phase */ ppb_1284_set_state(bus, PPB_NEGOCIATION); /* Event 0 - put the exten. value on the data lines */ ppb_wdtr(bus, request_mode); #ifdef PERIPH_1284 /* request remote host attention */ ppb_wctr(bus, (nINIT | STROBE) & ~(AUTOFEED | SELECTIN)); DELAY(1); ppb_wctr(bus, (nINIT) & ~(STROBE | AUTOFEED | SELECTIN)); #else DELAY(1); #endif /* !PERIPH_1284 */ /* Event 1 - enter IEEE1284 mode */ ppb_wctr(bus, (nINIT | AUTOFEED) & ~(STROBE | SELECTIN)); #ifdef PERIPH_1284 /* ignore the PError line, wait a bit more, remote host's * interrupts don't respond fast enough */ if (ppb_poll_bus(bus, 40, nACK | SELECT | nFAULT, SELECT | nFAULT, PPB_NOINTR | PPB_POLL)) { ppb_1284_set_error(bus, PPB_NOT_IEEE1284, 2); error = ENODEV; goto error; } #else /* Event 2 - trying IEEE1284 dialog */ if (do_1284_wait(bus, nACK | PERROR | SELECT | nFAULT, PERROR | SELECT | nFAULT)) { ppb_1284_set_error(bus, PPB_NOT_IEEE1284, 2); error = ENODEV; goto error; } #endif /* !PERIPH_1284 */ /* Event 3 - latch the ext. value to the peripheral */ ppb_wctr(bus, (nINIT | STROBE | AUTOFEED) & ~SELECTIN); DELAY(1); /* Event 4 - IEEE1284 device recognized */ ppb_wctr(bus, nINIT & ~(SELECTIN | AUTOFEED | STROBE)); /* Event 6 - waiting for status lines */ if (do_1284_wait(bus, nACK, nACK)) { ppb_1284_set_error(bus, PPB_TIMEOUT, 6); error = EBUSY; goto error; } /* Event 7 - quering result consider nACK not to misunderstand * a remote computer terminate sequence */ if (options & PPB_EXTENSIBILITY_LINK) { /* XXX not fully supported yet */ ppb_1284_terminate(bus); return (0); } if (request_mode == NIBBLE_1284_NORMAL) { if (do_1284_wait(bus, nACK | SELECT, nACK)) { ppb_1284_set_error(bus, PPB_MODE_UNSUPPORTED, 7); error = ENODEV; goto error; } } else { if (do_1284_wait(bus, nACK | SELECT, SELECT | nACK)) { ppb_1284_set_error(bus, PPB_MODE_UNSUPPORTED, 7); error = ENODEV; goto error; } } switch (mode) { case PPB_NIBBLE: case PPB_PS2: /* enter reverse idle phase */ ppb_1284_set_state(bus, PPB_REVERSE_IDLE); break; case PPB_ECP: /* negociation ok, now setup the communication */ ppb_1284_set_state(bus, PPB_SETUP); ppb_wctr(bus, (nINIT | AUTOFEED) & ~(SELECTIN | STROBE)); #ifdef PERIPH_1284 /* ignore PError line */ if (do_1284_wait(bus, nACK | SELECT | nBUSY, nACK | SELECT | nBUSY)) { ppb_1284_set_error(bus, PPB_TIMEOUT, 30); error = ENODEV; goto error; } #else if (do_1284_wait(bus, nACK | SELECT | PERROR | nBUSY, nACK | SELECT | PERROR | nBUSY)) { ppb_1284_set_error(bus, PPB_TIMEOUT, 30); error = ENODEV; goto error; } #endif /* !PERIPH_1284 */ /* ok, the host enters the ForwardIdle state */ ppb_1284_set_state(bus, PPB_ECP_FORWARD_IDLE); break; case PPB_EPP: ppb_1284_set_state(bus, PPB_EPP_IDLE); break; default: panic("%s: unknown mode (%d)!", __func__, mode); } ppb_set_mode(bus, mode); return (0); error: ppb_1284_terminate(bus); return (error); } /* * ppb_1284_terminate() * * IEEE1284 termination phase, return code should ignored since the host * is _always_ in compatible mode after ppb_1284_terminate() */ int ppb_1284_terminate(device_t bus) { #ifdef DEBUG_1284 printf("T"); #endif /* do not reset error here to keep the error that * may occured before the ppb_1284_terminate() call */ ppb_1284_set_state(bus, PPB_TERMINATION); #ifdef PERIPH_1284 /* request remote host attention */ ppb_wctr(bus, (nINIT | STROBE | SELECTIN) & ~(AUTOFEED)); DELAY(1); #endif /* PERIPH_1284 */ /* Event 22 - set nSelectin low and nAutoFeed high */ ppb_wctr(bus, (nINIT | SELECTIN) & ~(STROBE | AUTOFEED)); /* Event 24 - waiting for peripheral, Xflag ignored */ if (do_1284_wait(bus, nACK | nBUSY | nFAULT, nFAULT)) { ppb_1284_set_error(bus, PPB_TIMEOUT, 24); goto error; } /* Event 25 - set nAutoFd low */ ppb_wctr(bus, (nINIT | SELECTIN | AUTOFEED) & ~STROBE); /* Event 26 - compatible mode status is set */ /* Event 27 - peripheral set nAck high */ if (do_1284_wait(bus, nACK, nACK)) { ppb_1284_set_error(bus, PPB_TIMEOUT, 27); } /* Event 28 - end termination, return to idle phase */ ppb_wctr(bus, (nINIT | SELECTIN) & ~(STROBE | AUTOFEED)); error: /* return to compatible mode */ ppb_set_mode(bus, PPB_COMPATIBLE); ppb_1284_set_state(bus, PPB_FORWARD_IDLE); return (0); } Index: stable/9/sys/dev/ppbus/ppb_base.c =================================================================== --- stable/9/sys/dev/ppbus/ppb_base.c (revision 305554) +++ stable/9/sys/dev/ppbus/ppb_base.c (revision 305555) @@ -1,242 +1,242 @@ /*- * Copyright (c) 1997, 1998, 1999 Nicolas Souchu * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include "ppbus_if.h" #include MODULE_VERSION(ppbus, 1); #define DEVTOSOFTC(dev) ((struct ppb_data *)device_get_softc(dev)) /* * ppb_poll_bus() * * Polls the bus * * max is a delay in 10-milliseconds */ int ppb_poll_bus(device_t bus, int max, - char mask, char status, int how) + uint8_t mask, uint8_t status, int how) { struct ppb_data *ppb = DEVTOSOFTC(bus); int i, j, error; - char r; + uint8_t r; ppb_assert_locked(bus); /* try at least up to 10ms */ for (j = 0; j < ((how & PPB_POLL) ? max : 1); j++) { for (i = 0; i < 10000; i++) { r = ppb_rstr(bus); DELAY(1); if ((r & mask) == status) return (0); } } if (!(how & PPB_POLL)) { for (i = 0; max == PPB_FOREVER || i < max-1; i++) { if ((ppb_rstr(bus) & mask) == status) return (0); /* wait 10 ms */ error = mtx_sleep((caddr_t)bus, ppb->ppc_lock, PPBPRI | (how == PPB_NOINTR ? 0 : PCATCH), "ppbpoll", hz/100); if (error != EWOULDBLOCK) return (error); } } return (EWOULDBLOCK); } /* * ppb_get_epp_protocol() * * Return the chipset EPP protocol */ int ppb_get_epp_protocol(device_t bus) { uintptr_t protocol; ppb_assert_locked(bus); BUS_READ_IVAR(device_get_parent(bus), bus, PPC_IVAR_EPP_PROTO, &protocol); return (protocol); } /* * ppb_get_mode() * */ int ppb_get_mode(device_t bus) { struct ppb_data *ppb = DEVTOSOFTC(bus); /* XXX yet device mode = ppbus mode = chipset mode */ ppb_assert_locked(bus); return (ppb->mode); } /* * ppb_set_mode() * * Set the operating mode of the chipset, return the previous mode */ int ppb_set_mode(device_t bus, int mode) { struct ppb_data *ppb = DEVTOSOFTC(bus); int old_mode = ppb_get_mode(bus); ppb_assert_locked(bus); if (PPBUS_SETMODE(device_get_parent(bus), mode)) return (-1); /* XXX yet device mode = ppbus mode = chipset mode */ ppb->mode = (mode & PPB_MASK); return (old_mode); } /* * ppb_write() * * Write charaters to the port */ int ppb_write(device_t bus, char *buf, int len, int how) { ppb_assert_locked(bus); return (PPBUS_WRITE(device_get_parent(bus), buf, len, how)); } /* * ppb_reset_epp_timeout() * * Reset the EPP timeout bit in the status register */ int ppb_reset_epp_timeout(device_t bus) { ppb_assert_locked(bus); return(PPBUS_RESET_EPP(device_get_parent(bus))); } /* * ppb_ecp_sync() * * Wait for the ECP FIFO to be empty */ int ppb_ecp_sync(device_t bus) { ppb_assert_locked(bus); return (PPBUS_ECP_SYNC(device_get_parent(bus))); } /* * ppb_get_status() * * Read the status register and update the status info */ int ppb_get_status(device_t bus, struct ppb_status *status) { - register char r; + uint8_t r; ppb_assert_locked(bus); r = status->status = ppb_rstr(bus); status->timeout = r & TIMEOUT; status->error = !(r & nFAULT); status->select = r & SELECT; status->paper_end = r & PERROR; status->ack = !(r & nACK); status->busy = !(r & nBUSY); return (0); } void ppb_lock(device_t bus) { struct ppb_data *ppb = DEVTOSOFTC(bus); mtx_lock(ppb->ppc_lock); } void ppb_unlock(device_t bus) { struct ppb_data *ppb = DEVTOSOFTC(bus); mtx_unlock(ppb->ppc_lock); } void _ppb_assert_locked(device_t bus, const char *file, int line) { mtx_assert_(DEVTOSOFTC(bus)->ppc_lock, MA_OWNED, file, line); } void ppb_init_callout(device_t bus, struct callout *c, int flags) { struct ppb_data *ppb = DEVTOSOFTC(bus); callout_init_mtx(c, ppb->ppc_lock, flags); } int ppb_sleep(device_t bus, void *wchan, int priority, const char *wmesg, int timo) { struct ppb_data *ppb = DEVTOSOFTC(bus); return (mtx_sleep(wchan, ppb->ppc_lock, priority, wmesg, timo)); } Index: stable/9/sys/dev/ppbus/ppbconf.h =================================================================== --- stable/9/sys/dev/ppbus/ppbconf.h (revision 305554) +++ stable/9/sys/dev/ppbus/ppbconf.h (revision 305555) @@ -1,281 +1,281 @@ /*- * Copyright (c) 1997, 1998, 1999 Nicolas Souchu * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ * */ #ifndef __PPBCONF_H #define __PPBCONF_H #define n(flags) (~(flags) & (flags)) /* * Parallel Port Chipset control bits. */ #define STROBE 0x01 #define AUTOFEED 0x02 #define nINIT 0x04 #define SELECTIN 0x08 #define IRQENABLE 0x10 #define PCD 0x20 #define nSTROBE n(STROBE) #define nAUTOFEED n(AUTOFEED) #define INIT n(nINIT) #define nSELECTIN n(SELECTIN) #define nPCD n(PCD) /* * Parallel Port Chipset status bits. */ #define TIMEOUT 0x01 #define nFAULT 0x08 #define SELECT 0x10 #define PERROR 0x20 #define nACK 0x40 #define nBUSY 0x80 #ifdef _KERNEL #include /* * Parallel Port Bus sleep/wakeup queue. */ #define PPBPRI (PZERO+8) /* * Parallel Port Chipset mode masks. * NIBBLE mode is supposed to be available under each other modes. */ #define PPB_COMPATIBLE 0x0 /* Centronics compatible mode */ #define PPB_NIBBLE 0x1 /* reverse 4 bit mode */ #define PPB_PS2 0x2 /* PS/2 byte mode */ #define PPB_EPP 0x4 /* EPP mode, 32 bit */ #define PPB_ECP 0x8 /* ECP mode */ /* mode aliases */ #define PPB_SPP PPB_NIBBLE|PPB_PS2 #define PPB_BYTE PPB_PS2 #define PPB_MASK 0x0f #define PPB_OPTIONS_MASK 0xf0 #define PPB_IS_EPP(mode) (mode & PPB_EPP) #define PPB_IN_EPP_MODE(bus) (PPB_IS_EPP (ppb_get_mode (bus))) #define PPB_IN_NIBBLE_MODE(bus) (ppb_get_mode (bus) & PPB_NIBBLE) #define PPB_IN_PS2_MODE(bus) (ppb_get_mode (bus) & PPB_PS2) /* * Structure to store status information. */ struct ppb_status { unsigned char status; unsigned int timeout:1; unsigned int error:1; unsigned int select:1; unsigned int paper_end:1; unsigned int ack:1; unsigned int busy:1; }; /* Parallel port bus I/O opcodes */ #define PPB_OUTSB_EPP 1 #define PPB_OUTSW_EPP 2 #define PPB_OUTSL_EPP 3 #define PPB_INSB_EPP 4 #define PPB_INSW_EPP 5 #define PPB_INSL_EPP 6 #define PPB_RDTR 7 #define PPB_RSTR 8 #define PPB_RCTR 9 #define PPB_REPP_A 10 #define PPB_REPP_D 11 #define PPB_RECR 12 #define PPB_RFIFO 13 #define PPB_WDTR 14 #define PPB_WSTR 15 #define PPB_WCTR 16 #define PPB_WEPP_A 17 #define PPB_WEPP_D 18 #define PPB_WECR 19 #define PPB_WFIFO 20 /* * How tsleep() is called in ppb_request_bus(). */ #define PPB_DONTWAIT 0 #define PPB_NOINTR 0 #define PPB_WAIT 0x1 #define PPB_INTR 0x2 #define PPB_POLL 0x4 #define PPB_FOREVER -1 /* * Microsequence stuff. */ #define PPB_MS_MAXLEN 64 /* XXX according to MS_INS_MASK */ #define PPB_MS_MAXARGS 3 /* according to MS_ARG_MASK */ /* maximum number of mode dependent * submicrosequences for in/out operations */ #define PPB_MAX_XFER 6 union ppb_insarg { int i; void *p; char *c; int (* f)(void *, char *); }; struct ppb_microseq { int opcode; /* microins. opcode */ union ppb_insarg arg[PPB_MS_MAXARGS]; /* arguments */ }; /* microseqences used for GET/PUT operations */ struct ppb_xfer { struct ppb_microseq *loop; /* the loop microsequence */ }; /* * Parallel Port Bus Device structure. */ struct ppb_data; /* see below */ struct ppb_context { int valid; /* 1 if the struct is valid */ int mode; /* XXX chipset operating mode */ struct microseq *curpc; /* pc in curmsq */ struct microseq *curmsq; /* currently executed microseqence */ }; /* * List of IVARS available to ppb device drivers */ #define PPBUS_IVAR_MODE 0 /* other fields are reserved to the ppbus internals */ struct ppb_device { const char *name; /* name of the device */ u_int flags; /* flags */ struct ppb_context ctx; /* context of the device */ /* mode dependent get msq. If NULL, * IEEE1284 code is used */ struct ppb_xfer get_xfer[PPB_MAX_XFER]; /* mode dependent put msq. If NULL, * IEEE1284 code is used */ struct ppb_xfer put_xfer[PPB_MAX_XFER]; driver_intr_t *intr_hook; void *intr_arg; }; /* EPP standards */ #define EPP_1_9 0x0 /* default */ #define EPP_1_7 0x1 /* Parallel Port Chipset IVARS */ /* elsewhere XXX */ #define PPC_IVAR_EPP_PROTO 0 #define PPC_IVAR_LOCK 1 #define PPC_IVAR_INTR_HANDLER 2 /* * Maximum size of the PnP info string */ #define PPB_PnP_STRING_SIZE 256 /* XXX */ /* * Parallel Port Bus structure. */ struct ppb_data { #define PPB_PnP_PRINTER 0 #define PPB_PnP_MODEM 1 #define PPB_PnP_NET 2 #define PPB_PnP_HDC 3 #define PPB_PnP_PCMCIA 4 #define PPB_PnP_MEDIA 5 #define PPB_PnP_FDC 6 #define PPB_PnP_PORTS 7 #define PPB_PnP_SCANNER 8 #define PPB_PnP_DIGICAM 9 #define PPB_PnP_UNKNOWN 10 int class_id; /* not a PnP device if class_id < 0 */ int state; /* current IEEE1284 state */ int error; /* last IEEE1284 error */ int mode; /* IEEE 1284-1994 mode * NIBBLE, PS2, EPP or ECP */ device_t ppb_owner; /* device which owns the bus */ struct mtx *ppc_lock; /* lock of parent device */ struct resource *ppc_irq_res; }; struct callout; typedef int (*ppc_intr_handler)(void *); extern int ppb_attach_device(device_t); extern int ppb_request_bus(device_t, device_t, int); extern int ppb_release_bus(device_t, device_t); /* bus related functions */ extern void ppb_lock(device_t); extern void ppb_unlock(device_t); extern void _ppb_assert_locked(device_t, const char *, int); extern void ppb_init_callout(device_t, struct callout *, int); extern int ppb_sleep(device_t, void *, int, const char *, int); extern int ppb_get_status(device_t, struct ppb_status *); -extern int ppb_poll_bus(device_t, int, char, char, int); +extern int ppb_poll_bus(device_t, int, uint8_t, uint8_t, int); extern int ppb_reset_epp_timeout(device_t); extern int ppb_ecp_sync(device_t); extern int ppb_get_epp_protocol(device_t); extern int ppb_set_mode(device_t, int); /* returns old mode */ extern int ppb_get_mode(device_t); /* returns current mode */ extern int ppb_write(device_t, char *, int, int); #ifdef INVARIANTS #define ppb_assert_locked(dev) _ppb_assert_locked(dev, __FILE__, __LINE__) #else #define ppb_assert_locked(dev) #endif #endif /* _KERNEL */ #endif /* !__PPBCONF_H */ Index: stable/9/sys =================================================================== --- stable/9/sys (revision 305554) +++ stable/9/sys (revision 305555) Property changes on: stable/9/sys ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head/sys:r305345 Index: stable/9 =================================================================== --- stable/9 (revision 305554) +++ stable/9 (revision 305555) Property changes on: stable/9 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r305345