]> git.ipfire.org Git - people/ms/u-boot.git/blame - include/image-sparse.h
boards: axs10x, nsim, tb100: Enable cmdline history
[people/ms/u-boot.git] / include / image-sparse.h
CommitLineData
e6ca1ad6
SR
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
cc0f08cd
SR
12struct sparse_storage {
13 lbaint_t blksz;
14 lbaint_t start;
15 lbaint_t size;
16 void *priv;
17
18 lbaint_t (*write)(struct sparse_storage *info,
19 lbaint_t blk,
20 lbaint_t blkcnt,
21 const void *buffer);
2c724046
SR
22
23 lbaint_t (*reserve)(struct sparse_storage *info,
24 lbaint_t blk,
25 lbaint_t blkcnt);
cc0f08cd 26};
a5d1e04a 27
e6ca1ad6
SR
28static inline int is_sparse_image(void *buf)
29{
30 sparse_header_t *s_header = (sparse_header_t *)buf;
31
32 if ((le32_to_cpu(s_header->magic) == SPARSE_HEADER_MAGIC) &&
33 (le16_to_cpu(s_header->major_version) == 1))
34 return 1;
35
36 return 0;
37}
38
cc0f08cd 39void write_sparse_image(struct sparse_storage *info, const char *part_name,
9bc34799 40 void *data, unsigned sz);