blob: a2b0694190d99ed8235f98c622a581e589f347e3 [file] [log] [blame]
Steve Raee6ca1ad2014-09-03 10:05:54 -07001/*
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
Maxime Riparda5d1e042015-10-15 14:34:14 +020012typedef 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
Steve Raee6ca1ad2014-09-03 10:05:54 -070023static 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
Maxime Riparda5d1e042015-10-15 14:34:14 +020034int store_sparse_image(sparse_storage_t *storage, void *storage_priv,
35 void *data);