xref: /openbmc/u-boot/arch/x86/include/asm/fsp/fsp_hob.h (revision e8f80a5a)
1*83d290c5STom Rini /* SPDX-License-Identifier: Intel */
21021af4dSSimon Glass /*
31021af4dSSimon Glass  * Copyright (C) 2013, Intel Corporation
41021af4dSSimon Glass  * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
51021af4dSSimon Glass  */
61021af4dSSimon Glass 
71021af4dSSimon Glass #ifndef __FSP_HOB_H__
81021af4dSSimon Glass #define __FSP_HOB_H__
91021af4dSSimon Glass 
10867a6ac8SSimon Glass #include <efi.h>
11867a6ac8SSimon Glass 
121021af4dSSimon Glass /* Type of HOB Header */
131021af4dSSimon Glass #define HOB_TYPE_MEM_ALLOC	0x0002
141021af4dSSimon Glass #define HOB_TYPE_RES_DESC	0x0003
151021af4dSSimon Glass #define HOB_TYPE_GUID_EXT	0x0004
161021af4dSSimon Glass #define HOB_TYPE_UNUSED		0xFFFE
171021af4dSSimon Glass #define HOB_TYPE_EOH		0xFFFF
181021af4dSSimon Glass 
191021af4dSSimon Glass /*
201021af4dSSimon Glass  * Describes the format and size of the data inside the HOB.
211021af4dSSimon Glass  * All HOBs must contain this generic HOB header.
221021af4dSSimon Glass  */
231021af4dSSimon Glass struct hob_header {
241021af4dSSimon Glass 	u16	type;		/* HOB type */
251021af4dSSimon Glass 	u16	len;		/* HOB length */
261021af4dSSimon Glass 	u32	reserved;	/* always zero */
271021af4dSSimon Glass };
281021af4dSSimon Glass 
291021af4dSSimon Glass /*
301021af4dSSimon Glass  * Describes all memory ranges used during the HOB producer phase that
311021af4dSSimon Glass  * exist outside the HOB list. This HOB type describes how memory is used,
321021af4dSSimon Glass  * not the physical attributes of memory.
331021af4dSSimon Glass  */
341021af4dSSimon Glass struct hob_mem_alloc {
351021af4dSSimon Glass 	struct hob_header	hdr;
361021af4dSSimon Glass 	/*
371021af4dSSimon Glass 	 * A GUID that defines the memory allocation region's type and purpose,
381021af4dSSimon Glass 	 * as well as other fields within the memory allocation HOB. This GUID
391021af4dSSimon Glass 	 * is used to define the additional data within the HOB that may be
401021af4dSSimon Glass 	 * present for the memory allocation HOB. Type efi_guid is defined in
411021af4dSSimon Glass 	 * InstallProtocolInterface() in the UEFI 2.0 specification.
421021af4dSSimon Glass 	 */
431021af4dSSimon Glass 	struct efi_guid		name;
441021af4dSSimon Glass 	/*
451021af4dSSimon Glass 	 * The base address of memory allocated by this HOB.
461021af4dSSimon Glass 	 * Type phys_addr_t is defined in AllocatePages() in the UEFI 2.0
471021af4dSSimon Glass 	 * specification.
481021af4dSSimon Glass 	 */
491021af4dSSimon Glass 	phys_addr_t		mem_base;
501021af4dSSimon Glass 	/* The length in bytes of memory allocated by this HOB */
511021af4dSSimon Glass 	phys_size_t		mem_len;
521021af4dSSimon Glass 	/*
531021af4dSSimon Glass 	 * Defines the type of memory allocated by this HOB.
541021af4dSSimon Glass 	 * The memory type definition follows the EFI_MEMORY_TYPE definition.
551021af4dSSimon Glass 	 * Type EFI_MEMORY_TYPE is defined in AllocatePages() in the UEFI 2.0
561021af4dSSimon Glass 	 * specification.
571021af4dSSimon Glass 	 */
581021af4dSSimon Glass 	enum efi_mem_type	mem_type;
591021af4dSSimon Glass 	/* padding */
601021af4dSSimon Glass 	u8			reserved[4];
611021af4dSSimon Glass };
621021af4dSSimon Glass 
631021af4dSSimon Glass /* Value of ResourceType in HOB_RES_DESC */
641021af4dSSimon Glass #define RES_SYS_MEM		0x00000000
651021af4dSSimon Glass #define RES_MMAP_IO		0x00000001
661021af4dSSimon Glass #define RES_IO			0x00000002
671021af4dSSimon Glass #define RES_FW_DEVICE		0x00000003
681021af4dSSimon Glass #define RES_MMAP_IO_PORT	0x00000004
691021af4dSSimon Glass #define RES_MEM_RESERVED	0x00000005
701021af4dSSimon Glass #define RES_IO_RESERVED		0x00000006
711021af4dSSimon Glass #define RES_MAX_MEM_TYPE	0x00000007
721021af4dSSimon Glass 
731021af4dSSimon Glass /*
741021af4dSSimon Glass  * These types can be ORed together as needed.
751021af4dSSimon Glass  *
761021af4dSSimon Glass  * The first three enumerations describe settings
771021af4dSSimon Glass  * The rest of the settings describe capabilities
781021af4dSSimon Glass  */
791021af4dSSimon Glass #define RES_ATTR_PRESENT			0x00000001
801021af4dSSimon Glass #define RES_ATTR_INITIALIZED			0x00000002
811021af4dSSimon Glass #define RES_ATTR_TESTED				0x00000004
821021af4dSSimon Glass #define RES_ATTR_SINGLE_BIT_ECC			0x00000008
831021af4dSSimon Glass #define RES_ATTR_MULTIPLE_BIT_ECC		0x00000010
841021af4dSSimon Glass #define RES_ATTR_ECC_RESERVED_1			0x00000020
851021af4dSSimon Glass #define RES_ATTR_ECC_RESERVED_2			0x00000040
861021af4dSSimon Glass #define RES_ATTR_READ_PROTECTED			0x00000080
871021af4dSSimon Glass #define RES_ATTR_WRITE_PROTECTED		0x00000100
881021af4dSSimon Glass #define RES_ATTR_EXECUTION_PROTECTED		0x00000200
891021af4dSSimon Glass #define RES_ATTR_UNCACHEABLE			0x00000400
901021af4dSSimon Glass #define RES_ATTR_WRITE_COMBINEABLE		0x00000800
911021af4dSSimon Glass #define RES_ATTR_WRITE_THROUGH_CACHEABLE	0x00001000
921021af4dSSimon Glass #define RES_ATTR_WRITE_BACK_CACHEABLE		0x00002000
931021af4dSSimon Glass #define RES_ATTR_16_BIT_IO			0x00004000
941021af4dSSimon Glass #define RES_ATTR_32_BIT_IO			0x00008000
951021af4dSSimon Glass #define RES_ATTR_64_BIT_IO			0x00010000
961021af4dSSimon Glass #define RES_ATTR_UNCACHED_EXPORTED		0x00020000
971021af4dSSimon Glass 
981021af4dSSimon Glass /*
991021af4dSSimon Glass  * Describes the resource properties of all fixed, nonrelocatable resource
1001021af4dSSimon Glass  * ranges found on the processor host bus during the HOB producer phase.
1011021af4dSSimon Glass  */
1021021af4dSSimon Glass struct hob_res_desc {
1031021af4dSSimon Glass 	struct hob_header	hdr;
1041021af4dSSimon Glass 	/*
1051021af4dSSimon Glass 	 * A GUID representing the owner of the resource. This GUID is
1061021af4dSSimon Glass 	 * used by HOB consumer phase components to correlate device
1071021af4dSSimon Glass 	 * ownership of a resource.
1081021af4dSSimon Glass 	 */
1091021af4dSSimon Glass 	struct efi_guid		owner;
1101021af4dSSimon Glass 	u32			type;
1111021af4dSSimon Glass 	u32			attr;
1121021af4dSSimon Glass 	/* The physical start address of the resource region */
1131021af4dSSimon Glass 	phys_addr_t		phys_start;
1141021af4dSSimon Glass 	/* The number of bytes of the resource region */
1151021af4dSSimon Glass 	phys_size_t		len;
1161021af4dSSimon Glass };
1171021af4dSSimon Glass 
1181021af4dSSimon Glass /*
1191021af4dSSimon Glass  * Allows writers of executable content in the HOB producer phase to
1201021af4dSSimon Glass  * maintain and manage HOBs with specific GUID.
1211021af4dSSimon Glass  */
1221021af4dSSimon Glass struct hob_guid {
1231021af4dSSimon Glass 	struct hob_header	hdr;
1241021af4dSSimon Glass 	/* A GUID that defines the contents of this HOB */
1251021af4dSSimon Glass 	struct efi_guid		name;
1261021af4dSSimon Glass 	/* GUID specific data goes here */
1271021af4dSSimon Glass };
1281021af4dSSimon Glass 
1294ff333b7SBin Meng enum pixel_format {
1304ff333b7SBin Meng 	pixel_rgbx_8bpc,	/* RGB 8 bit per color */
1314ff333b7SBin Meng 	pixel_bgrx_8bpc,	/* BGR 8 bit per color */
1324ff333b7SBin Meng 	pixel_bitmask,
1334ff333b7SBin Meng };
1344ff333b7SBin Meng 
1354ff333b7SBin Meng struct __packed hob_graphics_info {
1364ff333b7SBin Meng 	phys_addr_t fb_base;	/* framebuffer base address */
1374ff333b7SBin Meng 	u32 fb_size;		/* framebuffer size */
1384ff333b7SBin Meng 	u32 version;
1394ff333b7SBin Meng 	u32 width;
1404ff333b7SBin Meng 	u32 height;
1414ff333b7SBin Meng 	enum pixel_format pixel_format;
1424ff333b7SBin Meng 	u32 red_mask;
1434ff333b7SBin Meng 	u32 green_mask;
1444ff333b7SBin Meng 	u32 blue_mask;
1454ff333b7SBin Meng 	u32 reserved_mask;
1464ff333b7SBin Meng 	u32 pixels_per_scanline;
1474ff333b7SBin Meng };
1484ff333b7SBin Meng 
1491021af4dSSimon Glass /**
1501021af4dSSimon Glass  * get_next_hob() - return a pointer to the next HOB in the HOB list
1511021af4dSSimon Glass  *
1521021af4dSSimon Glass  * This macro returns a pointer to HOB that follows the HOB specified by hob
1531021af4dSSimon Glass  * in the HOB List.
1541021af4dSSimon Glass  *
1551021af4dSSimon Glass  * @hdr:    A pointer to a HOB.
1561021af4dSSimon Glass  *
1571021af4dSSimon Glass  * @return: A pointer to the next HOB in the HOB list.
1581021af4dSSimon Glass  */
get_next_hob(const struct hob_header * hdr)1591021af4dSSimon Glass static inline const struct hob_header *get_next_hob(const struct hob_header *hdr)
1601021af4dSSimon Glass {
161beb4d65eSSimon Glass 	return (const struct hob_header *)((uintptr_t)hdr + hdr->len);
1621021af4dSSimon Glass }
1631021af4dSSimon Glass 
1641021af4dSSimon Glass /**
1651021af4dSSimon Glass  * end_of_hob() - determine if a HOB is the last HOB in the HOB list
1661021af4dSSimon Glass  *
1671021af4dSSimon Glass  * This macro determine if the HOB specified by hob is the last HOB in the
1681021af4dSSimon Glass  * HOB list.  If hob is last HOB in the HOB list, then true is returned.
1691021af4dSSimon Glass  * Otherwise, false is returned.
1701021af4dSSimon Glass  *
1711021af4dSSimon Glass  * @hdr:          A pointer to a HOB.
1721021af4dSSimon Glass  *
1731021af4dSSimon Glass  * @retval true:  The HOB specified by hdr is the last HOB in the HOB list.
1741021af4dSSimon Glass  * @retval false: The HOB specified by hdr is not the last HOB in the HOB list.
1751021af4dSSimon Glass  */
end_of_hob(const struct hob_header * hdr)1761021af4dSSimon Glass static inline bool end_of_hob(const struct hob_header *hdr)
1771021af4dSSimon Glass {
1781021af4dSSimon Glass 	return hdr->type == HOB_TYPE_EOH;
1791021af4dSSimon Glass }
1801021af4dSSimon Glass 
1811021af4dSSimon Glass /**
1821021af4dSSimon Glass  * get_guid_hob_data() - return a pointer to data buffer from a HOB of
1831021af4dSSimon Glass  *                       type HOB_TYPE_GUID_EXT
1841021af4dSSimon Glass  *
1851021af4dSSimon Glass  * This macro returns a pointer to the data buffer in a HOB specified by hob.
1861021af4dSSimon Glass  * hob is assumed to be a HOB of type HOB_TYPE_GUID_EXT.
1871021af4dSSimon Glass  *
1881021af4dSSimon Glass  * @hdr:    A pointer to a HOB.
1891021af4dSSimon Glass  *
1901021af4dSSimon Glass  * @return: A pointer to the data buffer in a HOB.
1911021af4dSSimon Glass  */
get_guid_hob_data(const struct hob_header * hdr)1921021af4dSSimon Glass static inline void *get_guid_hob_data(const struct hob_header *hdr)
1931021af4dSSimon Glass {
194beb4d65eSSimon Glass 	return (void *)((uintptr_t)hdr + sizeof(struct hob_guid));
1951021af4dSSimon Glass }
1961021af4dSSimon Glass 
1971021af4dSSimon Glass /**
1981021af4dSSimon Glass  * get_guid_hob_data_size() - return the size of the data buffer from a HOB
1991021af4dSSimon Glass  *                            of type HOB_TYPE_GUID_EXT
2001021af4dSSimon Glass  *
2011021af4dSSimon Glass  * This macro returns the size, in bytes, of the data buffer in a HOB
2021021af4dSSimon Glass  * specified by hob. hob is assumed to be a HOB of type HOB_TYPE_GUID_EXT.
2031021af4dSSimon Glass  *
2041021af4dSSimon Glass  * @hdr:    A pointer to a HOB.
2051021af4dSSimon Glass  *
2061021af4dSSimon Glass  * @return: The size of the data buffer.
2071021af4dSSimon Glass  */
get_guid_hob_data_size(const struct hob_header * hdr)2081021af4dSSimon Glass static inline u16 get_guid_hob_data_size(const struct hob_header *hdr)
2091021af4dSSimon Glass {
2101021af4dSSimon Glass 	return hdr->len - sizeof(struct hob_guid);
2111021af4dSSimon Glass }
2121021af4dSSimon Glass 
2131021af4dSSimon Glass /* FSP specific GUID HOB definitions */
2141021af4dSSimon Glass #define FSP_GUID_DATA1		0x912740be
2151021af4dSSimon Glass #define FSP_GUID_DATA2		0x2284
2161021af4dSSimon Glass #define FSP_GUID_DATA3		0x4734
2171021af4dSSimon Glass #define FSP_GUID_DATA4_0	0xb9
2181021af4dSSimon Glass #define FSP_GUID_DATA4_1	0x71
2191021af4dSSimon Glass #define FSP_GUID_DATA4_2	0x84
2201021af4dSSimon Glass #define FSP_GUID_DATA4_3	0xb0
2211021af4dSSimon Glass #define FSP_GUID_DATA4_4	0x27
2221021af4dSSimon Glass #define FSP_GUID_DATA4_5	0x35
2231021af4dSSimon Glass #define FSP_GUID_DATA4_6	0x3f
2241021af4dSSimon Glass #define FSP_GUID_DATA4_7	0x0c
2251021af4dSSimon Glass 
2261021af4dSSimon Glass #define FSP_HEADER_GUID \
2271021af4dSSimon Glass 	{ \
2281021af4dSSimon Glass 	FSP_GUID_DATA1, FSP_GUID_DATA2, FSP_GUID_DATA3, \
2291021af4dSSimon Glass 	{ FSP_GUID_DATA4_0, FSP_GUID_DATA4_1, FSP_GUID_DATA4_2, \
2301021af4dSSimon Glass 	  FSP_GUID_DATA4_3, FSP_GUID_DATA4_4, FSP_GUID_DATA4_5, \
2311021af4dSSimon Glass 	  FSP_GUID_DATA4_6, FSP_GUID_DATA4_7 } \
2321021af4dSSimon Glass 	}
2331021af4dSSimon Glass 
2341021af4dSSimon Glass #define FSP_NON_VOLATILE_STORAGE_HOB_GUID \
2351021af4dSSimon Glass 	{ \
2361021af4dSSimon Glass 	0x721acf02, 0x4d77, 0x4c2a, \
2371021af4dSSimon Glass 	{ 0xb3, 0xdc, 0x27, 0xb, 0x7b, 0xa9, 0xe4, 0xb0 } \
2381021af4dSSimon Glass 	}
2391021af4dSSimon Glass 
2401021af4dSSimon Glass #define FSP_BOOTLOADER_TEMP_MEM_HOB_GUID \
2411021af4dSSimon Glass 	{ \
2421021af4dSSimon Glass 	0xbbcff46c, 0xc8d3, 0x4113, \
2431021af4dSSimon Glass 	{ 0x89, 0x85, 0xb9, 0xd4, 0xf3, 0xb3, 0xf6, 0x4e } \
2441021af4dSSimon Glass 	}
2451021af4dSSimon Glass 
2461021af4dSSimon Glass #define FSP_HOB_RESOURCE_OWNER_FSP_GUID \
2471021af4dSSimon Glass 	{ \
2481021af4dSSimon Glass 	0x69a79759, 0x1373, 0x4367, \
2491021af4dSSimon Glass 	{ 0xa6, 0xc4, 0xc7, 0xf5, 0x9e, 0xfd, 0x98, 0x6e } \
2501021af4dSSimon Glass 	}
2511021af4dSSimon Glass 
2521021af4dSSimon Glass #define FSP_HOB_RESOURCE_OWNER_TSEG_GUID \
2531021af4dSSimon Glass 	{ \
2541021af4dSSimon Glass 	0xd038747c, 0xd00c, 0x4980, \
2551021af4dSSimon Glass 	{ 0xb3, 0x19, 0x49, 0x01, 0x99, 0xa4, 0x7d, 0x55 } \
2561021af4dSSimon Glass 	}
2571021af4dSSimon Glass 
2581021af4dSSimon Glass #define FSP_HOB_RESOURCE_OWNER_GRAPHICS_GUID \
2591021af4dSSimon Glass 	{ \
2601021af4dSSimon Glass 	0x9c7c3aa7, 0x5332, 0x4917, \
2611021af4dSSimon Glass 	{ 0x82, 0xb9, 0x56, 0xa5, 0xf3, 0xe6, 0x2a, 0x07 } \
2621021af4dSSimon Glass 	}
2631021af4dSSimon Glass 
264bb737cedSBin Meng /* The following GUIDs are newly introduced in FSP spec 1.1 */
265bb737cedSBin Meng 
266bb737cedSBin Meng #define FSP_HOB_RESOURCE_OWNER_BOOTLOADER_TOLUM_GUID \
267bb737cedSBin Meng 	{ \
268bb737cedSBin Meng 	0x73ff4f56, 0xaa8e, 0x4451, \
269bb737cedSBin Meng 	{ 0xb3, 0x16, 0x36, 0x35, 0x36, 0x67, 0xad, 0x44 } \
270bb737cedSBin Meng 	}
271bb737cedSBin Meng 
2724ff333b7SBin Meng #define FSP_GRAPHICS_INFO_HOB_GUID \
2734ff333b7SBin Meng 	{ \
2744ff333b7SBin Meng 	0x39f62cce, 0x6825, 0x4669, \
2754ff333b7SBin Meng 	{ 0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07 } \
2764ff333b7SBin Meng 	}
2774ff333b7SBin Meng 
2781021af4dSSimon Glass #endif
279