1 /*
2  * Copyright (C) 2021-2022 Intel Corporation.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef QUIRKS_SMBIOS_H
8 #define QUIRKS_SMBIOS_H
9 
10 #include <asm/guest/vm.h>
11 #include <boot.h>
12 
13 typedef struct {
14     uint32_t  Data1;
15     uint16_t  Data2;
16     uint16_t  Data3;
17     uint8_t   Data4[8];
18 } EFI_GUID;
19 
20 typedef struct _EFI_CONFIGURATION_TABLE {
21     EFI_GUID VendorGuid;
22     void *VendorTable;
23 } EFI_CONFIGURATION_TABLE;
24 
25 typedef struct _EFI_TABLE_HEADER {
26     uint64_t Signature;
27     uint32_t Revision;
28     uint32_t HeaderSize;
29     uint32_t CRC32;
30     uint32_t Reserved;
31 } EFI_TABLE_HEADER;
32 
33 typedef struct _EFI_SYSTEM_TABLE {
34     EFI_TABLE_HEADER Hdr;
35     uint16_t *FirmwareVendor;
36     uint32_t FirmwareRevision;
37     void *ConsoleInHandle;
38     void *ConIn;
39     void *ConsoleOutHandle;
40     void *ConOut;
41     void *StandardErrorHandle;
42     void *StdErr;
43     void *RuntimeServices;
44     void *BootServices;
45     uint64_t NumberOfTableEntries;
46     EFI_CONFIGURATION_TABLE *ConfigurationTable;
47 } EFI_SYSTEM_TABLE;
48 
49 struct smbios2_entry_point {
50     char anchor[4];			/* "_SM_" */
51 	uint8_t checksum;		/* covers the entire struct */
52 	uint8_t length;			/* length of this entry point structure, currently 1Fh */
53 	uint8_t major_ver;		/* version major */
54 	uint8_t minor_ver;		/* version minor */
55 	uint16_t max_struct_size;	/* size of the largest SMBIOS structure */
56 	uint8_t ep_rev;			/* entry point structure revision */
57 	uint8_t formatted[5];
58 	char int_anchor[5];		/* "_DMI_" */
59 	uint8_t int_checksum;	/* intermediate checksum, covers from start of int_anchor to bcd_revision */
60 	uint16_t st_length;		/* total length of SMBIOS structure table */
61 	uint32_t st_addr;		/* structure table address */
62 	uint16_t nstructs;		/* number of SMBIOS structures */
63 	uint8_t bcd_revision;	/* BCD revision */
64 } __attribute__((packed));
65 
66 struct smbios3_entry_point {
67     char anchor[5];			/* "_SM3_" */
68 	uint8_t checksum;
69 	uint8_t length;			/* length of this entry point structure, currently 18h */
70 	uint8_t major_ver;
71 	uint8_t minor_ver;
72 	uint8_t docrev;
73 	uint8_t ep_rev;
74 	uint8_t reserved;
75 	uint32_t max_st_size;	/* max structure table size. The actual size is guaranteed to be <= this value. */
76 	uint64_t st_addr;		/* structure table address */
77 } __attribute__((packed));
78 
79 #define SMBIOS2_TABLE_GUID {0xeb9d2d31, 0x2d88, 0x11d3, {0x9a,0x16,0x00,0x90,0x27,0x3f,0xc1,0x4d}}
80 #define SMBIOS3_TABLE_GUID {0xf2fd1544, 0x9794, 0x4a2c, {0x99,0x2e,0xe5,0xbb,0xcf,0x20,0xe3,0x94}}
81 
82 #endif
83