xref: /rk3399_rockchip-uboot/include/sparse_format.h (revision 478a32875a222ee42755c68b80593885e2d666f6)
1*478a3287SColin Cross /*
2*478a3287SColin Cross  * This is from the Android Project,
3*478a3287SColin Cross  * Repository: https://android.googlesource.com/platform/system/core
4*478a3287SColin Cross  * File: libsparse/sparse_format.h
5*478a3287SColin Cross  * Commit: 28fa5bc347390480fe190294c6c385b6a9f0d68b
6*478a3287SColin Cross  * Copyright (C) 2010 The Android Open Source Project
7*478a3287SColin Cross  *
8*478a3287SColin Cross  * SPDX-License-Identifier: BSD-3-Clause
9*478a3287SColin Cross  */
10*478a3287SColin Cross 
11*478a3287SColin Cross #ifndef _LIBSPARSE_SPARSE_FORMAT_H_
12*478a3287SColin Cross #define _LIBSPARSE_SPARSE_FORMAT_H_
13*478a3287SColin Cross #include "sparse_defs.h"
14*478a3287SColin Cross 
15*478a3287SColin Cross typedef struct sparse_header {
16*478a3287SColin Cross   __le32	magic;		/* 0xed26ff3a */
17*478a3287SColin Cross   __le16	major_version;	/* (0x1) - reject images with higher major versions */
18*478a3287SColin Cross   __le16	minor_version;	/* (0x0) - allow images with higer minor versions */
19*478a3287SColin Cross   __le16	file_hdr_sz;	/* 28 bytes for first revision of the file format */
20*478a3287SColin Cross   __le16	chunk_hdr_sz;	/* 12 bytes for first revision of the file format */
21*478a3287SColin Cross   __le32	blk_sz;		/* block size in bytes, must be a multiple of 4 (4096) */
22*478a3287SColin Cross   __le32	total_blks;	/* total blocks in the non-sparse output image */
23*478a3287SColin Cross   __le32	total_chunks;	/* total chunks in the sparse input image */
24*478a3287SColin Cross   __le32	image_checksum; /* CRC32 checksum of the original data, counting "don't care" */
25*478a3287SColin Cross 				/* as 0. Standard 802.3 polynomial, use a Public Domain */
26*478a3287SColin Cross 				/* table implementation */
27*478a3287SColin Cross } sparse_header_t;
28*478a3287SColin Cross 
29*478a3287SColin Cross #define SPARSE_HEADER_MAGIC	0xed26ff3a
30*478a3287SColin Cross 
31*478a3287SColin Cross #define CHUNK_TYPE_RAW		0xCAC1
32*478a3287SColin Cross #define CHUNK_TYPE_FILL		0xCAC2
33*478a3287SColin Cross #define CHUNK_TYPE_DONT_CARE	0xCAC3
34*478a3287SColin Cross #define CHUNK_TYPE_CRC32    0xCAC4
35*478a3287SColin Cross 
36*478a3287SColin Cross typedef struct chunk_header {
37*478a3287SColin Cross   __le16	chunk_type;	/* 0xCAC1 -> raw; 0xCAC2 -> fill; 0xCAC3 -> don't care */
38*478a3287SColin Cross   __le16	reserved1;
39*478a3287SColin Cross   __le32	chunk_sz;	/* in blocks in output image */
40*478a3287SColin Cross   __le32	total_sz;	/* in bytes of chunk input file including chunk header and data */
41*478a3287SColin Cross } chunk_header_t;
42*478a3287SColin Cross 
43*478a3287SColin Cross /* Following a Raw or Fill or CRC32 chunk is data.
44*478a3287SColin Cross  *  For a Raw chunk, it's the data in chunk_sz * blk_sz.
45*478a3287SColin Cross  *  For a Fill chunk, it's 4 bytes of the fill data.
46*478a3287SColin Cross  *  For a CRC32 chunk, it's 4 bytes of CRC32
47*478a3287SColin Cross  */
48*478a3287SColin Cross 
49*478a3287SColin Cross #endif
50