Martin Roth | a642716 | 2014-04-25 14:12:13 -0600 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2013-2014 Sage Electronic Engineering, LLC. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Martin Roth | a642716 | 2014-04-25 14:12:13 -0600 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #ifndef FSP_UTIL_H |
| 17 | #define FSP_UTIL_H |
| 18 | |
| 19 | #include <chipset_fsp_util.h> |
Martin Roth | 09dd70e | 2014-11-16 17:32:56 -0700 | [diff] [blame] | 20 | #include "fsp_values.h" |
Martin Roth | a642716 | 2014-04-25 14:12:13 -0600 | [diff] [blame] | 21 | |
| 22 | #if IS_ENABLED(CONFIG_ENABLE_MRC_CACHE) |
| 23 | int save_mrc_data(void *hob_start); |
| 24 | void * find_and_set_fastboot_cache(void); |
| 25 | #endif |
| 26 | |
| 27 | volatile u8 * find_fsp (void); |
| 28 | void fsp_early_init(FSP_INFO_HEADER *fsp_info); |
| 29 | void FspNotify(u32 Phase); |
| 30 | void FspNotifyReturnPoint(EFI_STATUS Status, VOID *HobListPtr); |
Martin Roth | a642716 | 2014-04-25 14:12:13 -0600 | [diff] [blame] | 31 | void romstage_fsp_rt_buffer_callback(FSP_INIT_RT_BUFFER *FspRtBuffer); |
| 32 | void print_fsp_info(void); |
Martin Roth | a642716 | 2014-04-25 14:12:13 -0600 | [diff] [blame] | 33 | void chipset_fsp_early_init(FSP_INIT_PARAMS *FspInitParams, |
| 34 | FSP_INFO_HEADER *fsp_ptr); |
| 35 | void ChipsetFspReturnPoint(EFI_STATUS Status, VOID *HobListPtr); |
Martin Roth | 5fc32bf | 2015-01-11 14:11:55 -0700 | [diff] [blame] | 36 | void * find_saved_temp_mem(void *hob_list_ptr); |
Martin Roth | 2213843 | 2015-01-30 20:56:05 -0700 | [diff] [blame] | 37 | void * find_fsp_reserved_mem(void *hob_list_ptr); |
Martin Roth | a642716 | 2014-04-25 14:12:13 -0600 | [diff] [blame] | 38 | |
Martin Roth | fc34750 | 2015-01-03 07:28:39 -0700 | [diff] [blame] | 39 | /* functions in hob.c */ |
| 40 | void print_hob_mem_attributes(void *Hobptr); |
| 41 | void print_hob_type_structure(u16 Hobtype, void *Hoblistptr); |
| 42 | void print_hob_resource_attributes(void *Hobptr); |
Martin Roth | 7b132de | 2015-01-03 17:18:58 -0700 | [diff] [blame] | 43 | void print_guid_type_attributes(void *Hobptr); |
Martin Roth | fc34750 | 2015-01-03 07:28:39 -0700 | [diff] [blame] | 44 | const char * get_hob_type_string(void *Hobptr); |
Martin Roth | 7b132de | 2015-01-03 17:18:58 -0700 | [diff] [blame] | 45 | void * find_hob_by_guid(void *Hoblistptr, EFI_GUID *guid1); |
| 46 | uint8_t guids_are_equal(EFI_GUID *guid1, EFI_GUID *guid2); |
| 47 | void printguid(EFI_GUID *guid); |
Martin Roth | fc34750 | 2015-01-03 07:28:39 -0700 | [diff] [blame] | 48 | |
Martin Roth | a642716 | 2014-04-25 14:12:13 -0600 | [diff] [blame] | 49 | /* Additional HOB types not included in the FSP: |
| 50 | * #define EFI_HOB_TYPE_HANDOFF 0x0001 |
| 51 | * #define EFI_HOB_TYPE_MEMORY_ALLOCATION 0x0002 |
| 52 | * #define EFI_HOB_TYPE_RESOURCE_DESCRIPTOR 0x0003 |
| 53 | * #define EFI_HOB_TYPE_GUID_EXTENSION 0x0004 |
| 54 | * #define EFI_HOB_TYPE_FV 0x0005 |
| 55 | * #define EFI_HOB_TYPE_CPU 0x0006 |
| 56 | * #define EFI_HOB_TYPE_MEMORY_POOL 0x0007 |
| 57 | * #define EFI_HOB_TYPE_CV 0x0008 |
| 58 | * #define EFI_HOB_TYPE_UNUSED 0xFFFE |
| 59 | * #define EFI_HOB_TYPE_END_OF_HOB_LIST 0xffff |
| 60 | */ |
| 61 | #define EFI_HOB_TYPE_HANDOFF 0x0001 |
| 62 | #define EFI_HOB_TYPE_MEMORY_POOL 0x0007 |
| 63 | |
| 64 | #if IS_ENABLED(CONFIG_ENABLE_MRC_CACHE) |
| 65 | #define MRC_DATA_ALIGN 0x1000 |
| 66 | #define MRC_DATA_SIGNATURE (('M'<<0)|('R'<<8)|('C'<<16)|('D'<<24)) |
| 67 | |
| 68 | struct mrc_data_container { |
| 69 | u32 mrc_signature; // "MRCD" |
| 70 | u32 mrc_data_size; // Actual total size of this structure |
| 71 | u32 mrc_checksum; // IP style checksum |
| 72 | u32 reserved; // For header alignment |
| 73 | u8 mrc_data[0]; // Variable size, platform/run time dependent. |
| 74 | } __attribute__ ((packed)); |
| 75 | |
| 76 | struct mrc_data_container *find_current_mrc_cache(void); |
| 77 | |
| 78 | #if !defined(__PRE_RAM__) |
| 79 | void update_mrc_cache(void *unused); |
| 80 | #endif |
| 81 | |
| 82 | #endif |
| 83 | |
| 84 | /* The offset in bytes from the start of the info structure */ |
| 85 | #define FSP_IMAGE_SIG_LOC 0 |
| 86 | #define FSP_IMAGE_ID_LOC 16 |
| 87 | #define FSP_IMAGE_BASE_LOC 28 |
| 88 | |
| 89 | #define FSP_SIG 0x48505346 /* 'FSPH' */ |
| 90 | |
| 91 | #define ERROR_NO_FV_SIG 1 |
| 92 | #define ERROR_NO_FFS_GUID 2 |
| 93 | #define ERROR_NO_INFO_HEADER 3 |
| 94 | #define ERROR_IMAGEBASE_MISMATCH 4 |
| 95 | #define ERROR_INFO_HEAD_SIG_MISMATCH 5 |
| 96 | #define ERROR_FSP_SIG_MISMATCH 6 |
| 97 | |
| 98 | #ifndef __PRE_RAM__ |
| 99 | extern void *FspHobListPtr; |
| 100 | #endif |
| 101 | |
Martin Roth | 09dd70e | 2014-11-16 17:32:56 -0700 | [diff] [blame] | 102 | #define UPD_DEFAULT_CHECK(member) \ |
| 103 | if (config->member != UPD_DEFAULT) { \ |
| 104 | UpdData->member = config->member - 1; \ |
| 105 | } \ |
| 106 | printk(FSP_INFO_LEVEL, #member ":\t\t0x%02x %s\n", UpdData->member, \ |
| 107 | config->member ? "(set)" : "(default)"); |
| 108 | |
| 109 | #define UPD_SPD_CHECK(member) \ |
| 110 | if (config->member == UPD_SPD_ADDR_DISABLED) { \ |
| 111 | UpdData->member = 0x00; \ |
| 112 | } else if (config->member != UPD_SPD_ADDR_DEFAULT) { \ |
| 113 | UpdData->member = config->member; \ |
| 114 | } \ |
| 115 | printk(FSP_INFO_LEVEL, #member ":\t\t0x%02x %s\n", UpdData->member, \ |
| 116 | config->member ? "(set)" : "(default)"); |
| 117 | |
| 118 | #define UPD_DEVICE_CHECK(devicename, member, statement) \ |
| 119 | case devicename: \ |
| 120 | UpdData->member = dev->enabled; \ |
| 121 | printk(FSP_INFO_LEVEL, statement "%s\n", \ |
| 122 | UpdData->member?"Enabled":"Disabled"); \ |
| 123 | break; |
| 124 | |
Martin Roth | 5fc32bf | 2015-01-11 14:11:55 -0700 | [diff] [blame] | 125 | |
| 126 | #ifndef FSP_BOOTLOADER_TEMPORARY_MEMORY_HOB_GUID |
| 127 | #define FSP_BOOTLOADER_TEMPORARY_MEMORY_HOB_GUID \ |
| 128 | { 0xbbcff46c, 0xc8d3, 0x4113, { 0x89, 0x85, 0xb9, 0xd4, 0xf3, 0xb3, 0xf6, 0x4e } }; |
| 129 | #endif |
| 130 | |
Martin Roth | a642716 | 2014-04-25 14:12:13 -0600 | [diff] [blame] | 131 | #endif /* FSP_UTIL_H */ |