Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2013-2014 Sage Electronic Engineering, LLC. |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 5 | * Copyright (C) 2015 Intel Corp. |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 6 | * |
| 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 Georgi | b890a12 | 2015-03-26 15:17:45 +0100 | [diff] [blame] | 18 | * Foundation, Inc. |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 19 | */ |
| 20 | |
Aaron Durbin | 789f2b6 | 2015-09-09 17:05:06 -0500 | [diff] [blame] | 21 | #ifndef FSP1_1_UTIL_H |
| 22 | #define FSP1_1_UTIL_H |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 23 | |
Aaron Durbin | 789f2b6 | 2015-09-09 17:05:06 -0500 | [diff] [blame] | 24 | #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 Durbin | 22ea007 | 2015-08-05 10:17:33 -0500 | [diff] [blame] | 28 | #include <program_loading.h> |
Aaron Durbin | dc9f5cd | 2015-09-08 13:34:43 -0500 | [diff] [blame] | 29 | #include <commonlib/region.h> |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 30 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 31 | /* find_fsp() should only be called from assembly code. */ |
Lee Leahy | a887492 | 2015-08-26 14:58:29 -0700 | [diff] [blame] | 32 | FSP_INFO_HEADER *find_fsp(uintptr_t fsp_base_address); |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 33 | /* Set FSP's runtime information. */ |
| 34 | void fsp_set_runtime(FSP_INFO_HEADER *fih, void *hob_list); |
| 35 | /* Use a new FSP_INFO_HEADER at runtime. */ |
| 36 | void fsp_update_fih(FSP_INFO_HEADER *fih); |
| 37 | /* fsp_get_fih() is only valid after calling fsp_set_runtime(). */ |
| 38 | FSP_INFO_HEADER *fsp_get_fih(void); |
| 39 | /* fsp_get_hob_list() is only valid after calling fsp_set_runtime(). */ |
| 40 | void *fsp_get_hob_list(void); |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 41 | void fsp_early_init(FSP_INFO_HEADER *fsp_info); |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 42 | void fsp_notify(u32 phase); |
| 43 | void print_hob_type_structure(u16 hob_type, void *hob_list_ptr); |
| 44 | void print_fsp_info(FSP_INFO_HEADER *fsp_header); |
| 45 | void *get_next_type_guid_hob(UINT16 type, const EFI_GUID *guid, |
| 46 | const void *hob_start); |
| 47 | void *get_next_resource_hob(const EFI_GUID *guid, const void *hob_start); |
| 48 | void *get_first_resource_hob(const EFI_GUID *guid); |
Lee Leahy | 66208bd | 2015-10-15 16:17:58 -0700 | [diff] [blame^] | 49 | void fsp_display_upd_value(const char *name, uint32_t size, uint64_t old, |
Lee Leahy | 94b856e | 2015-10-15 12:07:03 -0700 | [diff] [blame] | 50 | uint64_t new); |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 51 | /* |
Aaron Durbin | 22ea007 | 2015-08-05 10:17:33 -0500 | [diff] [blame] | 52 | * 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 Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 55 | */ |
Aaron Durbin | 22ea007 | 2015-08-05 10:17:33 -0500 | [diff] [blame] | 56 | int fsp_relocate(struct prog *fsp_relocd, const struct region_device *fsp_src); |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 57 | |
| 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 Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 73 | /* The offset in bytes from the start of the info structure */ |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 74 | #define FSP_IMAGE_SIG_LOC 0 |
| 75 | #define FSP_IMAGE_ID_LOC 16 |
| 76 | #define FSP_IMAGE_BASE_LOC 28 |
Lee Leahy | 4a8c19c | 2015-06-16 14:33:30 -0700 | [diff] [blame] | 77 | #define FSP_IMAGE_ATTRIBUTE_LOC 32 |
| 78 | #define GRAPHICS_SUPPORT_BIT (1 << 0) |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 79 | |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 80 | #define ERROR_NO_FV_SIG 1 |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 81 | #define ERROR_NO_FFS_GUID 2 |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 82 | #define ERROR_NO_INFO_HEADER 3 |
| 83 | #define ERROR_IMAGEBASE_MISMATCH 4 |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 84 | #define ERROR_INFO_HEAD_SIG_MISMATCH 5 |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 85 | #define ERROR_FSP_SIG_MISMATCH 6 |
| 86 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 87 | #if ENV_RAMSTAGE |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 88 | extern void *FspHobListPtr; |
| 89 | #endif |
| 90 | |
Aaron Durbin | 789f2b6 | 2015-09-09 17:05:06 -0500 | [diff] [blame] | 91 | /* TODO: Remove the EFI types and decorations from coreboot implementations. */ |
| 92 | VOID * EFIAPI get_hob_list(VOID); |
| 93 | VOID * EFIAPI get_next_hob(UINT16 type, CONST VOID *hob_start); |
| 94 | VOID * EFIAPI get_first_hob(UINT16 type); |
| 95 | VOID * EFIAPI get_next_guid_hob(CONST EFI_GUID * guid, CONST VOID *hob_start); |
| 96 | VOID * EFIAPI get_first_guid_hob(CONST EFI_GUID * guid); |
| 97 | |
| 98 | #endif /* FSP1_1_UTIL_H */ |