summaryrefslogtreecommitdiff
path: root/lib/x1000-installer/include/xf_flashmap.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/x1000-installer/include/xf_flashmap.h')
-rw-r--r--lib/x1000-installer/include/xf_flashmap.h91
1 files changed, 0 insertions, 91 deletions
diff --git a/lib/x1000-installer/include/xf_flashmap.h b/lib/x1000-installer/include/xf_flashmap.h
deleted file mode 100644
index b0470e58e0..0000000000
--- a/lib/x1000-installer/include/xf_flashmap.h
+++ /dev/null
@@ -1,91 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2021 Aidan MacDonald
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef _XF_FLASHMAP_H_
23#define _XF_FLASHMAP_H_
24
25#include "xf_stream.h"
26#include <stdint.h>
27
28#define XF_MAP_NAMELEN 63
29
30enum {
31 XF_MAP_HAS_MD5 = 0x01, /* 'md5' field is valid */
32 XF_MAP_HAS_FILE_LENGTH = 0x02, /* 'file_length' field is valid */
33};
34
35struct xf_map {
36 char name[XF_MAP_NAMELEN+1]; /* file name */
37 uint8_t md5[16]; /* MD5 sum of file */
38 uint32_t file_length; /* length of file in bytes */
39 uint32_t offset; /* offset in flash */
40 uint32_t length; /* region length in flash, in bytes */
41 int flags;
42};
43
44/* Parse a line with space- or tab-delimited fields of the form
45 * <name> <md5> <file_length> <offset> <length>
46 * <name> '-' <offset> <length>
47 *
48 * - name can be up to XF_FMAP_NAMELEN characters long
49 * - md5 is 32 hexadecimal characters (case insensitive)
50 * - file_length, offset, and length are 32-bit unsigned integers
51 * and can be given in decimal or (with '0x' prefix) hexadecimal
52 *
53 * Parsed data is written to *map. Returns zero on success and
54 * nonzero on error.
55 */
56int xf_map_parseline(const char* line, struct xf_map* map);
57
58/* Parse a file calling xf_map_parseline() on each line to populate
59 * a map of up to 'maxnum' regions. Blank and comment lines are
60 * ignored (comments start with '#').
61 *
62 * Returns the number of regions in the resulting map if the file was
63 * parsed successfully, or a negative value on error.
64 */
65int xf_map_parse(struct xf_stream* s, struct xf_map* map, int maxnum);
66
67/* Sort the map so its members are in ascending order with the lowest
68 * flash offset region first. After sorting, xf_map_validate() is used
69 * to check for overlapping regions.
70 *
71 * The return value is that of xf_map_validate().
72 */
73int xf_map_sort(struct xf_map* map, int num);
74
75/* Check if the input map is sorted and contains no overlap.
76 *
77 * Returns 0 if the map is sorted and contains no overlapping regions,
78 * -1 if the map isn't sorted, or if an overlapping region is detected,
79 * the index of the first overlapping region. (A returned index i is
80 * always positive: the two overlapped entries are map[i] and map[i-1].)
81 */
82int xf_map_validate(const struct xf_map* map, int num);
83
84/* Write the map to a stream. This does not check that the map is valid.
85 * Returns the number of bytes written to the stream or a negative value
86 * on error. The stream may be NULL, in which case the number of bytes
87 * that would be written are returned (similar to snprintf).
88 */
89int xf_map_write(struct xf_map* map, int num, struct xf_stream* s);
90
91#endif /* _XF_FLASHMAP_H_ */