blob: 90e4e7db269338d9ca33cf0a960b7233a69ccbd7 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: Intel
Bin Meng2922b3e2014-12-12 21:05:28 +08002/*
3 * Copyright (C) 2013, Intel Corporation
4 * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
Bin Meng2922b3e2014-12-12 21:05:28 +08005 */
6
Bin Meng01223e32014-12-12 21:05:29 +08007#include <common.h>
Simon Glassb93abfc2015-01-27 22:13:36 -07008#include <asm/fsp/fsp_support.h>
Bin Meng01223e32014-12-12 21:05:29 +08009#include <asm/post.h>
Bin Meng2922b3e2014-12-12 21:05:28 +080010
11/**
Bin Meng2922b3e2014-12-12 21:05:28 +080012 * Compares two GUIDs
13 *
Bin Mengdb60d862014-12-17 15:50:49 +080014 * If the GUIDs are identical then true is returned.
15 * If there are any bit differences in the two GUIDs, then false is returned.
Bin Meng2922b3e2014-12-12 21:05:28 +080016 *
17 * @guid1: A pointer to a 128 bit GUID.
18 * @guid2: A pointer to a 128 bit GUID.
19 *
Bin Mengdb60d862014-12-17 15:50:49 +080020 * @retval true: guid1 and guid2 are identical.
21 * @retval false: guid1 and guid2 are not identical.
Bin Meng2922b3e2014-12-12 21:05:28 +080022 */
Bin Mengdb60d862014-12-17 15:50:49 +080023static bool compare_guid(const struct efi_guid *guid1,
24 const struct efi_guid *guid2)
Bin Meng2922b3e2014-12-12 21:05:28 +080025{
Bin Mengdb60d862014-12-17 15:50:49 +080026 if (memcmp(guid1, guid2, sizeof(struct efi_guid)) == 0)
27 return true;
28 else
29 return false;
Bin Meng2922b3e2014-12-12 21:05:28 +080030}
31
Simon Glass457191e2015-01-27 22:13:37 -070032struct fsp_header *__attribute__((optimize("O0"))) find_fsp_header(void)
Bin Meng2922b3e2014-12-12 21:05:28 +080033{
Bin Mengdb60d862014-12-17 15:50:49 +080034 /*
35 * This function may be called before the a stack is established,
36 * so special care must be taken. First, it cannot declare any local
37 * variable using stack. Only register variable can be used here.
38 * Secondly, some compiler version will add prolog or epilog code
39 * for the C function. If so the function call may not work before
40 * stack is ready.
41 *
42 * GCC 4.8.1 has been verified to be working for the following codes.
43 */
Bin Meng2922b3e2014-12-12 21:05:28 +080044 volatile register u8 *fsp asm("eax");
45
46 /* Initalize the FSP base */
Bin Meng293f4972014-12-17 15:50:42 +080047 fsp = (u8 *)CONFIG_FSP_ADDR;
Bin Meng2922b3e2014-12-12 21:05:28 +080048
49 /* Check the FV signature, _FVH */
Bin Mengdb60d862014-12-17 15:50:49 +080050 if (((struct fv_header *)fsp)->sign == EFI_FVH_SIGNATURE) {
Bin Meng2922b3e2014-12-12 21:05:28 +080051 /* Go to the end of the FV header and align the address */
Bin Mengdb60d862014-12-17 15:50:49 +080052 fsp += ((struct fv_header *)fsp)->ext_hdr_off;
53 fsp += ((struct fv_ext_header *)fsp)->ext_hdr_size;
Bin Meng2922b3e2014-12-12 21:05:28 +080054 fsp = (u8 *)(((u32)fsp + 7) & 0xFFFFFFF8);
55 } else {
56 fsp = 0;
57 }
58
59 /* Check the FFS GUID */
60 if (fsp &&
Bin Mengdb60d862014-12-17 15:50:49 +080061 ((struct ffs_file_header *)fsp)->name.data1 == FSP_GUID_DATA1 &&
62 ((struct ffs_file_header *)fsp)->name.data2 == FSP_GUID_DATA2 &&
63 ((struct ffs_file_header *)fsp)->name.data3 == FSP_GUID_DATA3 &&
64 ((struct ffs_file_header *)fsp)->name.data4[0] == FSP_GUID_DATA4_0 &&
65 ((struct ffs_file_header *)fsp)->name.data4[1] == FSP_GUID_DATA4_1 &&
66 ((struct ffs_file_header *)fsp)->name.data4[2] == FSP_GUID_DATA4_2 &&
67 ((struct ffs_file_header *)fsp)->name.data4[3] == FSP_GUID_DATA4_3 &&
68 ((struct ffs_file_header *)fsp)->name.data4[4] == FSP_GUID_DATA4_4 &&
69 ((struct ffs_file_header *)fsp)->name.data4[5] == FSP_GUID_DATA4_5 &&
70 ((struct ffs_file_header *)fsp)->name.data4[6] == FSP_GUID_DATA4_6 &&
71 ((struct ffs_file_header *)fsp)->name.data4[7] == FSP_GUID_DATA4_7) {
Bin Meng2922b3e2014-12-12 21:05:28 +080072 /* Add the FFS header size to find the raw section header */
Bin Mengdb60d862014-12-17 15:50:49 +080073 fsp += sizeof(struct ffs_file_header);
Bin Meng2922b3e2014-12-12 21:05:28 +080074 } else {
75 fsp = 0;
76 }
77
78 if (fsp &&
Bin Mengdb60d862014-12-17 15:50:49 +080079 ((struct raw_section *)fsp)->type == EFI_SECTION_RAW) {
Bin Meng2922b3e2014-12-12 21:05:28 +080080 /* Add the raw section header size to find the FSP header */
Bin Mengdb60d862014-12-17 15:50:49 +080081 fsp += sizeof(struct raw_section);
Bin Meng2922b3e2014-12-12 21:05:28 +080082 } else {
83 fsp = 0;
84 }
85
Simon Glass457191e2015-01-27 22:13:37 -070086 return (struct fsp_header *)fsp;
Bin Meng2922b3e2014-12-12 21:05:28 +080087}
88
Bin Meng001d5c72015-12-10 22:02:56 -080089void fsp_continue(u32 status, void *hob_list)
Bin Meng2922b3e2014-12-12 21:05:28 +080090{
Bin Meng01223e32014-12-12 21:05:29 +080091 post_code(POST_MRC);
92
Bin Mengdb60d862014-12-17 15:50:49 +080093 assert(status == 0);
Bin Meng2922b3e2014-12-12 21:05:28 +080094
Bin Meng2922b3e2014-12-12 21:05:28 +080095 /* The boot loader main function entry */
Bin Meng01223e32014-12-12 21:05:29 +080096 fsp_init_done(hob_list);
Bin Meng2922b3e2014-12-12 21:05:28 +080097}
98
99void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
100{
Bin Menga0c94dc2015-12-10 22:02:59 -0800101 struct fsp_config_data config_data;
Bin Meng2922b3e2014-12-12 21:05:28 +0800102 fsp_init_f init;
Bin Mengdb60d862014-12-17 15:50:49 +0800103 struct fsp_init_params params;
104 struct fspinit_rtbuf rt_buf;
Bin Mengdb60d862014-12-17 15:50:49 +0800105 struct fsp_header *fsp_hdr;
106 struct fsp_init_params *params_ptr;
Bin Mengf9a61892015-12-10 22:03:01 -0800107#ifdef CONFIG_FSP_USE_UPD
108 struct vpd_region *fsp_vpd;
Bin Mengdb60d862014-12-17 15:50:49 +0800109 struct upd_region *fsp_upd;
Bin Mengf9a61892015-12-10 22:03:01 -0800110#endif
Bin Meng2922b3e2014-12-12 21:05:28 +0800111
Simon Glass8afe6ff2015-01-27 22:13:40 -0700112 fsp_hdr = find_fsp_header();
Bin Meng2922b3e2014-12-12 21:05:28 +0800113 if (fsp_hdr == NULL) {
114 /* No valid FSP info header was found */
Bin Mengdb60d862014-12-17 15:50:49 +0800115 panic("Invalid FSP header");
Bin Meng2922b3e2014-12-12 21:05:28 +0800116 }
117
Bin Mengc24aebd2015-12-10 22:03:00 -0800118 config_data.common.fsp_hdr = fsp_hdr;
119 config_data.common.stack_top = stack_top;
120 config_data.common.boot_mode = boot_mode;
121
Bin Mengf9a61892015-12-10 22:03:01 -0800122#ifdef CONFIG_FSP_USE_UPD
Bin Meng2922b3e2014-12-12 21:05:28 +0800123 /* Get VPD region start */
Bin Mengdb60d862014-12-17 15:50:49 +0800124 fsp_vpd = (struct vpd_region *)(fsp_hdr->img_base +
Bin Meng2922b3e2014-12-12 21:05:28 +0800125 fsp_hdr->cfg_region_off);
126
Simon Glass8afe6ff2015-01-27 22:13:40 -0700127 /* Verify the VPD data region is valid */
Bin Mengc44ed642015-08-08 22:01:23 +0800128 assert(fsp_vpd->sign == VPD_IMAGE_ID);
Bin Meng2922b3e2014-12-12 21:05:28 +0800129
Bin Mengf9a61892015-12-10 22:03:01 -0800130 fsp_upd = &config_data.fsp_upd;
131
Bin Meng2922b3e2014-12-12 21:05:28 +0800132 /* Copy default data from Flash */
133 memcpy(fsp_upd, (void *)(fsp_hdr->img_base + fsp_vpd->upd_offset),
Bin Mengdb60d862014-12-17 15:50:49 +0800134 sizeof(struct upd_region));
Bin Meng2922b3e2014-12-12 21:05:28 +0800135
Simon Glass8afe6ff2015-01-27 22:13:40 -0700136 /* Verify the UPD data region is valid */
Bin Mengdb60d862014-12-17 15:50:49 +0800137 assert(fsp_upd->terminator == UPD_TERMINATOR);
Bin Mengf9a61892015-12-10 22:03:01 -0800138#endif
139
140 memset(&rt_buf, 0, sizeof(struct fspinit_rtbuf));
141
Bin Mengc24aebd2015-12-10 22:03:00 -0800142 /* Override any configuration if required */
Bin Meng4a076fe2015-12-10 22:03:04 -0800143 update_fsp_configs(&config_data, &rt_buf);
Bin Meng2922b3e2014-12-12 21:05:28 +0800144
Bin Mengdb60d862014-12-17 15:50:49 +0800145 memset(&params, 0, sizeof(struct fsp_init_params));
Bin Meng2922b3e2014-12-12 21:05:28 +0800146 params.nvs_buf = nvs_buf;
Bin Mengdb60d862014-12-17 15:50:49 +0800147 params.rt_buf = (struct fspinit_rtbuf *)&rt_buf;
Bin Meng2922b3e2014-12-12 21:05:28 +0800148 params.continuation = (fsp_continuation_f)asm_continuation;
149
150 init = (fsp_init_f)(fsp_hdr->img_base + fsp_hdr->fsp_init);
151 params_ptr = &params;
152
Bin Meng01223e32014-12-12 21:05:29 +0800153 post_code(POST_PRE_MRC);
154
Bin Menga3c9fb02015-06-07 11:33:13 +0800155 /* Load GDT for FSP */
156 setup_fsp_gdt();
157
Bin Meng2922b3e2014-12-12 21:05:28 +0800158 /*
Bin Meng001d5c72015-12-10 22:02:56 -0800159 * Use ASM code to ensure the register value in EAX & EDX
160 * will be passed into fsp_continue
Bin Meng2922b3e2014-12-12 21:05:28 +0800161 */
162 asm volatile (
163 "pushl %0;"
164 "call *%%eax;"
165 ".global asm_continuation;"
166 "asm_continuation:;"
Bin Meng001d5c72015-12-10 22:02:56 -0800167 "movl 4(%%esp), %%eax;" /* status */
168 "movl 8(%%esp), %%edx;" /* hob_list */
Bin Meng2922b3e2014-12-12 21:05:28 +0800169 "jmp fsp_continue;"
Bin Meng001d5c72015-12-10 22:02:56 -0800170 : : "m"(params_ptr), "a"(init)
Bin Meng2922b3e2014-12-12 21:05:28 +0800171 );
172
173 /*
174 * Should never get here.
Bin Mengdb60d862014-12-17 15:50:49 +0800175 * Control will continue from fsp_continue.
Bin Meng2922b3e2014-12-12 21:05:28 +0800176 * This line below is to prevent the compiler from optimizing
177 * structure intialization.
Bin Mengdb60d862014-12-17 15:50:49 +0800178 *
179 * DO NOT REMOVE!
Bin Meng2922b3e2014-12-12 21:05:28 +0800180 */
181 init(&params);
Bin Meng2922b3e2014-12-12 21:05:28 +0800182}
183
Bin Mengdb60d862014-12-17 15:50:49 +0800184u32 fsp_notify(struct fsp_header *fsp_hdr, u32 phase)
Bin Meng2922b3e2014-12-12 21:05:28 +0800185{
186 fsp_notify_f notify;
Bin Mengdb60d862014-12-17 15:50:49 +0800187 struct fsp_notify_params params;
188 struct fsp_notify_params *params_ptr;
Bin Meng2922b3e2014-12-12 21:05:28 +0800189 u32 status;
190
191 if (!fsp_hdr)
Bin Mengdb60d862014-12-17 15:50:49 +0800192 fsp_hdr = (struct fsp_header *)find_fsp_header();
Bin Meng2922b3e2014-12-12 21:05:28 +0800193
194 if (fsp_hdr == NULL) {
195 /* No valid FSP info header */
Bin Mengdb60d862014-12-17 15:50:49 +0800196 panic("Invalid FSP header");
Bin Meng2922b3e2014-12-12 21:05:28 +0800197 }
198
199 notify = (fsp_notify_f)(fsp_hdr->img_base + fsp_hdr->fsp_notify);
200 params.phase = phase;
Bin Meng01223e32014-12-12 21:05:29 +0800201 params_ptr = &params;
202
203 /*
204 * Use ASM code to ensure correct parameter is on the stack for
205 * FspNotify as U-Boot is using different ABI from FSP
206 */
207 asm volatile (
208 "pushl %1;" /* push notify phase */
209 "call *%%eax;" /* call FspNotify */
210 "addl $4, %%esp;" /* clean up the stack */
211 : "=a"(status) : "m"(params_ptr), "a"(notify), "m"(*params_ptr)
212 );
Bin Meng2922b3e2014-12-12 21:05:28 +0800213
214 return status;
215}
216
Bin Mengdb60d862014-12-17 15:50:49 +0800217u32 fsp_get_usable_lowmem_top(const void *hob_list)
Bin Meng2922b3e2014-12-12 21:05:28 +0800218{
Bin Meng2b215982014-12-30 16:02:05 +0800219 const struct hob_header *hdr;
220 struct hob_res_desc *res_desc;
Bin Meng2922b3e2014-12-12 21:05:28 +0800221 phys_addr_t phys_start;
222 u32 top;
Bin Meng4c836c92016-02-17 00:16:23 -0800223#ifdef CONFIG_FSP_BROKEN_HOB
224 struct hob_mem_alloc *res_mem;
225 phys_addr_t mem_base = 0;
226#endif
Bin Meng2922b3e2014-12-12 21:05:28 +0800227
228 /* Get the HOB list for processing */
Bin Meng2b215982014-12-30 16:02:05 +0800229 hdr = hob_list;
Bin Meng2922b3e2014-12-12 21:05:28 +0800230
231 /* * Collect memory ranges */
Bin Mengdb60d862014-12-17 15:50:49 +0800232 top = FSP_LOWMEM_BASE;
Bin Meng2b215982014-12-30 16:02:05 +0800233 while (!end_of_hob(hdr)) {
Bin Meng2f848bc2015-01-06 14:04:36 +0800234 if (hdr->type == HOB_TYPE_RES_DESC) {
Bin Meng2b215982014-12-30 16:02:05 +0800235 res_desc = (struct hob_res_desc *)hdr;
236 if (res_desc->type == RES_SYS_MEM) {
237 phys_start = res_desc->phys_start;
Bin Meng2922b3e2014-12-12 21:05:28 +0800238 /* Need memory above 1MB to be collected here */
Bin Mengdb60d862014-12-17 15:50:49 +0800239 if (phys_start >= FSP_LOWMEM_BASE &&
240 phys_start < (phys_addr_t)FSP_HIGHMEM_BASE)
Bin Meng2b215982014-12-30 16:02:05 +0800241 top += (u32)(res_desc->len);
Bin Meng2922b3e2014-12-12 21:05:28 +0800242 }
243 }
Bin Meng4c836c92016-02-17 00:16:23 -0800244
245#ifdef CONFIG_FSP_BROKEN_HOB
246 /*
247 * Find out the lowest memory base address allocated by FSP
248 * for the boot service data
249 */
250 if (hdr->type == HOB_TYPE_MEM_ALLOC) {
251 res_mem = (struct hob_mem_alloc *)hdr;
252 if (!mem_base)
253 mem_base = res_mem->mem_base;
254 if (res_mem->mem_base < mem_base)
255 mem_base = res_mem->mem_base;
256 }
257#endif
258
Bin Meng2b215982014-12-30 16:02:05 +0800259 hdr = get_next_hob(hdr);
Bin Meng2922b3e2014-12-12 21:05:28 +0800260 }
261
Bin Meng4c836c92016-02-17 00:16:23 -0800262#ifdef CONFIG_FSP_BROKEN_HOB
263 /*
264 * Check whether the memory top address is below the FSP HOB list.
265 * If not, use the lowest memory base address allocated by FSP as
266 * the memory top address. This is to prevent U-Boot relocation
267 * overwrites the important boot service data which is used by FSP,
268 * otherwise the subsequent call to fsp_notify() will fail.
269 */
270 if (top > (u32)hob_list) {
271 debug("Adjust memory top address due to a buggy FSP\n");
272 top = (u32)mem_base;
273 }
274#endif
275
Bin Meng2922b3e2014-12-12 21:05:28 +0800276 return top;
277}
278
Bin Mengdb60d862014-12-17 15:50:49 +0800279u64 fsp_get_usable_highmem_top(const void *hob_list)
Bin Meng2922b3e2014-12-12 21:05:28 +0800280{
Bin Meng2b215982014-12-30 16:02:05 +0800281 const struct hob_header *hdr;
282 struct hob_res_desc *res_desc;
Bin Meng2922b3e2014-12-12 21:05:28 +0800283 phys_addr_t phys_start;
284 u64 top;
285
286 /* Get the HOB list for processing */
Bin Meng2b215982014-12-30 16:02:05 +0800287 hdr = hob_list;
Bin Meng2922b3e2014-12-12 21:05:28 +0800288
289 /* Collect memory ranges */
Bin Mengdb60d862014-12-17 15:50:49 +0800290 top = FSP_HIGHMEM_BASE;
Bin Meng2b215982014-12-30 16:02:05 +0800291 while (!end_of_hob(hdr)) {
Bin Meng2f848bc2015-01-06 14:04:36 +0800292 if (hdr->type == HOB_TYPE_RES_DESC) {
Bin Meng2b215982014-12-30 16:02:05 +0800293 res_desc = (struct hob_res_desc *)hdr;
294 if (res_desc->type == RES_SYS_MEM) {
295 phys_start = res_desc->phys_start;
Andrew Bradford17194d52015-05-22 15:11:23 -0400296 /* Need memory above 4GB to be collected here */
Bin Mengdb60d862014-12-17 15:50:49 +0800297 if (phys_start >= (phys_addr_t)FSP_HIGHMEM_BASE)
Bin Meng2b215982014-12-30 16:02:05 +0800298 top += (u32)(res_desc->len);
Bin Meng2922b3e2014-12-12 21:05:28 +0800299 }
300 }
Bin Meng2b215982014-12-30 16:02:05 +0800301 hdr = get_next_hob(hdr);
Bin Meng2922b3e2014-12-12 21:05:28 +0800302 }
303
304 return top;
305}
306
Bin Mengdb60d862014-12-17 15:50:49 +0800307u64 fsp_get_reserved_mem_from_guid(const void *hob_list, u64 *len,
308 struct efi_guid *guid)
Bin Meng2922b3e2014-12-12 21:05:28 +0800309{
Bin Meng2b215982014-12-30 16:02:05 +0800310 const struct hob_header *hdr;
311 struct hob_res_desc *res_desc;
Bin Meng2922b3e2014-12-12 21:05:28 +0800312
313 /* Get the HOB list for processing */
Bin Meng2b215982014-12-30 16:02:05 +0800314 hdr = hob_list;
Bin Meng2922b3e2014-12-12 21:05:28 +0800315
316 /* Collect memory ranges */
Bin Meng2b215982014-12-30 16:02:05 +0800317 while (!end_of_hob(hdr)) {
Bin Meng2f848bc2015-01-06 14:04:36 +0800318 if (hdr->type == HOB_TYPE_RES_DESC) {
Bin Meng2b215982014-12-30 16:02:05 +0800319 res_desc = (struct hob_res_desc *)hdr;
320 if (res_desc->type == RES_MEM_RESERVED) {
321 if (compare_guid(&res_desc->owner, guid)) {
Bin Meng2922b3e2014-12-12 21:05:28 +0800322 if (len)
Bin Meng2b215982014-12-30 16:02:05 +0800323 *len = (u32)(res_desc->len);
Bin Meng2922b3e2014-12-12 21:05:28 +0800324
Bin Meng2b215982014-12-30 16:02:05 +0800325 return (u64)(res_desc->phys_start);
Bin Meng2922b3e2014-12-12 21:05:28 +0800326 }
327 }
328 }
Bin Meng2b215982014-12-30 16:02:05 +0800329 hdr = get_next_hob(hdr);
Bin Meng2922b3e2014-12-12 21:05:28 +0800330 }
331
332 return 0;
333}
334
Bin Mengdb60d862014-12-17 15:50:49 +0800335u32 fsp_get_fsp_reserved_mem(const void *hob_list, u32 *len)
Bin Meng2922b3e2014-12-12 21:05:28 +0800336{
Bin Mengdb60d862014-12-17 15:50:49 +0800337 const struct efi_guid guid = FSP_HOB_RESOURCE_OWNER_FSP_GUID;
Bin Meng2922b3e2014-12-12 21:05:28 +0800338 u64 length;
339 u32 base;
340
Bin Mengdb60d862014-12-17 15:50:49 +0800341 base = (u32)fsp_get_reserved_mem_from_guid(hob_list,
342 &length, (struct efi_guid *)&guid);
Bin Meng2922b3e2014-12-12 21:05:28 +0800343 if ((len != 0) && (base != 0))
344 *len = (u32)length;
345
346 return base;
347}
348
Bin Mengdb60d862014-12-17 15:50:49 +0800349u32 fsp_get_tseg_reserved_mem(const void *hob_list, u32 *len)
Bin Meng2922b3e2014-12-12 21:05:28 +0800350{
Bin Mengdb60d862014-12-17 15:50:49 +0800351 const struct efi_guid guid = FSP_HOB_RESOURCE_OWNER_TSEG_GUID;
Bin Meng2922b3e2014-12-12 21:05:28 +0800352 u64 length;
353 u32 base;
354
Bin Mengdb60d862014-12-17 15:50:49 +0800355 base = (u32)fsp_get_reserved_mem_from_guid(hob_list,
356 &length, (struct efi_guid *)&guid);
Bin Meng2922b3e2014-12-12 21:05:28 +0800357 if ((len != 0) && (base != 0))
358 *len = (u32)length;
359
360 return base;
361}
362
Bin Meng2f848bc2015-01-06 14:04:36 +0800363const struct hob_header *fsp_get_next_hob(uint type, const void *hob_list)
Bin Meng2922b3e2014-12-12 21:05:28 +0800364{
Bin Meng2b215982014-12-30 16:02:05 +0800365 const struct hob_header *hdr;
Bin Meng2922b3e2014-12-12 21:05:28 +0800366
Bin Meng2b215982014-12-30 16:02:05 +0800367 hdr = hob_list;
Bin Meng2922b3e2014-12-12 21:05:28 +0800368
369 /* Parse the HOB list until end of list or matching type is found */
Bin Meng2b215982014-12-30 16:02:05 +0800370 while (!end_of_hob(hdr)) {
Bin Meng2f848bc2015-01-06 14:04:36 +0800371 if (hdr->type == type)
Bin Meng2b215982014-12-30 16:02:05 +0800372 return hdr;
Bin Meng2922b3e2014-12-12 21:05:28 +0800373
Bin Meng2b215982014-12-30 16:02:05 +0800374 hdr = get_next_hob(hdr);
Bin Meng2922b3e2014-12-12 21:05:28 +0800375 }
376
377 return NULL;
378}
379
Bin Meng2b215982014-12-30 16:02:05 +0800380const struct hob_header *fsp_get_next_guid_hob(const struct efi_guid *guid,
381 const void *hob_list)
Bin Meng2922b3e2014-12-12 21:05:28 +0800382{
Bin Meng2b215982014-12-30 16:02:05 +0800383 const struct hob_header *hdr;
384 struct hob_guid *guid_hob;
Bin Meng2922b3e2014-12-12 21:05:28 +0800385
Bin Meng2b215982014-12-30 16:02:05 +0800386 hdr = hob_list;
387 while ((hdr = fsp_get_next_hob(HOB_TYPE_GUID_EXT,
388 hdr)) != NULL) {
389 guid_hob = (struct hob_guid *)hdr;
390 if (compare_guid(guid, &(guid_hob->name)))
Bin Meng2922b3e2014-12-12 21:05:28 +0800391 break;
Bin Meng2b215982014-12-30 16:02:05 +0800392 hdr = get_next_hob(hdr);
Bin Meng2922b3e2014-12-12 21:05:28 +0800393 }
394
Bin Meng2b215982014-12-30 16:02:05 +0800395 return hdr;
Bin Meng2922b3e2014-12-12 21:05:28 +0800396}
397
Bin Mengdb60d862014-12-17 15:50:49 +0800398void *fsp_get_guid_hob_data(const void *hob_list, u32 *len,
399 struct efi_guid *guid)
Bin Meng2922b3e2014-12-12 21:05:28 +0800400{
Bin Meng2b215982014-12-30 16:02:05 +0800401 const struct hob_header *guid_hob;
Bin Meng2922b3e2014-12-12 21:05:28 +0800402
Bin Mengdb60d862014-12-17 15:50:49 +0800403 guid_hob = fsp_get_next_guid_hob(guid, hob_list);
Bin Meng2922b3e2014-12-12 21:05:28 +0800404 if (guid_hob == NULL) {
405 return NULL;
406 } else {
407 if (len)
Bin Mengdb60d862014-12-17 15:50:49 +0800408 *len = get_guid_hob_data_size(guid_hob);
Bin Meng2922b3e2014-12-12 21:05:28 +0800409
Bin Mengdb60d862014-12-17 15:50:49 +0800410 return get_guid_hob_data(guid_hob);
Bin Meng2922b3e2014-12-12 21:05:28 +0800411 }
412}
413
Bin Mengdb60d862014-12-17 15:50:49 +0800414void *fsp_get_nvs_data(const void *hob_list, u32 *len)
Bin Meng2922b3e2014-12-12 21:05:28 +0800415{
Bin Mengdb60d862014-12-17 15:50:49 +0800416 const struct efi_guid guid = FSP_NON_VOLATILE_STORAGE_HOB_GUID;
Bin Meng2922b3e2014-12-12 21:05:28 +0800417
Bin Mengdb60d862014-12-17 15:50:49 +0800418 return fsp_get_guid_hob_data(hob_list, len, (struct efi_guid *)&guid);
Bin Meng2922b3e2014-12-12 21:05:28 +0800419}
420
Bin Mengdb60d862014-12-17 15:50:49 +0800421void *fsp_get_bootloader_tmp_mem(const void *hob_list, u32 *len)
Bin Meng2922b3e2014-12-12 21:05:28 +0800422{
Bin Mengdb60d862014-12-17 15:50:49 +0800423 const struct efi_guid guid = FSP_BOOTLOADER_TEMP_MEM_HOB_GUID;
Bin Meng2922b3e2014-12-12 21:05:28 +0800424
Bin Mengdb60d862014-12-17 15:50:49 +0800425 return fsp_get_guid_hob_data(hob_list, len, (struct efi_guid *)&guid);
Bin Meng2922b3e2014-12-12 21:05:28 +0800426}
Bin Meng3c8b48a2017-08-15 22:41:52 -0700427
428void *fsp_get_graphics_info(const void *hob_list, u32 *len)
429{
430 const struct efi_guid guid = FSP_GRAPHICS_INFO_HOB_GUID;
431
432 return fsp_get_guid_hob_data(hob_list, len, (struct efi_guid *)&guid);
433}