diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-12-19 21:46:52 +0000 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2022-12-23 19:54:18 +0000 |
commit | ba010851fafea3da0d0655b103158f0a9efe6406 (patch) | |
tree | bb26879ee1ac5e2d578948701b20c1bb33db14a9 /lib/x1000-installer/include | |
parent | 6e794c9a2d9e91a926f70d0fcc66e255b0bdc221 (diff) | |
download | rockbox-ba010851fafea3da0d0655b103158f0a9efe6406.tar.gz rockbox-ba010851fafea3da0d0655b103158f0a9efe6406.zip |
Remove lib/x1000-installer
Carrying this library is somewhat of a maintenance burden because
some Rockbox APIs are mocked or duplicated in the test suite and
thus need to be fixed up when refactoring.
It's also unused & incomplete, so there's no good reason to keep
it in tree any more.
Change-Id: If39c62744b4edc0d81b1b6608ee5df69430e6581
Diffstat (limited to 'lib/x1000-installer/include')
-rw-r--r-- | lib/x1000-installer/include/xf_error.h | 43 | ||||
-rw-r--r-- | lib/x1000-installer/include/xf_flashmap.h | 91 | ||||
-rw-r--r-- | lib/x1000-installer/include/xf_nandio.h | 130 | ||||
-rw-r--r-- | lib/x1000-installer/include/xf_package.h | 65 | ||||
-rw-r--r-- | lib/x1000-installer/include/xf_stream.h | 64 | ||||
-rw-r--r-- | lib/x1000-installer/include/xf_update.h | 53 |
6 files changed, 0 insertions, 446 deletions
diff --git a/lib/x1000-installer/include/xf_error.h b/lib/x1000-installer/include/xf_error.h deleted file mode 100644 index 2f3f6a1a4f..0000000000 --- a/lib/x1000-installer/include/xf_error.h +++ /dev/null | |||
@@ -1,43 +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_ERROR_H_ | ||
23 | #define _XF_ERROR_H_ | ||
24 | |||
25 | enum { | ||
26 | XF_E_SUCCESS = 0, | ||
27 | XF_E_IO = -1, | ||
28 | XF_E_LINE_TOO_LONG = -2, | ||
29 | XF_E_FILENAME_TOO_LONG = -3, | ||
30 | XF_E_INT_OVERFLOW = -4, | ||
31 | XF_E_BUF_OVERFLOW = -5, | ||
32 | XF_E_SYNTAX_ERROR = -6, | ||
33 | XF_E_INVALID_PARAMETER = -7, | ||
34 | XF_E_NAND = -8, | ||
35 | XF_E_OUT_OF_MEMORY = -9, | ||
36 | XF_E_OUT_OF_RANGE = -10, | ||
37 | XF_E_VERIFY_FAILED = -11, | ||
38 | XF_E_CANNOT_OPEN_FILE = -12, | ||
39 | }; | ||
40 | |||
41 | const char* xf_strerror(int err); | ||
42 | |||
43 | #endif /* _XF_ERROR_H_ */ | ||
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 | |||
30 | enum { | ||
31 | XF_MAP_HAS_MD5 = 0x01, /* 'md5' field is valid */ | ||
32 | XF_MAP_HAS_FILE_LENGTH = 0x02, /* 'file_length' field is valid */ | ||
33 | }; | ||
34 | |||
35 | struct 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 | */ | ||
56 | int 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 | */ | ||
65 | int 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 | */ | ||
73 | int 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 | */ | ||
82 | int 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 | */ | ||
89 | int xf_map_write(struct xf_map* map, int num, struct xf_stream* s); | ||
90 | |||
91 | #endif /* _XF_FLASHMAP_H_ */ | ||
diff --git a/lib/x1000-installer/include/xf_nandio.h b/lib/x1000-installer/include/xf_nandio.h deleted file mode 100644 index a10b71992c..0000000000 --- a/lib/x1000-installer/include/xf_nandio.h +++ /dev/null | |||
@@ -1,130 +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_NANDIO_H_ | ||
23 | #define _XF_NANDIO_H_ | ||
24 | |||
25 | #include "nand-x1000.h" | ||
26 | #include <stdint.h> | ||
27 | #include <stddef.h> | ||
28 | |||
29 | enum xf_nandio_mode { | ||
30 | XF_NANDIO_READ = 0, | ||
31 | XF_NANDIO_PROGRAM, | ||
32 | XF_NANDIO_VERIFY, | ||
33 | }; | ||
34 | |||
35 | struct xf_nandio { | ||
36 | nand_drv* ndrv; | ||
37 | int nand_err; /* copy of the last NAND error code */ | ||
38 | int alloc_handle; | ||
39 | enum xf_nandio_mode mode; | ||
40 | |||
41 | size_t block_size; /* size of a block, in bytes */ | ||
42 | size_t page_size; /* size of a page, in bytes */ | ||
43 | |||
44 | uint8_t* old_buf; /* contains the 'old' block data already on chip */ | ||
45 | uint8_t* new_buf; /* contains the possibly modified 'new' block data */ | ||
46 | |||
47 | nand_block_t cur_block; /* address of the current block */ | ||
48 | size_t offset_in_block; /* byte offset in the current block */ | ||
49 | unsigned block_valid: 1; /* 1 if buffered block data is valid */ | ||
50 | }; | ||
51 | |||
52 | int xf_nandio_init(struct xf_nandio* nio); | ||
53 | void xf_nandio_destroy(struct xf_nandio* nio); | ||
54 | |||
55 | /** Sets the operational mode, which determines read/write/flush semantics. | ||
56 | * | ||
57 | * - XF_NANDIO_READ: Accesses the chip in read-only mode. Writes are allowed, | ||
58 | * but should not be used. (Writes will modify a temporary buffer but this | ||
59 | * will not alter the flash contents.) | ||
60 | * | ||
61 | * - XF_NANDIO_PROGRAM: Writes are allowed to modify the flash contents. | ||
62 | * Writes within a block are accumulated in a temporary buffer. When | ||
63 | * crossing a block boundary, either by writing past the end the current | ||
64 | * block or by seeking to a new one, the data written to the temporary | ||
65 | * buffer is compared against the current flash contents. If the block | ||
66 | * has been modified, it is erased and any non-blank pages are programmed | ||
67 | * with the new data. | ||
68 | * | ||
69 | * - XF_NANDIO_VERIFY: This mode allows callers to easily check whether the | ||
70 | * flash contents match some expected contents. Callers "write" the expected | ||
71 | * contents as if programming it with XF_NANDIO_PROGRAM. When a block is | ||
72 | * flushed, if the written data doesn't match the block contents, an | ||
73 | * XF_E_VERIFY_FAILED error is returned. The flash contents will not be | ||
74 | * altered in this mode. | ||
75 | * | ||
76 | * \returns XF_E_SUCCESS or a negative error code on failure. | ||
77 | */ | ||
78 | int xf_nandio_set_mode(struct xf_nandio* nio, enum xf_nandio_mode mode); | ||
79 | |||
80 | /** Seek to a given byte offset in the NAND flash. | ||
81 | * | ||
82 | * If the new offset is outside the current block, the current block will | ||
83 | * be automatically flushed. Note this can result in verification or program | ||
84 | * failures as with any other flush. | ||
85 | * | ||
86 | * \returns XF_E_SUCCESS or a negative error code on failure. | ||
87 | */ | ||
88 | int xf_nandio_seek(struct xf_nandio* nio, size_t offset); | ||
89 | |||
90 | /** Read or write a contiguous sequence of bytes from flash. | ||
91 | * | ||
92 | * The read or write starts at the current position and continues for `count` | ||
93 | * bytes. Both reads and writes may cross block boundaries. Modified blocks | ||
94 | * will be flushed automatically if the operation crosses a block boundary. | ||
95 | * | ||
96 | * After a successful read or write, the current position is advanced by | ||
97 | * exactly `count` bytes. After a failure, the position is indeterminate. | ||
98 | * | ||
99 | * \returns XF_E_SUCCESS or a negative error code on failure. | ||
100 | */ | ||
101 | int xf_nandio_read(struct xf_nandio* nio, void* buf, size_t count); | ||
102 | int xf_nandio_write(struct xf_nandio* nio, const void* buf, size_t count); | ||
103 | |||
104 | /** Get a pointer to the block buffer for direct read/write access. | ||
105 | * | ||
106 | * These functions can be used to read or write data without intermediate | ||
107 | * buffers. The caller passes in the amount of data to be transferred in | ||
108 | * `*count`. A pointer to part of the block buffer is returned in `*buf` | ||
109 | * and the number of bytes available in `*buf` is returned in `*count`. | ||
110 | * | ||
111 | * Data at the current position can be read from the returned buffer and | ||
112 | * it may be modified by writing to the buffer. The buffer is only valid | ||
113 | * until the next call to an `xf_nandio` function. | ||
114 | * | ||
115 | * The read/write position is advanced by the returned `*count` on success, | ||
116 | * and is unchanged on failure. | ||
117 | * | ||
118 | * \returns XF_E_SUCCESS or a negative error code on failure. | ||
119 | */ | ||
120 | int xf_nandio_get_buffer(struct xf_nandio* nio, void** buf, size_t* count); | ||
121 | |||
122 | /** Flush the buffered block to ensure all outstanding program or verification | ||
123 | * operations have been performed. This should only be called to ensure the | ||
124 | * final modified block is flushed after you have finished writing all data. | ||
125 | * | ||
126 | * \returns XF_E_SUCCESS or a negative error code on failure. | ||
127 | */ | ||
128 | int xf_nandio_flush(struct xf_nandio* nio); | ||
129 | |||
130 | #endif /* _XF_NANDIO_H_ */ | ||
diff --git a/lib/x1000-installer/include/xf_package.h b/lib/x1000-installer/include/xf_package.h deleted file mode 100644 index 6633766bd7..0000000000 --- a/lib/x1000-installer/include/xf_package.h +++ /dev/null | |||
@@ -1,65 +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_PACKAGE_H_ | ||
23 | #define _XF_PACKAGE_H_ | ||
24 | |||
25 | /* package format | ||
26 | * | ||
27 | * - bootloader-info.txt (contains a version label and optional metadata) | ||
28 | * - flashmap.txt (describes the flash update map) | ||
29 | * - [package must contain any other files referenced by the flash map] | ||
30 | * - [other files may be present, but are ignored] | ||
31 | */ | ||
32 | |||
33 | #include "xf_flashmap.h" | ||
34 | #include "xf_stream.h" | ||
35 | #include "microtar.h" | ||
36 | |||
37 | struct xf_package { | ||
38 | int alloc_handle; | ||
39 | mtar_t* tar; | ||
40 | struct xf_map* map; | ||
41 | int map_size; | ||
42 | char* metadata; | ||
43 | size_t metadata_len; | ||
44 | }; | ||
45 | |||
46 | /** Open an update package | ||
47 | * | ||
48 | * \param pkg Uninitialized package structure | ||
49 | * \param file Name of the package file | ||
50 | * \param dflt_map Default flash map for loading old format packages | ||
51 | * \param dflt_map_size Size of the default flash map | ||
52 | * \returns XF_E_SUCCESS or a negative error code | ||
53 | */ | ||
54 | int xf_package_open_ex(struct xf_package* pkg, const char* file, | ||
55 | const struct xf_map* dflt_map, int dflt_map_size); | ||
56 | |||
57 | /** Close a package which was previously opened successfully */ | ||
58 | void xf_package_close(struct xf_package* pkg); | ||
59 | |||
60 | static inline int xf_package_open(struct xf_package* pkg, const char* file) | ||
61 | { | ||
62 | return xf_package_open_ex(pkg, file, NULL, 0); | ||
63 | } | ||
64 | |||
65 | #endif /* _XF_PACKAGE_H_ */ | ||
diff --git a/lib/x1000-installer/include/xf_stream.h b/lib/x1000-installer/include/xf_stream.h deleted file mode 100644 index adbde1c6db..0000000000 --- a/lib/x1000-installer/include/xf_stream.h +++ /dev/null | |||
@@ -1,64 +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_STREAM_H_ | ||
23 | #define _XF_STREAM_H_ | ||
24 | |||
25 | #include <stddef.h> | ||
26 | #include <stdint.h> | ||
27 | #include <sys/types.h> /* ssize_t */ | ||
28 | #include "microtar.h" | ||
29 | |||
30 | struct xf_stream; | ||
31 | |||
32 | struct xf_stream_ops { | ||
33 | off_t(*xget_size)(struct xf_stream* s); | ||
34 | ssize_t(*xread)(struct xf_stream* s, void* buf, size_t len); | ||
35 | ssize_t(*xwrite)(struct xf_stream* s, const void* buf, size_t len); | ||
36 | int(*xclose)(struct xf_stream* s); | ||
37 | }; | ||
38 | |||
39 | struct xf_stream { | ||
40 | intptr_t data; | ||
41 | const struct xf_stream_ops* ops; | ||
42 | }; | ||
43 | |||
44 | inline size_t xf_stream_get_size(struct xf_stream* s) | ||
45 | { return s->ops->xget_size(s); } | ||
46 | |||
47 | inline ssize_t xf_stream_read(struct xf_stream* s, void* buf, size_t len) | ||
48 | { return s->ops->xread(s, buf, len); } | ||
49 | |||
50 | inline ssize_t xf_stream_write(struct xf_stream* s, const void* buf, size_t len) | ||
51 | { return s->ops->xwrite(s, buf, len); } | ||
52 | |||
53 | inline int xf_stream_close(struct xf_stream* s) | ||
54 | { return s->ops->xclose(s); } | ||
55 | |||
56 | int xf_open_file(const char* file, int flags, struct xf_stream* s); | ||
57 | int xf_open_tar(mtar_t* mtar, const char* file, struct xf_stream* s); | ||
58 | int xf_create_tar(mtar_t* mtar, const char* file, size_t size, struct xf_stream* s); | ||
59 | |||
60 | /* Utility function needed for a few things */ | ||
61 | int xf_stream_read_lines(struct xf_stream* s, char* buf, size_t bufsz, | ||
62 | int(*callback)(int n, char* buf, void* arg), void* arg); | ||
63 | |||
64 | #endif /* _XF_STREAM_H_ */ | ||
diff --git a/lib/x1000-installer/include/xf_update.h b/lib/x1000-installer/include/xf_update.h deleted file mode 100644 index e421a21793..0000000000 --- a/lib/x1000-installer/include/xf_update.h +++ /dev/null | |||
@@ -1,53 +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_UPDATE_H_ | ||
23 | #define _XF_UPDATE_H_ | ||
24 | |||
25 | #include "xf_package.h" | ||
26 | #include "xf_nandio.h" | ||
27 | #include "xf_flashmap.h" | ||
28 | |||
29 | typedef int(*xf_update_open_stream_cb)(void* arg, const char* file, | ||
30 | struct xf_stream* stream); | ||
31 | |||
32 | enum xf_update_mode { | ||
33 | XF_UPDATE, | ||
34 | XF_BACKUP, | ||
35 | XF_VERIFY, | ||
36 | }; | ||
37 | |||
38 | /** The main updater entry point | ||
39 | * | ||
40 | * \param mode Operational mode | ||
41 | * \param nio Initialized NAND I/O object. | ||
42 | * \param map Flash map describing what regions to update. | ||
43 | * \param map_size Number of entries in the map. | ||
44 | * \param open_stream Callback used to open a stream for each map entry. | ||
45 | * \param arg Argument passed to the `open_stream` callback. | ||
46 | * | ||
47 | * \returns XF_E_SUCCESS on success or a negative error code on failure. | ||
48 | */ | ||
49 | int xf_updater_run(enum xf_update_mode mode, struct xf_nandio* nio, | ||
50 | struct xf_map* map, int map_size, | ||
51 | xf_update_open_stream_cb open_stream, void* arg); | ||
52 | |||
53 | #endif /* _XF_UPDATE_H_ */ | ||