xref: /freebsd/sys/dev/sfxge/common/ef10_signed_image_layout.h (revision 1d386b48a555f61cb7325543adbbb5c3f3407a66)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2016-2018 Solarflare Communications Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice,
11  *    this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  *    this list of conditions and the following disclaimer in the documentation
14  *    and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * The views and conclusions contained in the software and documentation are
29  * those of the authors and should not be interpreted as representing official
30  * policies, either expressed or implied, of the FreeBSD Project.
31  */
32 
33 /*
34  * This is NOT the original source file. Do NOT edit it.
35  * To update the image layout headers, please edit the copy in
36  * the sfregistry repo and then, in that repo,
37  * "make layout_headers" or "make export" to
38  * regenerate and export all types of headers.
39  */
40 
41 /*
42  * These structures define the layouts for the signed firmware image binary
43  * saved in NVRAM. The original image is in the Cryptographic message
44  * syntax (CMS) format which contains the bootable firmware binary plus the
45  * signatures. The entire image is written into NVRAM to enable the firmware
46  * to validate the signatures. However, the bootrom still requires the
47  * bootable-image to start at offset 0 of the NVRAM partition. Hence the image
48  * is parsed upfront by host utilities (sfupdate) and written into nvram as
49  * 'signed_image_chunks' described by a header.
50  *
51  * This file is used by the MC as well as host-utilities (sfupdate).
52  */
53 
54 #ifndef _SYS_EF10_SIGNED_IMAGE_LAYOUT_H
55 #define	_SYS_EF10_SIGNED_IMAGE_LAYOUT_H
56 
57 /* Signed image chunk type identifiers */
58 enum {
59 	SIGNED_IMAGE_CHUNK_CMS_HEADER,		/* CMS header describing the signed data */
60 	SIGNED_IMAGE_CHUNK_REFLASH_HEADER,	/* Reflash header */
61 	SIGNED_IMAGE_CHUNK_IMAGE,		/* Bootable binary image */
62 	SIGNED_IMAGE_CHUNK_REFLASH_TRAILER,	/* Reflash trailer */
63 	SIGNED_IMAGE_CHUNK_SIGNATURE,		/* Remaining contents of the signed image,
64 						 * including the certifiates and signature */
65 	NUM_SIGNED_IMAGE_CHUNKS,
66 };
67 
68 /* Magic */
69 #define	SIGNED_IMAGE_CHUNK_HDR_MAGIC	0xEF105161	/* EF10 SIGned Image */
70 
71 /* Initial version definition - version 1 */
72 #define	SIGNED_IMAGE_CHUNK_HDR_VERSION	0x1
73 
74 /* Header length is 32 bytes */
75 #define	SIGNED_IMAGE_CHUNK_HDR_LEN	32
76 
77 /*
78  * Structure describing the header of each chunk of signed image
79  * as stored in NVRAM.
80  */
81 typedef struct signed_image_chunk_hdr_e {
82 	/*
83 	 * Magic field to recognise a valid entry
84 	 * should match SIGNED_IMAGE_CHUNK_HDR_MAGIC
85 	 */
86 	uint32_t magic;
87 	/* Version number of this header */
88 	uint32_t version;
89 	/* Chunk type identifier */
90 	uint32_t id;
91 	/* Chunk offset */
92 	uint32_t offset;
93 	/* Chunk length */
94 	uint32_t len;
95 	/*
96 	 * Reserved for future expansion of this structure - always
97 	 * set to zeros
98 	 */
99 	uint32_t reserved[3];
100 } signed_image_chunk_hdr_t;
101 
102 #endif	/* _SYS_EF10_SIGNED_IMAGE_LAYOUT_H */
103