1 /*
2  * Copyright (C) 2013, Intel Corporation
3  * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
4  *
5  * SPDX-License-Identifier:	Intel
6  */
7 
8 #ifndef __FSP_SUPPORT_H__
9 #define __FSP_SUPPORT_H__
10 
11 #include "fsp_types.h"
12 #include "fsp_fv.h"
13 #include "fsp_ffs.h"
14 #include "fsp_api.h"
15 #include "fsp_hob.h"
16 #include "fsp_infoheader.h"
17 #include "fsp_bootmode.h"
18 #include "fsp_azalia.h"
19 #include <asm/arch/fsp/fsp_vpd.h>
20 #include <asm/arch/fsp/fsp_configs.h>
21 
22 #define FSP_LOWMEM_BASE		0x100000UL
23 #define FSP_HIGHMEM_BASE	0x100000000ULL
24 #define UPD_TERMINATOR		0x55AA
25 
26 
27 /**
28  * FSP Continuation assembly helper routine
29  *
30  * This routine jumps to the C version of FSP continuation function
31  */
32 void asm_continuation(void);
33 
34 /**
35  * FSP initialization complete
36  *
37  * This is the function that indicates FSP initialization is complete and jumps
38  * back to the bootloader with HOB list pointer as the parameter.
39  *
40  * @hob_list:    HOB list pointer
41  */
42 void fsp_init_done(void *hob_list);
43 
44 /**
45  * FSP Continuation function
46  *
47  * @status:      Always 0
48  * @hob_list:    HOB list pointer
49  *
50  * @retval:      Never returns
51  */
52 void fsp_continue(u32 status, void *hob_list);
53 
54 /**
55  * Find FSP header offset in FSP image
56  *
57  * @retval: the offset of FSP header. If signature is invalid, returns 0.
58  */
59 struct fsp_header *find_fsp_header(void);
60 
61 /**
62  * FSP initialization wrapper function.
63  *
64  * @stack_top: bootloader stack top address
65  * @boot_mode: boot mode defined in fsp_bootmode.h
66  * @nvs_buf:   Non-volatile memory buffer pointer
67  */
68 void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf);
69 
70 /**
71  * FSP notification wrapper function
72  *
73  * @fsp_hdr: Pointer to FSP information header
74  * @phase:   FSP initialization phase defined in enum fsp_phase
75  *
76  * @retval:  compatible status code with EFI_STATUS defined in PI spec
77  */
78 u32 fsp_notify(struct fsp_header *fsp_hdr, u32 phase);
79 
80 /**
81  * This function retrieves the top of usable low memory.
82  *
83  * @hob_list: A HOB list pointer.
84  *
85  * @retval:   Usable low memory top.
86  */
87 u32 fsp_get_usable_lowmem_top(const void *hob_list);
88 
89 /**
90  * This function retrieves the top of usable high memory.
91  *
92  * @hob_list: A HOB list pointer.
93  *
94  * @retval:   Usable high memory top.
95  */
96 u64 fsp_get_usable_highmem_top(const void *hob_list);
97 
98 /**
99  * This function retrieves a special reserved memory region.
100  *
101  * @hob_list: A HOB list pointer.
102  * @len:      A pointer to the GUID HOB data buffer length.
103  *            If the GUID HOB is located, the length will be updated.
104  * @guid:     A pointer to the owner guild.
105  *
106  * @retval:   Reserved region start address.
107  *            0 if this region does not exist.
108  */
109 u64 fsp_get_reserved_mem_from_guid(const void *hob_list,
110 				   u64 *len, struct efi_guid *guid);
111 
112 /**
113  * This function retrieves the FSP reserved normal memory.
114  *
115  * @hob_list: A HOB list pointer.
116  * @len:      A pointer to the FSP reserved memory length buffer.
117  *            If the GUID HOB is located, the length will be updated.
118  * @retval:   FSP reserved memory base
119  *            0 if this region does not exist.
120  */
121 u32 fsp_get_fsp_reserved_mem(const void *hob_list, u32 *len);
122 
123 /**
124  * This function retrieves the TSEG reserved normal memory.
125  *
126  * @hob_list:      A HOB list pointer.
127  * @len:           A pointer to the TSEG reserved memory length buffer.
128  *                 If the GUID HOB is located, the length will be updated.
129  *
130  * @retval NULL:   Failed to find the TSEG reserved memory.
131  * @retval others: TSEG reserved memory base.
132  */
133 u32 fsp_get_tseg_reserved_mem(const void *hob_list, u32 *len);
134 
135 /**
136  * Returns the next instance of a HOB type from the starting HOB.
137  *
138  * @type:     HOB type to search
139  * @hob_list: A pointer to the HOB list
140  *
141  * @retval:   A HOB object with matching type; Otherwise NULL.
142  */
143 const struct hob_header *fsp_get_next_hob(uint type, const void *hob_list);
144 
145 /**
146  * Returns the next instance of the matched GUID HOB from the starting HOB.
147  *
148  * @guid:     GUID to search
149  * @hob_list: A pointer to the HOB list
150  *
151  * @retval:   A HOB object with matching GUID; Otherwise NULL.
152  */
153 const struct hob_header *fsp_get_next_guid_hob(const struct efi_guid *guid,
154 					       const void *hob_list);
155 
156 /**
157  * This function retrieves a GUID HOB data buffer and size.
158  *
159  * @hob_list:      A HOB list pointer.
160  * @len:           A pointer to the GUID HOB data buffer length.
161  *                 If the GUID HOB is located, the length will be updated.
162  * @guid           A pointer to HOB GUID.
163  *
164  * @retval NULL:   Failed to find the GUID HOB.
165  * @retval others: GUID HOB data buffer pointer.
166  */
167 void *fsp_get_guid_hob_data(const void *hob_list, u32 *len,
168 			    struct efi_guid *guid);
169 
170 /**
171  * This function retrieves FSP Non-volatile Storage HOB buffer and size.
172  *
173  * @hob_list:      A HOB list pointer.
174  * @len:           A pointer to the NVS data buffer length.
175  *                 If the HOB is located, the length will be updated.
176  *
177  * @retval NULL:   Failed to find the NVS HOB.
178  * @retval others: FSP NVS data buffer pointer.
179  */
180 void *fsp_get_nvs_data(const void *hob_list, u32 *len);
181 
182 /**
183  * This function retrieves Bootloader temporary stack buffer and size.
184  *
185  * @hob_list:      A HOB list pointer.
186  * @len:           A pointer to the bootloader temporary stack length.
187  *                 If the HOB is located, the length will be updated.
188  *
189  * @retval NULL:   Failed to find the bootloader temporary stack HOB.
190  * @retval others: Bootloader temporary stackbuffer pointer.
191  */
192 void *fsp_get_bootloader_tmp_mem(const void *hob_list, u32 *len);
193 
194 /**
195  * This function retrieves graphics information.
196  *
197  * @hob_list:      A HOB list pointer.
198  * @len:           A pointer to the graphics info HOB length.
199  *                 If the HOB is located, the length will be updated.
200  *
201  * @retval NULL:   Failed to find the graphics info HOB.
202  * @retval others: A pointer to struct hob_graphics_info.
203  */
204 void *fsp_get_graphics_info(const void *hob_list, u32 *len);
205 
206 /**
207  * This function overrides the default configurations of FSP.
208  *
209  * @config:  A pointer to the FSP configuration data structure
210  * @rt_buf:  A pointer to the FSP runtime buffer data structure
211  *
212  * @return:  None
213  */
214 void update_fsp_configs(struct fsp_config_data *config,
215 			struct fspinit_rtbuf *rt_buf);
216 
217 /**
218  * fsp_init_phase_pci() - Tell the FSP that we have completed PCI init
219  *
220  * @return 0 if OK, -EPERM if the FSP gave an error.
221  */
222 int fsp_init_phase_pci(void);
223 
224 #endif
225