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); |
| 49 | /* |
Aaron Durbin | 22ea007 | 2015-08-05 10:17:33 -0500 | [diff] [blame] | 50 | * 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 Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 53 | */ |
Aaron Durbin | 22ea007 | 2015-08-05 10:17:33 -0500 | [diff] [blame] | 54 | 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] | 55 | |
Aaron Durbin | a5be7fa | 2015-09-10 22:52:27 -0500 | [diff] [blame] | 56 | /* |
| 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 | */ |
| 60 | ssize_t fsp1_1_relocate(uintptr_t new_addr, void *fsp, size_t size); |
| 61 | |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 62 | /* 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 Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 77 | /* The offset in bytes from the start of the info structure */ |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 78 | #define FSP_IMAGE_SIG_LOC 0 |
| 79 | #define FSP_IMAGE_ID_LOC 16 |
| 80 | #define FSP_IMAGE_BASE_LOC 28 |
Lee Leahy | 4a8c19c | 2015-06-16 14:33:30 -0700 | [diff] [blame] | 81 | #define FSP_IMAGE_ATTRIBUTE_LOC 32 |
| 82 | #define GRAPHICS_SUPPORT_BIT (1 << 0) |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 83 | |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 84 | #define ERROR_NO_FV_SIG 1 |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 85 | #define ERROR_NO_FFS_GUID 2 |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 86 | #define ERROR_NO_INFO_HEADER 3 |
| 87 | #define ERROR_IMAGEBASE_MISMATCH 4 |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 88 | #define ERROR_INFO_HEAD_SIG_MISMATCH 5 |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 89 | #define ERROR_FSP_SIG_MISMATCH 6 |
| 90 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 91 | #if ENV_RAMSTAGE |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 92 | extern void *FspHobListPtr; |
| 93 | #endif |
| 94 | |
Aaron Durbin | 789f2b6 | 2015-09-09 17:05:06 -0500 | [diff] [blame] | 95 | /* TODO: Remove the EFI types and decorations from coreboot implementations. */ |
| 96 | VOID * EFIAPI get_hob_list(VOID); |
| 97 | VOID * EFIAPI get_next_hob(UINT16 type, CONST VOID *hob_start); |
| 98 | VOID * EFIAPI get_first_hob(UINT16 type); |
| 99 | VOID * EFIAPI get_next_guid_hob(CONST EFI_GUID * guid, CONST VOID *hob_start); |
| 100 | VOID * EFIAPI get_first_guid_hob(CONST EFI_GUID * guid); |
| 101 | |
| 102 | #endif /* FSP1_1_UTIL_H */ |