blob: 79c348ac5326256a708cbd1a8dfed7ada033314f [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);
49/*
Aaron Durbin22ea0072015-08-05 10:17:33 -050050 * Relocate FSP entire binary into ram. Returns < 0 on error, 0 on success.
51 * The FSP source is pointed to by region_device and the relocation information
52 * is encoded in a struct prog with its entry point set to the FSP info header.
Lee Leahyb5ad8272015-04-20 15:29:16 -070053 */
Aaron Durbin22ea0072015-08-05 10:17:33 -050054int fsp_relocate(struct prog *fsp_relocd, const struct region_device *fsp_src);
Lee Leahy3dad4892015-05-05 11:14:02 -070055
Aaron Durbina5be7fa2015-09-10 22:52:27 -050056/*
57 * Relocate FSP held within buffer defined by size to new_addr. Returns < 0
58 * on error, offset to FSP_INFO_HEADER on success.
59 */
60ssize_t fsp1_1_relocate(uintptr_t new_addr, void *fsp, size_t size);
61
Lee Leahy3dad4892015-05-05 11:14:02 -070062/* Additional HOB types not included in the FSP:
63 * #define EFI_HOB_TYPE_HANDOFF 0x0001
64 * #define EFI_HOB_TYPE_MEMORY_ALLOCATION 0x0002
65 * #define EFI_HOB_TYPE_RESOURCE_DESCRIPTOR 0x0003
66 * #define EFI_HOB_TYPE_GUID_EXTENSION 0x0004
67 * #define EFI_HOB_TYPE_FV 0x0005
68 * #define EFI_HOB_TYPE_CPU 0x0006
69 * #define EFI_HOB_TYPE_MEMORY_POOL 0x0007
70 * #define EFI_HOB_TYPE_CV 0x0008
71 * #define EFI_HOB_TYPE_UNUSED 0xFFFE
72 * #define EFI_HOB_TYPE_END_OF_HOB_LIST 0xffff
73 */
74#define EFI_HOB_TYPE_HANDOFF 0x0001
75#define EFI_HOB_TYPE_MEMORY_POOL 0x0007
76
Lee Leahy3dad4892015-05-05 11:14:02 -070077/* The offset in bytes from the start of the info structure */
Lee Leahyb5ad8272015-04-20 15:29:16 -070078#define FSP_IMAGE_SIG_LOC 0
79#define FSP_IMAGE_ID_LOC 16
80#define FSP_IMAGE_BASE_LOC 28
Lee Leahy4a8c19c2015-06-16 14:33:30 -070081#define FSP_IMAGE_ATTRIBUTE_LOC 32
82#define GRAPHICS_SUPPORT_BIT (1 << 0)
Lee Leahy3dad4892015-05-05 11:14:02 -070083
Lee Leahy3dad4892015-05-05 11:14:02 -070084#define ERROR_NO_FV_SIG 1
Lee Leahyb5ad8272015-04-20 15:29:16 -070085#define ERROR_NO_FFS_GUID 2
Lee Leahy3dad4892015-05-05 11:14:02 -070086#define ERROR_NO_INFO_HEADER 3
87#define ERROR_IMAGEBASE_MISMATCH 4
Lee Leahyb5ad8272015-04-20 15:29:16 -070088#define ERROR_INFO_HEAD_SIG_MISMATCH 5
Lee Leahy3dad4892015-05-05 11:14:02 -070089#define ERROR_FSP_SIG_MISMATCH 6
90
Lee Leahyb5ad8272015-04-20 15:29:16 -070091#if ENV_RAMSTAGE
Lee Leahy3dad4892015-05-05 11:14:02 -070092extern void *FspHobListPtr;
93#endif
94
Aaron Durbin789f2b62015-09-09 17:05:06 -050095/* TODO: Remove the EFI types and decorations from coreboot implementations. */
96VOID * EFIAPI get_hob_list(VOID);
97VOID * EFIAPI get_next_hob(UINT16 type, CONST VOID *hob_start);
98VOID * EFIAPI get_first_hob(UINT16 type);
99VOID * EFIAPI get_next_guid_hob(CONST EFI_GUID * guid, CONST VOID *hob_start);
100VOID * EFIAPI get_first_guid_hob(CONST EFI_GUID * guid);
101
102#endif /* FSP1_1_UTIL_H */