Steve Rae | e6ca1ad | 2014-09-03 10:05:54 -0700 | [diff] [blame] | 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 | |
Steve Rae | e6ca1ad | 2014-09-03 10:05:54 -0700 | [diff] [blame] | 12 | static inline int is_sparse_image(void *buf) |
| 13 | { |
| 14 | sparse_header_t *s_header = (sparse_header_t *)buf; |
| 15 | |
| 16 | if ((le32_to_cpu(s_header->magic) == SPARSE_HEADER_MAGIC) && |
| 17 | (le16_to_cpu(s_header->major_version) == 1)) |
| 18 | return 1; |
| 19 | |
| 20 | return 0; |
| 21 | } |
| 22 | |
Maxime Ripard | 3c8f98f | 2015-10-15 14:34:13 +0200 | [diff] [blame^] | 23 | int write_sparse_image(block_dev_desc_t *dev_desc, |
| 24 | disk_partition_t *info, const char *part_name, |
| 25 | void *data, unsigned sz); |