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