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'
39 // a .hex file chunk (base address + size)
40 typedef struct ihex_chunk_t {
41 uint32_t baseaddr; // offset it started at in the .hex file
42 uint8_t * data; // read data
43 uint32_t size; // read data size
44 } ihex_chunk_t, *ihex_chunk_p;
47 * Read a .hex file, detects the various different chunks in it from their starting
48 * addresses and allocate an array of ihex_chunk_t returned in 'chunks'.
49 * Returns the number of chunks found, or -1 if an error occurs.
54 ihex_chunk_p * chunks );
56 // reads IHEX file 'fname', puts it's decoded size in *'dsize' and returns
57 // a newly allocated buffer with the binary data (or NULL, if error)
64 // hex dump from pointer 'b' for 'l' bytes with string prefix 'w'
68 uint8_t *b, size_t l);
74 #endif /* __SIM_HEX_H___ */