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