b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2011, Marvell Semiconductor Inc. |
| 3 | * Lei Wen <leiwen@marvell.com> |
| 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
| 8 | typedef struct sparse_header { |
| 9 | __le32 magic; /* 0xed26ff3a */ |
| 10 | __le16 major_version; /* (0x1) - reject images with higher major versions */ |
| 11 | __le16 minor_version; /* (0x0) - allow images with higer minor versions */ |
| 12 | __le16 file_hdr_sz; /* 28 bytes for first revision of the file format */ |
| 13 | __le16 chunk_hdr_sz; /* 12 bytes for first revision of the file format */ |
| 14 | __le32 blk_sz; /* block size in bytes, must be a multiple of 4 (4096) */ |
| 15 | __le32 total_blks; /* total blocks in the non-sparse output image */ |
| 16 | __le32 total_chunks; /* total chunks in the sparse input image */ |
| 17 | __le32 image_checksum; /* CRC32 checksum of the original data, counting "don't care" */ |
| 18 | /* as 0. Standard 802.3 polynomial, use a Public Domain */ |
| 19 | /* table implementation */ |
| 20 | __le32 reserved1; |
| 21 | } sparse_header_t; |
| 22 | |
| 23 | #define SPARSE_HEADER_MAGIC 0xed26ff3a |
| 24 | |
| 25 | #define CHUNK_TYPE_RAW 0xCAC1 |
| 26 | #define CHUNK_TYPE_FILL 0xCAC2 |
| 27 | #define CHUNK_TYPE_DONT_CARE 0xCAC3 |
| 28 | |
| 29 | typedef struct chunk_header { |
| 30 | __le16 chunk_type; /* 0xCAC1 -> raw; 0xCAC2 -> fill; 0xCAC3 -> don't care */ |
| 31 | __le16 reserved1; |
| 32 | __le32 reserved2; |
| 33 | __le32 chunk_sz; /* in blocks in output image */ |
| 34 | __le32 total_sz; /* in bytes of chunk input file including chunk header and data */ |
| 35 | } chunk_header_t; |