coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
report_platform.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <arch/cpu.h>
5 #include <cpu/intel/microcode.h>
6 #include <string.h>
8 #include <device/pci_ops.h>
9 #include <cpu/x86/msr.h>
10 #include "haswell.h"
11 
12 static void report_cpu_info(void)
13 {
14  struct cpuid_result cpuidr;
15  u32 i, index, cpu_id, cpu_feature_flag;
16  char cpu_string[50], *cpu_name = cpu_string; /* 48 bytes are reported */
17  int vt, txt, aes;
18  const char *mode[] = {"NOT ", ""};
19 
20  index = 0x80000000;
21  cpuidr = cpuid(index);
22  if (cpuidr.eax < 0x80000004) {
23  strcpy(cpu_string, "Platform info not available");
24  } else {
25  u32 *p = (u32*) cpu_string;
26  for (i = 2; i <= 4; i++) {
27  cpuidr = cpuid(index + i);
28  *p++ = cpuidr.eax;
29  *p++ = cpuidr.ebx;
30  *p++ = cpuidr.ecx;
31  *p++ = cpuidr.edx;
32  }
33  }
34  /* Skip leading spaces in CPU name string */
35  while (cpu_name[0] == ' ')
36  cpu_name++;
37 
39  printk(BIOS_DEBUG, "CPU id(%x) ucode:%08x %s\n", cpu_id,
40  get_current_microcode_rev(), cpu_name);
41 
42  cpu_feature_flag = cpu_get_feature_flags_ecx();
43  aes = (cpu_feature_flag & CPUID_AES) ? 1 : 0;
44  txt = (cpu_feature_flag & CPUID_SMX) ? 1 : 0;
45  vt = (cpu_feature_flag & CPUID_VMX) ? 1 : 0;
46  printk(BIOS_DEBUG, "AES %ssupported, TXT %ssupported, VT %ssupported\n",
47  mode[aes], mode[txt], mode[vt]);
48 }
49 
50 /* The PCI id name match comes from Intel document 472178 */
51 static struct {
53  const char *dev_name;
54 } pch_table [] = {
55  {0x8c41, "Mobile Engineering Sample"},
56  {0x8c42, "Desktop Engineering Sample"},
57  {0x8c44, "Z87"},
58  {0x8c46, "Z85"},
59  {0x8c49, "HM86"},
60  {0x8c4a, "H87"},
61  {0x8c4b, "HM87"},
62  {0x8c4c, "Q85"},
63  {0x8c4e, "Q87"},
64  {0x8c4f, "QM87"},
65  {0x8c50, "B85"},
66  {0x8c52, "C222"},
67  {0x8c54, "C224"},
68  {0x8c56, "C226"},
69  {0x8c5c, "H81"},
70  {0x9c41, "LP Full Featured Engineering Sample"},
71  {0x9c43, "LP Premium"},
72  {0x9c45, "LP Mainstream"},
73  {0x9c47, "LP Value"},
74 };
75 
76 static void report_pch_info(void)
77 {
78  int i;
80 
81  const char *pch_type = "Unknown";
82  for (i = 0; i < ARRAY_SIZE(pch_table); i++) {
83  if (pch_table[i].dev_id == dev_id) {
84  pch_type = pch_table[i].dev_name;
85  break;
86  }
87  }
88  printk (BIOS_DEBUG, "PCH type: %s, device id: %x, rev id %x\n",
90 }
91 
93 {
96 }
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define printk(level,...)
Definition: stdlib.h:16
uint32_t cpu_get_feature_flags_ecx(void)
Definition: cpu_common.c:72
uint32_t cpu_get_cpuid(void)
Definition: cpu_common.c:63
#define CPUID_AES
Definition: msr.h:28
#define CPUID_VMX
Definition: msr.h:24
#define CPUID_SMX
Definition: msr.h:25
static __always_inline u16 pci_read_config16(const struct device *dev, u16 reg)
Definition: pci_ops.h:52
static __always_inline u8 pci_read_config8(const struct device *dev, u16 reg)
Definition: pci_ops.h:46
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
uint32_t get_current_microcode_rev(void)
Definition: microcode.c:112
void report_platform_info(void)
u16 dev_id
static struct @323 pch_table[]
static void report_pch_info(void)
const char * dev_name
static void report_cpu_info(void)
u32 cpuid
unsigned int cpu_id
Definition: chip.h:47
u16 pch_type(void)
Definition: pch.c:20
#define PCH_LPC_DEV
Definition: lpc.h:7
uint32_t u32
Definition: stdint.h:51
uint16_t u16
Definition: stdint.h:48
char * strcpy(char *dst, const char *src)
Definition: string.c:92
uint32_t ecx
Definition: cpu.h:32
uint32_t ebx
Definition: cpu.h:31
uint32_t edx
Definition: cpu.h:33
uint32_t eax
Definition: cpu.h:30