soc/intel/pantherlake: Remove soc_info.[hc] interface
[coreboot2.git] / src / soc / intel / common / block / acpi / sgx.c
blob4d2bab52f92d531a29be410d8a8f6269e5240ec2
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <acpi/acpigen.h>
4 #include <console/console.h>
5 #include <cpu/cpu.h>
6 #include <intelblocks/acpi.h>
7 #include <intelblocks/sgx.h>
9 #define SGX_RESOURCE_ENUM_CPUID_LEAF 0x12
10 #define SGX_RESOURCE_ENUM_CPUID_SUBLEAF 0x2
11 #define SGX_RESOURCE_ENUM_BIT 0x1
12 #define SGX_RESOURCE_MASK_LO 0xfffff000UL
13 #define SGX_RESOURCE_MASK_HI 0xfffffUL
15 static inline uint64_t sgx_resource(uint32_t low, uint32_t high)
17 uint64_t val;
18 val = (uint64_t)(high & SGX_RESOURCE_MASK_HI) << 32;
19 val |= low & SGX_RESOURCE_MASK_LO;
20 return val;
23 void sgx_fill_ssdt(void)
25 bool epcs = false;
26 struct cpuid_result cpuid_regs;
27 uint64_t emna = 0, elng = 0;
29 if (is_sgx_supported()) {
31 * Get EPC base and size.
32 * Intel SDM: Table 36-6. CPUID Leaf 12H, Sub-Leaf Index 2 or
33 * higher for enumeration of SGX resources
35 cpuid_regs = cpuid_ext(SGX_RESOURCE_ENUM_CPUID_LEAF,
36 SGX_RESOURCE_ENUM_CPUID_SUBLEAF);
38 if (cpuid_regs.eax & SGX_RESOURCE_ENUM_BIT) {
39 /* EPC section enumerated */
40 epcs = true;
41 emna = sgx_resource(cpuid_regs.eax, cpuid_regs.ebx);
42 elng = sgx_resource(cpuid_regs.ecx, cpuid_regs.edx);
45 printk(BIOS_DEBUG, "SGX: EPC status = %d base = 0x%llx len = 0x%llx\n",
46 epcs, emna, elng);
47 } else {
48 printk(BIOS_DEBUG, "SGX: not supported.\n");
51 acpigen_write_scope("\\_SB.EPC");
53 acpigen_write_name_byte("EPCS", epcs);
54 acpigen_write_name_qword("EMNA", emna);
55 acpigen_write_name_qword("ELNG", elng);
57 acpigen_pop_len();