blob: 5809235b10a28b6d7fdcf766b19f5e0c3f0026ee [file] [log] [blame]
Bin Meng2922b3e2014-12-12 21:05:28 +08001/*
2 * Copyright (C) 2013, Intel Corporation
3 * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
4 *
5 * SPDX-License-Identifier: Intel
6 */
7
Bin Meng01223e32014-12-12 21:05:29 +08008#include <common.h>
Simon Glassb93abfc2015-01-27 22:13:36 -07009#include <asm/fsp/fsp_support.h>
Bin Meng01223e32014-12-12 21:05:29 +080010#include <asm/post.h>
Bin Meng2922b3e2014-12-12 21:05:28 +080011
12/**
Bin Meng2922b3e2014-12-12 21:05:28 +080013 * Compares two GUIDs
14 *
Bin Mengdb60d862014-12-17 15:50:49 +080015 * If the GUIDs are identical then true is returned.
16 * If there are any bit differences in the two GUIDs, then false is returned.
Bin Meng2922b3e2014-12-12 21:05:28 +080017 *
18 * @guid1: A pointer to a 128 bit GUID.
19 * @guid2: A pointer to a 128 bit GUID.
20 *
Bin Mengdb60d862014-12-17 15:50:49 +080021 * @retval true: guid1 and guid2 are identical.
22 * @retval false: guid1 and guid2 are not identical.
Bin Meng2922b3e2014-12-12 21:05:28 +080023 */
Bin Mengdb60d862014-12-17 15:50:49 +080024static bool compare_guid(const struct efi_guid *guid1,
25 const struct efi_guid *guid2)
Bin Meng2922b3e2014-12-12 21:05:28 +080026{
Bin Mengdb60d862014-12-17 15:50:49 +080027 if (memcmp(guid1, guid2, sizeof(struct efi_guid)) == 0)
28 return true;
29 else
30 return false;
Bin Meng2922b3e2014-12-12 21:05:28 +080031}
32
Simon Glass457191e2015-01-27 22:13:37 -070033struct fsp_header *__attribute__((optimize("O0"))) find_fsp_header(void)
Bin Meng2922b3e2014-12-12 21:05:28 +080034{
Bin Mengdb60d862014-12-17 15:50:49 +080035 /*
36 * This function may be called before the a stack is established,
37 * so special care must be taken. First, it cannot declare any local
38 * variable using stack. Only register variable can be used here.
39 * Secondly, some compiler version will add prolog or epilog code
40 * for the C function. If so the function call may not work before
41 * stack is ready.
42 *
43 * GCC 4.8.1 has been verified to be working for the following codes.
44 */
Bin Meng2922b3e2014-12-12 21:05:28 +080045 volatile register u8 *fsp asm("eax");
46
47 /* Initalize the FSP base */
Bin Meng293f4972014-12-17 15:50:42 +080048 fsp = (u8 *)CONFIG_FSP_ADDR;
Bin Meng2922b3e2014-12-12 21:05:28 +080049
50 /* Check the FV signature, _FVH */
Bin Mengdb60d862014-12-17 15:50:49 +080051 if (((struct fv_header *)fsp)->sign == EFI_FVH_SIGNATURE) {
Bin Meng2922b3e2014-12-12 21:05:28 +080052 /* Go to the end of the FV header and align the address */
Bin Mengdb60d862014-12-17 15:50:49 +080053 fsp += ((struct fv_header *)fsp)->ext_hdr_off;
54 fsp += ((struct fv_ext_header *)fsp)->ext_hdr_size;
Bin Meng2922b3e2014-12-12 21:05:28 +080055 fsp = (u8 *)(((u32)fsp + 7) & 0xFFFFFFF8);
56 } else {
57 fsp = 0;
58 }
59
60 /* Check the FFS GUID */
61 if (fsp &&
Bin Mengdb60d862014-12-17 15:50:49 +080062 ((struct ffs_file_header *)fsp)->name.data1 == FSP_GUID_DATA1 &&
63 ((struct ffs_file_header *)fsp)->name.data2 == FSP_GUID_DATA2 &&
64 ((struct ffs_file_header *)fsp)->name.data3 == FSP_GUID_DATA3 &&
65 ((struct ffs_file_header *)fsp)->name.data4[0] == FSP_GUID_DATA4_0 &&
66 ((struct ffs_file_header *)fsp)->name.data4[1] == FSP_GUID_DATA4_1 &&
67 ((struct ffs_file_header *)fsp)->name.data4[2] == FSP_GUID_DATA4_2 &&
68 ((struct ffs_file_header *)fsp)->name.data4[3] == FSP_GUID_DATA4_3 &&
69 ((struct ffs_file_header *)fsp)->name.data4[4] == FSP_GUID_DATA4_4 &&
70 ((struct ffs_file_header *)fsp)->name.data4[5] == FSP_GUID_DATA4_5 &&
71 ((struct ffs_file_header *)fsp)->name.data4[6] == FSP_GUID_DATA4_6 &&
72 ((struct ffs_file_header *)fsp)->name.data4[7] == FSP_GUID_DATA4_7) {
Bin Meng2922b3e2014-12-12 21:05:28 +080073 /* Add the FFS header size to find the raw section header */
Bin Mengdb60d862014-12-17 15:50:49 +080074 fsp += sizeof(struct ffs_file_header);
Bin Meng2922b3e2014-12-12 21:05:28 +080075 } else {
76 fsp = 0;
77 }
78
79 if (fsp &&
Bin Mengdb60d862014-12-17 15:50:49 +080080 ((struct raw_section *)fsp)->type == EFI_SECTION_RAW) {
Bin Meng2922b3e2014-12-12 21:05:28 +080081 /* Add the raw section header size to find the FSP header */
Bin Mengdb60d862014-12-17 15:50:49 +080082 fsp += sizeof(struct raw_section);
Bin Meng2922b3e2014-12-12 21:05:28 +080083 } else {
84 fsp = 0;
85 }
86
Simon Glass457191e2015-01-27 22:13:37 -070087 return (struct fsp_header *)fsp;
Bin Meng2922b3e2014-12-12 21:05:28 +080088}
89
Bin Mengdb60d862014-12-17 15:50:49 +080090void fsp_continue(struct shared_data *shared_data, u32 status, void *hob_list)
Bin Meng2922b3e2014-12-12 21:05:28 +080091{
92 u32 stack_len;
93 u32 stack_base;
94 u32 stack_top;
95
Bin Meng01223e32014-12-12 21:05:29 +080096 post_code(POST_MRC);
97
Bin Mengdb60d862014-12-17 15:50:49 +080098 assert(status == 0);
Bin Meng2922b3e2014-12-12 21:05:28 +080099
100 /* Get the migrated stack in normal memory */
Bin Mengdb60d862014-12-17 15:50:49 +0800101 stack_base = (u32)fsp_get_bootloader_tmp_mem(hob_list, &stack_len);
102 assert(stack_base != 0);
Bin Meng2922b3e2014-12-12 21:05:28 +0800103 stack_top = stack_base + stack_len - sizeof(u32);
104
105 /*
106 * Old stack base is stored at the very end of the stack top,
107 * use it to calculate the migrated shared data base
108 */
Bin Mengdb60d862014-12-17 15:50:49 +0800109 shared_data = (struct shared_data *)(stack_base +
Bin Meng2922b3e2014-12-12 21:05:28 +0800110 ((u32)shared_data - *(u32 *)stack_top));
111
112 /* The boot loader main function entry */
Bin Meng01223e32014-12-12 21:05:29 +0800113 fsp_init_done(hob_list);
Bin Meng2922b3e2014-12-12 21:05:28 +0800114}
115
116void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
117{
Bin Mengdb60d862014-12-17 15:50:49 +0800118 struct shared_data shared_data;
Bin Meng2922b3e2014-12-12 21:05:28 +0800119 fsp_init_f init;
Bin Mengdb60d862014-12-17 15:50:49 +0800120 struct fsp_init_params params;
121 struct fspinit_rtbuf rt_buf;
122 struct vpd_region *fsp_vpd;
123 struct fsp_header *fsp_hdr;
124 struct fsp_init_params *params_ptr;
125 struct upd_region *fsp_upd;
Bin Meng2922b3e2014-12-12 21:05:28 +0800126
Simon Glass4661c2c2015-01-27 22:13:42 -0700127#ifdef CONFIG_DEBUG_UART
128 setup_early_uart();
129#endif
130
Simon Glass8afe6ff2015-01-27 22:13:40 -0700131 fsp_hdr = find_fsp_header();
Bin Meng2922b3e2014-12-12 21:05:28 +0800132 if (fsp_hdr == NULL) {
133 /* No valid FSP info header was found */
Bin Mengdb60d862014-12-17 15:50:49 +0800134 panic("Invalid FSP header");
Bin Meng2922b3e2014-12-12 21:05:28 +0800135 }
136
Simon Glass8afe6ff2015-01-27 22:13:40 -0700137 fsp_upd = &shared_data.fsp_upd;
Bin Mengdb60d862014-12-17 15:50:49 +0800138 memset(&rt_buf, 0, sizeof(struct fspinit_rtbuf));
Bin Meng2922b3e2014-12-12 21:05:28 +0800139
140 /* Reserve a gap in stack top */
141 rt_buf.common.stack_top = (u32 *)stack_top - 32;
142 rt_buf.common.boot_mode = boot_mode;
Simon Glass8afe6ff2015-01-27 22:13:40 -0700143 rt_buf.common.upd_data = fsp_upd;
Bin Meng2922b3e2014-12-12 21:05:28 +0800144
145 /* Get VPD region start */
Bin Mengdb60d862014-12-17 15:50:49 +0800146 fsp_vpd = (struct vpd_region *)(fsp_hdr->img_base +
Bin Meng2922b3e2014-12-12 21:05:28 +0800147 fsp_hdr->cfg_region_off);
148
Simon Glass8afe6ff2015-01-27 22:13:40 -0700149 /* Verify the VPD data region is valid */
Bin Mengdb60d862014-12-17 15:50:49 +0800150 assert((fsp_vpd->img_rev == VPD_IMAGE_REV) &&
Bin Meng2922b3e2014-12-12 21:05:28 +0800151 (fsp_vpd->sign == VPD_IMAGE_ID));
152
153 /* Copy default data from Flash */
154 memcpy(fsp_upd, (void *)(fsp_hdr->img_base + fsp_vpd->upd_offset),
Bin Mengdb60d862014-12-17 15:50:49 +0800155 sizeof(struct upd_region));
Bin Meng2922b3e2014-12-12 21:05:28 +0800156
Simon Glass8afe6ff2015-01-27 22:13:40 -0700157 /* Verify the UPD data region is valid */
Bin Mengdb60d862014-12-17 15:50:49 +0800158 assert(fsp_upd->terminator == UPD_TERMINATOR);
Bin Meng2922b3e2014-12-12 21:05:28 +0800159
160 /* Override any UPD setting if required */
161 update_fsp_upd(fsp_upd);
162
Bin Mengdb60d862014-12-17 15:50:49 +0800163 memset(&params, 0, sizeof(struct fsp_init_params));
Bin Meng2922b3e2014-12-12 21:05:28 +0800164 params.nvs_buf = nvs_buf;
Bin Mengdb60d862014-12-17 15:50:49 +0800165 params.rt_buf = (struct fspinit_rtbuf *)&rt_buf;
Bin Meng2922b3e2014-12-12 21:05:28 +0800166 params.continuation = (fsp_continuation_f)asm_continuation;
167
168 init = (fsp_init_f)(fsp_hdr->img_base + fsp_hdr->fsp_init);
169 params_ptr = &params;
170
171 shared_data.fsp_hdr = fsp_hdr;
172 shared_data.stack_top = (u32 *)stack_top;
173
Bin Meng01223e32014-12-12 21:05:29 +0800174 post_code(POST_PRE_MRC);
175
Bin Meng2922b3e2014-12-12 21:05:28 +0800176 /*
177 * Use ASM code to ensure the register value in EAX & ECX
178 * will be passed into BlContinuationFunc
179 */
180 asm volatile (
181 "pushl %0;"
182 "call *%%eax;"
183 ".global asm_continuation;"
184 "asm_continuation:;"
Bin Meng01223e32014-12-12 21:05:29 +0800185 "movl %%ebx, %%eax;" /* shared_data */
186 "movl 4(%%esp), %%edx;" /* status */
187 "movl 8(%%esp), %%ecx;" /* hob_list */
Bin Meng2922b3e2014-12-12 21:05:28 +0800188 "jmp fsp_continue;"
Bin Meng01223e32014-12-12 21:05:29 +0800189 : : "m"(params_ptr), "a"(init), "b"(&shared_data)
Bin Meng2922b3e2014-12-12 21:05:28 +0800190 );
191
192 /*
193 * Should never get here.
Bin Mengdb60d862014-12-17 15:50:49 +0800194 * Control will continue from fsp_continue.
Bin Meng2922b3e2014-12-12 21:05:28 +0800195 * This line below is to prevent the compiler from optimizing
196 * structure intialization.
Bin Mengdb60d862014-12-17 15:50:49 +0800197 *
198 * DO NOT REMOVE!
Bin Meng2922b3e2014-12-12 21:05:28 +0800199 */
200 init(&params);
Bin Meng2922b3e2014-12-12 21:05:28 +0800201}
202
Bin Mengdb60d862014-12-17 15:50:49 +0800203u32 fsp_notify(struct fsp_header *fsp_hdr, u32 phase)
Bin Meng2922b3e2014-12-12 21:05:28 +0800204{
205 fsp_notify_f notify;
Bin Mengdb60d862014-12-17 15:50:49 +0800206 struct fsp_notify_params params;
207 struct fsp_notify_params *params_ptr;
Bin Meng2922b3e2014-12-12 21:05:28 +0800208 u32 status;
209
210 if (!fsp_hdr)
Bin Mengdb60d862014-12-17 15:50:49 +0800211 fsp_hdr = (struct fsp_header *)find_fsp_header();
Bin Meng2922b3e2014-12-12 21:05:28 +0800212
213 if (fsp_hdr == NULL) {
214 /* No valid FSP info header */
Bin Mengdb60d862014-12-17 15:50:49 +0800215 panic("Invalid FSP header");
Bin Meng2922b3e2014-12-12 21:05:28 +0800216 }
217
218 notify = (fsp_notify_f)(fsp_hdr->img_base + fsp_hdr->fsp_notify);
219 params.phase = phase;
Bin Meng01223e32014-12-12 21:05:29 +0800220 params_ptr = &params;
221
222 /*
223 * Use ASM code to ensure correct parameter is on the stack for
224 * FspNotify as U-Boot is using different ABI from FSP
225 */
226 asm volatile (
227 "pushl %1;" /* push notify phase */
228 "call *%%eax;" /* call FspNotify */
229 "addl $4, %%esp;" /* clean up the stack */
230 : "=a"(status) : "m"(params_ptr), "a"(notify), "m"(*params_ptr)
231 );
Bin Meng2922b3e2014-12-12 21:05:28 +0800232
233 return status;
234}
235
Bin Mengdb60d862014-12-17 15:50:49 +0800236u32 fsp_get_usable_lowmem_top(const void *hob_list)
Bin Meng2922b3e2014-12-12 21:05:28 +0800237{
Bin Meng2b215982014-12-30 16:02:05 +0800238 const struct hob_header *hdr;
239 struct hob_res_desc *res_desc;
Bin Meng2922b3e2014-12-12 21:05:28 +0800240 phys_addr_t phys_start;
241 u32 top;
242
243 /* Get the HOB list for processing */
Bin Meng2b215982014-12-30 16:02:05 +0800244 hdr = hob_list;
Bin Meng2922b3e2014-12-12 21:05:28 +0800245
246 /* * Collect memory ranges */
Bin Mengdb60d862014-12-17 15:50:49 +0800247 top = FSP_LOWMEM_BASE;
Bin Meng2b215982014-12-30 16:02:05 +0800248 while (!end_of_hob(hdr)) {
Bin Meng2f848bc2015-01-06 14:04:36 +0800249 if (hdr->type == HOB_TYPE_RES_DESC) {
Bin Meng2b215982014-12-30 16:02:05 +0800250 res_desc = (struct hob_res_desc *)hdr;
251 if (res_desc->type == RES_SYS_MEM) {
252 phys_start = res_desc->phys_start;
Bin Meng2922b3e2014-12-12 21:05:28 +0800253 /* Need memory above 1MB to be collected here */
Bin Mengdb60d862014-12-17 15:50:49 +0800254 if (phys_start >= FSP_LOWMEM_BASE &&
255 phys_start < (phys_addr_t)FSP_HIGHMEM_BASE)
Bin Meng2b215982014-12-30 16:02:05 +0800256 top += (u32)(res_desc->len);
Bin Meng2922b3e2014-12-12 21:05:28 +0800257 }
258 }
Bin Meng2b215982014-12-30 16:02:05 +0800259 hdr = get_next_hob(hdr);
Bin Meng2922b3e2014-12-12 21:05:28 +0800260 }
261
262 return top;
263}
264
Bin Mengdb60d862014-12-17 15:50:49 +0800265u64 fsp_get_usable_highmem_top(const void *hob_list)
Bin Meng2922b3e2014-12-12 21:05:28 +0800266{
Bin Meng2b215982014-12-30 16:02:05 +0800267 const struct hob_header *hdr;
268 struct hob_res_desc *res_desc;
Bin Meng2922b3e2014-12-12 21:05:28 +0800269 phys_addr_t phys_start;
270 u64 top;
271
272 /* Get the HOB list for processing */
Bin Meng2b215982014-12-30 16:02:05 +0800273 hdr = hob_list;
Bin Meng2922b3e2014-12-12 21:05:28 +0800274
275 /* Collect memory ranges */
Bin Mengdb60d862014-12-17 15:50:49 +0800276 top = FSP_HIGHMEM_BASE;
Bin Meng2b215982014-12-30 16:02:05 +0800277 while (!end_of_hob(hdr)) {
Bin Meng2f848bc2015-01-06 14:04:36 +0800278 if (hdr->type == HOB_TYPE_RES_DESC) {
Bin Meng2b215982014-12-30 16:02:05 +0800279 res_desc = (struct hob_res_desc *)hdr;
280 if (res_desc->type == RES_SYS_MEM) {
281 phys_start = res_desc->phys_start;
Andrew Bradford17194d52015-05-22 15:11:23 -0400282 /* Need memory above 4GB to be collected here */
Bin Mengdb60d862014-12-17 15:50:49 +0800283 if (phys_start >= (phys_addr_t)FSP_HIGHMEM_BASE)
Bin Meng2b215982014-12-30 16:02:05 +0800284 top += (u32)(res_desc->len);
Bin Meng2922b3e2014-12-12 21:05:28 +0800285 }
286 }
Bin Meng2b215982014-12-30 16:02:05 +0800287 hdr = get_next_hob(hdr);
Bin Meng2922b3e2014-12-12 21:05:28 +0800288 }
289
290 return top;
291}
292
Bin Mengdb60d862014-12-17 15:50:49 +0800293u64 fsp_get_reserved_mem_from_guid(const void *hob_list, u64 *len,
294 struct efi_guid *guid)
Bin Meng2922b3e2014-12-12 21:05:28 +0800295{
Bin Meng2b215982014-12-30 16:02:05 +0800296 const struct hob_header *hdr;
297 struct hob_res_desc *res_desc;
Bin Meng2922b3e2014-12-12 21:05:28 +0800298
299 /* Get the HOB list for processing */
Bin Meng2b215982014-12-30 16:02:05 +0800300 hdr = hob_list;
Bin Meng2922b3e2014-12-12 21:05:28 +0800301
302 /* Collect memory ranges */
Bin Meng2b215982014-12-30 16:02:05 +0800303 while (!end_of_hob(hdr)) {
Bin Meng2f848bc2015-01-06 14:04:36 +0800304 if (hdr->type == HOB_TYPE_RES_DESC) {
Bin Meng2b215982014-12-30 16:02:05 +0800305 res_desc = (struct hob_res_desc *)hdr;
306 if (res_desc->type == RES_MEM_RESERVED) {
307 if (compare_guid(&res_desc->owner, guid)) {
Bin Meng2922b3e2014-12-12 21:05:28 +0800308 if (len)
Bin Meng2b215982014-12-30 16:02:05 +0800309 *len = (u32)(res_desc->len);
Bin Meng2922b3e2014-12-12 21:05:28 +0800310
Bin Meng2b215982014-12-30 16:02:05 +0800311 return (u64)(res_desc->phys_start);
Bin Meng2922b3e2014-12-12 21:05:28 +0800312 }
313 }
314 }
Bin Meng2b215982014-12-30 16:02:05 +0800315 hdr = get_next_hob(hdr);
Bin Meng2922b3e2014-12-12 21:05:28 +0800316 }
317
318 return 0;
319}
320
Bin Mengdb60d862014-12-17 15:50:49 +0800321u32 fsp_get_fsp_reserved_mem(const void *hob_list, u32 *len)
Bin Meng2922b3e2014-12-12 21:05:28 +0800322{
Bin Mengdb60d862014-12-17 15:50:49 +0800323 const struct efi_guid guid = FSP_HOB_RESOURCE_OWNER_FSP_GUID;
Bin Meng2922b3e2014-12-12 21:05:28 +0800324 u64 length;
325 u32 base;
326
Bin Mengdb60d862014-12-17 15:50:49 +0800327 base = (u32)fsp_get_reserved_mem_from_guid(hob_list,
328 &length, (struct efi_guid *)&guid);
Bin Meng2922b3e2014-12-12 21:05:28 +0800329 if ((len != 0) && (base != 0))
330 *len = (u32)length;
331
332 return base;
333}
334
Bin Mengdb60d862014-12-17 15:50:49 +0800335u32 fsp_get_tseg_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_TSEG_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 Meng2f848bc2015-01-06 14:04:36 +0800349const struct hob_header *fsp_get_next_hob(uint type, const void *hob_list)
Bin Meng2922b3e2014-12-12 21:05:28 +0800350{
Bin Meng2b215982014-12-30 16:02:05 +0800351 const struct hob_header *hdr;
Bin Meng2922b3e2014-12-12 21:05:28 +0800352
Bin Meng2b215982014-12-30 16:02:05 +0800353 hdr = hob_list;
Bin Meng2922b3e2014-12-12 21:05:28 +0800354
355 /* Parse the HOB list until end of list or matching type is found */
Bin Meng2b215982014-12-30 16:02:05 +0800356 while (!end_of_hob(hdr)) {
Bin Meng2f848bc2015-01-06 14:04:36 +0800357 if (hdr->type == type)
Bin Meng2b215982014-12-30 16:02:05 +0800358 return hdr;
Bin Meng2922b3e2014-12-12 21:05:28 +0800359
Bin Meng2b215982014-12-30 16:02:05 +0800360 hdr = get_next_hob(hdr);
Bin Meng2922b3e2014-12-12 21:05:28 +0800361 }
362
363 return NULL;
364}
365
Bin Meng2b215982014-12-30 16:02:05 +0800366const struct hob_header *fsp_get_next_guid_hob(const struct efi_guid *guid,
367 const void *hob_list)
Bin Meng2922b3e2014-12-12 21:05:28 +0800368{
Bin Meng2b215982014-12-30 16:02:05 +0800369 const struct hob_header *hdr;
370 struct hob_guid *guid_hob;
Bin Meng2922b3e2014-12-12 21:05:28 +0800371
Bin Meng2b215982014-12-30 16:02:05 +0800372 hdr = hob_list;
373 while ((hdr = fsp_get_next_hob(HOB_TYPE_GUID_EXT,
374 hdr)) != NULL) {
375 guid_hob = (struct hob_guid *)hdr;
376 if (compare_guid(guid, &(guid_hob->name)))
Bin Meng2922b3e2014-12-12 21:05:28 +0800377 break;
Bin Meng2b215982014-12-30 16:02:05 +0800378 hdr = get_next_hob(hdr);
Bin Meng2922b3e2014-12-12 21:05:28 +0800379 }
380
Bin Meng2b215982014-12-30 16:02:05 +0800381 return hdr;
Bin Meng2922b3e2014-12-12 21:05:28 +0800382}
383
Bin Mengdb60d862014-12-17 15:50:49 +0800384void *fsp_get_guid_hob_data(const void *hob_list, u32 *len,
385 struct efi_guid *guid)
Bin Meng2922b3e2014-12-12 21:05:28 +0800386{
Bin Meng2b215982014-12-30 16:02:05 +0800387 const struct hob_header *guid_hob;
Bin Meng2922b3e2014-12-12 21:05:28 +0800388
Bin Mengdb60d862014-12-17 15:50:49 +0800389 guid_hob = fsp_get_next_guid_hob(guid, hob_list);
Bin Meng2922b3e2014-12-12 21:05:28 +0800390 if (guid_hob == NULL) {
391 return NULL;
392 } else {
393 if (len)
Bin Mengdb60d862014-12-17 15:50:49 +0800394 *len = get_guid_hob_data_size(guid_hob);
Bin Meng2922b3e2014-12-12 21:05:28 +0800395
Bin Mengdb60d862014-12-17 15:50:49 +0800396 return get_guid_hob_data(guid_hob);
Bin Meng2922b3e2014-12-12 21:05:28 +0800397 }
398}
399
Bin Mengdb60d862014-12-17 15:50:49 +0800400void *fsp_get_nvs_data(const void *hob_list, u32 *len)
Bin Meng2922b3e2014-12-12 21:05:28 +0800401{
Bin Mengdb60d862014-12-17 15:50:49 +0800402 const struct efi_guid guid = FSP_NON_VOLATILE_STORAGE_HOB_GUID;
Bin Meng2922b3e2014-12-12 21:05:28 +0800403
Bin Mengdb60d862014-12-17 15:50:49 +0800404 return fsp_get_guid_hob_data(hob_list, len, (struct efi_guid *)&guid);
Bin Meng2922b3e2014-12-12 21:05:28 +0800405}
406
Bin Mengdb60d862014-12-17 15:50:49 +0800407void *fsp_get_bootloader_tmp_mem(const void *hob_list, u32 *len)
Bin Meng2922b3e2014-12-12 21:05:28 +0800408{
Bin Mengdb60d862014-12-17 15:50:49 +0800409 const struct efi_guid guid = FSP_BOOTLOADER_TEMP_MEM_HOB_GUID;
Bin Meng2922b3e2014-12-12 21:05:28 +0800410
Bin Mengdb60d862014-12-17 15:50:49 +0800411 return fsp_get_guid_hob_data(hob_list, len, (struct efi_guid *)&guid);
Bin Meng2922b3e2014-12-12 21:05:28 +0800412}