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