xref: /rk3399_rockchip-uboot/arch/x86/include/asm/fsp/fsp_hob.h (revision beb4d65e92ad091aefb1b5579ed839782ecb2008)
11021af4dSSimon Glass /*
21021af4dSSimon Glass  * Copyright (C) 2013, Intel Corporation
31021af4dSSimon Glass  * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
41021af4dSSimon Glass  *
51021af4dSSimon Glass  * SPDX-License-Identifier:	Intel
61021af4dSSimon Glass  */
71021af4dSSimon Glass 
81021af4dSSimon Glass #ifndef __FSP_HOB_H__
91021af4dSSimon Glass #define __FSP_HOB_H__
101021af4dSSimon Glass 
11867a6ac8SSimon Glass #include <efi.h>
12867a6ac8SSimon Glass 
131021af4dSSimon Glass /* Type of HOB Header */
141021af4dSSimon Glass #define HOB_TYPE_MEM_ALLOC	0x0002
151021af4dSSimon Glass #define HOB_TYPE_RES_DESC	0x0003
161021af4dSSimon Glass #define HOB_TYPE_GUID_EXT	0x0004
171021af4dSSimon Glass #define HOB_TYPE_UNUSED		0xFFFE
181021af4dSSimon Glass #define HOB_TYPE_EOH		0xFFFF
191021af4dSSimon Glass 
201021af4dSSimon Glass /*
211021af4dSSimon Glass  * Describes the format and size of the data inside the HOB.
221021af4dSSimon Glass  * All HOBs must contain this generic HOB header.
231021af4dSSimon Glass  */
241021af4dSSimon Glass struct hob_header {
251021af4dSSimon Glass 	u16	type;		/* HOB type */
261021af4dSSimon Glass 	u16	len;		/* HOB length */
271021af4dSSimon Glass 	u32	reserved;	/* always zero */
281021af4dSSimon Glass };
291021af4dSSimon Glass 
301021af4dSSimon Glass /*
311021af4dSSimon Glass  * Describes all memory ranges used during the HOB producer phase that
321021af4dSSimon Glass  * exist outside the HOB list. This HOB type describes how memory is used,
331021af4dSSimon Glass  * not the physical attributes of memory.
341021af4dSSimon Glass  */
351021af4dSSimon Glass struct hob_mem_alloc {
361021af4dSSimon Glass 	struct hob_header	hdr;
371021af4dSSimon Glass 	/*
381021af4dSSimon Glass 	 * A GUID that defines the memory allocation region's type and purpose,
391021af4dSSimon Glass 	 * as well as other fields within the memory allocation HOB. This GUID
401021af4dSSimon Glass 	 * is used to define the additional data within the HOB that may be
411021af4dSSimon Glass 	 * present for the memory allocation HOB. Type efi_guid is defined in
421021af4dSSimon Glass 	 * InstallProtocolInterface() in the UEFI 2.0 specification.
431021af4dSSimon Glass 	 */
441021af4dSSimon Glass 	struct efi_guid		name;
451021af4dSSimon Glass 	/*
461021af4dSSimon Glass 	 * The base address of memory allocated by this HOB.
471021af4dSSimon Glass 	 * Type phys_addr_t is defined in AllocatePages() in the UEFI 2.0
481021af4dSSimon Glass 	 * specification.
491021af4dSSimon Glass 	 */
501021af4dSSimon Glass 	phys_addr_t		mem_base;
511021af4dSSimon Glass 	/* The length in bytes of memory allocated by this HOB */
521021af4dSSimon Glass 	phys_size_t		mem_len;
531021af4dSSimon Glass 	/*
541021af4dSSimon Glass 	 * Defines the type of memory allocated by this HOB.
551021af4dSSimon Glass 	 * The memory type definition follows the EFI_MEMORY_TYPE definition.
561021af4dSSimon Glass 	 * Type EFI_MEMORY_TYPE is defined in AllocatePages() in the UEFI 2.0
571021af4dSSimon Glass 	 * specification.
581021af4dSSimon Glass 	 */
591021af4dSSimon Glass 	enum efi_mem_type	mem_type;
601021af4dSSimon Glass 	/* padding */
611021af4dSSimon Glass 	u8			reserved[4];
621021af4dSSimon Glass };
631021af4dSSimon Glass 
641021af4dSSimon Glass /* Value of ResourceType in HOB_RES_DESC */
651021af4dSSimon Glass #define RES_SYS_MEM		0x00000000
661021af4dSSimon Glass #define RES_MMAP_IO		0x00000001
671021af4dSSimon Glass #define RES_IO			0x00000002
681021af4dSSimon Glass #define RES_FW_DEVICE		0x00000003
691021af4dSSimon Glass #define RES_MMAP_IO_PORT	0x00000004
701021af4dSSimon Glass #define RES_MEM_RESERVED	0x00000005
711021af4dSSimon Glass #define RES_IO_RESERVED		0x00000006
721021af4dSSimon Glass #define RES_MAX_MEM_TYPE	0x00000007
731021af4dSSimon Glass 
741021af4dSSimon Glass /*
751021af4dSSimon Glass  * These types can be ORed together as needed.
761021af4dSSimon Glass  *
771021af4dSSimon Glass  * The first three enumerations describe settings
781021af4dSSimon Glass  * The rest of the settings describe capabilities
791021af4dSSimon Glass  */
801021af4dSSimon Glass #define RES_ATTR_PRESENT			0x00000001
811021af4dSSimon Glass #define RES_ATTR_INITIALIZED			0x00000002
821021af4dSSimon Glass #define RES_ATTR_TESTED				0x00000004
831021af4dSSimon Glass #define RES_ATTR_SINGLE_BIT_ECC			0x00000008
841021af4dSSimon Glass #define RES_ATTR_MULTIPLE_BIT_ECC		0x00000010
851021af4dSSimon Glass #define RES_ATTR_ECC_RESERVED_1			0x00000020
861021af4dSSimon Glass #define RES_ATTR_ECC_RESERVED_2			0x00000040
871021af4dSSimon Glass #define RES_ATTR_READ_PROTECTED			0x00000080
881021af4dSSimon Glass #define RES_ATTR_WRITE_PROTECTED		0x00000100
891021af4dSSimon Glass #define RES_ATTR_EXECUTION_PROTECTED		0x00000200
901021af4dSSimon Glass #define RES_ATTR_UNCACHEABLE			0x00000400
911021af4dSSimon Glass #define RES_ATTR_WRITE_COMBINEABLE		0x00000800
921021af4dSSimon Glass #define RES_ATTR_WRITE_THROUGH_CACHEABLE	0x00001000
931021af4dSSimon Glass #define RES_ATTR_WRITE_BACK_CACHEABLE		0x00002000
941021af4dSSimon Glass #define RES_ATTR_16_BIT_IO			0x00004000
951021af4dSSimon Glass #define RES_ATTR_32_BIT_IO			0x00008000
961021af4dSSimon Glass #define RES_ATTR_64_BIT_IO			0x00010000
971021af4dSSimon Glass #define RES_ATTR_UNCACHED_EXPORTED		0x00020000
981021af4dSSimon Glass 
991021af4dSSimon Glass /*
1001021af4dSSimon Glass  * Describes the resource properties of all fixed, nonrelocatable resource
1011021af4dSSimon Glass  * ranges found on the processor host bus during the HOB producer phase.
1021021af4dSSimon Glass  */
1031021af4dSSimon Glass struct hob_res_desc {
1041021af4dSSimon Glass 	struct hob_header	hdr;
1051021af4dSSimon Glass 	/*
1061021af4dSSimon Glass 	 * A GUID representing the owner of the resource. This GUID is
1071021af4dSSimon Glass 	 * used by HOB consumer phase components to correlate device
1081021af4dSSimon Glass 	 * ownership of a resource.
1091021af4dSSimon Glass 	 */
1101021af4dSSimon Glass 	struct efi_guid		owner;
1111021af4dSSimon Glass 	u32			type;
1121021af4dSSimon Glass 	u32			attr;
1131021af4dSSimon Glass 	/* The physical start address of the resource region */
1141021af4dSSimon Glass 	phys_addr_t		phys_start;
1151021af4dSSimon Glass 	/* The number of bytes of the resource region */
1161021af4dSSimon Glass 	phys_size_t		len;
1171021af4dSSimon Glass };
1181021af4dSSimon Glass 
1191021af4dSSimon Glass /*
1201021af4dSSimon Glass  * Allows writers of executable content in the HOB producer phase to
1211021af4dSSimon Glass  * maintain and manage HOBs with specific GUID.
1221021af4dSSimon Glass  */
1231021af4dSSimon Glass struct hob_guid {
1241021af4dSSimon Glass 	struct hob_header	hdr;
1251021af4dSSimon Glass 	/* A GUID that defines the contents of this HOB */
1261021af4dSSimon Glass 	struct efi_guid		name;
1271021af4dSSimon Glass 	/* GUID specific data goes here */
1281021af4dSSimon Glass };
1291021af4dSSimon Glass 
1301021af4dSSimon Glass /**
1311021af4dSSimon Glass  * get_next_hob() - return a pointer to the next HOB in the HOB list
1321021af4dSSimon Glass  *
1331021af4dSSimon Glass  * This macro returns a pointer to HOB that follows the HOB specified by hob
1341021af4dSSimon Glass  * in the HOB List.
1351021af4dSSimon Glass  *
1361021af4dSSimon Glass  * @hdr:    A pointer to a HOB.
1371021af4dSSimon Glass  *
1381021af4dSSimon Glass  * @return: A pointer to the next HOB in the HOB list.
1391021af4dSSimon Glass  */
get_next_hob(const struct hob_header * hdr)1401021af4dSSimon Glass static inline const struct hob_header *get_next_hob(const struct hob_header *hdr)
1411021af4dSSimon Glass {
142*beb4d65eSSimon Glass 	return (const struct hob_header *)((uintptr_t)hdr + hdr->len);
1431021af4dSSimon Glass }
1441021af4dSSimon Glass 
1451021af4dSSimon Glass /**
1461021af4dSSimon Glass  * end_of_hob() - determine if a HOB is the last HOB in the HOB list
1471021af4dSSimon Glass  *
1481021af4dSSimon Glass  * This macro determine if the HOB specified by hob is the last HOB in the
1491021af4dSSimon Glass  * HOB list.  If hob is last HOB in the HOB list, then true is returned.
1501021af4dSSimon Glass  * Otherwise, false is returned.
1511021af4dSSimon Glass  *
1521021af4dSSimon Glass  * @hdr:          A pointer to a HOB.
1531021af4dSSimon Glass  *
1541021af4dSSimon Glass  * @retval true:  The HOB specified by hdr is the last HOB in the HOB list.
1551021af4dSSimon Glass  * @retval false: The HOB specified by hdr is not the last HOB in the HOB list.
1561021af4dSSimon Glass  */
end_of_hob(const struct hob_header * hdr)1571021af4dSSimon Glass static inline bool end_of_hob(const struct hob_header *hdr)
1581021af4dSSimon Glass {
1591021af4dSSimon Glass 	return hdr->type == HOB_TYPE_EOH;
1601021af4dSSimon Glass }
1611021af4dSSimon Glass 
1621021af4dSSimon Glass /**
1631021af4dSSimon Glass  * get_guid_hob_data() - return a pointer to data buffer from a HOB of
1641021af4dSSimon Glass  *                       type HOB_TYPE_GUID_EXT
1651021af4dSSimon Glass  *
1661021af4dSSimon Glass  * This macro returns a pointer to the data buffer in a HOB specified by hob.
1671021af4dSSimon Glass  * hob is assumed to be a HOB of type HOB_TYPE_GUID_EXT.
1681021af4dSSimon Glass  *
1691021af4dSSimon Glass  * @hdr:    A pointer to a HOB.
1701021af4dSSimon Glass  *
1711021af4dSSimon Glass  * @return: A pointer to the data buffer in a HOB.
1721021af4dSSimon Glass  */
get_guid_hob_data(const struct hob_header * hdr)1731021af4dSSimon Glass static inline void *get_guid_hob_data(const struct hob_header *hdr)
1741021af4dSSimon Glass {
175*beb4d65eSSimon Glass 	return (void *)((uintptr_t)hdr + sizeof(struct hob_guid));
1761021af4dSSimon Glass }
1771021af4dSSimon Glass 
1781021af4dSSimon Glass /**
1791021af4dSSimon Glass  * get_guid_hob_data_size() - return the size of the data buffer from a HOB
1801021af4dSSimon Glass  *                            of type HOB_TYPE_GUID_EXT
1811021af4dSSimon Glass  *
1821021af4dSSimon Glass  * This macro returns the size, in bytes, of the data buffer in a HOB
1831021af4dSSimon Glass  * specified by hob. hob is assumed to be a HOB of type HOB_TYPE_GUID_EXT.
1841021af4dSSimon Glass  *
1851021af4dSSimon Glass  * @hdr:    A pointer to a HOB.
1861021af4dSSimon Glass  *
1871021af4dSSimon Glass  * @return: The size of the data buffer.
1881021af4dSSimon Glass  */
get_guid_hob_data_size(const struct hob_header * hdr)1891021af4dSSimon Glass static inline u16 get_guid_hob_data_size(const struct hob_header *hdr)
1901021af4dSSimon Glass {
1911021af4dSSimon Glass 	return hdr->len - sizeof(struct hob_guid);
1921021af4dSSimon Glass }
1931021af4dSSimon Glass 
1941021af4dSSimon Glass /* FSP specific GUID HOB definitions */
1951021af4dSSimon Glass #define FSP_GUID_DATA1		0x912740be
1961021af4dSSimon Glass #define FSP_GUID_DATA2		0x2284
1971021af4dSSimon Glass #define FSP_GUID_DATA3		0x4734
1981021af4dSSimon Glass #define FSP_GUID_DATA4_0	0xb9
1991021af4dSSimon Glass #define FSP_GUID_DATA4_1	0x71
2001021af4dSSimon Glass #define FSP_GUID_DATA4_2	0x84
2011021af4dSSimon Glass #define FSP_GUID_DATA4_3	0xb0
2021021af4dSSimon Glass #define FSP_GUID_DATA4_4	0x27
2031021af4dSSimon Glass #define FSP_GUID_DATA4_5	0x35
2041021af4dSSimon Glass #define FSP_GUID_DATA4_6	0x3f
2051021af4dSSimon Glass #define FSP_GUID_DATA4_7	0x0c
2061021af4dSSimon Glass 
2071021af4dSSimon Glass #define FSP_HEADER_GUID \
2081021af4dSSimon Glass 	{ \
2091021af4dSSimon Glass 	FSP_GUID_DATA1, FSP_GUID_DATA2, FSP_GUID_DATA3, \
2101021af4dSSimon Glass 	{ FSP_GUID_DATA4_0, FSP_GUID_DATA4_1, FSP_GUID_DATA4_2, \
2111021af4dSSimon Glass 	  FSP_GUID_DATA4_3, FSP_GUID_DATA4_4, FSP_GUID_DATA4_5, \
2121021af4dSSimon Glass 	  FSP_GUID_DATA4_6, FSP_GUID_DATA4_7 } \
2131021af4dSSimon Glass 	}
2141021af4dSSimon Glass 
2151021af4dSSimon Glass #define FSP_NON_VOLATILE_STORAGE_HOB_GUID \
2161021af4dSSimon Glass 	{ \
2171021af4dSSimon Glass 	0x721acf02, 0x4d77, 0x4c2a, \
2181021af4dSSimon Glass 	{ 0xb3, 0xdc, 0x27, 0xb, 0x7b, 0xa9, 0xe4, 0xb0 } \
2191021af4dSSimon Glass 	}
2201021af4dSSimon Glass 
2211021af4dSSimon Glass #define FSP_BOOTLOADER_TEMP_MEM_HOB_GUID \
2221021af4dSSimon Glass 	{ \
2231021af4dSSimon Glass 	0xbbcff46c, 0xc8d3, 0x4113, \
2241021af4dSSimon Glass 	{ 0x89, 0x85, 0xb9, 0xd4, 0xf3, 0xb3, 0xf6, 0x4e } \
2251021af4dSSimon Glass 	}
2261021af4dSSimon Glass 
2271021af4dSSimon Glass #define FSP_HOB_RESOURCE_OWNER_FSP_GUID \
2281021af4dSSimon Glass 	{ \
2291021af4dSSimon Glass 	0x69a79759, 0x1373, 0x4367, \
2301021af4dSSimon Glass 	{ 0xa6, 0xc4, 0xc7, 0xf5, 0x9e, 0xfd, 0x98, 0x6e } \
2311021af4dSSimon Glass 	}
2321021af4dSSimon Glass 
2331021af4dSSimon Glass #define FSP_HOB_RESOURCE_OWNER_TSEG_GUID \
2341021af4dSSimon Glass 	{ \
2351021af4dSSimon Glass 	0xd038747c, 0xd00c, 0x4980, \
2361021af4dSSimon Glass 	{ 0xb3, 0x19, 0x49, 0x01, 0x99, 0xa4, 0x7d, 0x55 } \
2371021af4dSSimon Glass 	}
2381021af4dSSimon Glass 
2391021af4dSSimon Glass #define FSP_HOB_RESOURCE_OWNER_GRAPHICS_GUID \
2401021af4dSSimon Glass 	{ \
2411021af4dSSimon Glass 	0x9c7c3aa7, 0x5332, 0x4917, \
2421021af4dSSimon Glass 	{ 0x82, 0xb9, 0x56, 0xa5, 0xf3, 0xe6, 0x2a, 0x07 } \
2431021af4dSSimon Glass 	}
2441021af4dSSimon Glass 
2451021af4dSSimon Glass #endif
246