blob: 511dfb78b81dae33a009938529df9b3ce5f46f7d [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: Intel */
Bin Meng2922b3e2014-12-12 21:05:28 +08002/*
3 * Copyright (C) 2013, Intel Corporation
4 * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
Bin Meng2922b3e2014-12-12 21:05:28 +08005 */
6
7#ifndef __FSP_FV___
8#define __FSP_FV___
9
10/* Value of EFI_FV_FILE_ATTRIBUTES */
11#define EFI_FV_FILE_ATTR_ALIGNMENT 0x0000001F
12#define EFI_FV_FILE_ATTR_FIXED 0x00000100
13#define EFI_FV_FILE_ATTR_MEMORY_MAPPED 0x00000200
14
15/* Attributes bit definitions */
16#define EFI_FVB2_READ_DISABLED_CAP 0x00000001
17#define EFI_FVB2_READ_ENABLED_CAP 0x00000002
18#define EFI_FVB2_READ_STATUS 0x00000004
19#define EFI_FVB2_WRITE_DISABLED_CAP 0x00000008
20#define EFI_FVB2_WRITE_ENABLED_CAP 0x00000010
21#define EFI_FVB2_WRITE_STATUS 0x00000020
22#define EFI_FVB2_LOCK_CAP 0x00000040
23#define EFI_FVB2_LOCK_STATUS 0x00000080
24#define EFI_FVB2_STICKY_WRITE 0x00000200
25#define EFI_FVB2_MEMORY_MAPPED 0x00000400
26#define EFI_FVB2_ERASE_POLARITY 0x00000800
27#define EFI_FVB2_READ_LOCK_CAP 0x00001000
28#define EFI_FVB2_READ_LOCK_STATUS 0x00002000
29#define EFI_FVB2_WRITE_LOCK_CAP 0x00004000
30#define EFI_FVB2_WRITE_LOCK_STATUS 0x00008000
31#define EFI_FVB2_ALIGNMENT 0x001F0000
32#define EFI_FVB2_ALIGNMENT_1 0x00000000
33#define EFI_FVB2_ALIGNMENT_2 0x00010000
34#define EFI_FVB2_ALIGNMENT_4 0x00020000
35#define EFI_FVB2_ALIGNMENT_8 0x00030000
36#define EFI_FVB2_ALIGNMENT_16 0x00040000
37#define EFI_FVB2_ALIGNMENT_32 0x00050000
38#define EFI_FVB2_ALIGNMENT_64 0x00060000
39#define EFI_FVB2_ALIGNMENT_128 0x00070000
40#define EFI_FVB2_ALIGNMENT_256 0x00080000
41#define EFI_FVB2_ALIGNMENT_512 0x00090000
42#define EFI_FVB2_ALIGNMENT_1K 0x000A0000
43#define EFI_FVB2_ALIGNMENT_2K 0x000B0000
44#define EFI_FVB2_ALIGNMENT_4K 0x000C0000
45#define EFI_FVB2_ALIGNMENT_8K 0x000D0000
46#define EFI_FVB2_ALIGNMENT_16K 0x000E0000
47#define EFI_FVB2_ALIGNMENT_32K 0x000F0000
48#define EFI_FVB2_ALIGNMENT_64K 0x00100000
49#define EFI_FVB2_ALIGNMENT_128K 0x00110000
50#define EFI_FVB2_ALIGNMENT_256K 0x00120000
51#define EFI_FVB2_ALIGNMENT_512K 0x00130000
52#define EFI_FVB2_ALIGNMENT_1M 0x00140000
53#define EFI_FVB2_ALIGNMENT_2M 0x00150000
54#define EFI_FVB2_ALIGNMENT_4M 0x00160000
55#define EFI_FVB2_ALIGNMENT_8M 0x00170000
56#define EFI_FVB2_ALIGNMENT_16M 0x00180000
57#define EFI_FVB2_ALIGNMENT_32M 0x00190000
58#define EFI_FVB2_ALIGNMENT_64M 0x001A0000
59#define EFI_FVB2_ALIGNMENT_128M 0x001B0000
60#define EFI_FVB2_ALIGNMENT_256M 0x001C0000
61#define EFI_FVB2_ALIGNMENT_512M 0x001D0000
62#define EFI_FVB2_ALIGNMENT_1G 0x001E0000
63#define EFI_FVB2_ALIGNMENT_2G 0x001F0000
64
Bin Mengdb60d862014-12-17 15:50:49 +080065struct fv_blkmap_entry {
Bin Meng2922b3e2014-12-12 21:05:28 +080066 /* The number of sequential blocks which are of the same size */
67 u32 num_blocks;
68 /* The size of the blocks */
69 u32 length;
70};
71
72/* Describes the features and layout of the firmware volume */
Bin Mengdb60d862014-12-17 15:50:49 +080073struct fv_header {
Bin Meng2922b3e2014-12-12 21:05:28 +080074 /*
75 * The first 16 bytes are reserved to allow for the reset vector of
76 * processors whose reset vector is at address 0.
77 */
78 u8 zero_vec[16];
79 /*
80 * Declares the file system with which the firmware volume
81 * is formatted.
82 */
Park, Aiden0961cf72019-08-03 08:30:20 +000083 efi_guid_t fs_guid;
Bin Meng2922b3e2014-12-12 21:05:28 +080084 /*
85 * Length in bytes of the complete firmware volume, including
86 * the header.
87 */
88 u64 fv_len;
89 /* Set to EFI_FVH_SIGNATURE */
90 u32 sign;
91 /*
92 * Declares capabilities and power-on defaults for the firmware
93 * volume.
94 */
95 u32 attr;
96 /* Length in bytes of the complete firmware volume header */
97 u16 hdr_len;
98 /*
99 * A 16-bit checksum of the firmware volume header.
100 * A valid header sums to zero.
101 */
102 u16 checksum;
103 /*
104 * Offset, relative to the start of the header, of the extended
105 * header (EFI_FIRMWARE_VOLUME_EXT_HEADER) or zero if there is
106 * no extended header.
107 */
108 u16 ext_hdr_off;
109 /* This field must always be set to zero */
110 u8 reserved[1];
111 /*
112 * Set to 2. Future versions of this specification may define new
113 * header fields and will increment the Revision field accordingly.
114 */
115 u8 rev;
116 /*
117 * An array of run-length encoded FvBlockMapEntry structures.
118 * The array is terminated with an entry of {0,0}.
119 */
Bin Mengdb60d862014-12-17 15:50:49 +0800120 struct fv_blkmap_entry block_map[1];
Bin Meng2922b3e2014-12-12 21:05:28 +0800121};
122
Bin Mengdb60d862014-12-17 15:50:49 +0800123#define EFI_FVH_SIGNATURE SIGNATURE_32('_', 'F', 'V', 'H')
Bin Meng2922b3e2014-12-12 21:05:28 +0800124
125/* Firmware Volume Header Revision definition */
126#define EFI_FVH_REVISION 0x02
127
128/* Extension header pointed by ExtHeaderOffset of volume header */
Bin Mengdb60d862014-12-17 15:50:49 +0800129struct fv_ext_header {
Bin Meng2922b3e2014-12-12 21:05:28 +0800130 /* firmware volume name */
Park, Aiden0961cf72019-08-03 08:30:20 +0000131 efi_guid_t fv_name;
Bin Meng2922b3e2014-12-12 21:05:28 +0800132 /* Size of the rest of the extension header including this structure */
133 u32 ext_hdr_size;
134};
135
136#endif