1 //==========================================================================
5 // usb download support for RedBoot
7 //==========================================================================
8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12 // Copyright (C) 2002, 2003 Gary Thomas
14 // eCos is free software; you can redistribute it and/or modify it under
15 // the terms of the GNU General Public License as published by the Free
16 // Software Foundation; either version 2 or (at your option) any later version.
18 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
19 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 // You should have received a copy of the GNU General Public License along
24 // with eCos; if not, write to the Free Software Foundation, Inc.,
25 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27 // As a special exception, if other files instantiate templates or use macros
28 // or inline functions from this file, or you compile this file and link it
29 // with other works to produce a work based on this file, this file does not
30 // by itself cause the resulting work to be covered by the GNU General Public
31 // License. However the source code for this file must still be made available
32 // in accordance with section (3) of the GNU General Public License.
34 // This exception does not invalidate any other reasons why a work based on
35 // this file might be covered by the GNU General Public License.
37 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
38 // at http://sources.redhat.com/ecos/ecos-license/
39 // -------------------------------------------
40 //####ECOSGPLCOPYRIGHTEND####
41 //==========================================================================
42 //#####DESCRIPTIONBEGIN####
44 // Author(s): Kevin Zhang
45 // Contributors: Kevin Zhang
48 // Description: this code is based on tftp_client.c
50 // This code is part of RedBoot (tm).
52 //####DESCRIPTIONEND####
54 //==========================================================================
60 int total_timeouts, packets_received;
61 unsigned long last_good_block;
62 int avail, actual_len;
63 // char data[SEGSIZE+sizeof(struct mxcusbhdr)];
67 extern void mxc_pcd_open(void);
68 extern void mxc_pcd_exit(void);
69 extern int mxc_pcd_int_hndlr(long buffer, long length);
72 mxcusb_stream_open(connection_info_t *info,
75 // diag_printf("%s()\n", __FUNCTION__);
82 mxcusb_stream_close(int *err)
84 // diag_printf("%s()\n", __FUNCTION__);
90 mxcusb_stream_terminate(bool abort,
95 // diag_printf("%s()\n", __FUNCTION__);
99 mxcusb_stream_read(char *buf,
103 // diag_printf("%s(len=%d buf=%x)\n", __FUNCTION__, len, buf);
105 return mxc_pcd_int_hndlr(buf, len);
109 mxcusb_error(int err)
111 char *errmsg = "Unknown error";
113 diag_printf("%s()\n", __FUNCTION__);
116 case MXCUSB_ENOTFOUND:
117 return "file not found";
119 return "access violation";
120 case MXCUSB_ENOSPACE:
121 return "disk full or allocation exceeded";
123 return "illegal MXCUSB operation";
125 return "unknown transfer ID";
127 return "file already exists";
129 return "no such user";
131 return "operation timed out";
133 return "invalid parameter";
134 case MXCUSB_TOOLARGE:
135 return "file is larger than buffer";
144 GETC_IO_FUNCS(mxcusb_io, mxcusb_stream_open, mxcusb_stream_close,
145 mxcusb_stream_terminate, mxcusb_stream_read, mxcusb_error);
146 RedBoot_load(usb, mxcusb_io, true, false, 0);