ppb_1284.c (119418) | ppb_1284.c (185003) |
---|---|
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> | 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 119418 2003-08-24 17:55:58Z obrien $"); | 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{ | 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 return (DEVTOSOFTC(bus)->state); | 95 96 return (DEVTOSOFTC(bus)->state); |
96} 97 98/* 99 * ppb_1284_set_state() 100 * 101 * Change IEEE1284 state if no error occured 102 */ 103int --- 184 unchanged lines hidden (view full) --- 288 289 /* Event 22 - wait up to host response time (1s) */ 290 if ((error = do_peripheral_wait(bus, SELECT | nBUSY, 0))) { 291 ppb_1284_set_error(bus, PPB_TIMEOUT, 22); 292 goto error; 293 } 294 295 /* Event 24 */ | 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 */ |
296 ppb_wctr(bus, (nINIT | STROBE) & ~(AUTOFEED | SELECTIN)); | 297 ppb_wctr(bus, (nINIT | STROBE) & ~(AUTOFEED | SELECTIN)); |
297 298 /* Event 25 - wait up to host response time (1s) */ 299 if ((error = do_peripheral_wait(bus, nBUSY, nBUSY))) { 300 ppb_1284_set_error(bus, PPB_TIMEOUT, 25); 301 goto error; 302 } 303 304 /* Event 26 */ | 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 */ |
305 ppb_wctr(bus, (SELECTIN | nINIT | STROBE) & ~(AUTOFEED)); | 306 ppb_wctr(bus, (SELECTIN | nINIT | STROBE) & ~(AUTOFEED)); |
306 DELAY(1); 307 /* Event 27 */ | 307 DELAY(1); 308 /* Event 27 */ |
308 ppb_wctr(bus, (SELECTIN | nINIT) & ~(STROBE | AUTOFEED)); | 309 ppb_wctr(bus, (SELECTIN | nINIT) & ~(STROBE | AUTOFEED)); |
309 310 /* Event 28 - wait up to host response time (1s) */ 311 if ((error = do_peripheral_wait(bus, nBUSY, 0))) { 312 ppb_1284_set_error(bus, PPB_TIMEOUT, 28); 313 goto error; 314 } | 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 } |
315 | 316 |
316error: 317 ppb_set_mode(bus, PPB_COMPATIBLE); 318 ppb_1284_set_state(bus, PPB_FORWARD_IDLE); 319 320 return (0); 321} 322 323/* --- 209 unchanged lines hidden (view full) --- 533 case PPB_FORWARD_IDLE: 534 if ((error = ppb_1284_negociate(bus, mode, 0))) 535 return (error); 536 break; 537 538 case PPB_REVERSE_IDLE: 539 terminate_after_transfer = 0; 540 break; | 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; |
541 | 542 |
542 default: 543 ppb_1284_terminate(bus); 544 if ((error = ppb_1284_negociate(bus, mode, 0))) 545 return (error); 546 break; 547 } 548 549 while ((len < max) && !(ppb_rstr(bus) & (nFAULT))) { --- 134 unchanged lines hidden (view full) --- 684 /* enter negociation phase */ 685 ppb_1284_set_state(bus, PPB_NEGOCIATION); 686 687 /* Event 0 - put the exten. value on the data lines */ 688 ppb_wdtr(bus, request_mode); 689 690#ifdef PERIPH_1284 691 /* request remote host attention */ | 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 */ |
692 ppb_wctr(bus, (nINIT | STROBE) & ~(AUTOFEED | SELECTIN)); 693 DELAY(1); 694 ppb_wctr(bus, (nINIT) & ~(STROBE | AUTOFEED | SELECTIN)); | 693 ppb_wctr(bus, (nINIT | STROBE) & ~(AUTOFEED | SELECTIN)); 694 DELAY(1); 695 ppb_wctr(bus, (nINIT) & ~(STROBE | AUTOFEED | SELECTIN)); |
695#else 696 DELAY(1); 697 698#endif /* !PERIPH_1284 */ 699 700 /* Event 1 - enter IEEE1284 mode */ 701 ppb_wctr(bus, (nINIT | AUTOFEED) & ~(STROBE | SELECTIN)); 702 703#ifdef PERIPH_1284 | 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 |
704 /* ignore the PError line, wait a bit more, remote host's | 705 /* ignore the PError line, wait a bit more, remote host's |
705 * interrupts don't respond fast enough */ 706 if (ppb_poll_bus(bus, 40, nACK | SELECT | nFAULT, 707 SELECT | nFAULT, PPB_NOINTR | PPB_POLL)) { | 706 * interrupts don't respond fast enough */ 707 if (ppb_poll_bus(bus, 40, nACK | SELECT | nFAULT, 708 SELECT | nFAULT, PPB_NOINTR | PPB_POLL)) { |
708 ppb_1284_set_error(bus, PPB_NOT_IEEE1284, 2); 709 error = ENODEV; 710 goto error; 711 } | 709 ppb_1284_set_error(bus, PPB_NOT_IEEE1284, 2); 710 error = ENODEV; 711 goto error; 712 } |
712#else 713 /* Event 2 - trying IEEE1284 dialog */ 714 if (do_1284_wait(bus, nACK | PERROR | SELECT | nFAULT, 715 PERROR | SELECT | nFAULT)) { 716 ppb_1284_set_error(bus, PPB_NOT_IEEE1284, 2); 717 error = ENODEV; 718 goto error; 719 } --- 45 unchanged lines hidden (view full) --- 765 case PPB_ECP: 766 /* negociation ok, now setup the communication */ 767 ppb_1284_set_state(bus, PPB_SETUP); 768 ppb_wctr(bus, (nINIT | AUTOFEED) & ~(SELECTIN | STROBE)); 769 770#ifdef PERIPH_1284 771 /* ignore PError line */ 772 if (do_1284_wait(bus, nACK | SELECT | nBUSY, | 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, |
773 nACK | SELECT | nBUSY)) { 774 ppb_1284_set_error(bus, PPB_TIMEOUT, 30); 775 error = ENODEV; 776 goto error; 777 } | 774 nACK | SELECT | nBUSY)) { 775 ppb_1284_set_error(bus, PPB_TIMEOUT, 30); 776 error = ENODEV; 777 goto error; 778 } |
778#else 779 if (do_1284_wait(bus, nACK | SELECT | PERROR | nBUSY, 780 nACK | SELECT | PERROR | nBUSY)) { 781 ppb_1284_set_error(bus, PPB_TIMEOUT, 30); 782 error = ENODEV; 783 goto error; 784 } 785#endif /* !PERIPH_1284 */ --- 33 unchanged lines hidden (view full) --- 819#endif 820 821 /* do not reset error here to keep the error that 822 * may occured before the ppb_1284_terminate() call */ 823 ppb_1284_set_state(bus, PPB_TERMINATION); 824 825#ifdef PERIPH_1284 826 /* request remote host attention */ | 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 */ |
827 ppb_wctr(bus, (nINIT | STROBE | SELECTIN) & ~(AUTOFEED)); 828 DELAY(1); | 828 ppb_wctr(bus, (nINIT | STROBE | SELECTIN) & ~(AUTOFEED)); 829 DELAY(1); |
829#endif /* PERIPH_1284 */ 830 831 /* Event 22 - set nSelectin low and nAutoFeed high */ 832 ppb_wctr(bus, (nINIT | SELECTIN) & ~(STROBE | AUTOFEED)); 833 834 /* Event 24 - waiting for peripheral, Xflag ignored */ 835 if (do_1284_wait(bus, nACK | nBUSY | nFAULT, nFAULT)) { 836 ppb_1284_set_error(bus, PPB_TIMEOUT, 24); --- 23 unchanged lines hidden --- | 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 --- |