4 Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
6 This file is part of simavr.
8 simavr is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 simavr 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 simavr. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef __SIM_HEX_H___
24 #define __SIM_HEX_H___
32 // parses a hex text string 'src' of at max 'maxlen' characters, decodes it into 'buffer'
33 int read_hex_string(const char * src, uint8_t * buffer, int maxlen);
35 // a .hex file chunk (base address + size)
37 uint32_t baseaddr; // offset it started at in the .hex file
38 uint8_t * data; // read data
39 uint32_t size; // read data size
43 * Read a .hex file, detects the various different chunks in it from their starting
44 * addresses and fills up the chunks passed as arguments up to max_chunks.
45 * Returns the number of chunks found, or -1 if an error occurs.
47 int read_ihex_chunks(const char * fname, struct ihex_chunk_t * chunks, int max_chunks);
49 // reads IHEX file 'fname', puts it's decoded size in *'dsize' and returns
50 // a newly allocated buffer with the binary data (or NULL, if error)
51 uint8_t * read_ihex_file(const char * fname, uint32_t * dsize, uint32_t * start);
53 // hex dump from pointer 'b' for 'l' bytes with string prefix 'w'
54 void hdump(const char *w, uint8_t *b, size_t l);
60 #endif /* __SIM_HEX_H___ */