blob: ac2e561a828b531840f97d124365cc03e73b1d23 [file] [log] [blame]
Lee Leahy3dad4892015-05-05 11:14:02 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013-2014 Sage Electronic Engineering, LLC.
Lee Leahyb5ad8272015-04-20 15:29:16 -07005 * Copyright (C) 2015 Intel Corp.
Lee Leahy3dad4892015-05-05 11:14:02 -07006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
Patrick Georgib890a122015-03-26 15:17:45 +010018 * Foundation, Inc.
Lee Leahy3dad4892015-05-05 11:14:02 -070019 */
20
Aaron Durbin789f2b62015-09-09 17:05:06 -050021#ifndef FSP1_1_UTIL_H
22#define FSP1_1_UTIL_H
Lee Leahy3dad4892015-05-05 11:14:02 -070023
Aaron Durbin789f2b62015-09-09 17:05:06 -050024#include <fsp/api.h>
25/* Current users expect to get the SoC's FSP definitions by including util.h. */
26#include <fsp/soc_binding.h>
27#include <fsp/gop.h>
Aaron Durbin22ea0072015-08-05 10:17:33 -050028#include <program_loading.h>
Aaron Durbindc9f5cd2015-09-08 13:34:43 -050029#include <commonlib/region.h>
Lee Leahyb5ad8272015-04-20 15:29:16 -070030
Lee Leahyb5ad8272015-04-20 15:29:16 -070031/* find_fsp() should only be called from assembly code. */
Lee Leahya8874922015-08-26 14:58:29 -070032FSP_INFO_HEADER *find_fsp(uintptr_t fsp_base_address);
Lee Leahyb5ad8272015-04-20 15:29:16 -070033/* Set FSP's runtime information. */
34void fsp_set_runtime(FSP_INFO_HEADER *fih, void *hob_list);
35/* Use a new FSP_INFO_HEADER at runtime. */
36void fsp_update_fih(FSP_INFO_HEADER *fih);
37/* fsp_get_fih() is only valid after calling fsp_set_runtime(). */
38FSP_INFO_HEADER *fsp_get_fih(void);
39/* fsp_get_hob_list() is only valid after calling fsp_set_runtime(). */
40void *fsp_get_hob_list(void);
Lee Leahy3dad4892015-05-05 11:14:02 -070041void fsp_early_init(FSP_INFO_HEADER *fsp_info);
Lee Leahyb5ad8272015-04-20 15:29:16 -070042void fsp_notify(u32 phase);
43void print_hob_type_structure(u16 hob_type, void *hob_list_ptr);
44void print_fsp_info(FSP_INFO_HEADER *fsp_header);
45void *get_next_type_guid_hob(UINT16 type, const EFI_GUID *guid,
46 const void *hob_start);
47void *get_next_resource_hob(const EFI_GUID *guid, const void *hob_start);
48void *get_first_resource_hob(const EFI_GUID *guid);
Lee Leahy66208bd2015-10-15 16:17:58 -070049void fsp_display_upd_value(const char *name, uint32_t size, uint64_t old,
Lee Leahy94b856e2015-10-15 12:07:03 -070050 uint64_t new);
Lee Leahyb5ad8272015-04-20 15:29:16 -070051/*
Aaron Durbin22ea0072015-08-05 10:17:33 -050052 * Relocate FSP entire binary into ram. Returns < 0 on error, 0 on success.
53 * The FSP source is pointed to by region_device and the relocation information
54 * is encoded in a struct prog with its entry point set to the FSP info header.
Lee Leahyb5ad8272015-04-20 15:29:16 -070055 */
Aaron Durbin22ea0072015-08-05 10:17:33 -050056int fsp_relocate(struct prog *fsp_relocd, const struct region_device *fsp_src);
Lee Leahy3dad4892015-05-05 11:14:02 -070057
58/* Additional HOB types not included in the FSP:
59 * #define EFI_HOB_TYPE_HANDOFF 0x0001
60 * #define EFI_HOB_TYPE_MEMORY_ALLOCATION 0x0002
61 * #define EFI_HOB_TYPE_RESOURCE_DESCRIPTOR 0x0003
62 * #define EFI_HOB_TYPE_GUID_EXTENSION 0x0004
63 * #define EFI_HOB_TYPE_FV 0x0005
64 * #define EFI_HOB_TYPE_CPU 0x0006
65 * #define EFI_HOB_TYPE_MEMORY_POOL 0x0007
66 * #define EFI_HOB_TYPE_CV 0x0008
67 * #define EFI_HOB_TYPE_UNUSED 0xFFFE
68 * #define EFI_HOB_TYPE_END_OF_HOB_LIST 0xffff
69 */
70#define EFI_HOB_TYPE_HANDOFF 0x0001
71#define EFI_HOB_TYPE_MEMORY_POOL 0x0007
72
Lee Leahy3dad4892015-05-05 11:14:02 -070073/* The offset in bytes from the start of the info structure */
Lee Leahyb5ad8272015-04-20 15:29:16 -070074#define FSP_IMAGE_SIG_LOC 0
75#define FSP_IMAGE_ID_LOC 16
76#define FSP_IMAGE_BASE_LOC 28
Lee Leahy4a8c19c2015-06-16 14:33:30 -070077#define FSP_IMAGE_ATTRIBUTE_LOC 32
78#define GRAPHICS_SUPPORT_BIT (1 << 0)
Lee Leahy3dad4892015-05-05 11:14:02 -070079
Lee Leahy3dad4892015-05-05 11:14:02 -070080#define ERROR_NO_FV_SIG 1
Lee Leahyb5ad8272015-04-20 15:29:16 -070081#define ERROR_NO_FFS_GUID 2
Lee Leahy3dad4892015-05-05 11:14:02 -070082#define ERROR_NO_INFO_HEADER 3
83#define ERROR_IMAGEBASE_MISMATCH 4
Lee Leahyb5ad8272015-04-20 15:29:16 -070084#define ERROR_INFO_HEAD_SIG_MISMATCH 5
Lee Leahy3dad4892015-05-05 11:14:02 -070085#define ERROR_FSP_SIG_MISMATCH 6
86
Lee Leahyb5ad8272015-04-20 15:29:16 -070087#if ENV_RAMSTAGE
Lee Leahy3dad4892015-05-05 11:14:02 -070088extern void *FspHobListPtr;
89#endif
90
Aaron Durbin789f2b62015-09-09 17:05:06 -050091/* TODO: Remove the EFI types and decorations from coreboot implementations. */
92VOID * EFIAPI get_hob_list(VOID);
93VOID * EFIAPI get_next_hob(UINT16 type, CONST VOID *hob_start);
94VOID * EFIAPI get_first_hob(UINT16 type);
95VOID * EFIAPI get_next_guid_hob(CONST EFI_GUID * guid, CONST VOID *hob_start);
96VOID * EFIAPI get_first_guid_hob(CONST EFI_GUID * guid);
97
98#endif /* FSP1_1_UTIL_H */