summaryrefslogtreecommitdiff
path: root/Core/EM/SMBIOS/SmbiosDMIEditSupport/SmbiosDMIEdit.h
blob: 92b5f2aa62550579d411b32791f24304a3a8fd14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
//**********************************************************************//
//**********************************************************************//
//**                                                                  **//
//**        (C)Copyright 1985-2016, American Megatrends, Inc.         **//
//**                                                                  **//
//**                       All Rights Reserved.                       **//
//**                                                                  **//
//**        5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093         **//
//**                                                                  **//
//**                       Phone: (770)-246-8600                      **//
//**                                                                  **//
//**********************************************************************//
//**********************************************************************//

//**********************************************************************//
// $Header: /Alaska/SOURCE/Modules/SMBIOS/SmbiosDMIEditSupport/SmbiosDMIEdit.h 15    4/04/16 11:42a Davidd $
//
// $Revision: 15 $
//
// $Date: 4/04/16 11:42a $
//**********************************************************************//
// Revision History
// ----------------
// $Log: /Alaska/SOURCE/Modules/SMBIOS/SmbiosDMIEditSupport/SmbiosDMIEdit.h $
// 
// 15    4/04/16 11:42a Davidd
// [TAG]  		EIP262865
// [Category]  	Improvement
// [Description]  	[APTIO4][Smbios]DmiEdit needs changes as smiflash
// protocol is being changed to deny calls with Smm buffer
// [Files]  		SmbiosDMIEdit.mak
// SmbiosDMIEdit.h
// SmbiosDMIEdit.c
// SmbiosDMIEditFunc.c
//
// 14    6/12/12 11:28a Davidd
// [TAG]  		EIP92073
// [Category]  	Bug Fix
// [Severity]  	Normal
// [Symptom]  	"write once" not updating properly for multiple instances
// of the same structure type using AMI DmiEdit tool
// [RootCause]  	Write-once implementation only supported single instance
// of a structure.
// [Solution]  	Changes made to support more than one instance of a given
// structure.
// [Files]  		SmbiosDMIEdit.h
// SmbiosDMIEditFunc.c
//
// 13    6/08/12 6:02p Davidd
// [TAG]  		EIP88664
// [Category]  	New Feature
// [Description]  	Need tool to update smbios information
// [Files]  		SmbiosDMIEdit.c
// SmbiosDMIEdit.h
// SmbiosDMIEdit.sdl
// SmbiosDMIEditFunc.c
//
// 12    11/17/11 2:39p Davidd
// [TAG]           EIP74579
// [Category]      Improvement
// [Description]   Update SMBIOS moudule to let AMDELNX support SMBIOS
// spec 2.7
//                 (remove the 64 characters string limitation)
// [Files]         Smbios.h
//                 SmbiosStaticData.sdl
//                 Smbios.c
//                 SMBios.dxs
//                 SmbiosDMIEdit.sdl
//                 SmbiosDMIEdit.h
//                 SmbiosDMIEditFunc.c
//                 SmbiosNvram.c
//                 SmbiosFlashData.sdl
//
// 11    5/11/11 12:33p Davidd
// [TAG]           EIP58171
// [Category]      Bug Fix
// [Severity]      Important
// [Symptom]       TABLE_INFO structure of SmbiosDMIEdit is not backward
// compatible for AFU preserve DMI structure feature.
// [RootCause]     TABLE_INFO structure of SmbiosDMIEdit is not backward
// compatible.
// [Solution]      New TABLE_INFO structure defined for backward
// compatibility and support added.
// [Files]         Smbios.c
//                 SmbiosDMIEdit.h
//                 SmbiosDMIEditFunc.c
//                 SmbiosGetFlashData.c
//
// 10    11/02/10 4:13p Davidd
// [TAG]           EIP42938
// [Category]      BUG FIX
// [Severity]      Critical
// [Symptom]       The SMBIOS string field cannot be successfully updated
// if it was programmed to Null by the 3-party SMBIOS tool
// [RootCause]     BIOS did not have support for NULL strings
// [Solution]      Problem has been fixed with code changes
// [Files]
//    Smbios.c
//    SmbiosDMIEditFunc.c
//    SmbiosGetFlashData.c
//    SmbiosDMIEdit.h
//    SmbiosFlashData.sdl
//
// 9     5/18/10 5:10p Davidd
// Added PnP function 52h commands 3 and 4 support - EIP 38010.
//
// 8     8/05/09 6:20p Davidd
// Added DMIEDIT support for Type 0 and Type 12 structures - EIP 24878
//
// 7     1/28/09 11:52a Davidd
// New changes added to support DMIEdit data storage location in flash
// selectable via SMBIOS_DMIEDIT_DATA_LOC SDL token
//
// 6     1/03/08 12:30p Olegi
// Fix in GET_SMBIOS_INFO structure for x64 projects.
//
// 5     3/29/07 6:02p Davidd
// Changed the year in the AMI banner and clean up the code.
//
// 4     12/15/06 5:42p Davidd
// Code cleanup and reformatted to coding standard.
//
// 3     11/30/06 3:33p Davidd
// Changes made for 64 bit support.
//
// 2     3/02/06 11:10a Davidd
// Removed FLASH_START definition. Not needed.
//
// 1     4/29/05 2:06p Davidd
// Initial checkin.
//
//**********************************************************************//

