forked from patrickmt/mdloader
-
Notifications
You must be signed in to change notification settings - Fork 79
/
mdloader_parser.h
54 lines (47 loc) · 1.53 KB
/
mdloader_parser.h
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
/*
* Copyright (C) 2018 Massdrop Inc.
*
* This file is part of Massdrop Loader.
*
* Massdrop Loader 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.
*
* Massdrop Loader 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 Massdrop Loader. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _MDLOADER_PARSER_H
#define _MDLOADER_PARSER_H
#define EXT_HEX ".hex"
#define EXT_BIN ".bin"
#define FTYPE_NONE 0 //No file type
#define FTYPE_HEX 1 //HEX file type detected
#define FTYPE_BIN 2 //BIN file type detected
typedef struct data_s {
uint32_t addr;
uint32_t size;
char *data;
} data_t;
void free_data(data_t *data);
data_t *create_data(uint32_t data_length);
data_t *load_file(char *fname);
#pragma pack(push, 1)
typedef struct hex_record_s {
char start_code; //:
char byte_count[2]; //XX
union {
uint32_t i;
uint8_t c[4]; //XXXX
} address;
char record_type[2]; //XX
//<- variable length ASCII data matching byte_count*2 ->
//XX checksum
} hex_record_t;
#pragma pack(pop)
#endif //_MDLOADER_PARSER_H