soc/intel/xeon_sp: Add memory type check utils
FSP memory type representations change across Xeon-SP SoCs. This patch adds type check utils to abstract the differences. TEST=intel/archercity CRB Change-Id: I2f5f3c0f16dc50bc739146e46afce2e5fbf4f62c Signed-off-by: Shuo Liu <shuo.liu@intel.com> Signed-off-by: Jincheng Li <jincheng.li@intel.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/80632 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
This commit is contained in:
		@@ -121,3 +121,18 @@ void get_iiostack_info(struct iiostack_resource *info)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool is_memtype_reserved(uint16_t mem_type)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return !!(mem_type & MEM_TYPE_RESERVED);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool is_memtype_non_volatile(uint16_t mem_type)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return !(mem_type & MEMTYPE_VOLATILE_MASK);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool is_memtype_processor_attached(uint16_t mem_type)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,6 +19,10 @@ bool soc_cpu_is_enabled(const size_t idx);
 | 
				
			|||||||
void set_bios_init_completion(void);
 | 
					void set_bios_init_completion(void);
 | 
				
			||||||
uint8_t soc_get_iio_ioapicid(int socket, int stack);
 | 
					uint8_t soc_get_iio_ioapicid(int socket, int stack);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool is_memtype_non_volatile(uint16_t mem_type);
 | 
				
			||||||
 | 
					bool is_memtype_reserved(uint16_t mem_type);
 | 
				
			||||||
 | 
					bool is_memtype_processor_attached(uint16_t mem_type);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct iiostack_resource {
 | 
					struct iiostack_resource {
 | 
				
			||||||
	uint8_t     no_of_stacks;
 | 
						uint8_t     no_of_stacks;
 | 
				
			||||||
	STACK_RES   res[CONFIG_MAX_SOCKET * MAX_IIO_STACK];
 | 
						STACK_RES   res[CONFIG_MAX_SOCKET * MAX_IIO_STACK];
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -195,3 +195,18 @@ uint8_t soc_get_iio_ioapicid(int socket, int stack)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	return ioapic_id;
 | 
						return ioapic_id;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool is_memtype_reserved(uint16_t mem_type)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return !!(mem_type & MEM_TYPE_RESERVED);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool is_memtype_non_volatile(uint16_t mem_type)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return !(mem_type & MEMTYPE_VOLATILE_MASK);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool is_memtype_processor_attached(uint16_t mem_type)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -167,3 +167,24 @@ void soc_set_mrc_cold_boot_flag(bool cold_boot_required)
 | 
				
			|||||||
		cmos_write(new_mrc_status, CMOS_OFFSET_MRC_STATUS);
 | 
							cmos_write(new_mrc_status, CMOS_OFFSET_MRC_STATUS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool is_memtype_reserved(uint16_t mem_type)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return !!(mem_type & MEM_TYPE_RESERVED);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool is_memtype_non_volatile(uint16_t mem_type)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return !(mem_type & MEMTYPE_VOLATILE_MASK);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool is_memtype_processor_attached(uint16_t mem_type)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						 * Refer to the definition of MEM_TYPE enum type in
 | 
				
			||||||
 | 
						 * vendorcode/intel/fsp/fsp2_0/sapphirerapids_sp/MemoryMapDataHob.h,
 | 
				
			||||||
 | 
						 * values less than MemTypeCxlAccVolatileMem represents
 | 
				
			||||||
 | 
						 * processor attached memory
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						return (mem_type < MemTypeCxlAccVolatileMem);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -99,19 +99,17 @@ static unsigned int get_srat_memory_entries(acpi_srat_mem_t *srat_mem)
 | 
				
			|||||||
			"ElementSize: 0x%x, type: %d, reserved: %d\n",
 | 
								"ElementSize: 0x%x, type: %d, reserved: %d\n",
 | 
				
			||||||
			e, addr, mem_element->BaseAddress, size,
 | 
								e, addr, mem_element->BaseAddress, size,
 | 
				
			||||||
			mem_element->ElementSize, mem_element->Type,
 | 
								mem_element->ElementSize, mem_element->Type,
 | 
				
			||||||
			(mem_element->Type & MEM_TYPE_RESERVED));
 | 
								is_memtype_reserved(mem_element->Type));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		assert(mmap_index < MAX_ACPI_MEMORY_AFFINITY_COUNT);
 | 
							assert(mmap_index < MAX_ACPI_MEMORY_AFFINITY_COUNT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* skip reserved memory region */
 | 
							/* skip reserved memory region */
 | 
				
			||||||
		if (mem_element->Type & MEM_TYPE_RESERVED)
 | 
							if (is_memtype_reserved(mem_element->Type))
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
#if CONFIG(SOC_INTEL_SAPPHIRERAPIDS_SP)
 | 
							/* skip all non processor attached memory regions */
 | 
				
			||||||
		/* Skip all non processor attached memory regions */
 | 
							if (CONFIG(SOC_INTEL_HAS_CXL) &&
 | 
				
			||||||
		/* In other words, skip all the types >= MemTypeCxlAccVolatileMem */
 | 
								(!is_memtype_processor_attached(mem_element->Type)))
 | 
				
			||||||
		if (mem_element->Type >= MemTypeCxlAccVolatileMem)
 | 
					 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* skip if this address is already added */
 | 
							/* skip if this address is already added */
 | 
				
			||||||
		bool skip = false;
 | 
							bool skip = false;
 | 
				
			||||||
@@ -134,7 +132,7 @@ static unsigned int get_srat_memory_entries(acpi_srat_mem_t *srat_mem)
 | 
				
			|||||||
		srat_mem[mmap_index].length_high = (uint32_t)(size >> 32);
 | 
							srat_mem[mmap_index].length_high = (uint32_t)(size >> 32);
 | 
				
			||||||
		srat_mem[mmap_index].proximity_domain = mem_element->SocketId;
 | 
							srat_mem[mmap_index].proximity_domain = mem_element->SocketId;
 | 
				
			||||||
		srat_mem[mmap_index].flags = ACPI_SRAT_MEMORY_ENABLED;
 | 
							srat_mem[mmap_index].flags = ACPI_SRAT_MEMORY_ENABLED;
 | 
				
			||||||
		if ((mem_element->Type & MEMTYPE_VOLATILE_MASK) == 0)
 | 
							if (is_memtype_non_volatile(mem_element->Type))
 | 
				
			||||||
			srat_mem[mmap_index].flags |= ACPI_SRAT_MEMORY_NONVOLATILE;
 | 
								srat_mem[mmap_index].flags |= ACPI_SRAT_MEMORY_NONVOLATILE;
 | 
				
			||||||
		++mmap_index;
 | 
							++mmap_index;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user