blob: 00657b62c76df2b45b9b4c8629d1f9c9d6ea31b6 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: Intel */
Bin Meng2922b3e2014-12-12 21:05:28 +08002/*
3 * Copyright (C) 2013, Intel Corporation
4 * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
Bin Meng2922b3e2014-12-12 21:05:28 +08005 */
6
7#ifndef __FSP_HOB_H__
8#define __FSP_HOB_H__
9
Simon Glass9539e692015-07-31 09:31:36 -060010#include <efi.h>
11
Bin Meng2922b3e2014-12-12 21:05:28 +080012/* Type of HOB Header */
13#define HOB_TYPE_MEM_ALLOC 0x0002
14#define HOB_TYPE_RES_DESC 0x0003
15#define HOB_TYPE_GUID_EXT 0x0004
16#define HOB_TYPE_UNUSED 0xFFFE
17#define HOB_TYPE_EOH 0xFFFF
18
19/*
20 * Describes the format and size of the data inside the HOB.
21 * All HOBs must contain this generic HOB header.
22 */
Bin Mengdb60d862014-12-17 15:50:49 +080023struct hob_header {
Bin Meng2922b3e2014-12-12 21:05:28 +080024 u16 type; /* HOB type */
25 u16 len; /* HOB length */
26 u32 reserved; /* always zero */
27};
28
Bin Meng2922b3e2014-12-12 21:05:28 +080029/*
30 * Describes all memory ranges used during the HOB producer phase that
31 * exist outside the HOB list. This HOB type describes how memory is used,
32 * not the physical attributes of memory.
33 */
Bin Mengdb60d862014-12-17 15:50:49 +080034struct hob_mem_alloc {
35 struct hob_header hdr;
Bin Meng2922b3e2014-12-12 21:05:28 +080036 /*
37 * A GUID that defines the memory allocation region's type and purpose,
38 * as well as other fields within the memory allocation HOB. This GUID
39 * is used to define the additional data within the HOB that may be
Bin Mengdb60d862014-12-17 15:50:49 +080040 * present for the memory allocation HOB. Type efi_guid is defined in
Bin Meng2922b3e2014-12-12 21:05:28 +080041 * InstallProtocolInterface() in the UEFI 2.0 specification.
42 */
Bin Mengdb60d862014-12-17 15:50:49 +080043 struct efi_guid name;
Bin Meng2922b3e2014-12-12 21:05:28 +080044 /*
45 * The base address of memory allocated by this HOB.
46 * Type phys_addr_t is defined in AllocatePages() in the UEFI 2.0
47 * specification.
48 */
49 phys_addr_t mem_base;
50 /* The length in bytes of memory allocated by this HOB */
51 phys_size_t mem_len;
52 /*
53 * Defines the type of memory allocated by this HOB.
54 * The memory type definition follows the EFI_MEMORY_TYPE definition.
55 * Type EFI_MEMORY_TYPE is defined in AllocatePages() in the UEFI 2.0
56 * specification.
57 */
Bin Mengdb60d862014-12-17 15:50:49 +080058 enum efi_mem_type mem_type;
Bin Meng2922b3e2014-12-12 21:05:28 +080059 /* padding */
60 u8 reserved[4];
61};
62
63/* Value of ResourceType in HOB_RES_DESC */
64#define RES_SYS_MEM 0x00000000
65#define RES_MMAP_IO 0x00000001
66#define RES_IO 0x00000002
67#define RES_FW_DEVICE 0x00000003
68#define RES_MMAP_IO_PORT 0x00000004
69#define RES_MEM_RESERVED 0x00000005
70#define RES_IO_RESERVED 0x00000006
71#define RES_MAX_MEM_TYPE 0x00000007
72
73/*
74 * These types can be ORed together as needed.
75 *
76 * The first three enumerations describe settings
77 * The rest of the settings describe capabilities
78 */
79#define RES_ATTR_PRESENT 0x00000001
80#define RES_ATTR_INITIALIZED 0x00000002
81#define RES_ATTR_TESTED 0x00000004
82#define RES_ATTR_SINGLE_BIT_ECC 0x00000008
83#define RES_ATTR_MULTIPLE_BIT_ECC 0x00000010
84#define RES_ATTR_ECC_RESERVED_1 0x00000020
85#define RES_ATTR_ECC_RESERVED_2 0x00000040
86#define RES_ATTR_READ_PROTECTED 0x00000080
87#define RES_ATTR_WRITE_PROTECTED 0x00000100
88#define RES_ATTR_EXECUTION_PROTECTED 0x00000200
89#define RES_ATTR_UNCACHEABLE 0x00000400
90#define RES_ATTR_WRITE_COMBINEABLE 0x00000800
91#define RES_ATTR_WRITE_THROUGH_CACHEABLE 0x00001000
92#define RES_ATTR_WRITE_BACK_CACHEABLE 0x00002000
93#define RES_ATTR_16_BIT_IO 0x00004000
94#define RES_ATTR_32_BIT_IO 0x00008000
95#define RES_ATTR_64_BIT_IO 0x00010000
96#define RES_ATTR_UNCACHED_EXPORTED 0x00020000
97
98/*
99 * Describes the resource properties of all fixed, nonrelocatable resource
100 * ranges found on the processor host bus during the HOB producer phase.
101 */
Bin Mengdb60d862014-12-17 15:50:49 +0800102struct hob_res_desc {
103 struct hob_header hdr;
Bin Meng2922b3e2014-12-12 21:05:28 +0800104 /*
105 * A GUID representing the owner of the resource. This GUID is
106 * used by HOB consumer phase components to correlate device
107 * ownership of a resource.
108 */
Bin Mengdb60d862014-12-17 15:50:49 +0800109 struct efi_guid owner;
Bin Meng2922b3e2014-12-12 21:05:28 +0800110 u32 type;
111 u32 attr;
112 /* The physical start address of the resource region */
113 phys_addr_t phys_start;
114 /* The number of bytes of the resource region */
115 phys_size_t len;
116};
117
118/*
119 * Allows writers of executable content in the HOB producer phase to
120 * maintain and manage HOBs with specific GUID.
121 */
Bin Mengdb60d862014-12-17 15:50:49 +0800122struct hob_guid {
123 struct hob_header hdr;
Bin Meng2922b3e2014-12-12 21:05:28 +0800124 /* A GUID that defines the contents of this HOB */
Bin Mengdb60d862014-12-17 15:50:49 +0800125 struct efi_guid name;
Bin Meng2922b3e2014-12-12 21:05:28 +0800126 /* GUID specific data goes here */
127};
128
Bin Meng3c8b48a2017-08-15 22:41:52 -0700129enum pixel_format {
130 pixel_rgbx_8bpc, /* RGB 8 bit per color */
131 pixel_bgrx_8bpc, /* BGR 8 bit per color */
132 pixel_bitmask,
133};
134
135struct __packed hob_graphics_info {
136 phys_addr_t fb_base; /* framebuffer base address */
137 u32 fb_size; /* framebuffer size */
138 u32 version;
139 u32 width;
140 u32 height;
141 enum pixel_format pixel_format;
142 u32 red_mask;
143 u32 green_mask;
144 u32 blue_mask;
145 u32 reserved_mask;
146 u32 pixels_per_scanline;
147};
148
Bin Meng2922b3e2014-12-12 21:05:28 +0800149/**
Bin Mengdb60d862014-12-17 15:50:49 +0800150 * get_next_hob() - return a pointer to the next HOB in the HOB list
Bin Meng2922b3e2014-12-12 21:05:28 +0800151 *
152 * This macro returns a pointer to HOB that follows the HOB specified by hob
153 * in the HOB List.
154 *
Bin Meng2b215982014-12-30 16:02:05 +0800155 * @hdr: A pointer to a HOB.
Bin Meng2922b3e2014-12-12 21:05:28 +0800156 *
157 * @return: A pointer to the next HOB in the HOB list.
158 */
Bin Meng2b215982014-12-30 16:02:05 +0800159static inline const struct hob_header *get_next_hob(const struct hob_header *hdr)
Bin Mengdb60d862014-12-17 15:50:49 +0800160{
Simon Glass29265452017-01-16 07:03:41 -0700161 return (const struct hob_header *)((uintptr_t)hdr + hdr->len);
Bin Mengdb60d862014-12-17 15:50:49 +0800162}
Bin Meng2922b3e2014-12-12 21:05:28 +0800163
164/**
Bin Mengdb60d862014-12-17 15:50:49 +0800165 * end_of_hob() - determine if a HOB is the last HOB in the HOB list
Bin Meng2922b3e2014-12-12 21:05:28 +0800166 *
167 * This macro determine if the HOB specified by hob is the last HOB in the
Bin Mengdb60d862014-12-17 15:50:49 +0800168 * HOB list. If hob is last HOB in the HOB list, then true is returned.
169 * Otherwise, false is returned.
Bin Meng2922b3e2014-12-12 21:05:28 +0800170 *
Bin Meng2b215982014-12-30 16:02:05 +0800171 * @hdr: A pointer to a HOB.
Bin Meng2922b3e2014-12-12 21:05:28 +0800172 *
Bin Meng2b215982014-12-30 16:02:05 +0800173 * @retval true: The HOB specified by hdr is the last HOB in the HOB list.
174 * @retval false: The HOB specified by hdr is not the last HOB in the HOB list.
Bin Meng2922b3e2014-12-12 21:05:28 +0800175 */
Bin Meng2b215982014-12-30 16:02:05 +0800176static inline bool end_of_hob(const struct hob_header *hdr)
Bin Mengdb60d862014-12-17 15:50:49 +0800177{
Bin Meng2f848bc2015-01-06 14:04:36 +0800178 return hdr->type == HOB_TYPE_EOH;
Bin Mengdb60d862014-12-17 15:50:49 +0800179}
Bin Meng2922b3e2014-12-12 21:05:28 +0800180
181/**
Bin Mengdb60d862014-12-17 15:50:49 +0800182 * get_guid_hob_data() - return a pointer to data buffer from a HOB of
183 * type HOB_TYPE_GUID_EXT
Bin Meng2922b3e2014-12-12 21:05:28 +0800184 *
185 * This macro returns a pointer to the data buffer in a HOB specified by hob.
186 * hob is assumed to be a HOB of type HOB_TYPE_GUID_EXT.
187 *
Bin Meng2b215982014-12-30 16:02:05 +0800188 * @hdr: A pointer to a HOB.
Bin Meng2922b3e2014-12-12 21:05:28 +0800189 *
190 * @return: A pointer to the data buffer in a HOB.
191 */
Bin Meng2b215982014-12-30 16:02:05 +0800192static inline void *get_guid_hob_data(const struct hob_header *hdr)
Bin Mengdb60d862014-12-17 15:50:49 +0800193{
Simon Glass29265452017-01-16 07:03:41 -0700194 return (void *)((uintptr_t)hdr + sizeof(struct hob_guid));
Bin Mengdb60d862014-12-17 15:50:49 +0800195}
Bin Meng2922b3e2014-12-12 21:05:28 +0800196
197/**
Bin Mengdb60d862014-12-17 15:50:49 +0800198 * get_guid_hob_data_size() - return the size of the data buffer from a HOB
199 * of type HOB_TYPE_GUID_EXT
Bin Meng2922b3e2014-12-12 21:05:28 +0800200 *
201 * This macro returns the size, in bytes, of the data buffer in a HOB
202 * specified by hob. hob is assumed to be a HOB of type HOB_TYPE_GUID_EXT.
203 *
Bin Meng2b215982014-12-30 16:02:05 +0800204 * @hdr: A pointer to a HOB.
Bin Meng2922b3e2014-12-12 21:05:28 +0800205 *
206 * @return: The size of the data buffer.
207 */
Bin Meng2b215982014-12-30 16:02:05 +0800208static inline u16 get_guid_hob_data_size(const struct hob_header *hdr)
Bin Mengdb60d862014-12-17 15:50:49 +0800209{
Bin Meng2f848bc2015-01-06 14:04:36 +0800210 return hdr->len - sizeof(struct hob_guid);
Bin Mengdb60d862014-12-17 15:50:49 +0800211}
Bin Meng2922b3e2014-12-12 21:05:28 +0800212
213/* FSP specific GUID HOB definitions */
Bin Mengdb60d862014-12-17 15:50:49 +0800214#define FSP_GUID_DATA1 0x912740be
215#define FSP_GUID_DATA2 0x2284
216#define FSP_GUID_DATA3 0x4734
217#define FSP_GUID_DATA4_0 0xb9
218#define FSP_GUID_DATA4_1 0x71
219#define FSP_GUID_DATA4_2 0x84
220#define FSP_GUID_DATA4_3 0xb0
221#define FSP_GUID_DATA4_4 0x27
222#define FSP_GUID_DATA4_5 0x35
223#define FSP_GUID_DATA4_6 0x3f
224#define FSP_GUID_DATA4_7 0x0c
225
Bin Meng2922b3e2014-12-12 21:05:28 +0800226#define FSP_HEADER_GUID \
227 { \
Bin Mengdb60d862014-12-17 15:50:49 +0800228 FSP_GUID_DATA1, FSP_GUID_DATA2, FSP_GUID_DATA3, \
229 { FSP_GUID_DATA4_0, FSP_GUID_DATA4_1, FSP_GUID_DATA4_2, \
230 FSP_GUID_DATA4_3, FSP_GUID_DATA4_4, FSP_GUID_DATA4_5, \
231 FSP_GUID_DATA4_6, FSP_GUID_DATA4_7 } \
Bin Meng2922b3e2014-12-12 21:05:28 +0800232 }
233
234#define FSP_NON_VOLATILE_STORAGE_HOB_GUID \
235 { \
236 0x721acf02, 0x4d77, 0x4c2a, \
237 { 0xb3, 0xdc, 0x27, 0xb, 0x7b, 0xa9, 0xe4, 0xb0 } \
238 }
239
240#define FSP_BOOTLOADER_TEMP_MEM_HOB_GUID \
241 { \
242 0xbbcff46c, 0xc8d3, 0x4113, \
243 { 0x89, 0x85, 0xb9, 0xd4, 0xf3, 0xb3, 0xf6, 0x4e } \
244 }
245
246#define FSP_HOB_RESOURCE_OWNER_FSP_GUID \
247 { \
248 0x69a79759, 0x1373, 0x4367, \
249 { 0xa6, 0xc4, 0xc7, 0xf5, 0x9e, 0xfd, 0x98, 0x6e } \
250 }
251
252#define FSP_HOB_RESOURCE_OWNER_TSEG_GUID \
253 { \
254 0xd038747c, 0xd00c, 0x4980, \
255 { 0xb3, 0x19, 0x49, 0x01, 0x99, 0xa4, 0x7d, 0x55 } \
256 }
257
258#define FSP_HOB_RESOURCE_OWNER_GRAPHICS_GUID \
259 { \
260 0x9c7c3aa7, 0x5332, 0x4917, \
261 { 0x82, 0xb9, 0x56, 0xa5, 0xf3, 0xe6, 0x2a, 0x07 } \
262 }
263
Bin Mengf3c06322017-08-15 22:41:51 -0700264/* The following GUIDs are newly introduced in FSP spec 1.1 */
265
266#define FSP_HOB_RESOURCE_OWNER_BOOTLOADER_TOLUM_GUID \
267 { \
268 0x73ff4f56, 0xaa8e, 0x4451, \
269 { 0xb3, 0x16, 0x36, 0x35, 0x36, 0x67, 0xad, 0x44 } \
270 }
271
Bin Meng3c8b48a2017-08-15 22:41:52 -0700272#define FSP_GRAPHICS_INFO_HOB_GUID \
273 { \
274 0x39f62cce, 0x6825, 0x4669, \
275 { 0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07 } \
276 }
277
Bin Meng2922b3e2014-12-12 21:05:28 +0800278#endif