Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Andrey Petrov | b37fd67 | 2016-03-01 16:25:38 -0800 | [diff] [blame] | 2 | |
| 3 | #ifndef _FSP2_0_UTIL_H_ |
| 4 | #define _FSP2_0_UTIL_H_ |
| 5 | |
| 6 | #include <boot/coreboot_tables.h> |
Julius Werner | 8205ce6 | 2021-03-10 17:25:01 -0800 | [diff] [blame^] | 7 | #include <cbfs.h> |
Aaron Durbin | a413e5e | 2016-07-17 23:06:03 -0500 | [diff] [blame] | 8 | #include <commonlib/region.h> |
Lee Leahy | 672df16 | 2016-07-24 18:21:13 -0700 | [diff] [blame] | 9 | #include <arch/cpu.h> |
Andrey Petrov | 901e43c | 2016-06-22 19:22:30 -0700 | [diff] [blame] | 10 | #include <fsp/api.h> |
Andrey Petrov | b37fd67 | 2016-03-01 16:25:38 -0800 | [diff] [blame] | 11 | #include <fsp/info_header.h> |
Andrey Petrov | b37fd67 | 2016-03-01 16:25:38 -0800 | [diff] [blame] | 12 | #include <memrange.h> |
Aaron Durbin | a85febc | 2020-05-15 15:09:10 -0600 | [diff] [blame] | 13 | #include <program_loading.h> |
Elyes HAOUAS | bd1683d | 2019-05-15 21:05:37 +0200 | [diff] [blame] | 14 | #include <types.h> |
Andrey Petrov | b37fd67 | 2016-03-01 16:25:38 -0800 | [diff] [blame] | 15 | |
Johnny Lin | b8899ef | 2020-05-28 14:04:58 +0800 | [diff] [blame] | 16 | #define FSP_VER_LEN 30 |
| 17 | |
Lee Leahy | 672df16 | 2016-07-24 18:21:13 -0700 | [diff] [blame] | 18 | struct hob_header { |
| 19 | uint16_t type; |
| 20 | uint16_t length; |
Stefan Reinauer | 6a00113 | 2017-07-13 02:20:27 +0200 | [diff] [blame] | 21 | } __packed; |
Lee Leahy | 672df16 | 2016-07-24 18:21:13 -0700 | [diff] [blame] | 22 | |
| 23 | struct fsp_notify_params { |
| 24 | enum fsp_notify_phase phase; |
| 25 | }; |
| 26 | |
Subrata Banik | 33d9c4a | 2020-05-26 18:26:54 +0530 | [diff] [blame] | 27 | enum fsp_multi_phase_action { |
| 28 | GET_NUMBER_OF_PHASES = 0, |
| 29 | EXECUTE_PHASE = 1 |
| 30 | }; |
| 31 | |
| 32 | struct fsp_multi_phase_params { |
| 33 | enum fsp_multi_phase_action multi_phase_action; |
| 34 | uint32_t phase_index; |
| 35 | void *multi_phase_param_ptr; |
| 36 | }; |
| 37 | |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 38 | struct hob_resource { |
| 39 | uint8_t owner_guid[16]; |
| 40 | uint32_t type; |
| 41 | uint32_t attribute_type; |
| 42 | uint64_t addr; |
| 43 | uint64_t length; |
Stefan Reinauer | 6a00113 | 2017-07-13 02:20:27 +0200 | [diff] [blame] | 44 | } __packed; |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 45 | |
Johnny Lin | 5b47d77 | 2020-11-13 17:21:25 +0800 | [diff] [blame] | 46 | union fsp_revision { |
| 47 | uint32_t val; |
| 48 | struct { |
| 49 | uint8_t bld_num; |
| 50 | uint8_t revision; |
| 51 | uint8_t minor; |
| 52 | uint8_t major; |
| 53 | } rev; |
| 54 | }; |
| 55 | |
Subrata Banik | 491728f | 2018-01-22 16:30:56 +0530 | [diff] [blame] | 56 | #if CONFIG_UDK_VERSION < CONFIG_UDK_2017_VERSION |
Lee Leahy | 5a9ca4d | 2016-09-28 17:15:00 -0700 | [diff] [blame] | 57 | enum resource_type { |
| 58 | EFI_RESOURCE_SYSTEM_MEMORY = 0, |
| 59 | EFI_RESOURCE_MEMORY_MAPPED_IO = 1, |
| 60 | EFI_RESOURCE_IO = 2, |
| 61 | EFI_RESOURCE_FIRMWARE_DEVICE = 3, |
| 62 | EFI_RESOURCE_MEMORY_MAPPED_IO_PORT = 4, |
| 63 | EFI_RESOURCE_MEMORY_RESERVED = 5, |
| 64 | EFI_RESOURCE_IO_RESERVED = 6, |
| 65 | EFI_RESOURCE_MAX_MEMORY_TYPE = 7, |
| 66 | }; |
Subrata Banik | 491728f | 2018-01-22 16:30:56 +0530 | [diff] [blame] | 67 | #endif |
Lee Leahy | 5a9ca4d | 2016-09-28 17:15:00 -0700 | [diff] [blame] | 68 | |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 69 | enum hob_type { |
| 70 | HOB_TYPE_HANDOFF = 0x0001, |
| 71 | HOB_TYPE_MEMORY_ALLOCATION = 0x0002, |
| 72 | HOB_TYPE_RESOURCE_DESCRIPTOR = 0x0003, |
| 73 | HOB_TYPE_GUID_EXTENSION = 0x0004, |
| 74 | HOB_TYPE_FV = 0x0005, |
| 75 | HOB_TYPE_CPU = 0x0006, |
| 76 | HOB_TYPE_MEMORY_POOL = 0x0007, |
| 77 | HOB_TYPE_FV2 = 0x0009, |
| 78 | HOB_TYPE_LOAD_PEIM_UNUSED = 0x000A, |
| 79 | HOB_TYPE_UCAPSULE = 0x000B, |
| 80 | HOB_TYPE_UNUSED = 0xFFFE, |
| 81 | HOB_TYPE_END_OF_HOB_LIST = 0xFFFF, |
| 82 | }; |
| 83 | |
Lee Leahy | 52d0c68 | 2016-08-01 15:47:42 -0700 | [diff] [blame] | 84 | extern const uint8_t fsp_bootloader_tolum_guid[16]; |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 85 | extern const uint8_t fsp_nv_storage_guid[16]; |
| 86 | extern const uint8_t fsp_reserved_memory_guid[16]; |
| 87 | |
Andrey Petrov | b37fd67 | 2016-03-01 16:25:38 -0800 | [diff] [blame] | 88 | const void *fsp_get_hob_list(void); |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 89 | void *fsp_get_hob_list_ptr(void); |
| 90 | const void *fsp_find_extension_hob_by_guid(const uint8_t *guid, size_t *size); |
Hannah Williams | 3503b3f | 2016-03-04 12:14:52 -0800 | [diff] [blame] | 91 | const void *fsp_find_nv_storage_data(size_t *size); |
Lee Leahy | 52d0c68 | 2016-08-01 15:47:42 -0700 | [diff] [blame] | 92 | int fsp_find_range_hob(struct range_entry *re, const uint8_t guid[16]); |
Subrata Banik | 73b67dc | 2018-01-23 16:31:03 +0530 | [diff] [blame] | 93 | void fsp_display_fvi_version_hob(void); |
Michael Niewöhner | bc1dbb3 | 2019-10-24 22:58:25 +0200 | [diff] [blame] | 94 | void fsp_find_reserved_memory(struct range_entry *re); |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 95 | const struct hob_resource *fsp_hob_header_to_resource( |
| 96 | const struct hob_header *hob); |
| 97 | const struct hob_header *fsp_next_hob(const struct hob_header *parent); |
| 98 | bool fsp_guid_compare(const uint8_t guid1[16], const uint8_t guid2[16]); |
Michael Niewöhner | bc1dbb3 | 2019-10-24 22:58:25 +0200 | [diff] [blame] | 99 | void fsp_find_bootloader_tolum(struct range_entry *re); |
Johnny Lin | b8899ef | 2020-05-28 14:04:58 +0800 | [diff] [blame] | 100 | void fsp_get_version(char *buf); |
Felix Held | 8899598 | 2021-01-28 22:43:52 +0100 | [diff] [blame] | 101 | /* fsp_verify_upd_header_signature calls die() on signature mismatch */ |
| 102 | void fsp_verify_upd_header_signature(uint64_t upd_signature, uint64_t expected_signature); |
Johnny Lin | b8899ef | 2020-05-28 14:04:58 +0800 | [diff] [blame] | 103 | void lb_string_platform_blob_version(struct lb_header *header); |
Arthur Heymans | 5a66334 | 2020-10-28 14:03:14 +0100 | [diff] [blame] | 104 | void report_fspt_output(void); |
Johnny Lin | 5b47d77 | 2020-11-13 17:21:25 +0800 | [diff] [blame] | 105 | void soc_validate_fsp_version(const struct fsp_header *hdr); |
Andrey Petrov | b37fd67 | 2016-03-01 16:25:38 -0800 | [diff] [blame] | 106 | |
Aaron Durbin | a413e5e | 2016-07-17 23:06:03 -0500 | [diff] [blame] | 107 | /* Fill in header and validate sanity of component within region device. */ |
| 108 | enum cb_err fsp_validate_component(struct fsp_header *hdr, |
| 109 | const struct region_device *rdev); |
| 110 | |
Aaron Durbin | a85febc | 2020-05-15 15:09:10 -0600 | [diff] [blame] | 111 | struct fsp_load_descriptor { |
| 112 | /* fsp_prog object will have region_device initialized to final |
| 113 | * load location in memory. */ |
| 114 | struct prog fsp_prog; |
Julius Werner | 8205ce6 | 2021-03-10 17:25:01 -0800 | [diff] [blame^] | 115 | /* CBFS allocator to place loaded FSP. NULL to map flash directly. */ |
| 116 | cbfs_allocator_t alloc; |
Aaron Durbin | ecbfa99 | 2020-05-15 17:01:58 -0600 | [diff] [blame] | 117 | /* Optional argument to be utilized by get_destination() callback. */ |
| 118 | void *arg; |
Aaron Durbin | a85febc | 2020-05-15 15:09:10 -0600 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | /* Load the FSP component described by fsp_load_descriptor from cbfs. The FSP |
| 122 | * header object will be validated and filled in on successful load. */ |
| 123 | enum cb_err fsp_load_component(struct fsp_load_descriptor *fspld, struct fsp_header *hdr); |
| 124 | |
Andrey Petrov | 3a94a3b | 2016-07-18 00:15:41 -0700 | [diff] [blame] | 125 | /* |
| 126 | * Handle FSP reboot request status. Chipset/soc is expected to provide |
| 127 | * chipset_handle_reset() that deals with reset type codes specific to given |
| 128 | * SoC. If the requested status is not a reboot status or unhandled, this |
| 129 | * function does nothing. |
| 130 | */ |
Brandon Breitenstein | c31ba0e | 2016-07-27 17:34:45 -0700 | [diff] [blame] | 131 | void fsp_handle_reset(uint32_t status); |
Andrey Petrov | 3a94a3b | 2016-07-18 00:15:41 -0700 | [diff] [blame] | 132 | |
| 133 | /* SoC/chipset must provide this to handle platform-specific reset codes */ |
Brandon Breitenstein | c31ba0e | 2016-07-27 17:34:45 -0700 | [diff] [blame] | 134 | void chipset_handle_reset(uint32_t status); |
Andrey Petrov | 901e43c | 2016-06-22 19:22:30 -0700 | [diff] [blame] | 135 | |
Brenton Dong | 0a5971c | 2016-10-18 11:35:15 -0700 | [diff] [blame] | 136 | typedef asmlinkage uint32_t (*temp_ram_exit_fn)(void *param); |
Brandon Breitenstein | c31ba0e | 2016-07-27 17:34:45 -0700 | [diff] [blame] | 137 | typedef asmlinkage uint32_t (*fsp_memory_init_fn) |
Lee Leahy | 672df16 | 2016-07-24 18:21:13 -0700 | [diff] [blame] | 138 | (void *raminit_upd, void **hob_list); |
Brandon Breitenstein | c31ba0e | 2016-07-27 17:34:45 -0700 | [diff] [blame] | 139 | typedef asmlinkage uint32_t (*fsp_silicon_init_fn)(void *silicon_upd); |
Subrata Banik | 33d9c4a | 2020-05-26 18:26:54 +0530 | [diff] [blame] | 140 | typedef asmlinkage uint32_t (*fsp_multi_phase_si_init_fn)(struct fsp_multi_phase_params *); |
Brandon Breitenstein | c31ba0e | 2016-07-27 17:34:45 -0700 | [diff] [blame] | 141 | typedef asmlinkage uint32_t (*fsp_notify_fn)(struct fsp_notify_params *); |
Lee Leahy | 672df16 | 2016-07-24 18:21:13 -0700 | [diff] [blame] | 142 | #include <fsp/debug.h> |
| 143 | |
Andrey Petrov | b37fd67 | 2016-03-01 16:25:38 -0800 | [diff] [blame] | 144 | #endif /* _FSP2_0_UTIL_H_ */ |