#ifndef _SmbiosDMIEdit_DRIVER_H
#define _SmbiosDMIEdit_DRIVER_H

#include <efi.h>
#include <token.h>

#if !defined(SMBIOS_DMIEDIT_DATA_LOC) || SMBIOS_DMIEDIT_DATA_LOC != 2
#include <Protocol/SmiFlash.h>
#include <Protocol/FlashProtocol.h>
#endif

extern EFI_BOOT_SERVICES		*pBS;

UINT16 GetSmbiosInfo(GET_SMBIOS_INFO);
UINT16 GetSmbiosStructure(GET_SMBIOS_STRUCTURE);
UINT16 SetSmbiosStructure(SET_SMBIOS_STRUCTURE);

#pragma pack(1)

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:  SMBIOS_TABLE_ENTRY
//
// Description: SMBIOS Entry Point structure
//----------------------------------------------------------------------------
//<AMI_SHDR_END>
typedef struct {
    UINT32    AnchorString;
    UINT8     EntryPointStructChecksum;
    UINT8     EntryPointLength;
    UINT8     MajorVersion;
    UINT8     MinorVersion;
    UINT16    MaximumStructSize;
    UINT8     EntryPointRevision;
    UINT8     FormattedArea[5];
    UINT8     IntermediateAnchor[5];
    UINT8     IntermediateChecksum;
    UINT16    StructTableLength;
    UINT32    StructTableAddress;
    UINT16    NumStructs;
    UINT8     SmbiosBCDRevision;
} SMBIOS_TABLE_ENTRY;

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:  DMI_STRUC
//
// Description: Structure Header
//----------------------------------------------------------------------------
//<AMI_SHDR_END>
typedef struct {
    UINT8		Type;
    UINT8		Length;
    UINT16		Handle;
} DMI_STRUC;

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:  SET_SMBIOS_STRUCTURE_DATA
//
// Description: Set SMBIOS Structure Data
//----------------------------------------------------------------------------
//<AMI_SHDR_END>
typedef struct {
    UINT8     Command;
    UINT8     FieldOffset;
    UINT32    ChangeMask;
    UINT32    ChangeValue;
    UINT16    DataLength;
    DMI_STRUC StructureHeader;
    UINT8     StructureData[1];
} SET_SMBIOS_STRUCTURE_DATA;

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:  GET_SMBIOS_INFO
//
// Description: Get SMBIOS Information
//----------------------------------------------------------------------------
//<AMI_SHDR_END>
typedef struct {
    UINT16		Function;
    UINT32		DmiBiosRevision32BitAddr;
    UINT32		NumStructures32BitAddr;
    UINT32		StructureSize32BitAddr;
    UINT32		DmiStorageBase32BitAddr;
    UINT32		DmiStorageSize32BitAddr;
    UINT16		BiosSelector; //Always 0.
/////////////////////////////////////
// The above pointers point below. //
/////////////////////////////////////
    UINT32		DmiBiosRevision;
    UINT32		NumStructures;
    UINT32		StructureSize;
    UINT32		pDmiStorageBase;
    UINT32		DmiStorageSize;
} GET_SMBIOS_INFO;

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:  GET_SMBIOS_STRUCTURE
//
// Description: Get SMBIOS Structure
//----------------------------------------------------------------------------
//<AMI_SHDR_END>
typedef struct {
    UINT16		Function;
    UINT32		Handle32BitAddr;
    UINT32		Buffer32BitAddr;
    UINT16		DmiSelector;  //Always 0
    UINT16		BiosSelector; //Always 0
/////////////////////////////////////
// The above pointers point below. //
/////////////////////////////////////
    UINT16		Handle;
    UINT8		Buffer[1];    //Variable Length;
} GET_SMBIOS_STRUCTURE;

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:  SET_SMBIOS_STRUCTURE
//
// Description: Set SMBIOS Structure
//----------------------------------------------------------------------------
//<AMI_SHDR_END>
typedef struct {
    UINT16		Function;
    UINT32		Buffer32BitAddr;
    UINT32		DmiWorkBuffer32BitAddr;
    UINT8		Control;    //?
    UINT16		DmiSelector;  //Always 0
    UINT16		BiosSelector; //Always 0
/////////////////////////////////////
// The above pointers point below. //
/////////////////////////////////////
    SET_SMBIOS_STRUCTURE_DATA StructureData;    //Variable Length;
} SET_SMBIOS_STRUCTURE;

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:  TABLE_INFO
//
// Description: DMI data record
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#define DMIEDIT_WRITE_ONCE      0x01
#define DMIEDIT_DELETE_STRUC    0x02
#define DMIEDIT_ADD_STRUC       0x04
#define DMIEDIT_EXTENDED_HDR    0x80

