xref: /openbmc/u-boot/include/image-sparse.h (revision 23ff8633)
1 /*
2  * Copyright 2014 Broadcom Corporation.
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 
7 #include <part.h>
8 #include <sparse_format.h>
9 
10 #define ROUNDUP(x, y)	(((x) + ((y) - 1)) & ~((y) - 1))
11 
12 typedef struct sparse_storage {
13 	unsigned int	block_sz;
14 	unsigned int	start;
15 	unsigned int	size;
16 	const char	*name;
17 
18 	int	(*write)(struct sparse_storage *storage, void *priv,
19 			 unsigned int offset, unsigned int size,
20 			 char *data);
21 } sparse_storage_t;
22 
23 static inline int is_sparse_image(void *buf)
24 {
25 	sparse_header_t *s_header = (sparse_header_t *)buf;
26 
27 	if ((le32_to_cpu(s_header->magic) == SPARSE_HEADER_MAGIC) &&
28 	    (le16_to_cpu(s_header->major_version) == 1))
29 		return 1;
30 
31 	return 0;
32 }
33 
34 int store_sparse_image(sparse_storage_t *storage, void *storage_priv,
35 		       unsigned int session_id, void *data);
36