1 /* SPDX-License-Identifier: Intel */ 2 /* 3 * Copyright (C) 2013, Intel Corporation 4 * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com> 5 */ 6 7 #ifndef __FSP_SUPPORT_H__ 8 #define __FSP_SUPPORT_H__ 9 10 #include <asm/fsp/fsp_bootmode.h> 11 #include <asm/fsp/fsp_fv.h> 12 #include <asm/fsp/fsp_hob.h> 13 #include <asm/fsp/fsp_infoheader.h> 14 #include <asm/fsp/fsp_types.h> 15 #include <asm/fsp_arch.h> 16 #include <asm/fsp/fsp_azalia.h> 17 18 #define FSP_LOWMEM_BASE 0x100000UL 19 #define FSP_HIGHMEM_BASE 0x100000000ULL 20 #define UPD_TERMINATOR 0x55AA 21 22 /** 23 * fsp_find_header() - Find FSP header offset in FSP image 24 * 25 * @return the offset of FSP header. If signature is invalid, returns 0. 26 */ 27 struct fsp_header *fsp_find_header(void); 28 29 /** 30 * fsp_notify() - FSP notification wrapper function 31 * 32 * @fsp_hdr: Pointer to FSP information header 33 * @phase: FSP initialization phase defined in enum fsp_phase 34 * 35 * @return compatible status code with EFI_STATUS defined in PI spec 36 */ 37 u32 fsp_notify(struct fsp_header *fsp_hdr, u32 phase); 38 39 /** 40 * fsp_get_usable_lowmem_top() - retrieves the top of usable low memory 41 * 42 * @hob_list: A HOB list pointer. 43 * 44 * @return Usable low memory top. 45 */ 46 u32 fsp_get_usable_lowmem_top(const void *hob_list); 47 48 /** 49 * fsp_get_usable_highmem_top() - retrieves the top of usable high memory 50 * 51 * @hob_list: A HOB list pointer. 52 * 53 * @return Usable high memory top. 54 */ 55 u64 fsp_get_usable_highmem_top(const void *hob_list); 56 57 /** 58 * fsp_get_reserved_mem_from_guid() - retrieves a special reserved memory region 59 * 60 * @hob_list: A HOB list pointer. 61 * @len: A pointer to the GUID HOB data buffer length. 62 * If the GUID HOB is located, the length will be updated. 63 * @guid: A pointer to the owner guild. 64 * 65 * @return Reserved region start address. 66 * 0 if this region does not exist. 67 */ 68 u64 fsp_get_reserved_mem_from_guid(const void *hob_list, 69 u64 *len, const efi_guid_t *guid); 70 71 /** 72 * fsp_get_fsp_reserved_mem() - retrieves the FSP reserved normal memory 73 * 74 * @hob_list: A HOB list pointer. 75 * @len: A pointer to the FSP reserved memory length buffer. 76 * If the GUID HOB is located, the length will be updated. 77 * @return FSP reserved memory base 78 * 0 if this region does not exist. 79 */ 80 u32 fsp_get_fsp_reserved_mem(const void *hob_list, u32 *len); 81 82 /** 83 * fsp_get_tseg_reserved_mem() - retrieves the TSEG reserved normal memory 84 * 85 * @hob_list: A HOB list pointer. 86 * @len: A pointer to the TSEG reserved memory length buffer. 87 * If the GUID HOB is located, the length will be updated. 88 * 89 * @return NULL: Failed to find the TSEG reserved memory. 90 * @return others: TSEG reserved memory base. 91 */ 92 u32 fsp_get_tseg_reserved_mem(const void *hob_list, u32 *len); 93 94 /** 95 * fsp_get_nvs_data() - retrieves FSP Non-volatile Storage HOB buffer and size 96 * 97 * @hob_list: A HOB list pointer. 98 * @len: A pointer to the NVS data buffer length. 99 * If the HOB is located, the length will be updated. 100 * 101 * @return NULL: Failed to find the NVS HOB. 102 * @return others: FSP NVS data buffer pointer. 103 */ 104 void *fsp_get_nvs_data(const void *hob_list, u32 *len); 105 106 /** 107 * fsp_get_var_nvs_data() - get FSP variable Non-volatile Storage HOB buffer 108 * 109 * @hob_list: A HOB list pointer. 110 * @len: A pointer to the NVS data buffer length. 111 * If the HOB is located, the length will be updated. 112 * 113 * @return NULL: Failed to find the NVS HOB. 114 * @return others: FSP NVS data buffer pointer. 115 */ 116 void *fsp_get_var_nvs_data(const void *hob_list, u32 *len); 117 118 /** 119 * fsp_get_graphics_info() - retrieves graphics information. 120 * 121 * @hob_list: A HOB list pointer. 122 * @len: A pointer to the graphics info HOB length. 123 * If the HOB is located, the length will be updated. 124 * 125 * @return NULL: Failed to find the graphics info HOB. 126 * @return others: A pointer to struct hob_graphics_info. 127 */ 128 void *fsp_get_graphics_info(const void *hob_list, u32 *len); 129 130 /** 131 * fsp_init_phase_pci() - Tell the FSP that we have completed PCI init 132 * 133 * @return 0 if OK, -EPERM if the FSP gave an error. 134 */ 135 int fsp_init_phase_pci(void); 136 137 /** 138 * fsp_scan_for_ram_size() - Scan the HOB list to find the RAM size 139 * 140 * This sets gd->ram_size based on what it finds. 141 * 142 * @return 0 if OK, -ve on error 143 */ 144 int fsp_scan_for_ram_size(void); 145 146 /** 147 * fsp_prepare_mrc_cache() - Find the DRAM training data from the MRC cache 148 * 149 * @return pointer to data, or NULL if no cache or no data found in the cache 150 */ 151 void *fsp_prepare_mrc_cache(void); 152 153 /** 154 * fsp_notify() - FSP notification wrapper function 155 * 156 * @fsp_hdr: Pointer to FSP information header 157 * @phase: FSP initialization phase defined in enum fsp_phase 158 * 159 * @return compatible status code with EFI_STATUS defined in PI spec 160 */ 161 u32 fsp_notify(struct fsp_header *fsp_hdr, u32 phase); 162 163 #endif 164