/usr/include/simavr/sim_hex.h is in libsimavr-dev 1.5+dfsg1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | /*
sim_hex.h
Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
This file is part of simavr.
simavr is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
simavr is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with simavr. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __SIM_HEX_H___
#define __SIM_HEX_H___
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
// parses a hex text string 'src' of at max 'maxlen' characters, decodes it into 'buffer'
int
read_hex_string(
const char * src,
uint8_t * buffer,
int maxlen);
// a .hex file chunk (base address + size)
typedef struct ihex_chunk_t {
uint32_t baseaddr; // offset it started at in the .hex file
uint8_t * data; // read data
uint32_t size; // read data size
} ihex_chunk_t, *ihex_chunk_p;
/*
* Read a .hex file, detects the various different chunks in it from their starting
* addresses and allocate an array of ihex_chunk_t returned in 'chunks'.
* Returns the number of chunks found, or -1 if an error occurs.
*/
int
read_ihex_chunks(
const char * fname,
ihex_chunk_p * chunks );
/* Frees previously allocated chunks */
void
free_ihex_chunks(
ihex_chunk_p chunks);
// reads IHEX file 'fname', puts it's decoded size in *'dsize' and returns
// a newly allocated buffer with the binary data (or NULL, if error)
uint8_t *
read_ihex_file(
const char * fname,
uint32_t * dsize,
uint32_t * start);
// hex dump from pointer 'b' for 'l' bytes with string prefix 'w'
void
hdump(
const char *w,
uint8_t *b, size_t l);
#ifdef __cplusplus
};
#endif
#endif /* __SIM_HEX_H___ */
|