1391763d7SAndrew Rybchenko /*-
24d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3391763d7SAndrew Rybchenko  *
4391763d7SAndrew Rybchenko  * Copyright (c) 2016-2018 Solarflare Communications Inc.
5391763d7SAndrew Rybchenko  * All rights reserved.
6391763d7SAndrew Rybchenko  *
7391763d7SAndrew Rybchenko  * Redistribution and use in source and binary forms, with or without
8391763d7SAndrew Rybchenko  * modification, are permitted provided that the following conditions are met:
9391763d7SAndrew Rybchenko  *
10391763d7SAndrew Rybchenko  * 1. Redistributions of source code must retain the above copyright notice,
11391763d7SAndrew Rybchenko  *    this list of conditions and the following disclaimer.
12391763d7SAndrew Rybchenko  * 2. Redistributions in binary form must reproduce the above copyright notice,
13391763d7SAndrew Rybchenko  *    this list of conditions and the following disclaimer in the documentation
14391763d7SAndrew Rybchenko  *    and/or other materials provided with the distribution.
15391763d7SAndrew Rybchenko  *
16391763d7SAndrew Rybchenko  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17391763d7SAndrew Rybchenko  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18391763d7SAndrew Rybchenko  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19391763d7SAndrew Rybchenko  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20391763d7SAndrew Rybchenko  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21391763d7SAndrew Rybchenko  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22391763d7SAndrew Rybchenko  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23391763d7SAndrew Rybchenko  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24391763d7SAndrew Rybchenko  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25391763d7SAndrew Rybchenko  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26391763d7SAndrew Rybchenko  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27391763d7SAndrew Rybchenko  *
28391763d7SAndrew Rybchenko  * The views and conclusions contained in the software and documentation are
29391763d7SAndrew Rybchenko  * those of the authors and should not be interpreted as representing official
30391763d7SAndrew Rybchenko  * policies, either expressed or implied, of the FreeBSD Project.
31391763d7SAndrew Rybchenko  */
32391763d7SAndrew Rybchenko 
33391763d7SAndrew Rybchenko /*
34391763d7SAndrew Rybchenko  * This is NOT the original source file. Do NOT edit it.
35391763d7SAndrew Rybchenko  * To update the image layout headers, please edit the copy in
36391763d7SAndrew Rybchenko  * the sfregistry repo and then, in that repo,
37391763d7SAndrew Rybchenko  * "make layout_headers" or "make export" to
38391763d7SAndrew Rybchenko  * regenerate and export all types of headers.
39391763d7SAndrew Rybchenko  */
40391763d7SAndrew Rybchenko 
41391763d7SAndrew Rybchenko /*
42391763d7SAndrew Rybchenko  * These structures define the layouts for the signed firmware image binary
43391763d7SAndrew Rybchenko  * saved in NVRAM. The original image is in the Cryptographic message
44391763d7SAndrew Rybchenko  * syntax (CMS) format which contains the bootable firmware binary plus the
45391763d7SAndrew Rybchenko  * signatures. The entire image is written into NVRAM to enable the firmware
46391763d7SAndrew Rybchenko  * to validate the signatures. However, the bootrom still requires the
47391763d7SAndrew Rybchenko  * bootable-image to start at offset 0 of the NVRAM partition. Hence the image
48391763d7SAndrew Rybchenko  * is parsed upfront by host utilities (sfupdate) and written into nvram as
49391763d7SAndrew Rybchenko  * 'signed_image_chunks' described by a header.
50391763d7SAndrew Rybchenko  *
51391763d7SAndrew Rybchenko  * This file is used by the MC as well as host-utilities (sfupdate).
52391763d7SAndrew Rybchenko  */
53391763d7SAndrew Rybchenko 
54391763d7SAndrew Rybchenko #ifndef _SYS_EF10_SIGNED_IMAGE_LAYOUT_H
55391763d7SAndrew Rybchenko #define	_SYS_EF10_SIGNED_IMAGE_LAYOUT_H
56391763d7SAndrew Rybchenko 
57391763d7SAndrew Rybchenko /* Signed image chunk type identifiers */
58391763d7SAndrew Rybchenko enum {
59391763d7SAndrew Rybchenko 	SIGNED_IMAGE_CHUNK_CMS_HEADER,		/* CMS header describing the signed data */
60391763d7SAndrew Rybchenko 	SIGNED_IMAGE_CHUNK_REFLASH_HEADER,	/* Reflash header */
61391763d7SAndrew Rybchenko 	SIGNED_IMAGE_CHUNK_IMAGE,		/* Bootable binary image */
62391763d7SAndrew Rybchenko 	SIGNED_IMAGE_CHUNK_REFLASH_TRAILER,	/* Reflash trailer */
63391763d7SAndrew Rybchenko 	SIGNED_IMAGE_CHUNK_SIGNATURE,		/* Remaining contents of the signed image,
64391763d7SAndrew Rybchenko 						 * including the certifiates and signature */
65391763d7SAndrew Rybchenko 	NUM_SIGNED_IMAGE_CHUNKS,
66391763d7SAndrew Rybchenko };
67391763d7SAndrew Rybchenko 
68391763d7SAndrew Rybchenko /* Magic */
69391763d7SAndrew Rybchenko #define	SIGNED_IMAGE_CHUNK_HDR_MAGIC	0xEF105161	/* EF10 SIGned Image */
70391763d7SAndrew Rybchenko 
71391763d7SAndrew Rybchenko /* Initial version definition - version 1 */
72391763d7SAndrew Rybchenko #define	SIGNED_IMAGE_CHUNK_HDR_VERSION	0x1
73391763d7SAndrew Rybchenko 
74391763d7SAndrew Rybchenko /* Header length is 32 bytes */
75391763d7SAndrew Rybchenko #define	SIGNED_IMAGE_CHUNK_HDR_LEN	32
76391763d7SAndrew Rybchenko 
77391763d7SAndrew Rybchenko /*
78391763d7SAndrew Rybchenko  * Structure describing the header of each chunk of signed image
79391763d7SAndrew Rybchenko  * as stored in NVRAM.
80391763d7SAndrew Rybchenko  */
81391763d7SAndrew Rybchenko typedef struct signed_image_chunk_hdr_e {
82391763d7SAndrew Rybchenko 	/*
83391763d7SAndrew Rybchenko 	 * Magic field to recognise a valid entry
84391763d7SAndrew Rybchenko 	 * should match SIGNED_IMAGE_CHUNK_HDR_MAGIC
85391763d7SAndrew Rybchenko 	 */
86391763d7SAndrew Rybchenko 	uint32_t magic;
87391763d7SAndrew Rybchenko 	/* Version number of this header */
88391763d7SAndrew Rybchenko 	uint32_t version;
89391763d7SAndrew Rybchenko 	/* Chunk type identifier */
90391763d7SAndrew Rybchenko 	uint32_t id;
91391763d7SAndrew Rybchenko 	/* Chunk offset */
92391763d7SAndrew Rybchenko 	uint32_t offset;
93391763d7SAndrew Rybchenko 	/* Chunk length */
94391763d7SAndrew Rybchenko 	uint32_t len;
95391763d7SAndrew Rybchenko 	/*
96391763d7SAndrew Rybchenko 	 * Reserved for future expansion of this structure - always
97391763d7SAndrew Rybchenko 	 * set to zeros
98391763d7SAndrew Rybchenko 	 */
99391763d7SAndrew Rybchenko 	uint32_t reserved[3];
100391763d7SAndrew Rybchenko } signed_image_chunk_hdr_t;
101391763d7SAndrew Rybchenko 
102391763d7SAndrew Rybchenko #endif	/* _SYS_EF10_SIGNED_IMAGE_LAYOUT_H */
103