blob: 11b79968b0b8e71a8996903cfe2cfc665c063654 [file] [log] [blame]
Zheng Baoc5e28ab2020-10-28 11:38:09 +08001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#ifndef _AMD_FW_TOOL_H_
4#define _AMD_FW_TOOL_H_
5
Karthikeyan Ramasubramanian236245e2022-09-06 14:02:41 -06006#include <commonlib/bsd/compiler.h>
Elyes Haouas7d67a192022-10-14 09:58:29 +02007#include <commonlib/bsd/helpers.h>
Kangheui Won5b84dfd2021-12-21 15:45:06 +11008#include <openssl/sha.h>
Zheng Bao6be1ab62021-05-26 10:16:33 +08009#include <stdint.h>
Zheng Baoba3af5e2021-11-04 18:56:47 +080010#include <stdbool.h>
Zheng Bao6be1ab62021-05-26 10:16:33 +080011
Zheng Baof080cd52023-03-22 12:50:36 +080012#define ERASE_ALIGNMENT 0x1000U
13#define TABLE_ALIGNMENT 0x1000U
14#define BLOB_ALIGNMENT 0x100U
15#define TABLE_ERASE_ALIGNMENT _MAX(TABLE_ALIGNMENT, ERASE_ALIGNMENT)
16#define BLOB_ERASE_ALIGNMENT _MAX(BLOB_ALIGNMENT, ERASE_ALIGNMENT)
17
Zheng Bao4bf6f492023-01-25 22:37:29 +080018enum platform {
19 PLATFORM_UNKNOWN,
20 PLATFORM_CARRIZO,
21 PLATFORM_STONEYRIDGE,
22 PLATFORM_RAVEN,
23 PLATFORM_PICASSO,
24 PLATFORM_RENOIR,
25 PLATFORM_CEZANNE,
26 PLATFORM_MENDOCINO,
27 PLATFORM_LUCIENNE,
28 PLATFORM_PHOENIX,
29 PLATFORM_GLINDA
30};
31
Zheng Baoc5e28ab2020-10-28 11:38:09 +080032typedef enum _amd_fw_type {
Arthur Heymansaafbe132022-09-30 08:33:28 +020033 AMD_FW_PSP_PUBKEY = 0x00,
34 AMD_FW_PSP_BOOTLOADER = 0x01,
35 AMD_FW_PSP_SECURED_OS = 0x02,
36 AMD_FW_PSP_RECOVERY = 0x03,
37 AMD_FW_PSP_NVRAM = 0x04,
38 AMD_FW_PSP_RTM_PUBKEY = 0x05,
39 AMD_FW_PSP_SMU_FIRMWARE = 0x08,
40 AMD_FW_PSP_SECURED_DEBUG = 0x09,
Arthur Heymans1f05c802022-10-04 17:50:21 +020041 AMD_FW_ABL_PUBKEY = 0x0a,
Arthur Heymansaafbe132022-09-30 08:33:28 +020042 AMD_PSP_FUSE_CHAIN = 0x0b,
43 AMD_FW_PSP_TRUSTLETS = 0x0c,
44 AMD_FW_PSP_TRUSTLETKEY = 0x0d,
45 AMD_FW_PSP_SMU_FIRMWARE2 = 0x12,
Zheng Baoc5e28ab2020-10-28 11:38:09 +080046 AMD_DEBUG_UNLOCK = 0x13,
Zheng Bao8eba6622022-10-16 20:29:03 +080047 AMD_BOOT_DRIVER = 0x1b,
48 AMD_SOC_DRIVER = 0x1c,
49 AMD_DEBUG_DRIVER = 0x1d,
50 AMD_INTERFACE_DRIVER = 0x1f,
Zheng Baobf29a0d2020-12-03 23:00:48 +080051 AMD_HW_IPCFG = 0x20,
Zheng Baoc5e28ab2020-10-28 11:38:09 +080052 AMD_WRAPPED_IKEK = 0x21,
53 AMD_TOKEN_UNLOCK = 0x22,
54 AMD_SEC_GASKET = 0x24,
55 AMD_MP2_FW = 0x25,
56 AMD_DRIVER_ENTRIES = 0x28,
Zheng Baobf29a0d2020-12-03 23:00:48 +080057 AMD_FW_KVM_IMAGE = 0x29,
Arthur Heymans1f05c802022-10-04 17:50:21 +020058 AMD_FW_MP5 = 0x2a,
Zheng Baoc5e28ab2020-10-28 11:38:09 +080059 AMD_S0I3_DRIVER = 0x2d,
60 AMD_ABL0 = 0x30,
61 AMD_ABL1 = 0x31,
62 AMD_ABL2 = 0x32,
63 AMD_ABL3 = 0x33,
64 AMD_ABL4 = 0x34,
65 AMD_ABL5 = 0x35,
66 AMD_ABL6 = 0x36,
67 AMD_ABL7 = 0x37,
Arthur Heymans1f05c802022-10-04 17:50:21 +020068 AMD_SEV_DATA = 0x38,
69 AMD_SEV_CODE = 0x39,
Zheng Baoc5e28ab2020-10-28 11:38:09 +080070 AMD_FW_PSP_WHITELIST = 0x3a,
Zheng Baobf29a0d2020-12-03 23:00:48 +080071 AMD_VBIOS_BTLOADER = 0x3c,
Zheng Baoc5e28ab2020-10-28 11:38:09 +080072 AMD_FW_L2_PTR = 0x40,
Arthur Heymans1f05c802022-10-04 17:50:21 +020073 AMD_FW_DXIO = 0x42,
Zheng Baobf29a0d2020-12-03 23:00:48 +080074 AMD_FW_USB_PHY = 0x44,
75 AMD_FW_TOS_SEC_POLICY = 0x45,
76 AMD_FW_DRTM_TA = 0x47,
Zheng Bao990d1542021-09-17 13:24:54 +080077 AMD_FW_RECOVERYAB_A = 0x48,
78 AMD_FW_RECOVERYAB_B = 0x4A,
79 AMD_FW_BIOS_TABLE = 0x49,
Zheng Baobf29a0d2020-12-03 23:00:48 +080080 AMD_FW_KEYDB_BL = 0x50,
81 AMD_FW_KEYDB_TOS = 0x51,
Zheng Baoc5e28ab2020-10-28 11:38:09 +080082 AMD_FW_PSP_VERSTAGE = 0x52,
83 AMD_FW_VERSTAGE_SIG = 0x53,
Zheng Baobf29a0d2020-12-03 23:00:48 +080084 AMD_RPMC_NVRAM = 0x54,
Zheng Baoab84fd72022-01-27 22:38:27 +080085 AMD_FW_SPL = 0x55,
Zheng Baobf29a0d2020-12-03 23:00:48 +080086 AMD_FW_DMCU_ERAM = 0x58,
87 AMD_FW_DMCU_ISR = 0x59,
Felix Held5f18bb72022-03-24 02:04:51 +010088 AMD_FW_MSMU = 0x5a,
89 AMD_FW_SPIROM_CFG = 0x5c,
Arthur Heymans1f05c802022-10-04 17:50:21 +020090 AMD_FW_MPIO = 0x5d,
Felix Held9f5a5ee2023-02-01 19:21:11 +010091 AMD_FW_TPMLITE = 0x5f, /* family 17h & 19h */
92 AMD_FW_PSP_SMUSCS = 0x5f, /* family 15h & 16h */
Felix Held5f18bb72022-03-24 02:04:51 +010093 AMD_FW_DMCUB = 0x71,
Zheng Baob993cb22021-02-02 18:48:23 +080094 AMD_FW_PSP_BOOTLOADER_AB = 0x73,
Arthur Heymans1f05c802022-10-04 17:50:21 +020095 AMD_RIB = 0x76,
Zheng Bao8eba6622022-10-16 20:29:03 +080096 AMD_FW_AMF_SRAM = 0x85,
97 AMD_FW_AMF_DRAM = 0x86,
98 AMD_FW_AMF_WLAN = 0x88,
99 AMD_FW_AMF_MFD = 0x89,
Arthur Heymans1f05c802022-10-04 17:50:21 +0200100 AMD_FW_MPDMA_TF = 0x8c,
Karthikeyan Ramasubramanian0ab04d22022-05-03 18:16:34 -0600101 AMD_TA_IKEK = 0x8d,
Zheng Bao8eba6622022-10-16 20:29:03 +0800102 AMD_FW_MPCCX = 0x90,
Arthur Heymans1f05c802022-10-04 17:50:21 +0200103 AMD_FW_GMI3_PHY = 0x91,
104 AMD_FW_MPDMA_PM = 0x92,
Zheng Bao8eba6622022-10-16 20:29:03 +0800105 AMD_FW_LSDMA = 0x94,
106 AMD_FW_C20_MP = 0x95,
107 AMD_FW_FCFG_TABLE = 0x98,
108 AMD_FW_MINIMSMU = 0x9a,
109 AMD_FW_SRAM_FW_EXT = 0x9d,
Fred Reitbergerc4f3a332023-02-07 12:12:40 -0500110 AMD_FW_UMSMU = 0xa2,
Zheng Baoc5e28ab2020-10-28 11:38:09 +0800111 AMD_FW_IMC = 0x200, /* Large enough to be larger than the top BHD entry type. */
112 AMD_FW_GEC,
113 AMD_FW_XHCI,
114 AMD_FW_INVALID, /* Real last one to detect the last entry in table. */
115 AMD_FW_SKIP /* This is for non-applicable options. */
116} amd_fw_type;
117
118typedef enum _amd_bios_type {
Ritul Guru9a321f32022-07-29 11:06:40 +0530119 AMD_BIOS_RTM_PUBKEY = 0x05,
120 AMD_BIOS_SIG = 0x07,
Zheng Baoc5e28ab2020-10-28 11:38:09 +0800121 AMD_BIOS_APCB = 0x60,
122 AMD_BIOS_APOB = 0x61,
123 AMD_BIOS_BIN = 0x62,
124 AMD_BIOS_APOB_NV = 0x63,
125 AMD_BIOS_PMUI = 0x64,
126 AMD_BIOS_PMUD = 0x65,
127 AMD_BIOS_UCODE = 0x66,
128 AMD_BIOS_APCB_BK = 0x68,
129 AMD_BIOS_MP2_CFG = 0x6a,
130 AMD_BIOS_PSP_SHARED_MEM = 0x6b,
131 AMD_BIOS_L2_PTR = 0x70,
132 AMD_BIOS_INVALID,
133 AMD_BIOS_SKIP
134} amd_bios_type;
135
Robert Zieba29bc79f2022-03-14 15:59:12 -0600136typedef enum _amd_addr_mode {
137 AMD_ADDR_PHYSICAL = 0, /* Physical address */
138 AMD_ADDR_REL_BIOS, /* Relative to beginning of image */
139 AMD_ADDR_REL_TAB, /* Relative to table */
140 AMD_ADDR_REL_SLOT, /* Relative to slot */
141} amd_addr_mode;
142
Zheng Bao6be1ab62021-05-26 10:16:33 +0800143struct second_gen_efs { /* todo: expand for Server products */
144 int gen:1; /* Client products only use bit 0 */
145 int reserved:31;
146} __attribute__((packed));
147
148#define EFS_SECOND_GEN 0
Zheng Bao487d0452022-04-03 12:50:07 +0800149#define EFS_BEFORE_SECOND_GEN 1
Zheng Bao6be1ab62021-05-26 10:16:33 +0800150
151typedef struct _embedded_firmware {
152 uint32_t signature; /* 0x55aa55aa */
153 uint32_t imc_entry;
154 uint32_t gec_entry;
155 uint32_t xhci_entry;
Felix Heldad68b072021-10-18 14:00:35 +0200156 uint32_t psp_directory;
Felix Heldc5c7fa42023-03-20 16:02:47 +0100157 uint32_t new_psp_directory; /* also used as combo_psp_directory */
Zheng Bao6be1ab62021-05-26 10:16:33 +0800158 uint32_t bios0_entry; /* todo: add way to select correct entry */
159 uint32_t bios1_entry;
160 uint32_t bios2_entry;
161 struct second_gen_efs efs_gen;
162 uint32_t bios3_entry;
163 uint32_t reserved_2Ch;
164 uint32_t promontory_fw_ptr;
165 uint32_t lp_promontory_fw_ptr;
166 uint32_t reserved_38h;
167 uint32_t reserved_3Ch;
168 uint8_t spi_readmode_f15_mod_60_6f;
169 uint8_t fast_speed_new_f15_mod_60_6f;
170 uint8_t reserved_42h;
171 uint8_t spi_readmode_f17_mod_00_2f;
172 uint8_t spi_fastspeed_f17_mod_00_2f;
173 uint8_t qpr_dummy_cycle_f17_mod_00_2f;
174 uint8_t reserved_46h;
175 uint8_t spi_readmode_f17_mod_30_3f;
176 uint8_t spi_fastspeed_f17_mod_30_3f;
177 uint8_t micron_detect_f17_mod_30_3f;
178 uint8_t reserved_4Ah;
179 uint8_t reserved_4Bh;
180 uint32_t reserved_4Ch;
181} __attribute__((packed, aligned(16))) embedded_firmware;
182
183typedef struct _psp_directory_header {
184 uint32_t cookie;
185 uint32_t checksum;
186 uint32_t num_entries;
Zheng Bao6fff2492021-11-15 19:53:21 +0800187 union {
188 uint32_t additional_info;
189 struct {
190 uint32_t dir_size:10;
191 uint32_t spi_block_size:4;
192 uint32_t base_addr:15;
193 uint32_t address_mode:2;
194 uint32_t not_used:1;
195 } __attribute__((packed)) additional_info_fields;
196 };
Zheng Bao6be1ab62021-05-26 10:16:33 +0800197} __attribute__((packed, aligned(16))) psp_directory_header;
198
199typedef struct _psp_directory_entry {
200 uint8_t type;
201 uint8_t subprog;
Zheng Bao5ca13432022-10-16 20:18:40 +0800202 union {
203 uint16_t rsvd;
204 struct {
205 uint8_t rom_id:2;
206 uint8_t writable:1;
207 uint8_t inst:4;
208 uint8_t rsvd_1:1;
209 uint8_t rsvd_2:8;
210 } __attribute__((packed));
211 };
Zheng Bao6be1ab62021-05-26 10:16:33 +0800212 uint32_t size;
Zheng Bao6fff2492021-11-15 19:53:21 +0800213 uint64_t addr:62; /* or a value in some cases */
214 uint64_t address_mode:2;
Zheng Bao6be1ab62021-05-26 10:16:33 +0800215} __attribute__((packed)) psp_directory_entry;
216
217typedef struct _psp_directory_table {
218 psp_directory_header header;
219 psp_directory_entry entries[];
220} __attribute__((packed, aligned(16))) psp_directory_table;
221
Fred Reitbergera194e622023-03-09 12:33:52 -0500222#define MAX_PSP_ENTRIES 0xff
Zheng Bao6be1ab62021-05-26 10:16:33 +0800223
224typedef struct _psp_combo_header {
225 uint32_t cookie;
226 uint32_t checksum;
227 uint32_t num_entries;
228 uint32_t lookup;
229 uint64_t reserved[2];
230} __attribute__((packed, aligned(16))) psp_combo_header;
231
232typedef struct _psp_combo_entry {
233 uint32_t id_sel;
234 uint32_t id;
235 uint64_t lvl2_addr;
236} __attribute__((packed)) psp_combo_entry;
237
238typedef struct _psp_combo_directory {
239 psp_combo_header header;
240 psp_combo_entry entries[];
241} __attribute__((packed, aligned(16))) psp_combo_directory;
242
Zheng Bao0e3d18b2023-03-07 15:28:57 +0800243#define MAX_COMBO_ENTRIES 2
Zheng Bao6be1ab62021-05-26 10:16:33 +0800244
245typedef struct _bios_directory_hdr {
246 uint32_t cookie;
247 uint32_t checksum;
248 uint32_t num_entries;
Zheng Bao6fff2492021-11-15 19:53:21 +0800249 union {
250 uint32_t additional_info;
251 struct {
252 uint32_t dir_size:10;
253 uint32_t spi_block_size:4;
254 uint32_t base_addr:15;
255 uint32_t address_mode:2;
256 uint32_t not_used:1;
257 } __attribute__((packed)) additional_info_fields;
258 };
Zheng Bao6be1ab62021-05-26 10:16:33 +0800259} __attribute__((packed, aligned(16))) bios_directory_hdr;
260
261typedef struct _bios_directory_entry {
262 uint8_t type;
263 uint8_t region_type;
264 int reset:1;
265 int copy:1;
266 int ro:1;
267 int compressed:1;
268 int inst:4;
269 uint8_t subprog; /* b[7:3] reserved */
270 uint32_t size;
Zheng Bao6fff2492021-11-15 19:53:21 +0800271 uint64_t source:62;
272 uint64_t address_mode:2;
Zheng Bao6be1ab62021-05-26 10:16:33 +0800273 uint64_t dest;
274} __attribute__((packed)) bios_directory_entry;
275
276typedef struct _bios_directory_table {
277 bios_directory_hdr header;
278 bios_directory_entry entries[];
279} bios_directory_table;
Zheng Baoc5e28ab2020-10-28 11:38:09 +0800280
Altamshali Hirani8915abe2022-03-17 13:26:31 -0500281#define MAX_BIOS_ENTRIES 0x2f
282
Zheng Bao33351332021-10-30 16:53:23 +0800283#define BDT_LVL1 (1 << 0)
284#define BDT_LVL2 (1 << 1)
Zheng Bao990d1542021-09-17 13:24:54 +0800285#define BDT_LVL1_AB (1 << 2)
286#define BDT_LVL2_AB (1 << 3)
Zheng Baoc5e28ab2020-10-28 11:38:09 +0800287#define BDT_BOTH (BDT_LVL1 | BDT_LVL2)
Zheng Bao990d1542021-09-17 13:24:54 +0800288#define BDT_BOTH_AB (BDT_LVL1_AB | BDT_LVL2_AB)
Zheng Baoc5e28ab2020-10-28 11:38:09 +0800289typedef struct _amd_bios_entry {
290 amd_bios_type type;
291 char *filename;
292 int subpr;
293 int region_type;
294 int reset;
295 int copy;
296 int ro;
297 int zlib;
298 int inst;
299 uint64_t src;
300 uint64_t dest;
301 size_t size;
302 int level;
303} amd_bios_entry;
304
Zheng Baofdd47ef2021-09-17 13:30:08 +0800305typedef struct _ish_directory_table {
306 uint32_t checksum;
307 uint32_t boot_priority;
308 uint32_t update_retry_count;
309 uint8_t glitch_retry_count;
310 uint8_t glitch_higherbits_reserved[3];
311 uint32_t pl2_location;
312 uint32_t psp_id;
313 uint32_t slot_max_size;
314 uint32_t reserved;
315} __attribute__((packed)) ish_directory_table;
316
Zheng Bao6be1ab62021-05-26 10:16:33 +0800317#define EMBEDDED_FW_SIGNATURE 0x55aa55aa
318#define PSP_COOKIE 0x50535024 /* 'PSP$' */
319#define PSPL2_COOKIE 0x324c5024 /* '2LP$' */
320#define PSP2_COOKIE 0x50535032 /* 'PSP2' */
Zheng Bao96a33712021-06-11 15:54:40 +0800321#define BHD_COOKIE 0x44484224 /* 'DHB$ */
322#define BHDL2_COOKIE 0x324c4224 /* '2LB$ */
Zheng Bao84fb9ea2022-08-18 15:54:47 +0800323#define BHD2_COOKIE 0x44484232 /* 'DHB2' */
Zheng Baoc5e28ab2020-10-28 11:38:09 +0800324
Zheng Bao33351332021-10-30 16:53:23 +0800325#define PSP_LVL1 (1 << 0)
326#define PSP_LVL2 (1 << 1)
Zheng Bao990d1542021-09-17 13:24:54 +0800327#define PSP_LVL1_AB (1 << 2)
328#define PSP_LVL2_AB (1 << 3)
Zheng Baoc5e28ab2020-10-28 11:38:09 +0800329#define PSP_BOTH (PSP_LVL1 | PSP_LVL2)
Zheng Bao990d1542021-09-17 13:24:54 +0800330#define PSP_BOTH_AB (PSP_LVL1_AB | PSP_LVL2_AB)
Kangheui Won5b84dfd2021-12-21 15:45:06 +1100331
332typedef struct _amd_fw_entry_hash {
333 uint16_t fw_id;
334 uint16_t subtype;
335 uint32_t sha_len;
336 uint8_t sha[SHA384_DIGEST_LENGTH];
337} amd_fw_entry_hash;
338
Zheng Baoc5e28ab2020-10-28 11:38:09 +0800339typedef struct _amd_fw_entry {
340 amd_fw_type type;
Kangheui Won3c164e12021-12-03 20:25:05 +1100341 /* Mendocino and later SoCs use fw_id instead of fw_type. fw_type is still around
342 for backwards compatibility. fw_id can be populated from the PSP binary file. */
343 uint16_t fw_id;
Zheng Baoc5e28ab2020-10-28 11:38:09 +0800344 char *filename;
345 uint8_t subprog;
Zheng Bao5ca13432022-10-16 20:18:40 +0800346 uint8_t inst;
Ritul Gurua2cb3402022-08-29 00:51:08 +0530347 uint64_t dest;
348 size_t size;
Zheng Baoc5e28ab2020-10-28 11:38:09 +0800349 int level;
350 uint64_t other;
Kangheui Won3c164e12021-12-03 20:25:05 +1100351 /* If the binary is signed and the tool is invoked to keep the signed binaries separate,
352 then this field is populated with the offset of the concerned PSP binary (relative to
353 BIOS or PSP Directory table). */
354 uint64_t addr_signed;
355 uint32_t file_size;
356 /* Some files that don't have amd_fw_header have to be skipped from hashing. These files
357 include but not limited to: *iKek*, *.tkn, *.stkn */
358 bool skip_hashing;
Karthikeyan Ramasubramaniand7a5d9e2023-05-03 13:34:41 -0600359 uint8_t hash_tbl_id;
Kangheui Won5b84dfd2021-12-21 15:45:06 +1100360 uint32_t num_hash_entries;
361 amd_fw_entry_hash *hash_entries;
Grzegorz Bernackidfdf81c2023-04-05 09:35:42 +0000362 bool generate_manifest;
Zheng Baoc5e28ab2020-10-28 11:38:09 +0800363} amd_fw_entry;
364
Kangheui Won3c164e12021-12-03 20:25:05 +1100365/* Most PSP binaries, if not all, have the following header format. */
366struct amd_fw_header {
367 uint8_t reserved_0[20];
368 uint32_t fw_size_signed;
369 uint8_t reserved_18[24];
370 /* 1 if the image is signed, 0 otherwise */
371 uint32_t sig_opt;
372 uint32_t sig_id;
373 uint8_t sig_param[16];
374 uint32_t comp_opt;
375 uint8_t reserved_4c[4];
376 uint32_t uncomp_size;
377 uint32_t comp_size;
378 /* Starting MDN fw_id is populated instead of fw_type. */
379 uint16_t fw_id;
Grzegorz Bernackidfdf81c2023-04-05 09:35:42 +0000380 uint8_t reserved_5a[6];
381 uint8_t version[4];
382 uint8_t reserved_64[8];
Kangheui Won3c164e12021-12-03 20:25:05 +1100383 uint32_t size_total;
384 uint8_t reserved_70[12];
385 /* Starting MDN fw_id is populated instead of fw_type. fw_type will still be around
386 for backwards compatibility. */
387 uint8_t fw_type;
388 uint8_t fw_subtype;
389 uint8_t fw_subprog;
390 uint8_t reserved_7f;
391 uint8_t reserved_80[128];
392} __packed;
393
Karthikeyan Ramasubramaniand7a5d9e2023-05-03 13:34:41 -0600394/* Based on the available PSP resources and increasing number of signed PSP binaries,
395 AMD recommends to split the hash table into 3 parts for now. */
396#define MAX_NUM_HASH_TABLES 3
Kangheui Won5b84dfd2021-12-21 15:45:06 +1100397struct psp_fw_hash_table {
398 uint16_t version;
399 uint16_t no_of_entries_256;
400 uint16_t no_of_entries_384;
401 /* The next 2 elements are pointers to arrays of SHA256 and SHA384 entries. */
402 /* It does not make sense to store pointers in the CBFS file */
403} __packed;
404
Zheng Baoc5e28ab2020-10-28 11:38:09 +0800405typedef struct _amd_cb_config {
Zheng Baoba3af5e2021-11-04 18:56:47 +0800406 bool have_whitelist;
407 bool unlock_secure;
408 bool use_secureos;
409 bool load_mp2_fw;
410 bool multi_level;
411 bool s0i3;
Zheng Baoc3007f32022-04-03 12:53:51 +0800412 bool second_gen;
Zheng Bao6c5ec8e2022-02-11 11:51:26 +0800413 bool have_mb_spl;
Zheng Bao990d1542021-09-17 13:24:54 +0800414 bool recovery_ab;
Karthikeyan Ramasubramanianad06bae2022-04-08 14:19:55 -0600415 bool recovery_ab_single_copy;
Zheng Baofdd47ef2021-09-17 13:30:08 +0800416 bool need_ish;
Zheng Bao993b43f2021-11-10 12:21:46 +0800417 bool use_combo;
Karthikeyan Ramasubramanian8d885612023-03-09 17:39:31 -0700418 bool have_apcb_bk;
Zheng Bao4bf6f492023-01-25 22:37:29 +0800419 enum platform soc_id;
Zheng Baoc5e28ab2020-10-28 11:38:09 +0800420} amd_cb_config;
421
422void register_fw_fuse(char *str);
Zheng Bao994ff522023-03-09 11:43:55 +0800423uint8_t process_config(FILE *config, amd_cb_config *cb_config);
Zheng Baof080cd52023-03-22 12:50:36 +0800424void process_signed_psp_firmwares(const char *signed_rom,
425 amd_fw_entry *fw_table,
426 uint64_t signed_start_addr,
427 enum platform soc_id);
428void write_or_fail(int fd, void *ptr, size_t size);
429ssize_t read_from_file_to_buf(int fd, void *buf, size_t buf_size);
430ssize_t write_from_buf_to_file(int fd, const void *buf, size_t buf_size);
Zheng Baoc5e28ab2020-10-28 11:38:09 +0800431#define OK 0
432
433#define LINE_EOF (1)
434#define LINE_TOO_LONG (2)
435
Zheng Baoc5e28ab2020-10-28 11:38:09 +0800436#endif /* _AMD_FW_TOOL_H_ */