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