Deleted Added
sdiff udiff text old ( 119418 ) new ( 185003 )
full compact
1/*-
2 * Copyright (c) 1997 Nicolas Souchu
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 *
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/dev/ppbus/ppb_1284.c 185003 2008-11-16 17:42:02Z jhb $");
31
32/*
33 * General purpose routines for the IEEE1284-1994 Standard
34 */
35
36#include "opt_ppb_1284.h"
37
38#include <sys/param.h>

--- 48 unchanged lines hidden (view full) ---

87/*
88 * ppb_1284_get_state()
89 *
90 * Get IEEE1284 state
91 */
92int
93ppb_1284_get_state(device_t bus)
94{
95
96 return (DEVTOSOFTC(bus)->state);
97}
98
99/*
100 * ppb_1284_set_state()
101 *
102 * Change IEEE1284 state if no error occured
103 */
104int

--- 184 unchanged lines hidden (view full) ---

289
290 /* Event 22 - wait up to host response time (1s) */
291 if ((error = do_peripheral_wait(bus, SELECT | nBUSY, 0))) {
292 ppb_1284_set_error(bus, PPB_TIMEOUT, 22);
293 goto error;
294 }
295
296 /* Event 24 */
297 ppb_wctr(bus, (nINIT | STROBE) & ~(AUTOFEED | SELECTIN));
298
299 /* Event 25 - wait up to host response time (1s) */
300 if ((error = do_peripheral_wait(bus, nBUSY, nBUSY))) {
301 ppb_1284_set_error(bus, PPB_TIMEOUT, 25);
302 goto error;
303 }
304
305 /* Event 26 */
306 ppb_wctr(bus, (SELECTIN | nINIT | STROBE) & ~(AUTOFEED));
307 DELAY(1);
308 /* Event 27 */
309 ppb_wctr(bus, (SELECTIN | nINIT) & ~(STROBE | AUTOFEED));
310
311 /* Event 28 - wait up to host response time (1s) */
312 if ((error = do_peripheral_wait(bus, nBUSY, 0))) {
313 ppb_1284_set_error(bus, PPB_TIMEOUT, 28);
314 goto error;
315 }
316
317error:
318 ppb_set_mode(bus, PPB_COMPATIBLE);
319 ppb_1284_set_state(bus, PPB_FORWARD_IDLE);
320
321 return (0);
322}
323
324/*

--- 209 unchanged lines hidden (view full) ---

534 case PPB_FORWARD_IDLE:
535 if ((error = ppb_1284_negociate(bus, mode, 0)))
536 return (error);
537 break;
538
539 case PPB_REVERSE_IDLE:
540 terminate_after_transfer = 0;
541 break;
542
543 default:
544 ppb_1284_terminate(bus);
545 if ((error = ppb_1284_negociate(bus, mode, 0)))
546 return (error);
547 break;
548 }
549
550 while ((len < max) && !(ppb_rstr(bus) & (nFAULT))) {

--- 134 unchanged lines hidden (view full) ---

685 /* enter negociation phase */
686 ppb_1284_set_state(bus, PPB_NEGOCIATION);
687
688 /* Event 0 - put the exten. value on the data lines */
689 ppb_wdtr(bus, request_mode);
690
691#ifdef PERIPH_1284
692 /* request remote host attention */
693 ppb_wctr(bus, (nINIT | STROBE) & ~(AUTOFEED | SELECTIN));
694 DELAY(1);
695 ppb_wctr(bus, (nINIT) & ~(STROBE | AUTOFEED | SELECTIN));
696#else
697 DELAY(1);
698
699#endif /* !PERIPH_1284 */
700
701 /* Event 1 - enter IEEE1284 mode */
702 ppb_wctr(bus, (nINIT | AUTOFEED) & ~(STROBE | SELECTIN));
703
704#ifdef PERIPH_1284
705 /* ignore the PError line, wait a bit more, remote host's
706 * interrupts don't respond fast enough */
707 if (ppb_poll_bus(bus, 40, nACK | SELECT | nFAULT,
708 SELECT | nFAULT, PPB_NOINTR | PPB_POLL)) {
709 ppb_1284_set_error(bus, PPB_NOT_IEEE1284, 2);
710 error = ENODEV;
711 goto error;
712 }
713#else
714 /* Event 2 - trying IEEE1284 dialog */
715 if (do_1284_wait(bus, nACK | PERROR | SELECT | nFAULT,
716 PERROR | SELECT | nFAULT)) {
717 ppb_1284_set_error(bus, PPB_NOT_IEEE1284, 2);
718 error = ENODEV;
719 goto error;
720 }

--- 45 unchanged lines hidden (view full) ---

766 case PPB_ECP:
767 /* negociation ok, now setup the communication */
768 ppb_1284_set_state(bus, PPB_SETUP);
769 ppb_wctr(bus, (nINIT | AUTOFEED) & ~(SELECTIN | STROBE));
770
771#ifdef PERIPH_1284
772 /* ignore PError line */
773 if (do_1284_wait(bus, nACK | SELECT | nBUSY,
774 nACK | SELECT | nBUSY)) {
775 ppb_1284_set_error(bus, PPB_TIMEOUT, 30);
776 error = ENODEV;
777 goto error;
778 }
779#else
780 if (do_1284_wait(bus, nACK | SELECT | PERROR | nBUSY,
781 nACK | SELECT | PERROR | nBUSY)) {
782 ppb_1284_set_error(bus, PPB_TIMEOUT, 30);
783 error = ENODEV;
784 goto error;
785 }
786#endif /* !PERIPH_1284 */

--- 33 unchanged lines hidden (view full) ---

820#endif
821
822 /* do not reset error here to keep the error that
823 * may occured before the ppb_1284_terminate() call */
824 ppb_1284_set_state(bus, PPB_TERMINATION);
825
826#ifdef PERIPH_1284
827 /* request remote host attention */
828 ppb_wctr(bus, (nINIT | STROBE | SELECTIN) & ~(AUTOFEED));
829 DELAY(1);
830#endif /* PERIPH_1284 */
831
832 /* Event 22 - set nSelectin low and nAutoFeed high */
833 ppb_wctr(bus, (nINIT | SELECTIN) & ~(STROBE | AUTOFEED));
834
835 /* Event 24 - waiting for peripheral, Xflag ignored */
836 if (do_1284_wait(bus, nACK | nBUSY | nFAULT, nFAULT)) {
837 ppb_1284_set_error(bus, PPB_TIMEOUT, 24);

--- 23 unchanged lines hidden ---