]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
e6ca1ad6 SR |
2 | /* |
3 | * Copyright 2014 Broadcom Corporation. | |
e6ca1ad6 SR |
4 | */ |
5 | ||
6 | #include <part.h> | |
7 | #include <sparse_format.h> | |
8 | ||
9 | #define ROUNDUP(x, y) (((x) + ((y) - 1)) & ~((y) - 1)) | |
10 | ||
cc0f08cd SR |
11 | struct sparse_storage { |
12 | lbaint_t blksz; | |
13 | lbaint_t start; | |
14 | lbaint_t size; | |
15 | void *priv; | |
16 | ||
17 | lbaint_t (*write)(struct sparse_storage *info, | |
18 | lbaint_t blk, | |
19 | lbaint_t blkcnt, | |
20 | const void *buffer); | |
2c724046 SR |
21 | |
22 | lbaint_t (*reserve)(struct sparse_storage *info, | |
23 | lbaint_t blk, | |
24 | lbaint_t blkcnt); | |
2f83f219 | 25 | |
c4ded03e | 26 | void (*mssg)(const char *str, char *response); |
cc0f08cd | 27 | }; |
a5d1e04a | 28 | |
e6ca1ad6 SR |
29 | static inline int is_sparse_image(void *buf) |
30 | { | |
31 | sparse_header_t *s_header = (sparse_header_t *)buf; | |
32 | ||
33 | if ((le32_to_cpu(s_header->magic) == SPARSE_HEADER_MAGIC) && | |
34 | (le16_to_cpu(s_header->major_version) == 1)) | |
35 | return 1; | |
36 | ||
37 | return 0; | |
38 | } | |
39 | ||
2f83f219 | 40 | int write_sparse_image(struct sparse_storage *info, const char *part_name, |
c4ded03e | 41 | void *data, char *response); |