xref: /freebsd/sys/dev/sfxge/common/ef10_signed_image_layout.h (revision 6be3386466ab79a84b48429ae66244f21526d3df)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
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  * $FreeBSD$
33  */
34 
35 /*
36  * This is NOT the original source file. Do NOT edit it.
37  * To update the image layout headers, please edit the copy in
38  * the sfregistry repo and then, in that repo,
39  * "make layout_headers" or "make export" to
40  * regenerate and export all types of headers.
41  */
42 
43 /*
44  * These structures define the layouts for the signed firmware image binary
45  * saved in NVRAM. The original image is in the Cryptographic message
46  * syntax (CMS) format which contains the bootable firmware binary plus the
47  * signatures. The entire image is written into NVRAM to enable the firmware
48  * to validate the signatures. However, the bootrom still requires the
49  * bootable-image to start at offset 0 of the NVRAM partition. Hence the image
50  * is parsed upfront by host utilities (sfupdate) and written into nvram as
51  * 'signed_image_chunks' described by a header.
52  *
53  * This file is used by the MC as well as host-utilities (sfupdate).
54  */
55 
56 #ifndef _SYS_EF10_SIGNED_IMAGE_LAYOUT_H
57 #define	_SYS_EF10_SIGNED_IMAGE_LAYOUT_H
58 
59 /* Signed image chunk type identifiers */
60 enum {
61 	SIGNED_IMAGE_CHUNK_CMS_HEADER,		/* CMS header describing the signed data */
62 	SIGNED_IMAGE_CHUNK_REFLASH_HEADER,	/* Reflash header */
63 	SIGNED_IMAGE_CHUNK_IMAGE,		/* Bootable binary image */
64 	SIGNED_IMAGE_CHUNK_REFLASH_TRAILER,	/* Reflash trailer */
65 	SIGNED_IMAGE_CHUNK_SIGNATURE,		/* Remaining contents of the signed image,
66 						 * including the certifiates and signature */
67 	NUM_SIGNED_IMAGE_CHUNKS,
68 };
69 
70 /* Magic */
71 #define	SIGNED_IMAGE_CHUNK_HDR_MAGIC	0xEF105161	/* EF10 SIGned Image */
72 
73 /* Initial version definition - version 1 */
74 #define	SIGNED_IMAGE_CHUNK_HDR_VERSION	0x1
75 
76 /* Header length is 32 bytes */
77 #define	SIGNED_IMAGE_CHUNK_HDR_LEN	32
78 
79 /*
80  * Structure describing the header of each chunk of signed image
81  * as stored in NVRAM.
82  */
83 typedef struct signed_image_chunk_hdr_e {
84 	/*
85 	 * Magic field to recognise a valid entry
86 	 * should match SIGNED_IMAGE_CHUNK_HDR_MAGIC
87 	 */
88 	uint32_t magic;
89 	/* Version number of this header */
90 	uint32_t version;
91 	/* Chunk type identifier */
92 	uint32_t id;
93 	/* Chunk offset */
94 	uint32_t offset;
95 	/* Chunk length */
96 	uint32_t len;
97 	/*
98 	 * Reserved for future expansion of this structure - always
99 	 * set to zeros
100 	 */
101 	uint32_t reserved[3];
102 } signed_image_chunk_hdr_t;
103 
104 #endif	/* _SYS_EF10_SIGNED_IMAGE_LAYOUT_H */
105