1 /***************************************************************************
2 * Copyright (C) 2007 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
23 #define FILEIO_MAX_ERROR_STRING (128)
25 /* make buffering of complete intel-hex format files optional
26 * to account for resource-limited hosts
28 #define FILEIO_BUFFER_COMPLETE_IHEX
43 * Possible future enhancements:
53 * Possible future enhancements:
64 FILEIO_READ, /* open for reading, position at beginning */
65 FILEIO_WRITE, /* open for writing, position at beginning */
66 FILEIO_READWRITE, /* open for writing, position at beginning, allow reading */
67 FILEIO_APPEND, /* open for writing, position at end */
68 FILEIO_APPENDREAD, /* open for writing, position at end, allow reading */
71 typedef struct fileio_s
74 char error_str[FILEIO_MAX_ERROR_STRING];
76 enum fileio_pri_type pri_type;
77 enum fileio_sec_type sec_type;
78 enum fileio_location location;
79 enum fileio_access access;
80 void *location_private;
81 void *pri_type_private;
82 void *sec_type_private;
85 typedef struct fileio_text_s
89 typedef struct fileio_image_s
92 int has_start_address;
96 typedef struct fileio_local_s
99 struct stat file_stat;
102 typedef struct fileio_ihex_s
106 #ifdef FILEIO_BUFFER_COMPLETE_IHEX
111 extern int fileio_identify_image_type(enum fileio_sec_type *sec_type, char *type_string);
112 extern int fileio_write(fileio_t *fileio, u32 size, u8 *buffer, u32 *size_written);
113 extern int fileio_read(fileio_t *fileio, u32 size, u8 *buffer, u32 *size_read);
114 extern int fileio_seek(fileio_t *fileio, u32 position);
115 extern int fileio_close(fileio_t *fileio);
116 extern int fileio_open(fileio_t *fileio, char *url, enum fileio_access access,
117 enum fileio_pri_type pri_type, void *pri_info, enum fileio_sec_type sec_type);
119 #define ERROR_FILEIO_LOCATION_UNKNOWN (-1200)
120 #define ERROR_FILEIO_NOT_FOUND (-1201)
121 #define ERROR_FILEIO_OPERATION_FAILED (-1202)
122 #define ERROR_FILEIO_ACCESS_NOT_SUPPORTED (-1203)
123 #define ERROR_FILEIO_RESOURCE_TYPE_UNKNOWN (-1204)
124 #define ERROR_FILEIO_OPERATION_NOT_SUPPORTED (-1205)
126 #endif /* FILEIO_H */