blob: bbdd4de1480f415cea90b21f69d0a591c0ebb0d1 [file] [log] [blame]
Martin Rotha6427162014-04-25 14:12:13 -06001/*
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 Rotha6427162014-04-25 14:12:13 -060014 */
15
16#ifndef FSP_UTIL_H
17#define FSP_UTIL_H
18
19#include <chipset_fsp_util.h>
Martin Roth09dd70e2014-11-16 17:32:56 -070020#include "fsp_values.h"
Martin Rotha6427162014-04-25 14:12:13 -060021
22#if IS_ENABLED(CONFIG_ENABLE_MRC_CACHE)
23int save_mrc_data(void *hob_start);
24void * find_and_set_fastboot_cache(void);
25#endif
26
27volatile u8 * find_fsp (void);
28void fsp_early_init(FSP_INFO_HEADER *fsp_info);
29void FspNotify(u32 Phase);
30void FspNotifyReturnPoint(EFI_STATUS Status, VOID *HobListPtr);
Martin Rotha6427162014-04-25 14:12:13 -060031void romstage_fsp_rt_buffer_callback(FSP_INIT_RT_BUFFER *FspRtBuffer);
32void print_fsp_info(void);
Martin Rotha6427162014-04-25 14:12:13 -060033void chipset_fsp_early_init(FSP_INIT_PARAMS *FspInitParams,
34 FSP_INFO_HEADER *fsp_ptr);
35void ChipsetFspReturnPoint(EFI_STATUS Status, VOID *HobListPtr);
Martin Roth5fc32bf2015-01-11 14:11:55 -070036void * find_saved_temp_mem(void *hob_list_ptr);
Martin Roth22138432015-01-30 20:56:05 -070037void * find_fsp_reserved_mem(void *hob_list_ptr);
Martin Rotha6427162014-04-25 14:12:13 -060038
Martin Rothfc347502015-01-03 07:28:39 -070039/* functions in hob.c */
40void print_hob_mem_attributes(void *Hobptr);
41void print_hob_type_structure(u16 Hobtype, void *Hoblistptr);
42void print_hob_resource_attributes(void *Hobptr);
Martin Roth7b132de2015-01-03 17:18:58 -070043void print_guid_type_attributes(void *Hobptr);
Martin Rothfc347502015-01-03 07:28:39 -070044const char * get_hob_type_string(void *Hobptr);
Martin Roth7b132de2015-01-03 17:18:58 -070045void * find_hob_by_guid(void *Hoblistptr, EFI_GUID *guid1);
46uint8_t guids_are_equal(EFI_GUID *guid1, EFI_GUID *guid2);
47void printguid(EFI_GUID *guid);
Martin Rothfc347502015-01-03 07:28:39 -070048
Martin Rotha6427162014-04-25 14:12:13 -060049/* 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
68struct 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
76struct mrc_data_container *find_current_mrc_cache(void);
77
78#if !defined(__PRE_RAM__)
79void 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__
99extern void *FspHobListPtr;
100#endif
101
Martin Roth09dd70e2014-11-16 17:32:56 -0700102#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 Roth5fc32bf2015-01-11 14:11:55 -0700125
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 Rotha6427162014-04-25 14:12:13 -0600131#endif /* FSP_UTIL_H */