SimAVR
AVR Simulator
sim_hex.h
Go to the documentation of this file.
1 /*
2  * sim_hex.h
3  *
4  * Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
5  *
6  * This file is part of simavr.
7  *
8  * simavr is free software: you can redistribute it and/or modify it under the terms of the GNU
9  * General Public License as published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * simavr is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
13  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14  * Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along with simavr. If not, see
17  * <http://www.gnu.org/licenses/>.
18  */
19 
25 #ifndef __SIM_HEX_H___
26 #define __SIM_HEX_H___
27 
28 #include <stdint.h>
29 
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif
34 
36  int read_hex_string (const char *src, uint8_t * buffer, int maxlen);
37 
39  typedef struct ihex_chunk_t
40  {
41  uint32_t baseaddr;
42  uint8_t *data;
43  uint32_t size;
45 
49  int read_ihex_chunks (const char *fname, ihex_chunk_p * chunks);
50 
53  uint8_t *read_ihex_file (const char *fname, uint32_t * dsize, uint32_t * start);
54 
56  void hdump (const char *w, uint8_t * b, size_t l);
57 
58 #ifdef __cplusplus
59 };
60 #endif
61 
62 #endif /* __SIM_HEX_H___ */
63 
int read_hex_string(const char *src, uint8_t *buffer, int maxlen)
Parses a hex text string 'src' of at max 'maxlen' characters, decodes it into 'buffer'.
Definition: sim_hex.c:57
struct ihex_chunk_t * ihex_chunk_p
void hdump(const char *w, uint8_t *b, size_t l)
Hex dump from pointer 'b' for 'l' bytes with string prefix 'w'.
Definition: sim_hex.c:28
uint32_t baseaddr
offset it started at in the .hex file
Definition: sim_hex.h:41
uint8_t * data
read data
Definition: sim_hex.h:42
struct ihex_chunk_t ihex_chunk_t
A .hex file chunk (base address + size)
A .hex file chunk (base address + size)
Definition: sim_hex.h:39
int read_ihex_chunks(const char *fname, ihex_chunk_p *chunks)
Read a .hex file, detects the various different chunks in it from their starting addresses and alloca...
Definition: sim_hex.c:174
uint32_t size
read data size
Definition: sim_hex.h:43
uint8_t * read_ihex_file(const char *fname, uint32_t *dsize, uint32_t *start)
Reads IHEX file 'fname', puts it's decoded size in *'dsize' and returns a newly allocated buffer with...
Definition: sim_hex.c:97