typedef struct {
    UINT8   Type;
    UINT8   Offset;     // Structure field offset, or string number for Type 11 and 12
    UINT8   Reserved;   // Size of string including \0 or UUID (16)
    UINT8   Flags;      // Bit0 = Write Once
                        // Bit1 = Delete Structure
                        // Bit2 = Add structure
                        // Bit7 = Extended Header
    UINT8   HdrLength;
    UINT16  Size;
    UINT16  Handle;
} TABLE_INFO;

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:  WRITE_ONCE_TABLE
//
// Description: Write Once structure
//----------------------------------------------------------------------------
//<AMI_SHDR_END>
typedef struct {
    UINT8   Type;
    UINT8   Offset;
  	BOOLEAN WriteOnce;
} WRITE_ONCE_TABLE;

typedef struct {
    UINT8   Type;
    UINT8   Offset;
    UINT16  Handle;
} WRITE_ONCE_STATUS;

#if !defined(SMBIOS_DMIEDIT_DATA_LOC) || SMBIOS_DMIEDIT_DATA_LOC != 2   // FV_BB or FV_MAIN

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:  FLASH_DATA_INFO
//
// Description: Flash Data Information
//----------------------------------------------------------------------------
//<AMI_SHDR_END>
typedef struct {
	UINT8		*Location;
	UINT16		Size;
	UINT8		*EndOfData;
} FLASH_DATA_INFO;

extern UINT8  					*gBlockSave;
extern VOID   					*gFlashData;
extern UINT32 					gFlashDataSize;
extern EFI_SMI_FLASH_PROTOCOL   *mSmiFlash;
extern FLASH_PROTOCOL           *mFlash;

#endif                                  // SMBIOS_DMIEDIT_DATA_LOC

#if (defined(NonSmiDmiEdit_Support) && (NonSmiDmiEdit_Support == 1))
#define AMI_DMIEDIT_SMBIOS_GUID \
    { 0x74211cd7, 0x3d8e, 0x496f, { 0xba, 0x2, 0x91, 0x9c, 0x2e, 0x1f, 0x6, 0xcb } }

typedef struct _EFI_SMBIOS_DMIEDIT_PROTOCOL EFI_SMBIOS_DMIEDIT_PROTOCOL;

typedef UINT32  (EFIAPI *DMIEDIT_NONSMI_HANDLER) (
    IN UINT8                    Data,
    IN UINT64                   pCommBuff
);

typedef struct _EFI_SMBIOS_DMIEDIT_PROTOCOL {
    DMIEDIT_NONSMI_HANDLER      DmiEditNonSmiHandler;
};

UINT32 DmiEditNonSmiHandler(
    IN UINT8            Data,
    IN UINT64           pCommBuff
);
#endif                                  // NonSmiDmiEdit_Support

#pragma pack()

#endif

//**********************************************************************//
//**********************************************************************//
//**                                                                  **//
//**        (C)Copyright 1985-2016, American Megatrends, Inc.         **//
//**                                                                  **//
//**                       All Rights Reserved.                       **//
//**                                                                  **//
//**        5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093         **//
//**                                                                  **//
//**                       Phone: (770)-246-8600                      **//
//**                                                                  **//
//**********************************************************************//
//**********************************************************************//