2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 #include <cmd_autoscript.h>
36 #if (CONFIG_COMMANDS & CFG_CMD_LOADS)
37 static ulong load_serial (ulong offset);
38 static int read_record (char *buf, ulong len);
39 # if (CONFIG_COMMANDS & CFG_CMD_SAVES)
40 static int save_serial (ulong offset, ulong size);
41 static int write_record (char *buf);
42 # endif /* CFG_CMD_SAVES */
44 static int do_echo = 1;
45 #endif /* CFG_CMD_LOADS */
48 #if (CONFIG_COMMANDS & CFG_CMD_BDI)
49 static void print_num(const char *, ulong);
51 #ifndef CONFIG_ARM /* PowerPC and other */
53 static void print_str(const char *, const char *);
55 int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
57 DECLARE_GLOBAL_DATA_PTR;
64 print_num ("bd address", (ulong)bd );
66 print_num ("memstart", bd->bi_memstart );
67 print_num ("memsize", bd->bi_memsize );
68 print_num ("flashstart", bd->bi_flashstart );
69 print_num ("flashsize", bd->bi_flashsize );
70 print_num ("flashoffset", bd->bi_flashoffset );
71 print_num ("sramstart", bd->bi_sramstart );
72 print_num ("sramsize", bd->bi_sramsize );
73 #if defined(CONFIG_8xx) || defined(CONFIG_8260)
74 print_num ("immr_base", bd->bi_immr_base );
76 print_num ("bootflags", bd->bi_bootflags );
77 #if defined(CONFIG_405GP) || defined(CONFIG_405CR)
78 print_str ("procfreq", strmhz(buf, bd->bi_procfreq));
79 print_str ("plb_busfreq", strmhz(buf, bd->bi_plb_busfreq));
80 #if defined(CONFIG_405GP)
81 print_str ("pci_busfreq", strmhz(buf, bd->bi_pci_busfreq));
84 #if defined(CONFIG_8260)
85 print_str ("vco", strmhz(buf, bd->bi_vco));
86 print_str ("sccfreq", strmhz(buf, bd->bi_sccfreq));
87 print_str ("brgfreq", strmhz(buf, bd->bi_brgfreq));
89 print_str ("intfreq", strmhz(buf, bd->bi_intfreq));
90 #if defined(CONFIG_8260)
91 print_str ("cpmfreq", strmhz(buf, bd->bi_cpmfreq));
93 print_str ("busfreq", strmhz(buf, bd->bi_busfreq));
94 #endif /* defined(CONFIG_405GP) || defined(CONFIG_405CR) */
97 printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
100 printf ("\neth1addr =");
101 for (i=0; i<6; ++i) {
102 printf ("%c%02X", i ? ':' : ' ', bd->bi_enet1addr[i]);
104 #endif /* CONFIG_PN62 */
106 print_str ("ethspeed", strmhz(buf, bd->bi_ethspeed));
108 printf ("\nIP addr = "); print_IPaddr (bd->bi_ip_addr);
109 printf ("\nbaudrate = %6ld bps\n", bd->bi_baudrate );
115 int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
117 DECLARE_GLOBAL_DATA_PTR;
122 print_num ("arch_number", bd->bi_arch_number);
123 print_num ("env_t", (ulong)bd->bi_env);
124 print_num ("boot_params", (ulong)bd->bi_boot_params);
126 for (i=0; i<CONFIG_NR_DRAM_BANKS; ++i) {
127 printf ("DRAM:%02d.start = %08lX\n",
128 i, bd->bi_dram[i].start);
129 printf ("DRAM:%02d.size = %08lX\n",
130 i, bd->bi_dram[i].size);
133 printf ("ethaddr =");
134 for (i=0; i<6; ++i) {
135 printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
139 print_IPaddr (bd->bi_ip_addr);
141 "baudrate = %d bps\n", bd->bi_baudrate);
146 #endif /* CONFIG_ARM XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
148 static void print_num(const char *name, ulong value)
150 printf ("%-12s= 0x%08lX\n", name, value);
154 static void print_str(const char *name, const char *str)
156 printf ("%-12s= %6s MHz\n", name, str);
158 #endif /* CONFIG_ARM */
160 #endif /* CFG_CMD_BDI */
162 int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
168 printf ("Usage:\n%s\n", cmdtp->usage);
172 addr = simple_strtoul(argv[1], NULL, 16);
174 printf ("## Starting application at 0x%08lx ...\n", addr);
177 * pass address parameter as argv[0] (aka command name),
178 * and all remaining args
180 rc = ((ulong (*)(int, char *[]))addr) (--argc, &argv[1]);
181 if (rc != 0) rcode = 1;
183 printf ("## Application terminated, rc = 0x%lx\n", rc);
187 #if (CONFIG_COMMANDS & CFG_CMD_LOADS)
188 int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
195 #ifdef CFG_LOADS_BAUD_CHANGE
196 DECLARE_GLOBAL_DATA_PTR;
197 int load_baudrate, current_baudrate;
199 load_baudrate = current_baudrate = gd->baudrate;
202 if (((env_echo = getenv("loads_echo")) != NULL) && (*env_echo == '1')) {
208 #ifdef CFG_LOADS_BAUD_CHANGE
210 offset = simple_strtoul(argv[1], NULL, 16);
213 load_baudrate = (int)simple_strtoul(argv[2], NULL, 10);
215 /* default to current baudrate */
216 if (load_baudrate == 0)
217 load_baudrate = current_baudrate;
219 #else /* ! CFG_LOADS_BAUD_CHANGE */
221 offset = simple_strtoul(argv[1], NULL, 16);
223 #endif /* CFG_LOADS_BAUD_CHANGE */
225 #ifdef CFG_LOADS_BAUD_CHANGE
226 if (load_baudrate != current_baudrate) {
227 printf ("## Switch baudrate to %d bps and press ENTER ...\n",
230 gd->baudrate = load_baudrate;
238 #endif /* CFG_LOADS_BAUD_CHANGE */
239 printf ("## Ready for S-Record download ...\n");
241 addr = load_serial (offset);
244 * Gather any trailing characters (for instance, the ^D which
245 * is sent by 'cu' after sending a file), and give the
246 * box some time (100 * 1 ms)
248 for (i=0; i<100; ++i) {
250 (void) serial_getc();
256 printf ("## S-Record download aborted\n");
259 printf ("## Start Addr = 0x%08lx\n", addr);
263 #ifdef CFG_LOADS_BAUD_CHANGE
264 if (load_baudrate != current_baudrate) {
265 printf ("## Switch baudrate to %d bps and press ESC ...\n",
268 gd->baudrate = current_baudrate;
272 if (getc() == 0x1B) /* ESC */
281 load_serial (ulong offset)
283 char record[SREC_MAXRECLEN + 1]; /* buffer for one S-Record */
284 char binbuf[SREC_MAXBINLEN]; /* buffer for binary data */
285 int binlen; /* no. of data bytes in S-Rec. */
286 int type; /* return code for record type */
287 ulong addr; /* load address from S-Record */
288 ulong size; /* number of bytes transferred */
291 ulong start_addr = ~0;
295 while (read_record(record, SREC_MAXRECLEN + 1) >= 0) {
296 type = srec_decode (record, &binlen, &addr, binbuf);
299 return (~0); /* Invalid S-Record */
306 store_addr = addr + offset;
307 if (addr2info(store_addr)) {
310 rc = flash_write((uchar *)binbuf,store_addr,binlen);
316 memcpy ((char *)(store_addr), binbuf, binlen);
318 if ((store_addr) < start_addr)
319 start_addr = store_addr;
320 if ((store_addr + binlen - 1) > end_addr)
321 end_addr = store_addr + binlen - 1;
327 size = end_addr - start_addr + 1;
329 "## First Load Addr = 0x%08lX\n"
330 "## Last Load Addr = 0x%08lX\n"
331 "## Total Size = 0x%08lX = %ld Bytes\n",
332 start_addr, end_addr, size, size
334 flush_cache (addr, size);
335 sprintf(buf, "%lX", size);
336 setenv("filesize", buf);
343 if (!do_echo) { /* print a '.' every 100 lines */
344 if ((++line_count % 100) == 0)
349 return (~0); /* Download aborted */
353 read_record (char *buf, ulong len)
358 --len; /* always leave room for terminating '\0' byte */
360 for (p=buf; p < buf+len; ++p) {
361 c = serial_getc(); /* read character */
363 serial_putc (c); /* ... and echo it */
371 case 0x03: /* ^C - Control C */
377 /* Check for the console hangup (if any different from serial) */
379 if (syscall_tbl[SYSCALL_GETC] != serial_getc) {
386 /* line too long - truncate */
391 #if (CONFIG_COMMANDS & CFG_CMD_SAVES)
393 int do_save_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
397 #ifdef CFG_LOADS_BAUD_CHANGE
398 DECLARE_GLOBAL_DATA_PTR;
399 int save_baudrate, current_baudrate;
401 save_baudrate = current_baudrate = gd->baudrate;
405 offset = simple_strtoul(argv[1], NULL, 16);
407 #ifdef CFG_LOADS_BAUD_CHANGE
409 size = simple_strtoul(argv[2], NULL, 16);
412 save_baudrate = (int)simple_strtoul(argv[3], NULL, 10);
414 /* default to current baudrate */
415 if (save_baudrate == 0)
416 save_baudrate = current_baudrate;
418 #else /* ! CFG_LOADS_BAUD_CHANGE */
420 size = simple_strtoul(argv[2], NULL, 16);
422 #endif /* CFG_LOADS_BAUD_CHANGE */
424 #ifdef CFG_LOADS_BAUD_CHANGE
425 if (save_baudrate != current_baudrate) {
426 printf ("## Switch baudrate to %d bps and press ENTER ...\n",
429 gd->baudrate = save_baudrate;
437 #endif /* CFG_LOADS_BAUD_CHANGE */
438 printf ("## Ready for S-Record upload, press ENTER to proceed ...\n");
443 if(save_serial (offset, size)) {
444 printf ("## S-Record upload aborted\n");
446 printf ("## S-Record upload complete\n");
448 #ifdef CFG_LOADS_BAUD_CHANGE
449 if (save_baudrate != current_baudrate) {
450 printf ("## Switch baudrate to %d bps and press ESC ...\n",
451 (int)current_baudrate);
453 gd->baudrate = current_baudrate;
457 if (getc() == 0x1B) /* ESC */
465 #define SREC3_START "S0030000FC\n"
466 #define SREC3_FORMAT "S3%02X%08lX%s%02X\n"
467 #define SREC3_END "S70500000000FA\n"
468 #define SREC_BYTES_PER_RECORD 16
470 static int save_serial (ulong address, ulong count)
472 int i, c, reclen, checksum, length;
473 char *hex = "0123456789ABCDEF";
474 char record[2*SREC_BYTES_PER_RECORD+16]; /* buffer for one S-Record */
475 char data[2*SREC_BYTES_PER_RECORD+1]; /* buffer for hex data */
480 if(write_record(SREC3_START)) /* write the header */
483 if(count) { /* collect hex data in the buffer */
484 c = *(volatile uchar*)(address + reclen); /* get one byte */
485 checksum += c; /* accumulate checksum */
486 data[2*reclen] = hex[(c>>4)&0x0f];
487 data[2*reclen+1] = hex[c & 0x0f];
488 data[2*reclen+2] = '\0';
492 if(reclen == SREC_BYTES_PER_RECORD || count == 0) {
493 /* enough data collected for one record: dump it */
494 if(reclen) { /* build & write a data record: */
495 /* address + data + checksum */
496 length = 4 + reclen + 1;
498 /* accumulate length bytes into checksum */
499 for(i = 0; i < 2; i++)
500 checksum += (length >> (8*i)) & 0xff;
502 /* accumulate address bytes into checksum: */
503 for(i = 0; i < 4; i++)
504 checksum += (address >> (8*i)) & 0xff;
506 /* make proper checksum byte: */
507 checksum = ~checksum & 0xff;
509 /* output one record: */
510 sprintf(record, SREC3_FORMAT, length, address, data, checksum);
511 if(write_record(record))
514 address += reclen; /* increment address */
520 if(write_record(SREC3_END)) /* write the final record */
526 write_record (char *buf)
533 /* Check for the console hangup (if any different from serial) */
540 # endif /* CFG_CMD_SAVES */
542 #endif /* CFG_CMD_LOADS */
545 #if (CONFIG_COMMANDS & CFG_CMD_LOADB) /* loadb command (load binary) included */
549 #define START_CHAR 0x01
550 #define END_CHAR 0x0D
552 #define K_ESCAPE 0x23
553 #define SEND_TYPE 'S'
554 #define DATA_TYPE 'D'
556 #define NACK_TYPE 'N'
557 #define BREAK_TYPE 'B'
558 #define tochar(x) ((char) (((x) + SPACE) & 0xff))
559 #define untochar(x) ((int) (((x) - SPACE) & 0xff))
561 extern int os_data_count;
562 extern int os_data_header[8];
564 static void set_kerm_bin_mode(unsigned long *);
565 static int k_recv(void);
566 static ulong load_serial_bin (ulong offset);
569 char his_eol; /* character he needs at end of packet */
570 int his_pad_count; /* number of pad chars he needs */
571 char his_pad_char; /* pad chars he needs */
572 char his_quote; /* quote chars he'll use */
574 int do_load_serial_bin (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
576 DECLARE_GLOBAL_DATA_PTR;
581 int load_baudrate, current_baudrate;
584 load_baudrate = current_baudrate = gd->baudrate;
587 offset = simple_strtoul(argv[1], NULL, 16);
590 load_baudrate = (int)simple_strtoul(argv[2], NULL, 10);
592 /* default to current baudrate */
593 if (load_baudrate == 0)
594 load_baudrate = current_baudrate;
597 if (load_baudrate != current_baudrate) {
598 printf ("## Switch baudrate to %d bps and press ENTER ...\n",
601 gd->baudrate = load_baudrate;
609 printf ("## Ready for binary (kermit) download ...\n");
611 addr = load_serial_bin (offset);
614 * Gather any trailing characters (for instance, the ^D which
615 * is sent by 'cu' after sending a file), and give the
616 * box some time (100 * 1 ms)
618 for (i=0; i<100; ++i) {
620 (void) serial_getc();
627 printf ("## Binary (kermit) download aborted\n");
630 printf ("## Start Addr = 0x%08lx\n", addr);
634 if (load_baudrate != current_baudrate) {
635 printf ("## Switch baudrate to %d bps and press ESC ...\n",
638 gd->baudrate = current_baudrate;
642 if (getc() == 0x1B) /* ESC */
647 #ifdef CONFIG_AUTOSCRIPT
651 if (((s = getenv("autoscript")) != NULL) && (strcmp(s,"yes") == 0)) {
652 printf("Running autoscript at addr 0x%08lX ...\n", load_addr);
653 rcode = autoscript (load_addr);
661 static ulong load_serial_bin (ulong offset)
666 set_kerm_bin_mode ((ulong *) offset);
668 flush_cache (offset, size);
670 printf("## Total Size = 0x%08x = %d Bytes\n", size, size);
671 sprintf(buf, "%X", size);
672 setenv("filesize", buf);
679 int count = his_pad_count;
682 serial_putc (his_pad_char);
685 /* converts escaped kermit char to binary char */
686 char ktrans (char in)
688 if ((in & 0x60) == 0x40) {
689 return (char) (in & ~0x40);
690 } else if ((in & 0x7f) == 0x3f) {
691 return (char) (in | 0x40);
696 int chk1 (char *buffer)
703 return (int) ((total + ((total >> 6) & 0x03)) & 0x3f);
706 void s1_sendpacket (char *packet)
710 serial_putc (*packet++);
715 void send_ack (int n)
722 a_b[4] = tochar (chk1 (&a_b[1]));
728 void send_nack (int n)
735 a_b[4] = tochar (chk1 (&a_b[1]));
743 /* os_data_* takes an OS Open image and puts it into memory, and
744 puts the boot header in an array named os_data_header
746 if image is binary, no header is stored in os_data_header.
748 void (*os_data_init) (void);
749 void (*os_data_char) (char new_char);
750 static int os_data_state, os_data_state_saved;
752 static int os_data_count_saved;
753 static char *os_data_addr, *os_data_addr_saved;
754 static char *bin_start_address;
755 int os_data_header[8];
756 static void bin_data_init (void)
760 os_data_addr = bin_start_address;
762 static void os_data_save (void)
764 os_data_state_saved = os_data_state;
765 os_data_count_saved = os_data_count;
766 os_data_addr_saved = os_data_addr;
768 static void os_data_restore (void)
770 os_data_state = os_data_state_saved;
771 os_data_count = os_data_count_saved;
772 os_data_addr = os_data_addr_saved;
774 static void bin_data_char (char new_char)
776 switch (os_data_state) {
778 *os_data_addr++ = new_char;
783 static void set_kerm_bin_mode (unsigned long *addr)
785 bin_start_address = (char *) addr;
786 os_data_init = bin_data_init;
787 os_data_char = bin_data_char;
791 /* k_data_* simply handles the kermit escape translations */
792 static int k_data_escape, k_data_escape_saved;
793 void k_data_init (void)
798 void k_data_save (void)
800 k_data_escape_saved = k_data_escape;
803 void k_data_restore (void)
805 k_data_escape = k_data_escape_saved;
808 void k_data_char (char new_char)
811 /* last char was escape - translate this character */
812 os_data_char (ktrans (new_char));
815 if (new_char == his_quote) {
816 /* this char is escape - remember */
819 /* otherwise send this char as-is */
820 os_data_char (new_char);
825 #define SEND_DATA_SIZE 20
826 char send_parms[SEND_DATA_SIZE];
829 /* handle_send_packet interprits the protocol info and builds and
830 sends an appropriate ack for what we can do */
831 void handle_send_packet (int n)
836 /* initialize some protocol parameters */
837 his_eol = END_CHAR; /* default end of line character */
840 his_quote = K_ESCAPE;
842 /* ignore last character if it filled the buffer */
843 if (send_ptr == &send_parms[SEND_DATA_SIZE - 1])
845 bytes = send_ptr - send_parms; /* how many bytes we'll process */
849 /* handle MAXL - max length */
850 /* ignore what he says - most I'll take (here) is 94 */
851 a_b[++length] = tochar (94);
854 /* handle TIME - time you should wait for my packets */
855 /* ignore what he says - don't wait for my ack longer than 1 second */
856 a_b[++length] = tochar (1);
859 /* handle NPAD - number of pad chars I need */
860 /* remember what he says - I need none */
861 his_pad_count = untochar (send_parms[2]);
862 a_b[++length] = tochar (0);
865 /* handle PADC - pad chars I need */
866 /* remember what he says - I need none */
867 his_pad_char = ktrans (send_parms[3]);
868 a_b[++length] = 0x40; /* He should ignore this */
871 /* handle EOL - end of line he needs */
872 /* remember what he says - I need CR */
873 his_eol = untochar (send_parms[4]);
874 a_b[++length] = tochar (END_CHAR);
877 /* handle QCTL - quote control char he'll use */
878 /* remember what he says - I'll use '#' */
879 his_quote = send_parms[5];
883 /* handle QBIN - 8-th bit prefixing */
884 /* ignore what he says - I refuse */
888 /* handle CHKT - the clock check type */
889 /* ignore what he says - I do type 1 (for now) */
893 /* handle REPT - the repeat prefix */
894 /* ignore what he says - I refuse (for now) */
898 /* handle CAPAS - the capabilities mask */
899 /* ignore what he says - I only do long packets - I don't do windows */
900 a_b[++length] = tochar (2); /* only long packets */
901 a_b[++length] = tochar (0); /* no windows */
902 a_b[++length] = tochar (94); /* large packet msb */
903 a_b[++length] = tochar (94); /* large packet lsb */
907 a_b[1] = tochar (length);
910 a_b[++length] = '\0';
911 a_b[length] = tochar (chk1 (&a_b[1]));
912 a_b[++length] = his_eol;
913 a_b[++length] = '\0';
917 /* k_recv receives a OS Open image file over kermit line */
918 static int k_recv (void)
921 char k_state, k_state_saved;
929 /* initialize some protocol parameters */
930 his_eol = END_CHAR; /* default end of line character */
933 his_quote = K_ESCAPE;
935 /* initialize the k_recv and k_data state machine */
939 k_state_saved = k_state;
941 n = 0; /* just to get rid of a warning */
944 /* expect this "type" sequence (but don't check):
949 B: break transmission
952 /* enter main loop */
954 /* set the send packet pointer to begining of send packet parms */
955 send_ptr = send_parms;
957 /* With each packet, start summing the bytes starting with the length.
958 Save the current sequence number.
959 Note the type of the packet.
960 If a character less than SPACE (0x20) is received - error.
964 /* OLD CODE, Prior to checking sequence numbers */
965 /* first have all state machines save current states */
966 k_state_saved = k_state;
971 /* wait for the starting character */
972 while (serial_getc () != START_CHAR);
973 /* get length of packet */
975 new_char = serial_getc ();
976 if ((new_char & 0xE0) == 0)
978 sum += new_char & 0xff;
979 length = untochar (new_char);
980 /* get sequence number */
981 new_char = serial_getc ();
982 if ((new_char & 0xE0) == 0)
984 sum += new_char & 0xff;
985 n = untochar (new_char);
988 /* NEW CODE - check sequence numbers for retried packets */
989 /* Note - this new code assumes that the sequence number is correctly
990 * received. Handling an invalid sequence number adds another layer
991 * of complexity that may not be needed - yet! At this time, I'm hoping
992 * that I don't need to buffer the incoming data packets and can write
993 * the data into memory in real time.
996 /* same sequence number, restore the previous state */
997 k_state = k_state_saved;
1000 /* new sequence number, checkpoint the download */
1002 k_state_saved = k_state;
1007 /* get packet type */
1008 new_char = serial_getc ();
1009 if ((new_char & 0xE0) == 0)
1011 sum += new_char & 0xff;
1014 /* check for extended length */
1016 /* (length byte was 0, decremented twice) */
1017 /* get the two length bytes */
1018 new_char = serial_getc ();
1019 if ((new_char & 0xE0) == 0)
1021 sum += new_char & 0xff;
1022 len_hi = untochar (new_char);
1023 new_char = serial_getc ();
1024 if ((new_char & 0xE0) == 0)
1026 sum += new_char & 0xff;
1027 len_lo = untochar (new_char);
1028 length = len_hi * 95 + len_lo;
1029 /* check header checksum */
1030 new_char = serial_getc ();
1031 if ((new_char & 0xE0) == 0)
1033 if (new_char != tochar ((sum + ((sum >> 6) & 0x03)) & 0x3f))
1035 sum += new_char & 0xff;
1036 /* --length; */ /* new length includes only data and block check to come */
1038 /* bring in rest of packet */
1039 while (length > 1) {
1040 new_char = serial_getc ();
1041 if ((new_char & 0xE0) == 0)
1043 sum += new_char & 0xff;
1045 if (k_state == DATA_TYPE) {
1046 /* pass on the data if this is a data packet */
1047 k_data_char (new_char);
1048 } else if (k_state == SEND_TYPE) {
1049 /* save send pack in buffer as is */
1050 *send_ptr++ = new_char;
1051 /* if too much data, back off the pointer */
1052 if (send_ptr >= &send_parms[SEND_DATA_SIZE])
1056 /* get and validate checksum character */
1057 new_char = serial_getc ();
1058 if ((new_char & 0xE0) == 0)
1060 if (new_char != tochar ((sum + ((sum >> 6) & 0x03)) & 0x3f))
1063 new_char = serial_getc ();
1064 if (new_char != END_CHAR) {
1066 /* restore state machines */
1067 k_state = k_state_saved;
1069 /* send a negative acknowledge packet in */
1071 } else if (k_state == SEND_TYPE) {
1072 /* crack the protocol parms, build an appropriate ack packet */
1073 handle_send_packet (n);
1075 /* send simple acknowledge packet in */
1077 /* quit if end of transmission */
1078 if (k_state == BREAK_TYPE)
1083 return ((ulong) os_data_addr - (ulong) bin_start_address);
1085 #endif /* CFG_CMD_LOADB */
1086 #if (CONFIG_COMMANDS & CFG_CMD_HWFLOW)
1087 int do_hwflow (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
1089 extern int hwflow_onoff(int);
1092 if (strcmp(argv[1], "off") == 0)
1095 if (strcmp(argv[1], "on") == 0)
1098 printf("Usage: %s\n", cmdtp->usage);
1100 printf("RTS/CTS hardware flow control: %s\n", hwflow_onoff(0) ? "on" : "off");
1103 #endif /* CFG_CMD_HWFLOW */