blob: 6c5d4c0acfea69d67cef9228efe2694842e7cdc4 [file] [log] [blame]
Martin Rothc7acf162020-05-28 00:44:50 -06001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#ifndef PSP_VERSTAGE_H
4#define PSP_VERSTAGE_H
5
Kangheui Wonce0fad52021-06-25 16:03:05 +10006#include <2crypto.h>
Kangheui Won26bb4aa2021-10-18 15:31:45 +11007#include <amdblocks/psp_efs.h>
Kangheui Wonce0fad52021-06-25 16:03:05 +10008#include <bl_uapp/bl_syscall_public.h>
Martin Rothc7acf162020-05-28 00:44:50 -06009#include <stdint.h>
Martin Roth0c12abe2020-06-26 08:40:56 -060010#include <soc/psp_transfer.h>
Martin Rothc7acf162020-05-28 00:44:50 -060011
12#define EMBEDDED_FW_SIGNATURE 0x55aa55aa
13#define PSP_COOKIE 0x50535024 /* 'PSP$' */
Zheng Bao96a33712021-06-11 15:54:40 +080014#define BHD_COOKIE 0x44484224 /* 'DHB$ */
Martin Rothc7acf162020-05-28 00:44:50 -060015
16#define PSP_VBOOT_ERROR_SUBCODE 0x0D5D0000
17
18#define POSTCODE_ENTERED_PSP_VERSTAGE 0x00
19#define POSTCODE_CONSOLE_INIT 0x01
20#define POSTCODE_EARLY_INIT 0x02
21#define POSTCODE_LATE_INIT 0x03
22#define POSTCODE_VERSTAGE_MAIN 0x04
Rob Barnesb35acf92021-11-02 17:47:47 -060023#define POSTCODE_VERSTAGE_S0I3_RESUME 0x05
Martin Rothc7acf162020-05-28 00:44:50 -060024
Martin Roth0b6f35d2020-07-23 16:43:36 -060025#define POSTCODE_SAVE_BUFFERS 0x0E
Martin Rothc7acf162020-05-28 00:44:50 -060026#define POSTCODE_UPDATE_BOOT_REGION 0x0F
27
28#define POSTCODE_DEFAULT_BUFFER_SIZE_NOTICE 0xC0
29#define POSTCODE_WORKBUF_RESIZE_WARNING 0xC1
30#define POSTCODE_WORKBUF_SAVE_ERROR 0xC2
31#define POSTCODE_WORKBUF_BUFFER_SIZE_ERROR 0xC3
32#define POSTCODE_ROMSIG_MISMATCH_ERROR 0xC4
33#define POSTCODE_PSP_COOKIE_MISMATCH_ERROR 0xC5
Zheng Bao96a33712021-06-11 15:54:40 +080034#define POSTCODE_BHD_COOKIE_MISMATCH_ERROR 0xC6
Martin Rothc7acf162020-05-28 00:44:50 -060035#define POSTCODE_UPDATE_PSP_BIOS_DIR_ERROR 0xC7
Martin Rothe21698b2020-06-26 08:55:15 -060036#define POSTCODE_FMAP_REGION_MISSING 0xC8
37#define POSTCODE_AMD_FW_MISSING 0xC9
Martin Roth50cca762020-08-13 11:06:18 -060038#define POSTCODE_CMOS_RECOVERY 0xCA
Rob Barnesc30a1fa2021-11-08 06:43:07 -070039#define POSTCODE_EARLY_INIT_ERROR 0xCB
Rob Barnesb35acf92021-11-02 17:47:47 -060040#define POSTCODE_INIT_TPM_FAILED 0xCC
Karthikeyan Ramasubramanian6f1b03b2023-04-21 14:26:51 -060041#define POSTCODE_MAP_SPI_ROM_FAILED 0xCD
Martin Rothc7acf162020-05-28 00:44:50 -060042
43#define POSTCODE_UNMAP_SPI_ROM 0xF0
44#define POSTCODE_UNMAP_FCH_DEVICES 0xF1
45#define POSTCODE_LEAVING_VERSTAGE 0xF2
46
47#define SPI_ADDR_MASK 0x00ffffff
Martin Roth0c12abe2020-06-26 08:40:56 -060048#define MIN_TRANSFER_BUFFER_SIZE (8 * KiB)
49#define MIN_WORKBUF_TRANSFER_SIZE (MIN_TRANSFER_BUFFER_SIZE - TRANSFER_INFO_SIZE)
Martin Rothc7acf162020-05-28 00:44:50 -060050
Martin Rothc7acf162020-05-28 00:44:50 -060051void test_svc_calls(void);
52uint32_t unmap_fch_devices(void);
53uint32_t verstage_soc_early_init(void);
Rob Barnesf6e421f2021-11-08 13:04:18 -070054void verstage_mainboard_espi_init(void);
Rob Barnes188be6b2021-11-09 13:21:28 -070055void verstage_mainboard_tpm_init(void);
Rob Barnes847a39f2021-11-15 12:56:34 -070056void verstage_soc_aoac_init(void);
57void verstage_soc_espi_init(void);
58void verstage_soc_i2c_init(void);
59void verstage_soc_spi_init(void);
Karthikeyan Ramasubramanian6f1b03b2023-04-21 14:26:51 -060060void *map_spi_rom(void);
Martin Rothc7acf162020-05-28 00:44:50 -060061
Kangheui Wona767eb42021-04-14 09:35:28 +100062uint32_t update_psp_bios_dir(uint32_t *psp_dir_offset, uint32_t *bios_dir_offset);
63uint32_t save_uapp_data(void *address, uint32_t size);
Kangheui Won26bb4aa2021-10-18 15:31:45 +110064uint32_t get_bios_dir_addr(struct embedded_firmware *ef_table);
Kangheui Wonce0fad52021-06-25 16:03:05 +100065int platform_set_sha_op(enum vb2_hash_algorithm hash_alg,
66 struct sha_generic_data *sha_op);
Kangheui Won7e91db72022-01-25 18:55:04 +110067void platform_report_mode(int developer_mode_enabled);
Kangheui Wona767eb42021-04-14 09:35:28 +100068
Kangheui Won5fb435a2021-12-22 12:24:17 +110069void update_psp_fw_hash_table(const char *fname);
70
Karthikeyan Ramasubramanianef129762022-12-22 13:07:28 -070071void report_prev_boot_status_to_vboot(void);
72
Karthikeyan Ramasubramaniane5f627a2022-12-22 13:05:12 -070073void report_hsp_secure_state(void);
74
Karthikeyan Ramasubramanian6f1b03b2023-04-21 14:26:51 -060075uint32_t boot_dev_get_active_map_count(void);
76
Martin Rothc7acf162020-05-28 00:44:50 -060077#endif /* PSP_VERSTAGE_H */