]> git.proxmox.com Git - mirror_edk2.git/blob - EmulatorPkg/Include/Library/SmbiosLib.h
EmulatorPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / EmulatorPkg / Include / Library / SmbiosLib.h
1 /** @file
2 Provides library functions for common SMBIOS operations. Only available to DXE
3 and UEFI module types.
4
5
6 Copyright (c) 2012, Apple Inc. All rights reserved.
7 Portitions Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
9
10 **/
11
12 #ifndef _SMBIOS_LIB_H__
13 #define _SMBIOS_LIB_H__
14
15 #include <IndustryStandard/SmBios.h>
16 #include <Protocol/Smbios.h>
17
18
19 ///
20 /// Cache copy of the SMBIOS Protocol pointer
21 ///
22 extern EFI_SMBIOS_PROTOCOL *gSmbios;
23
24
25 ///
26 /// Template for SMBIOS table initialization.
27 /// The SMBIOS_TABLE_STRING types in the formated area must match the
28 /// StringArray sequene.
29 ///
30 typedef struct {
31 //
32 // formatted area of a given SMBIOS record
33 //
34 SMBIOS_STRUCTURE *Entry;
35 //
36 // NULL terminated array of ASCII strings to be added to the SMBIOS record.
37 //
38 CHAR8 **StringArray;
39 } SMBIOS_TEMPLATE_ENTRY;
40
41
42 /**
43 Create an initial SMBIOS Table from an array of SMBIOS_TEMPLATE_ENTRY
44 entries. SMBIOS_TEMPLATE_ENTRY.NULL indicates the end of the table.
45
46 @param Template Array of SMBIOS_TEMPLATE_ENTRY entries.
47
48 @retval EFI_SUCCESS New SMBIOS tables were created.
49 @retval EFI_OUT_OF_RESOURCES New SMBIOS tables were not created.
50 **/
51 EFI_STATUS
52 EFIAPI
53 SmbiosLibInitializeFromTemplate (
54 IN SMBIOS_TEMPLATE_ENTRY *Template
55 );
56
57
58
59 /**
60 Create SMBIOS record.
61
62 Converts a fixed SMBIOS structure and an array of pointers to strings into
63 an SMBIOS record where the strings are cat'ed on the end of the fixed record
64 and terminated via a double NULL and add to SMBIOS table.
65
66 SMBIOS_TABLE_TYPE32 gSmbiosType12 = {
67 { EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS, sizeof (SMBIOS_TABLE_TYPE12), 0 },
68 1 // StringCount
69 };
70 CHAR8 *gSmbiosType12Strings[] = {
71 "Not Found",
72 NULL
73 };
74
75 ...
76 AddSmbiosEntryFromTemplate (
77 (EFI_SMBIOS_TABLE_HEADER*)&gSmbiosType12,
78 gSmbiosType12Strings
79 );
80
81 @param SmbiosEntry Fixed SMBIOS structure
82 @param StringArray Array of strings to convert to an SMBIOS string pack.
83 NULL is OK.
84
85 @retval EFI_SUCCESS New SmbiosEntry was added to SMBIOS table.
86 @retval EFI_OUT_OF_RESOURCES SmbiosEntry was not added.
87 **/
88 EFI_STATUS
89 EFIAPI
90 SmbiosLibCreateEntry (
91 IN SMBIOS_STRUCTURE *SmbiosEntry,
92 IN CHAR8 **StringArray
93 );
94
95
96 /**
97 Update the string associated with an existing SMBIOS record.
98
99 This function allows the update of specific SMBIOS strings. The number of valid strings for any
100 SMBIOS record is defined by how many strings were present when Add() was called.
101
102 @param[in] SmbiosHandle SMBIOS Handle of structure that will have its string updated.
103 @param[in] StringNumber The non-zero string number of the string to update.
104 @param[in] String Update the StringNumber string with String.
105
106 @retval EFI_SUCCESS SmbiosHandle had its StringNumber String updated.
107 @retval EFI_INVALID_PARAMETER SmbiosHandle does not exist. Or String is invalid.
108 @retval EFI_UNSUPPORTED String was not added because it is longer than the SMBIOS Table supports.
109 @retval EFI_NOT_FOUND The StringNumber.is not valid for this SMBIOS record.
110 **/
111 EFI_STATUS
112 EFIAPI
113 SmbiosLibUpdateString (
114 IN EFI_SMBIOS_HANDLE SmbiosHandle,
115 IN SMBIOS_TABLE_STRING StringNumber,
116 IN CHAR8 *String
117 );
118
119 /**
120 Update the string associated with an existing SMBIOS record.
121
122 This function allows the update of specific SMBIOS strings. The number of valid strings for any
123 SMBIOS record is defined by how many strings were present when Add() was called.
124
125 @param[in] SmbiosHandle SMBIOS Handle of structure that will have its string updated.
126 @param[in] StringNumber The non-zero string number of the string to update.
127 @param[in] String Update the StringNumber string with String.
128
129 @retval EFI_SUCCESS SmbiosHandle had its StringNumber String updated.
130 @retval EFI_INVALID_PARAMETER SmbiosHandle does not exist. Or String is invalid.
131 @retval EFI_UNSUPPORTED String was not added because it is longer than the SMBIOS Table supports.
132 @retval EFI_NOT_FOUND The StringNumber.is not valid for this SMBIOS record.
133 **/
134 EFI_STATUS
135 EFIAPI
136 SmbiosLibUpdateUnicodeString (
137 IN EFI_SMBIOS_HANDLE SmbiosHandle,
138 IN SMBIOS_TABLE_STRING StringNumber,
139 IN CHAR16 *String
140 );
141
142 /**
143 Allow caller to read a specific SMBIOS string
144
145 @param[in] Header SMBIOS record that contains the string.
146 @param[in[ StringNumber Instance of SMBIOS string 1 - N.
147
148 @retval NULL Instance of Type SMBIOS string was not found.
149 @retval Other Pointer to matching SMBIOS string.
150 **/
151 CHAR8 *
152 EFIAPI
153 SmbiosLibReadString (
154 IN SMBIOS_STRUCTURE *Header,
155 IN EFI_SMBIOS_STRING StringNumber
156 );
157
158
159 /**
160 Allow the caller to discover a specific SMBIOS entry, and patch it if necissary.
161
162 @param[in] Type Type of the next SMBIOS record to return.
163 @param[in[ Instance Instance of SMBIOS record 0 - N-1.
164 @param[out] SmbiosHandle Returns SMBIOS handle for the matching record.
165
166 @retval NULL Instance of Type SMBIOS record was not found.
167 @retval Other Pointer to matching SMBIOS record.
168 **/
169 SMBIOS_STRUCTURE *
170 EFIAPI
171 SmbiosLibGetRecord (
172 IN EFI_SMBIOS_TYPE Type,
173 IN UINTN Instance,
174 OUT EFI_SMBIOS_HANDLE *SmbiosHandle
175 );
176
177 /**
178 Remove an SMBIOS record.
179
180 This function removes an SMBIOS record using the handle specified by SmbiosHandle.
181
182 @param[in] SmbiosHandle The handle of the SMBIOS record to remove.
183
184 @retval EFI_SUCCESS SMBIOS record was removed.
185 @retval EFI_INVALID_PARAMETER SmbiosHandle does not specify a valid SMBIOS record.
186 **/
187 EFI_STATUS
188 EFIAPI
189 SmbiosLibRemove (
190 OUT EFI_SMBIOS_HANDLE SmbiosHandle
191 );
192
193
194
195
196 #endif