Lines Matching +full:always +full:- +full:wait +full:- +full:for +full:- +full:ack
1 // SPDX-License-Identifier: eCos-2.0
7 * RedBoot stream handler for xyzModem protocol
14 * Date: 2000-07-14
27 #include <u-boot/crc.h>
30 /* Assumption - run xyzModem protocol over the console port */
36 #define ACK 0x06 macro
40 #define EOF 0x1A /* ^Z for DOS officionados */
58 #define xyzModem_CAN_COUNT 3 /* Wait for 3 CAN before quitting */
103 ret = (c - '0'); in _from_hex()
107 ret = (c - 'a' + 0x0a); in _from_hex()
111 ret = (c - 'A' + 0x0A); in _from_hex()
122 c = (c - 'A') + 'a'; in _tolower()
228 zm_dump_buf (zm_buf, zm_bp - zm_buf); in zm_dump()
236 /* Wait for the line to go idle */
266 CYGACC_COMM_IF_PUTC (*xyz.__chan, ACK); in xyzModem_get_hdr()
294 /* Wait for multiple CAN to avoid early quits */ in xyzModem_get_hdr()
301 CYGACC_COMM_IF_PUTC (*xyz.__chan, ACK); in xyzModem_get_hdr()
302 ZM_DEBUG (zm_dprintf ("ACK on EOT #%d\n", __LINE__)); in xyzModem_get_hdr()
307 /* Ignore, waiting for start of header */ in xyzModem_get_hdr()
338 for (i = 0; i < xyz.len; i++) in xyzModem_get_hdr()
374 ("Framing error - blk: %x/%x/%x\n", xyz.blk, xyz.cblk, in xyzModem_get_hdr()
386 ZM_DEBUG (zm_dprintf ("CRC error - recvd: %02x%02x, computed: %x\n", in xyzModem_get_hdr()
394 for (i = 0; i < xyz.len; i++) in xyzModem_get_hdr()
401 ("Checksum error - recvd: %x, computed: %x\n", xyz.crc1, in xyzModem_get_hdr()
419 if (info->mode == xyzModem_zmodem) in xyzModem_stream_open()
422 return -1; in xyzModem_stream_open()
433 xyz.mode = info->mode; in xyzModem_stream_open()
445 /* X-modem doesn't have an information header - exit here */ in xyzModem_stream_open()
450 while (retries-- > 0) in xyzModem_stream_open()
455 /* Y-modem file information header */ in xyzModem_stream_open()
471 if (--crc_retries <= 0) in xyzModem_stream_open()
473 CYGACC_CALL_IF_DELAY_US (5 * 100000); /* Extra delay for startup */ in xyzModem_stream_open()
485 return -1; in xyzModem_stream_open()
502 while (retries-- > 0) in xyzModem_stream_read()
511 ("ACK block %d (%d)\n", xyz.blk, __LINE__)); in xyzModem_stream_read()
518 if ((xyz.bufp[xyz.len - 1] == EOF) && in xyzModem_stream_read()
519 (xyz.bufp[xyz.len - 2] == EOF) && in xyzModem_stream_read()
520 (xyz.bufp[xyz.len - 3] == EOF)) in xyzModem_stream_read()
523 && (xyz.bufp[xyz.len - 1] == EOF)) in xyzModem_stream_read()
525 xyz.len--; in xyzModem_stream_read()
533 * Only do this for Y-modem (and Z-modem should it ever in xyzModem_stream_read()
534 * be supported since it can fall back to Y-modem mode). in xyzModem_stream_read()
541 xyz.len -= (xyz.read_length - xyz.file_length); in xyzModem_stream_read()
546 else if (xyz.blk == ((xyz.next_blk - 1) & 0xFF)) in xyzModem_stream_read()
548 /* Just re-ACK this so sender will get on with it */ in xyzModem_stream_read()
549 CYGACC_COMM_IF_PUTC (*xyz.__chan, ACK); in xyzModem_stream_read()
563 CYGACC_COMM_IF_PUTC (*xyz.__chan, ACK); in xyzModem_stream_read()
564 ZM_DEBUG (zm_dprintf ("ACK (%d)\n", __LINE__)); in xyzModem_stream_read()
572 CYGACC_COMM_IF_PUTC (*xyz.__chan, ACK); in xyzModem_stream_read()
573 ZM_DEBUG (zm_dprintf ("FINAL ACK (%d)\n", __LINE__)); in xyzModem_stream_read()
585 xyz.len = -1; in xyzModem_stream_read()
596 size -= len; in xyzModem_stream_read()
599 xyz.len -= len; in xyzModem_stream_read()
610 ("xyzModem - %s mode, %d(SOH)/%d(STX)/%d(CAN) packets, %d retries\n", in xyzModem_stream_close()
658 * of the transfer block size, there will almost always be some gunk here. in xyzModem_stream_terminate()
662 while ((c = (*getc) ()) > -1) in xyzModem_stream_terminate()