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"
21 struct shared_data_t {
22 struct fsp_header_t *fsp_hdr;
24 struct upd_region_t fsp_upd;
27 void asm_continuation(void);
29 void fsp_init_done(void *hob_list);
32 * FSP Continuation function
34 * @shared_data: Shared data base before stack migration
36 * @hob_list: HOB list pointer
38 * @retval: Never returns
40 void fsp_continue(struct shared_data_t *shared_data, u32 status,
44 * Find FSP header offset in FSP image
46 * If this function is called before the a stack is established, special care
47 * must be taken. First, it cannot declare any local variable using stack.
48 * Only register variable can be used here. Secondly, some compiler version
49 * will add prolog or epilog code for the C function. If so the function call
50 * may not work before stack is ready. GCC 4.8.1 has been verified to be
51 * working for the following code.
53 * @retval: the offset of FSP header. If signature is invalid, returns 0.
55 u32 find_fsp_header(void);
58 * FSP initialization wrapper function.
60 * @stack_top: bootloader stack top address
61 * @boot_mode: boot mode defined in fsp_bootmode.h
62 * @nvs_buf: Non-volatile memory buffer pointer
64 void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf);
67 * FSP notification wrapper function
69 * @fsp_hdr: Pointer to FSP information header
70 * @phase: FSP initialization phase defined in enum fsp_phase_t
72 * @retval: compatible status code with EFI_STATUS defined in PI spec
74 u32 fsp_notify(struct fsp_header_t *fsp_hdr, u32 phase);
77 * This function retrieves the top of usable low memory.
79 * @hob_list: A HOB list pointer.
81 * @retval: Usable low memory top.
83 u32 get_usable_lowmem_top(const void *hob_list);
86 * This function retrieves the top of usable high memory.
88 * @hob_list: A HOB list pointer.
90 * @retval: Usable high memory top.
92 u64 get_usable_highmem_top(const void *hob_list);
95 * This function retrieves a special reserved memory region.
97 * @hob_list: A HOB list pointer.
98 * @len: A pointer to the GUID HOB data buffer length.
99 * If the GUID HOB is located, the length will be updated.
100 * @guid: A pointer to the owner guild.
102 * @retval: Reserved region start address.
103 * 0 if this region does not exist.
105 u64 get_fsp_reserved_mem_from_guid(const void *hob_list,
106 u64 *len, struct efi_guid_t *guid);
109 * This function retrieves the FSP reserved normal memory.
111 * @hob_list: A HOB list pointer.
112 * @len: A pointer to the FSP reserved memory length buffer.
113 * If the GUID HOB is located, the length will be updated.
114 * @retval: FSP reserved memory base
115 * 0 if this region does not exist.
117 u32 get_fsp_reserved_mem(const void *hob_list, u32 *len);
120 * This function retrieves the TSEG reserved normal memory.
122 * @hob_list: A HOB list pointer.
123 * @len: A pointer to the TSEG reserved memory length buffer.
124 * If the GUID HOB is located, the length will be updated.
126 * @retval NULL: Failed to find the TSEG reserved memory.
127 * @retval others: TSEG reserved memory base.
129 u32 get_tseg_reserved_mem(const void *hob_list, u32 *len);
132 * Returns the next instance of a HOB type from the starting HOB.
134 * @type: HOB type to search
135 * @hob_list: A pointer to the HOB list
137 * @retval: A HOB object with matching type; Otherwise NULL.
139 void *get_next_hob(u16 type, const void *hob_list);
142 * Returns the next instance of the matched GUID HOB from the starting HOB.
144 * @guid: GUID to search
145 * @hob_list: A pointer to the HOB list
147 * @retval: A HOB object with matching GUID; Otherwise NULL.
149 void *get_next_guid_hob(const struct efi_guid_t *guid, const void *hob_list);
152 * This function retrieves a GUID HOB data buffer and size.
154 * @hob_list: A HOB list pointer.
155 * @len: A pointer to the GUID HOB data buffer length.
156 * If the GUID HOB is located, the length will be updated.
157 * @guid A pointer to HOB GUID.
159 * @retval NULL: Failed to find the GUID HOB.
160 * @retval others: GUID HOB data buffer pointer.
162 void *get_guid_hob_data(const void *hob_list, u32 *len,
163 struct efi_guid_t *guid);
166 * This function retrieves FSP Non-volatile Storage HOB buffer and size.
168 * @hob_list: A HOB list pointer.
169 * @len: A pointer to the NVS data buffer length.
170 * If the HOB is located, the length will be updated.
172 * @retval NULL: Failed to find the NVS HOB.
173 * @retval others: FSP NVS data buffer pointer.
175 void *get_fsp_nvs_data(const void *hob_list, u32 *len);
178 * This function retrieves Bootloader temporary stack buffer and size.
180 * @hob_list: A HOB list pointer.
181 * @len: A pointer to the bootloader temporary stack length.
182 * If the HOB is located, the length will be updated.
184 * @retval NULL: Failed to find the bootloader temporary stack HOB.
185 * @retval others: Bootloader temporary stackbuffer pointer.
187 void *get_bootloader_tmp_mem(const void *hob_list, u32 *len);
190 * This function overrides the default configurations in the UPD data region.
192 * @fsp_upd: A pointer to the upd_region_t data strcture
196 void update_fsp_upd(struct upd_region_t *fsp_upd);