diff options
author | Iru Cai <mytbk920423@gmail.com> | 2019-10-30 14:21:52 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2019-10-30 14:48:38 +0800 |
commit | ae51f41d14f548d494ac41e0d21137c5a4c3f59c (patch) | |
tree | 6ddb9d1aaa7bd5bad5bbf8497edc2e08ff208d79 /include/image-sparse.h | |
download | uext4-ae51f41d14f548d494ac41e0d21137c5a4c3f59c.tar.xz |
import the U-Boot code and make it compile
Diffstat (limited to 'include/image-sparse.h')
-rw-r--r-- | include/image-sparse.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/include/image-sparse.h b/include/image-sparse.h new file mode 100644 index 0000000..234c237 --- /dev/null +++ b/include/image-sparse.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2014 Broadcom Corporation. + */ + +#include <part.h> +#include <sparse_format.h> + +#define ROUNDUP(x, y) (((x) + ((y) - 1)) & ~((y) - 1)) + +struct sparse_storage { + lbaint_t blksz; + lbaint_t start; + lbaint_t size; + void *priv; + + lbaint_t (*write)(struct sparse_storage *info, + lbaint_t blk, + lbaint_t blkcnt, + const void *buffer); + + lbaint_t (*reserve)(struct sparse_storage *info, + lbaint_t blk, + lbaint_t blkcnt); + + void (*mssg)(const char *str, char *response); +}; + +static inline int is_sparse_image(void *buf) +{ + sparse_header_t *s_header = (sparse_header_t *)buf; + + if ((le32_to_cpu(s_header->magic) == SPARSE_HEADER_MAGIC) && + (le16_to_cpu(s_header->major_version) == 1)) + return 1; + + return 0; +} + +int write_sparse_image(struct sparse_storage *info, const char *part_name, + void *data, char *response); |