blob: 7c22bcd5cd8e7448d1daffd41a28abf0069a8dfa [file] [log] [blame]
Bin Meng2922b3e2014-12-12 21:05:28 +08001/*
2 * Copyright (C) 2013, Intel Corporation
3 * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
4 *
5 * SPDX-License-Identifier: Intel
6 */
7
8#ifndef __FSP_HOB_H__
9#define __FSP_HOB_H__
10
Simon Glass9539e692015-07-31 09:31:36 -060011#include <efi.h>
12
Bin Meng2922b3e2014-12-12 21:05:28 +080013/* Type of HOB Header */
14#define HOB_TYPE_MEM_ALLOC 0x0002
15#define HOB_TYPE_RES_DESC 0x0003
16#define HOB_TYPE_GUID_EXT 0x0004
17#define HOB_TYPE_UNUSED 0xFFFE
18#define HOB_TYPE_EOH 0xFFFF
19
20/*
21 * Describes the format and size of the data inside the HOB.
22 * All HOBs must contain this generic HOB header.
23 */
Bin Mengdb60d862014-12-17 15:50:49 +080024struct hob_header {
Bin Meng2922b3e2014-12-12 21:05:28 +080025 u16 type; /* HOB type */
26 u16 len; /* HOB length */
27 u32 reserved; /* always zero */
28};
29
Bin Meng2922b3e2014-12-12 21:05:28 +080030/*
31 * Describes all memory ranges used during the HOB producer phase that
32 * exist outside the HOB list. This HOB type describes how memory is used,
33 * not the physical attributes of memory.
34 */
Bin Mengdb60d862014-12-17 15:50:49 +080035struct hob_mem_alloc {
36 struct hob_header hdr;
Bin Meng2922b3e2014-12-12 21:05:28 +080037 /*
38 * A GUID that defines the memory allocation region's type and purpose,
39 * as well as other fields within the memory allocation HOB. This GUID
40 * is used to define the additional data within the HOB that may be
Bin Mengdb60d862014-12-17 15:50:49 +080041 * present for the memory allocation HOB. Type efi_guid is defined in
Bin Meng2922b3e2014-12-12 21:05:28 +080042 * InstallProtocolInterface() in the UEFI 2.0 specification.
43 */
Bin Mengdb60d862014-12-17 15:50:49 +080044 struct efi_guid name;
Bin Meng2922b3e2014-12-12 21:05:28 +080045 /*
46 * The base address of memory allocated by this HOB.
47 * Type phys_addr_t is defined in AllocatePages() in the UEFI 2.0
48 * specification.
49 */
50 phys_addr_t mem_base;
51 /* The length in bytes of memory allocated by this HOB */
52 phys_size_t mem_len;
53 /*
54 * Defines the type of memory allocated by this HOB.
55 * The memory type definition follows the EFI_MEMORY_TYPE definition.
56 * Type EFI_MEMORY_TYPE is defined in AllocatePages() in the UEFI 2.0
57 * specification.
58 */
Bin Mengdb60d862014-12-17 15:50:49 +080059 enum efi_mem_type mem_type;
Bin Meng2922b3e2014-12-12 21:05:28 +080060 /* padding */
61 u8 reserved[4];
62};
63
64/* Value of ResourceType in HOB_RES_DESC */
65#define RES_SYS_MEM 0x00000000
66#define RES_MMAP_IO 0x00000001
67#define RES_IO 0x00000002
68#define RES_FW_DEVICE 0x00000003
69#define RES_MMAP_IO_PORT 0x00000004
70#define RES_MEM_RESERVED 0x00000005
71#define RES_IO_RESERVED 0x00000006
72#define RES_MAX_MEM_TYPE 0x00000007
73
74/*
75 * These types can be ORed together as needed.
76 *
77 * The first three enumerations describe settings
78 * The rest of the settings describe capabilities
79 */
80#define RES_ATTR_PRESENT 0x00000001
81#define RES_ATTR_INITIALIZED 0x00000002
82#define RES_ATTR_TESTED 0x00000004
83#define RES_ATTR_SINGLE_BIT_ECC 0x00000008
84#define RES_ATTR_MULTIPLE_BIT_ECC 0x00000010
85#define RES_ATTR_ECC_RESERVED_1 0x00000020
86#define RES_ATTR_ECC_RESERVED_2 0x00000040
87#define RES_ATTR_READ_PROTECTED 0x00000080
88#define RES_ATTR_WRITE_PROTECTED 0x00000100
89#define RES_ATTR_EXECUTION_PROTECTED 0x00000200
90#define RES_ATTR_UNCACHEABLE 0x00000400
91#define RES_ATTR_WRITE_COMBINEABLE 0x00000800
92#define RES_ATTR_WRITE_THROUGH_CACHEABLE 0x00001000
93#define RES_ATTR_WRITE_BACK_CACHEABLE 0x00002000
94#define RES_ATTR_16_BIT_IO 0x00004000
95#define RES_ATTR_32_BIT_IO 0x00008000
96#define RES_ATTR_64_BIT_IO 0x00010000
97#define RES_ATTR_UNCACHED_EXPORTED 0x00020000
98
99/*
100 * Describes the resource properties of all fixed, nonrelocatable resource
101 * ranges found on the processor host bus during the HOB producer phase.
102 */
Bin Mengdb60d862014-12-17 15:50:49 +0800103struct hob_res_desc {
104 struct hob_header hdr;
Bin Meng2922b3e2014-12-12 21:05:28 +0800105 /*
106 * A GUID representing the owner of the resource. This GUID is
107 * used by HOB consumer phase components to correlate device
108 * ownership of a resource.
109 */
Bin Mengdb60d862014-12-17 15:50:49 +0800110 struct efi_guid owner;
Bin Meng2922b3e2014-12-12 21:05:28 +0800111 u32 type;
112 u32 attr;
113 /* The physical start address of the resource region */
114 phys_addr_t phys_start;
115 /* The number of bytes of the resource region */
116 phys_size_t len;
117};
118
119/*
120 * Allows writers of executable content in the HOB producer phase to
121 * maintain and manage HOBs with specific GUID.
122 */
Bin Mengdb60d862014-12-17 15:50:49 +0800123struct hob_guid {
124 struct hob_header hdr;
Bin Meng2922b3e2014-12-12 21:05:28 +0800125 /* A GUID that defines the contents of this HOB */
Bin Mengdb60d862014-12-17 15:50:49 +0800126 struct efi_guid name;
Bin Meng2922b3e2014-12-12 21:05:28 +0800127 /* GUID specific data goes here */
128};
129
Bin Meng2922b3e2014-12-12 21:05:28 +0800130/**
Bin Mengdb60d862014-12-17 15:50:49 +0800131 * get_next_hob() - return a pointer to the next HOB in the HOB list
Bin Meng2922b3e2014-12-12 21:05:28 +0800132 *
133 * This macro returns a pointer to HOB that follows the HOB specified by hob
134 * in the HOB List.
135 *
Bin Meng2b215982014-12-30 16:02:05 +0800136 * @hdr: A pointer to a HOB.
Bin Meng2922b3e2014-12-12 21:05:28 +0800137 *
138 * @return: A pointer to the next HOB in the HOB list.
139 */
Bin Meng2b215982014-12-30 16:02:05 +0800140static inline const struct hob_header *get_next_hob(const struct hob_header *hdr)
Bin Mengdb60d862014-12-17 15:50:49 +0800141{
Simon Glass29265452017-01-16 07:03:41 -0700142 return (const struct hob_header *)((uintptr_t)hdr + hdr->len);
Bin Mengdb60d862014-12-17 15:50:49 +0800143}
Bin Meng2922b3e2014-12-12 21:05:28 +0800144
145/**
Bin Mengdb60d862014-12-17 15:50:49 +0800146 * end_of_hob() - determine if a HOB is the last HOB in the HOB list
Bin Meng2922b3e2014-12-12 21:05:28 +0800147 *
148 * This macro determine if the HOB specified by hob is the last HOB in the
Bin Mengdb60d862014-12-17 15:50:49 +0800149 * HOB list. If hob is last HOB in the HOB list, then true is returned.
150 * Otherwise, false is returned.
Bin Meng2922b3e2014-12-12 21:05:28 +0800151 *
Bin Meng2b215982014-12-30 16:02:05 +0800152 * @hdr: A pointer to a HOB.
Bin Meng2922b3e2014-12-12 21:05:28 +0800153 *
Bin Meng2b215982014-12-30 16:02:05 +0800154 * @retval true: The HOB specified by hdr is the last HOB in the HOB list.
155 * @retval false: The HOB specified by hdr is not the last HOB in the HOB list.
Bin Meng2922b3e2014-12-12 21:05:28 +0800156 */
Bin Meng2b215982014-12-30 16:02:05 +0800157static inline bool end_of_hob(const struct hob_header *hdr)
Bin Mengdb60d862014-12-17 15:50:49 +0800158{
Bin Meng2f848bc2015-01-06 14:04:36 +0800159 return hdr->type == HOB_TYPE_EOH;
Bin Mengdb60d862014-12-17 15:50:49 +0800160}
Bin Meng2922b3e2014-12-12 21:05:28 +0800161
162/**
Bin Mengdb60d862014-12-17 15:50:49 +0800163 * get_guid_hob_data() - return a pointer to data buffer from a HOB of
164 * type HOB_TYPE_GUID_EXT
Bin Meng2922b3e2014-12-12 21:05:28 +0800165 *
166 * This macro returns a pointer to the data buffer in a HOB specified by hob.
167 * hob is assumed to be a HOB of type HOB_TYPE_GUID_EXT.
168 *
Bin Meng2b215982014-12-30 16:02:05 +0800169 * @hdr: A pointer to a HOB.
Bin Meng2922b3e2014-12-12 21:05:28 +0800170 *
171 * @return: A pointer to the data buffer in a HOB.
172 */
Bin Meng2b215982014-12-30 16:02:05 +0800173static inline void *get_guid_hob_data(const struct hob_header *hdr)
Bin Mengdb60d862014-12-17 15:50:49 +0800174{
Simon Glass29265452017-01-16 07:03:41 -0700175 return (void *)((uintptr_t)hdr + sizeof(struct hob_guid));
Bin Mengdb60d862014-12-17 15:50:49 +0800176}
Bin Meng2922b3e2014-12-12 21:05:28 +0800177
178/**
Bin Mengdb60d862014-12-17 15:50:49 +0800179 * get_guid_hob_data_size() - return the size of the data buffer from a HOB
180 * of type HOB_TYPE_GUID_EXT
Bin Meng2922b3e2014-12-12 21:05:28 +0800181 *
182 * This macro returns the size, in bytes, of the data buffer in a HOB
183 * specified by hob. hob is assumed to be a HOB of type HOB_TYPE_GUID_EXT.
184 *
Bin Meng2b215982014-12-30 16:02:05 +0800185 * @hdr: A pointer to a HOB.
Bin Meng2922b3e2014-12-12 21:05:28 +0800186 *
187 * @return: The size of the data buffer.
188 */
Bin Meng2b215982014-12-30 16:02:05 +0800189static inline u16 get_guid_hob_data_size(const struct hob_header *hdr)
Bin Mengdb60d862014-12-17 15:50:49 +0800190{
Bin Meng2f848bc2015-01-06 14:04:36 +0800191 return hdr->len - sizeof(struct hob_guid);
Bin Mengdb60d862014-12-17 15:50:49 +0800192}
Bin Meng2922b3e2014-12-12 21:05:28 +0800193
194/* FSP specific GUID HOB definitions */
Bin Mengdb60d862014-12-17 15:50:49 +0800195#define FSP_GUID_DATA1 0x912740be
196#define FSP_GUID_DATA2 0x2284
197#define FSP_GUID_DATA3 0x4734
198#define FSP_GUID_DATA4_0 0xb9
199#define FSP_GUID_DATA4_1 0x71
200#define FSP_GUID_DATA4_2 0x84
201#define FSP_GUID_DATA4_3 0xb0
202#define FSP_GUID_DATA4_4 0x27
203#define FSP_GUID_DATA4_5 0x35
204#define FSP_GUID_DATA4_6 0x3f
205#define FSP_GUID_DATA4_7 0x0c
206
Bin Meng2922b3e2014-12-12 21:05:28 +0800207#define FSP_HEADER_GUID \
208 { \
Bin Mengdb60d862014-12-17 15:50:49 +0800209 FSP_GUID_DATA1, FSP_GUID_DATA2, FSP_GUID_DATA3, \
210 { FSP_GUID_DATA4_0, FSP_GUID_DATA4_1, FSP_GUID_DATA4_2, \
211 FSP_GUID_DATA4_3, FSP_GUID_DATA4_4, FSP_GUID_DATA4_5, \
212 FSP_GUID_DATA4_6, FSP_GUID_DATA4_7 } \
Bin Meng2922b3e2014-12-12 21:05:28 +0800213 }
214
215#define FSP_NON_VOLATILE_STORAGE_HOB_GUID \
216 { \
217 0x721acf02, 0x4d77, 0x4c2a, \
218 { 0xb3, 0xdc, 0x27, 0xb, 0x7b, 0xa9, 0xe4, 0xb0 } \
219 }
220
221#define FSP_BOOTLOADER_TEMP_MEM_HOB_GUID \
222 { \
223 0xbbcff46c, 0xc8d3, 0x4113, \
224 { 0x89, 0x85, 0xb9, 0xd4, 0xf3, 0xb3, 0xf6, 0x4e } \
225 }
226
227#define FSP_HOB_RESOURCE_OWNER_FSP_GUID \
228 { \
229 0x69a79759, 0x1373, 0x4367, \
230 { 0xa6, 0xc4, 0xc7, 0xf5, 0x9e, 0xfd, 0x98, 0x6e } \
231 }
232
233#define FSP_HOB_RESOURCE_OWNER_TSEG_GUID \
234 { \
235 0xd038747c, 0xd00c, 0x4980, \
236 { 0xb3, 0x19, 0x49, 0x01, 0x99, 0xa4, 0x7d, 0x55 } \
237 }
238
239#define FSP_HOB_RESOURCE_OWNER_GRAPHICS_GUID \
240 { \
241 0x9c7c3aa7, 0x5332, 0x4917, \
242 { 0x82, 0xb9, 0x56, 0xa5, 0xf3, 0xe6, 0x2a, 0x07 } \
243 }
244
245#endif