mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-11 15:37:23 +00:00
2c72404687
In order to process the CHUNK_TYPE_DONT_CARE properly, there is a requirement to be able to 'reserve' a specified number of blocks in the storage media. Because of the special handling of "bad blocks" in NAND devices, this is implemented in a storage abstraction function. Signed-off-by: Steve Rae <srae@broadcom.com> Reviewed-by: Maxime Ripard <maxime.ripard@free-electrons.com>
40 lines
836 B
C
40 lines
836 B
C
/*
|
|
* Copyright 2014 Broadcom Corporation.
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
*/
|
|
|
|
#include <part.h>
|
|
#include <sparse_format.h>
|
|
|
|
#define ROUNDUP(x, y) (((x) + ((y) - 1)) & ~((y) - 1))
|
|
|
|
struct sparse_storage {
|
|
lbaint_t blksz;
|
|
lbaint_t start;
|
|
lbaint_t size;
|
|
void *priv;
|
|
|
|
lbaint_t (*write)(struct sparse_storage *info,
|
|
lbaint_t blk,
|
|
lbaint_t blkcnt,
|
|
const void *buffer);
|
|
|
|
lbaint_t (*reserve)(struct sparse_storage *info,
|
|
lbaint_t blk,
|
|
lbaint_t blkcnt);
|
|
};
|
|
|
|
static inline int is_sparse_image(void *buf)
|
|
{
|
|
sparse_header_t *s_header = (sparse_header_t *)buf;
|
|
|
|
if ((le32_to_cpu(s_header->magic) == SPARSE_HEADER_MAGIC) &&
|
|
(le16_to_cpu(s_header->major_version) == 1))
|
|
return 1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
void write_sparse_image(struct sparse_storage *info, const char *part_name,
|
|
void *data, unsigned sz);
|