1 | /** @file
|
---|
2 | This code supports the implementation of the Smbios protocol
|
---|
3 |
|
---|
4 | Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR>
|
---|
5 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 |
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #ifndef _SMBIOS_DXE_H_
|
---|
10 | #define _SMBIOS_DXE_H_
|
---|
11 |
|
---|
12 | #include <PiDxe.h>
|
---|
13 |
|
---|
14 | #include <Protocol/Smbios.h>
|
---|
15 | #include <IndustryStandard/SmBios.h>
|
---|
16 | #include <Guid/EventGroup.h>
|
---|
17 | #include <Guid/SmBios.h>
|
---|
18 | #include <Library/DebugLib.h>
|
---|
19 | #include <Library/UefiDriverEntryPoint.h>
|
---|
20 | #include <Library/UefiLib.h>
|
---|
21 | #include <Library/BaseLib.h>
|
---|
22 | #include <Library/BaseMemoryLib.h>
|
---|
23 | #include <Library/MemoryAllocationLib.h>
|
---|
24 | #include <Library/UefiBootServicesTableLib.h>
|
---|
25 | #include <Library/PcdLib.h>
|
---|
26 | #include <Library/HobLib.h>
|
---|
27 | #include <UniversalPayload/SmbiosTable.h>
|
---|
28 |
|
---|
29 | #define SMBIOS_INSTANCE_SIGNATURE SIGNATURE_32 ('S', 'B', 'i', 's')
|
---|
30 | typedef struct {
|
---|
31 | UINT32 Signature;
|
---|
32 | EFI_HANDLE Handle;
|
---|
33 | //
|
---|
34 | // Produced protocol
|
---|
35 | //
|
---|
36 | EFI_SMBIOS_PROTOCOL Smbios;
|
---|
37 | //
|
---|
38 | // Updates to record list must be locked.
|
---|
39 | //
|
---|
40 | EFI_LOCK DataLock;
|
---|
41 | //
|
---|
42 | // List of EFI_SMBIOS_ENTRY structures.
|
---|
43 | //
|
---|
44 | LIST_ENTRY DataListHead;
|
---|
45 | //
|
---|
46 | // List of allocated SMBIOS handle.
|
---|
47 | //
|
---|
48 | LIST_ENTRY AllocatedHandleListHead;
|
---|
49 | } SMBIOS_INSTANCE;
|
---|
50 |
|
---|
51 | #define SMBIOS_INSTANCE_FROM_THIS(this) CR (this, SMBIOS_INSTANCE, Smbios, SMBIOS_INSTANCE_SIGNATURE)
|
---|
52 |
|
---|
53 | //
|
---|
54 | // SMBIOS record Header
|
---|
55 | //
|
---|
56 | // An SMBIOS internal Record is an EFI_SMBIOS_RECORD_HEADER followed by (RecordSize - HeaderSize) bytes of
|
---|
57 | // data. The format of the data is defined by the SMBIOS spec.
|
---|
58 | //
|
---|
59 | //
|
---|
60 | #define EFI_SMBIOS_RECORD_HEADER_VERSION 0x0100
|
---|
61 | typedef struct {
|
---|
62 | UINT16 Version;
|
---|
63 | UINT16 HeaderSize;
|
---|
64 | UINTN RecordSize;
|
---|
65 | EFI_HANDLE ProducerHandle;
|
---|
66 | UINTN NumberOfStrings;
|
---|
67 | } EFI_SMBIOS_RECORD_HEADER;
|
---|
68 |
|
---|
69 | //
|
---|
70 | // Private data structure to contain the SMBIOS record. One record per
|
---|
71 | // structure. SmbiosRecord is a copy of the data passed in and follows RecordHeader .
|
---|
72 | //
|
---|
73 | #define EFI_SMBIOS_ENTRY_SIGNATURE SIGNATURE_32 ('S', 'r', 'e', 'c')
|
---|
74 | typedef struct {
|
---|
75 | UINT32 Signature;
|
---|
76 | LIST_ENTRY Link;
|
---|
77 | EFI_SMBIOS_RECORD_HEADER *RecordHeader;
|
---|
78 | UINTN RecordSize;
|
---|
79 | //
|
---|
80 | // Indicate which table this record is added to.
|
---|
81 | //
|
---|
82 | BOOLEAN Smbios32BitTable;
|
---|
83 | BOOLEAN Smbios64BitTable;
|
---|
84 | } EFI_SMBIOS_ENTRY;
|
---|
85 |
|
---|
86 | #define SMBIOS_ENTRY_FROM_LINK(link) CR (link, EFI_SMBIOS_ENTRY, Link, EFI_SMBIOS_ENTRY_SIGNATURE)
|
---|
87 |
|
---|
88 | //
|
---|
89 | // Private data to contain the Smbios handle that already allocated.
|
---|
90 | //
|
---|
91 | #define SMBIOS_HANDLE_ENTRY_SIGNATURE SIGNATURE_32 ('S', 'h', 'r', 'd')
|
---|
92 |
|
---|
93 | typedef struct {
|
---|
94 | UINT32 Signature;
|
---|
95 | LIST_ENTRY Link;
|
---|
96 | //
|
---|
97 | // Filter driver will register what record guid filter should be used.
|
---|
98 | //
|
---|
99 | EFI_SMBIOS_HANDLE SmbiosHandle;
|
---|
100 | } SMBIOS_HANDLE_ENTRY;
|
---|
101 |
|
---|
102 | #define SMBIOS_HANDLE_ENTRY_FROM_LINK(link) CR (link, SMBIOS_HANDLE_ENTRY, Link, SMBIOS_HANDLE_ENTRY_SIGNATURE)
|
---|
103 |
|
---|
104 | typedef struct {
|
---|
105 | EFI_SMBIOS_TABLE_HEADER Header;
|
---|
106 | UINT8 Tailing[2];
|
---|
107 | } EFI_SMBIOS_TABLE_END_STRUCTURE;
|
---|
108 |
|
---|
109 | /**
|
---|
110 | Create Smbios Table and installs the Smbios Table to the System Table.
|
---|
111 |
|
---|
112 | @param Smbios32BitTable The flag to update 32-bit table.
|
---|
113 | @param Smbios64BitTable The flag to update 64-bit table.
|
---|
114 |
|
---|
115 | **/
|
---|
116 | VOID
|
---|
117 | EFIAPI
|
---|
118 | SmbiosTableConstruction (
|
---|
119 | BOOLEAN Smbios32BitTable,
|
---|
120 | BOOLEAN Smbios64BitTable
|
---|
121 | );
|
---|
122 |
|
---|
123 | /**
|
---|
124 | Validates a SMBIOS 3.0 table entry point.
|
---|
125 |
|
---|
126 | @param TableEntry The SmBios table entry to validate.
|
---|
127 | @param TableAddress On exit, point to the smbios table addres.
|
---|
128 | @param TableMaximumSize On exit, point to the maximum size of the table.
|
---|
129 |
|
---|
130 | @retval TRUE SMBIOS table entry point is valid.
|
---|
131 | @retval FALSE SMBIOS table entry point is malformed.
|
---|
132 |
|
---|
133 | **/
|
---|
134 | STATIC
|
---|
135 | BOOLEAN
|
---|
136 | IsValidSmbios30Table (
|
---|
137 | IN VOID *TableEntry,
|
---|
138 | OUT VOID **TableAddress,
|
---|
139 | OUT UINTN *TableMaximumSize,
|
---|
140 | OUT UINT8 *MajorVersion,
|
---|
141 | OUT UINT8 *MinorVersion
|
---|
142 | );
|
---|
143 |
|
---|
144 | /**
|
---|
145 | Validates a SMBIOS 2.0 table entry point.
|
---|
146 |
|
---|
147 | @param TableEntry The SmBios table entry to validate.
|
---|
148 | @param TableAddress On exit, point to the smbios table addres.
|
---|
149 | @param TableMaximumSize On exit, point to the maximum size of the table.
|
---|
150 |
|
---|
151 | @retval TRUE SMBIOS table entry point is valid.
|
---|
152 | @retval FALSE SMBIOS table entry point is malformed.
|
---|
153 |
|
---|
154 | **/
|
---|
155 | STATIC
|
---|
156 | BOOLEAN
|
---|
157 | IsValidSmbios20Table (
|
---|
158 | IN VOID *TableEntry,
|
---|
159 | OUT VOID **TableAddress,
|
---|
160 | OUT UINTN *TableMaximumSize,
|
---|
161 | OUT UINT8 *MajorVersion,
|
---|
162 | OUT UINT8 *MinorVersion
|
---|
163 | );
|
---|
164 |
|
---|
165 | /**
|
---|
166 | Validates a SMBIOS table entry point.
|
---|
167 |
|
---|
168 | @param TableEntry The SmBios table entry to validate.
|
---|
169 | @param TableAddress On exit, point to the smbios table addres.
|
---|
170 | @param TableMaximumSize On exit, point to the maximum size of the table.
|
---|
171 |
|
---|
172 | @retval TRUE SMBIOS table entry point is valid.
|
---|
173 | @retval FALSE SMBIOS table entry point is malformed.
|
---|
174 |
|
---|
175 | **/
|
---|
176 | typedef
|
---|
177 | BOOLEAN
|
---|
178 | (*IS_SMBIOS_TABLE_VALID) (
|
---|
179 | IN VOID *TableEntry,
|
---|
180 | OUT VOID **TableAddress,
|
---|
181 | OUT UINTN *TableMaximumSize,
|
---|
182 | OUT UINT8 *MajorVersion,
|
---|
183 | OUT UINT8 *MinorVersion
|
---|
184 | );
|
---|
185 | typedef struct {
|
---|
186 | EFI_GUID *Guid;
|
---|
187 | IS_SMBIOS_TABLE_VALID IsValid;
|
---|
188 | } IS_SMBIOS_TABLE_VALID_ENTRY;
|
---|
189 |
|
---|
190 | #endif
|
---|