2 * Copyright (C) 2013, Intel Corporation
3 * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
5 * SPDX-License-Identifier: Intel
8 #ifndef __FSP_SUPPORT_H__
9 #define __FSP_SUPPORT_H__
11 #include "fsp_types.h"
16 #include "fsp_platform.h"
17 #include "fsp_infoheader.h"
18 #include "fsp_bootmode.h"
19 #include <asm/arch/fsp/fsp_vpd.h>
22 struct fsp_header *fsp_hdr;
24 struct upd_region fsp_upd;
27 #define FSP_LOWMEM_BASE 0x100000UL
28 #define FSP_HIGHMEM_BASE 0x100000000ULL
31 * FSP Continuation assembly helper routine
33 * This routine jumps to the C version of FSP continuation function
35 void asm_continuation(void);
38 * FSP initialization complete
40 * This is the function that indicates FSP initialization is complete and jumps
41 * back to the bootloader with HOB list pointer as the parameter.
43 * @hob_list: HOB list pointer
45 void fsp_init_done(void *hob_list);
48 * FSP Continuation function
50 * @shared_data: Shared data base before stack migration
52 * @hob_list: HOB list pointer
54 * @retval: Never returns
56 void fsp_continue(struct shared_data *shared_data, u32 status,
60 * Find FSP header offset in FSP image
62 * @retval: the offset of FSP header. If signature is invalid, returns 0.
64 u32 find_fsp_header(void);
67 * FSP initialization wrapper function.
69 * @stack_top: bootloader stack top address
70 * @boot_mode: boot mode defined in fsp_bootmode.h
71 * @nvs_buf: Non-volatile memory buffer pointer
73 void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf);
76 * FSP notification wrapper function
78 * @fsp_hdr: Pointer to FSP information header
79 * @phase: FSP initialization phase defined in enum fsp_phase
81 * @retval: compatible status code with EFI_STATUS defined in PI spec
83 u32 fsp_notify(struct fsp_header *fsp_hdr, u32 phase);
86 * This function retrieves the top of usable low memory.
88 * @hob_list: A HOB list pointer.
90 * @retval: Usable low memory top.
92 u32 fsp_get_usable_lowmem_top(const void *hob_list);
95 * This function retrieves the top of usable high memory.
97 * @hob_list: A HOB list pointer.
99 * @retval: Usable high memory top.
101 u64 fsp_get_usable_highmem_top(const void *hob_list);
104 * This function retrieves a special reserved memory region.
106 * @hob_list: A HOB list pointer.
107 * @len: A pointer to the GUID HOB data buffer length.
108 * If the GUID HOB is located, the length will be updated.
109 * @guid: A pointer to the owner guild.
111 * @retval: Reserved region start address.
112 * 0 if this region does not exist.
114 u64 fsp_get_reserved_mem_from_guid(const void *hob_list,
115 u64 *len, struct efi_guid *guid);
118 * This function retrieves the FSP reserved normal memory.
120 * @hob_list: A HOB list pointer.
121 * @len: A pointer to the FSP reserved memory length buffer.
122 * If the GUID HOB is located, the length will be updated.
123 * @retval: FSP reserved memory base
124 * 0 if this region does not exist.
126 u32 fsp_get_fsp_reserved_mem(const void *hob_list, u32 *len);
129 * This function retrieves the TSEG reserved normal memory.
131 * @hob_list: A HOB list pointer.
132 * @len: A pointer to the TSEG reserved memory length buffer.
133 * If the GUID HOB is located, the length will be updated.
135 * @retval NULL: Failed to find the TSEG reserved memory.
136 * @retval others: TSEG reserved memory base.
138 u32 fsp_get_tseg_reserved_mem(const void *hob_list, u32 *len);
141 * Returns the next instance of a HOB type from the starting HOB.
143 * @type: HOB type to search
144 * @hob_list: A pointer to the HOB list
146 * @retval: A HOB object with matching type; Otherwise NULL.
148 const struct hob_header *fsp_get_next_hob(uint type, const void *hob_list);
151 * Returns the next instance of the matched GUID HOB from the starting HOB.
153 * @guid: GUID to search
154 * @hob_list: A pointer to the HOB list
156 * @retval: A HOB object with matching GUID; Otherwise NULL.
158 const struct hob_header *fsp_get_next_guid_hob(const struct efi_guid *guid,
159 const void *hob_list);
162 * This function retrieves a GUID HOB data buffer and size.
164 * @hob_list: A HOB list pointer.
165 * @len: A pointer to the GUID HOB data buffer length.
166 * If the GUID HOB is located, the length will be updated.
167 * @guid A pointer to HOB GUID.
169 * @retval NULL: Failed to find the GUID HOB.
170 * @retval others: GUID HOB data buffer pointer.
172 void *fsp_get_guid_hob_data(const void *hob_list, u32 *len,
173 struct efi_guid *guid);
176 * This function retrieves FSP Non-volatile Storage HOB buffer and size.
178 * @hob_list: A HOB list pointer.
179 * @len: A pointer to the NVS data buffer length.
180 * If the HOB is located, the length will be updated.
182 * @retval NULL: Failed to find the NVS HOB.
183 * @retval others: FSP NVS data buffer pointer.
185 void *fsp_get_nvs_data(const void *hob_list, u32 *len);
188 * This function retrieves Bootloader temporary stack buffer and size.
190 * @hob_list: A HOB list pointer.
191 * @len: A pointer to the bootloader temporary stack length.
192 * If the HOB is located, the length will be updated.
194 * @retval NULL: Failed to find the bootloader temporary stack HOB.
195 * @retval others: Bootloader temporary stackbuffer pointer.
197 void *fsp_get_bootloader_tmp_mem(const void *hob_list, u32 *len);
200 * This function overrides the default configurations in the UPD data region.
202 * @fsp_upd: A pointer to the upd_region data strcture
206 void update_fsp_upd(struct upd_region *fsp_upd);