]> git.ipfire.org Git - thirdparty/u-boot.git/blame - include/image-sparse.h
configs: at91: sama7g54_curiosity: Add initial default configs
[thirdparty/u-boot.git] / include / image-sparse.h
CommitLineData
83d290c5 1/* SPDX-License-Identifier: GPL-2.0+ */
e6ca1ad6
SR
2/*
3 * Copyright 2014 Broadcom Corporation.
e6ca1ad6
SR
4 */
5
401d1c4f 6#include <compiler.h>
e6ca1ad6
SR
7#include <part.h>
8#include <sparse_format.h>
9
b1aade87
MK
10#define FASTBOOT_MAX_BLK_WRITE 16384
11
e6ca1ad6
SR
12#define ROUNDUP(x, y) (((x) + ((y) - 1)) & ~((y) - 1))
13
cc0f08cd
SR
14struct sparse_storage {
15 lbaint_t blksz;
16 lbaint_t start;
17 lbaint_t size;
18 void *priv;
19
20 lbaint_t (*write)(struct sparse_storage *info,
21 lbaint_t blk,
22 lbaint_t blkcnt,
23 const void *buffer);
2c724046
SR
24
25 lbaint_t (*reserve)(struct sparse_storage *info,
26 lbaint_t blk,
27 lbaint_t blkcnt);
2f83f219 28
c4ded03e 29 void (*mssg)(const char *str, char *response);
cc0f08cd 30};
a5d1e04a 31
e6ca1ad6
SR
32static inline int is_sparse_image(void *buf)
33{
34 sparse_header_t *s_header = (sparse_header_t *)buf;
35
36 if ((le32_to_cpu(s_header->magic) == SPARSE_HEADER_MAGIC) &&
37 (le16_to_cpu(s_header->major_version) == 1))
38 return 1;
39
40 return 0;
41}
42
2f83f219 43int write_sparse_image(struct sparse_storage *info, const char *part_name,
c4ded03e 44 void *data, char *response);