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