]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
db8322631c33db446305adfed8a59d13a1ba7700
[mirror_edk2.git] / MdeModulePkg / Library / SmmLockBoxLib / SmmLockBoxDxeLib.c
1 /** @file
2
3 Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
4
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions
7 of the BSD License which accompanies this distribution. The
8 full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #include <PiDxe.h>
17 #include <Library/UefiBootServicesTableLib.h>
18 #include <Library/UefiRuntimeServicesTableLib.h>
19 #include <Library/BaseLib.h>
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/LockBoxLib.h>
22 #include <Library/DebugLib.h>
23 #include <Library/UefiLib.h>
24 #include <Protocol/SmmCommunication.h>
25 #include <Guid/SmmLockBox.h>
26 #include <Guid/PiSmmCommunicationRegionTable.h>
27
28 #include "SmmLockBoxLibPrivate.h"
29
30 EFI_SMM_COMMUNICATION_PROTOCOL *mLockBoxSmmCommProtocol = NULL;
31 UINT8 *mLockBoxSmmCommBuffer = NULL;
32
33 /**
34 Get smm communication protocol for lockbox.
35
36 @return Pointer to smm communication protocol, NULL if not found.
37
38 **/
39 EFI_SMM_COMMUNICATION_PROTOCOL *
40 LockBoxGetSmmCommProtocol (
41 VOID
42 )
43 {
44 EFI_STATUS Status;
45
46 //
47 // If the protocol has been got previously, return it.
48 //
49 if (mLockBoxSmmCommProtocol != NULL) {
50 return mLockBoxSmmCommProtocol;
51 }
52
53 Status = gBS->LocateProtocol (
54 &gEfiSmmCommunicationProtocolGuid,
55 NULL,
56 (VOID **)&mLockBoxSmmCommProtocol
57 );
58 if (EFI_ERROR (Status)) {
59 mLockBoxSmmCommProtocol = NULL;
60 }
61 return mLockBoxSmmCommProtocol;
62 }
63
64 /**
65 Get smm communication buffer for lockbox.
66
67 @return Pointer to smm communication buffer, NULL if not found.
68
69 **/
70 UINT8 *
71 LockBoxGetSmmCommBuffer (
72 VOID
73 )
74 {
75 EFI_STATUS Status;
76 UINTN MinimalSizeNeeded;
77 EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *PiSmmCommunicationRegionTable;
78 UINT32 Index;
79 EFI_MEMORY_DESCRIPTOR *Entry;
80 UINTN Size;
81
82 //
83 // If the buffer has been got previously, return it.
84 //
85 if (mLockBoxSmmCommBuffer != NULL) {
86 return mLockBoxSmmCommBuffer;
87 }
88
89 MinimalSizeNeeded = sizeof (EFI_GUID) +
90 sizeof (UINTN) +
91 MAX (sizeof (EFI_SMM_LOCK_BOX_PARAMETER_SAVE),
92 MAX (sizeof (EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES),
93 MAX (sizeof (EFI_SMM_LOCK_BOX_PARAMETER_UPDATE),
94 MAX (sizeof (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE),
95 sizeof (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE)))));
96
97 Status = EfiGetSystemConfigurationTable (
98 &gEdkiiPiSmmCommunicationRegionTableGuid,
99 (VOID **) &PiSmmCommunicationRegionTable
100 );
101 if (EFI_ERROR (Status)) {
102 mLockBoxSmmCommBuffer = NULL;
103 return mLockBoxSmmCommBuffer;
104 }
105 ASSERT (PiSmmCommunicationRegionTable != NULL);
106 Entry = (EFI_MEMORY_DESCRIPTOR *) (PiSmmCommunicationRegionTable + 1);
107 Size = 0;
108 for (Index = 0; Index < PiSmmCommunicationRegionTable->NumberOfEntries; Index++) {
109 if (Entry->Type == EfiConventionalMemory) {
110 Size = EFI_PAGES_TO_SIZE ((UINTN) Entry->NumberOfPages);
111 if (Size >= MinimalSizeNeeded) {
112 break;
113 }
114 }
115 Entry = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) Entry + PiSmmCommunicationRegionTable->DescriptorSize);
116 }
117 if (Index >= PiSmmCommunicationRegionTable->NumberOfEntries) {
118 mLockBoxSmmCommBuffer = NULL;
119 } else {
120 mLockBoxSmmCommBuffer = (UINT8 *) (UINTN) Entry->PhysicalStart;
121 }
122 return mLockBoxSmmCommBuffer;
123 }
124
125 /**
126 This function will save confidential information to lockbox.
127
128 @param Guid the guid to identify the confidential information
129 @param Buffer the address of the confidential information
130 @param Length the length of the confidential information
131
132 @retval RETURN_SUCCESS the information is saved successfully.
133 @retval RETURN_INVALID_PARAMETER the Guid is NULL, or Buffer is NULL, or Length is 0
134 @retval RETURN_ALREADY_STARTED the requested GUID already exist.
135 @retval RETURN_OUT_OF_RESOURCES no enough resource to save the information.
136 @retval RETURN_ACCESS_DENIED it is too late to invoke this interface
137 @retval RETURN_NOT_STARTED it is too early to invoke this interface
138 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
139 **/
140 RETURN_STATUS
141 EFIAPI
142 SaveLockBox (
143 IN GUID *Guid,
144 IN VOID *Buffer,
145 IN UINTN Length
146 )
147 {
148 EFI_STATUS Status;
149 EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
150 EFI_SMM_LOCK_BOX_PARAMETER_SAVE *LockBoxParameterSave;
151 EFI_SMM_COMMUNICATE_HEADER *CommHeader;
152 UINT8 TempCommBuffer[sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SAVE)];
153 UINT8 *CommBuffer;
154 UINTN CommSize;
155
156 DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib SaveLockBox - Enter\n"));
157
158 //
159 // Basic check
160 //
161 if ((Guid == NULL) || (Buffer == NULL) || (Length == 0)) {
162 return EFI_INVALID_PARAMETER;
163 }
164
165 SmmCommunication = LockBoxGetSmmCommProtocol ();
166 if (SmmCommunication == NULL) {
167 return EFI_NOT_STARTED;
168 }
169
170 //
171 // Prepare parameter
172 //
173 CommBuffer = LockBoxGetSmmCommBuffer ();
174 if (CommBuffer == NULL) {
175 CommBuffer = &TempCommBuffer[0];
176 }
177 CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
178 CopyMem (&CommHeader->HeaderGuid, &gEfiSmmLockBoxCommunicationGuid, sizeof(gEfiSmmLockBoxCommunicationGuid));
179 CommHeader->MessageLength = sizeof(*LockBoxParameterSave);
180
181 LockBoxParameterSave = (EFI_SMM_LOCK_BOX_PARAMETER_SAVE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
182 LockBoxParameterSave->Header.Command = EFI_SMM_LOCK_BOX_COMMAND_SAVE;
183 LockBoxParameterSave->Header.DataLength = sizeof(*LockBoxParameterSave);
184 LockBoxParameterSave->Header.ReturnStatus = (UINT64)-1;
185 CopyMem (&LockBoxParameterSave->Guid, Guid, sizeof(*Guid));
186 LockBoxParameterSave->Buffer = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
187 LockBoxParameterSave->Length = (UINT64)Length;
188
189 //
190 // Send command
191 //
192 CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SAVE);
193 Status = SmmCommunication->Communicate (
194 SmmCommunication,
195 &CommBuffer[0],
196 &CommSize
197 );
198 ASSERT_EFI_ERROR (Status);
199
200 Status = (EFI_STATUS)LockBoxParameterSave->Header.ReturnStatus;
201
202 DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib SaveLockBox - Exit (%r)\n", Status));
203
204 //
205 // Done
206 //
207 return Status;
208 }
209
210 /**
211 This function will set lockbox attributes.
212
213 @param Guid the guid to identify the confidential information
214 @param Attributes the attributes of the lockbox
215
216 @retval RETURN_SUCCESS the information is saved successfully.
217 @retval RETURN_INVALID_PARAMETER attributes is invalid.
218 @retval RETURN_NOT_FOUND the requested GUID not found.
219 @retval RETURN_ACCESS_DENIED it is too late to invoke this interface
220 @retval RETURN_NOT_STARTED it is too early to invoke this interface
221 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
222 **/
223 RETURN_STATUS
224 EFIAPI
225 SetLockBoxAttributes (
226 IN GUID *Guid,
227 IN UINT64 Attributes
228 )
229 {
230 EFI_STATUS Status;
231 EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
232 EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES *LockBoxParameterSetAttributes;
233 EFI_SMM_COMMUNICATE_HEADER *CommHeader;
234 UINT8 TempCommBuffer[sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES)];
235 UINT8 *CommBuffer;
236 UINTN CommSize;
237
238 DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib SetLockBoxAttributes - Enter\n"));
239
240 //
241 // Basic check
242 //
243 if ((Guid == NULL) ||
244 ((Attributes & ~(LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE | LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY)) != 0)) {
245 return EFI_INVALID_PARAMETER;
246 }
247
248 SmmCommunication = LockBoxGetSmmCommProtocol ();
249 if (SmmCommunication == NULL) {
250 return EFI_NOT_STARTED;
251 }
252
253 //
254 // Prepare parameter
255 //
256 CommBuffer = LockBoxGetSmmCommBuffer ();
257 if (CommBuffer == NULL) {
258 CommBuffer = &TempCommBuffer[0];
259 }
260 CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
261 CopyMem (&CommHeader->HeaderGuid, &gEfiSmmLockBoxCommunicationGuid, sizeof(gEfiSmmLockBoxCommunicationGuid));
262 CommHeader->MessageLength = sizeof(*LockBoxParameterSetAttributes);
263
264 LockBoxParameterSetAttributes = (EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
265 LockBoxParameterSetAttributes->Header.Command = EFI_SMM_LOCK_BOX_COMMAND_SET_ATTRIBUTES;
266 LockBoxParameterSetAttributes->Header.DataLength = sizeof(*LockBoxParameterSetAttributes);
267 LockBoxParameterSetAttributes->Header.ReturnStatus = (UINT64)-1;
268 CopyMem (&LockBoxParameterSetAttributes->Guid, Guid, sizeof(*Guid));
269 LockBoxParameterSetAttributes->Attributes = (UINT64)Attributes;
270
271 //
272 // Send command
273 //
274 CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES);
275 Status = SmmCommunication->Communicate (
276 SmmCommunication,
277 &CommBuffer[0],
278 &CommSize
279 );
280 ASSERT_EFI_ERROR (Status);
281
282 Status = (EFI_STATUS)LockBoxParameterSetAttributes->Header.ReturnStatus;
283
284 DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib SetLockBoxAttributes - Exit (%r)\n", Status));
285
286 //
287 // Done
288 //
289 return Status;
290 }
291
292 /**
293 This function will update confidential information to lockbox.
294
295 @param Guid the guid to identify the original confidential information
296 @param Offset the offset of the original confidential information
297 @param Buffer the address of the updated confidential information
298 @param Length the length of the updated confidential information
299
300 @retval RETURN_SUCCESS the information is saved successfully.
301 @retval RETURN_INVALID_PARAMETER the Guid is NULL, or Buffer is NULL, or Length is 0.
302 @retval RETURN_NOT_FOUND the requested GUID not found.
303 @retval RETURN_BUFFER_TOO_SMALL for lockbox without attribute LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY,
304 the original buffer to too small to hold new information.
305 @retval RETURN_OUT_OF_RESOURCES for lockbox with attribute LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY,
306 no enough resource to save the information.
307 @retval RETURN_ACCESS_DENIED it is too late to invoke this interface
308 @retval RETURN_NOT_STARTED it is too early to invoke this interface
309 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
310 **/
311 RETURN_STATUS
312 EFIAPI
313 UpdateLockBox (
314 IN GUID *Guid,
315 IN UINTN Offset,
316 IN VOID *Buffer,
317 IN UINTN Length
318 )
319 {
320 EFI_STATUS Status;
321 EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
322 EFI_SMM_LOCK_BOX_PARAMETER_UPDATE *LockBoxParameterUpdate;
323 EFI_SMM_COMMUNICATE_HEADER *CommHeader;
324 UINT8 TempCommBuffer[sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_UPDATE)];
325 UINT8 *CommBuffer;
326 UINTN CommSize;
327
328 DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib UpdateLockBox - Enter\n"));
329
330 //
331 // Basic check
332 //
333 if ((Guid == NULL) || (Buffer == NULL) || (Length == 0)) {
334 return EFI_INVALID_PARAMETER;
335 }
336
337 SmmCommunication = LockBoxGetSmmCommProtocol ();
338 if (SmmCommunication == NULL) {
339 return EFI_NOT_STARTED;
340 }
341
342 //
343 // Prepare parameter
344 //
345 CommBuffer = LockBoxGetSmmCommBuffer ();
346 if (CommBuffer == NULL) {
347 CommBuffer = &TempCommBuffer[0];
348 }
349 CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
350 CopyMem (&CommHeader->HeaderGuid, &gEfiSmmLockBoxCommunicationGuid, sizeof(gEfiSmmLockBoxCommunicationGuid));
351 CommHeader->MessageLength = sizeof(*LockBoxParameterUpdate);
352
353 LockBoxParameterUpdate = (EFI_SMM_LOCK_BOX_PARAMETER_UPDATE *)(UINTN)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
354 LockBoxParameterUpdate->Header.Command = EFI_SMM_LOCK_BOX_COMMAND_UPDATE;
355 LockBoxParameterUpdate->Header.DataLength = sizeof(*LockBoxParameterUpdate);
356 LockBoxParameterUpdate->Header.ReturnStatus = (UINT64)-1;
357 CopyMem (&LockBoxParameterUpdate->Guid, Guid, sizeof(*Guid));
358 LockBoxParameterUpdate->Offset = (UINT64)Offset;
359 LockBoxParameterUpdate->Buffer = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
360 LockBoxParameterUpdate->Length = (UINT64)Length;
361
362 //
363 // Send command
364 //
365 CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_UPDATE);
366 Status = SmmCommunication->Communicate (
367 SmmCommunication,
368 &CommBuffer[0],
369 &CommSize
370 );
371 ASSERT_EFI_ERROR (Status);
372
373 Status = (EFI_STATUS)LockBoxParameterUpdate->Header.ReturnStatus;
374
375 DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib UpdateLockBox - Exit (%r)\n", Status));
376
377 //
378 // Done
379 //
380 return Status;
381 }
382
383 /**
384 This function will restore confidential information from lockbox.
385
386 @param Guid the guid to identify the confidential information
387 @param Buffer the address of the restored confidential information
388 NULL means restored to original address, Length MUST be NULL at same time.
389 @param Length the length of the restored confidential information
390
391 @retval RETURN_SUCCESS the information is restored successfully.
392 @retval RETURN_INVALID_PARAMETER the Guid is NULL, or one of Buffer and Length is NULL.
393 @retval RETURN_WRITE_PROTECTED Buffer and Length are NULL, but the LockBox has no
394 LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE attribute.
395 @retval RETURN_BUFFER_TOO_SMALL the Length is too small to hold the confidential information.
396 @retval RETURN_NOT_FOUND the requested GUID not found.
397 @retval RETURN_NOT_STARTED it is too early to invoke this interface
398 @retval RETURN_ACCESS_DENIED not allow to restore to the address
399 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
400 **/
401 RETURN_STATUS
402 EFIAPI
403 RestoreLockBox (
404 IN GUID *Guid,
405 IN VOID *Buffer, OPTIONAL
406 IN OUT UINTN *Length OPTIONAL
407 )
408 {
409 EFI_STATUS Status;
410 EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
411 EFI_SMM_LOCK_BOX_PARAMETER_RESTORE *LockBoxParameterRestore;
412 EFI_SMM_COMMUNICATE_HEADER *CommHeader;
413 UINT8 TempCommBuffer[sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE)];
414 UINT8 *CommBuffer;
415 UINTN CommSize;
416
417 DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib RestoreLockBox - Enter\n"));
418
419 //
420 // Basic check
421 //
422 if ((Guid == NULL) ||
423 ((Buffer == NULL) && (Length != NULL)) ||
424 ((Buffer != NULL) && (Length == NULL))) {
425 return EFI_INVALID_PARAMETER;
426 }
427
428 SmmCommunication = LockBoxGetSmmCommProtocol ();
429 if (SmmCommunication == NULL) {
430 return EFI_NOT_STARTED;
431 }
432
433 //
434 // Prepare parameter
435 //
436 CommBuffer = LockBoxGetSmmCommBuffer ();
437 if (CommBuffer == NULL) {
438 CommBuffer = &TempCommBuffer[0];
439 }
440 CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
441 CopyMem (&CommHeader->HeaderGuid, &gEfiSmmLockBoxCommunicationGuid, sizeof(gEfiSmmLockBoxCommunicationGuid));
442 CommHeader->MessageLength = sizeof(*LockBoxParameterRestore);
443
444 LockBoxParameterRestore = (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
445 LockBoxParameterRestore->Header.Command = EFI_SMM_LOCK_BOX_COMMAND_RESTORE;
446 LockBoxParameterRestore->Header.DataLength = sizeof(*LockBoxParameterRestore);
447 LockBoxParameterRestore->Header.ReturnStatus = (UINT64)-1;
448 CopyMem (&LockBoxParameterRestore->Guid, Guid, sizeof(*Guid));
449 LockBoxParameterRestore->Buffer = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
450 if (Length != NULL) {
451 LockBoxParameterRestore->Length = (EFI_PHYSICAL_ADDRESS)*Length;
452 } else {
453 LockBoxParameterRestore->Length = 0;
454 }
455
456 //
457 // Send command
458 //
459 CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE);
460 Status = SmmCommunication->Communicate (
461 SmmCommunication,
462 &CommBuffer[0],
463 &CommSize
464 );
465 ASSERT_EFI_ERROR (Status);
466
467 if (Length != NULL) {
468 *Length = (UINTN)LockBoxParameterRestore->Length;
469 }
470
471 Status = (EFI_STATUS)LockBoxParameterRestore->Header.ReturnStatus;
472
473 DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib RestoreLockBox - Exit (%r)\n", Status));
474
475 //
476 // Done
477 //
478 return Status;
479 }
480
481 /**
482 This function will restore confidential information from all lockbox which have RestoreInPlace attribute.
483
484 @retval RETURN_SUCCESS the information is restored successfully.
485 @retval RETURN_NOT_STARTED it is too early to invoke this interface
486 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
487 **/
488 RETURN_STATUS
489 EFIAPI
490 RestoreAllLockBoxInPlace (
491 VOID
492 )
493 {
494 EFI_STATUS Status;
495 EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
496 EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE *LockBoxParameterRestoreAllInPlace;
497 EFI_SMM_COMMUNICATE_HEADER *CommHeader;
498 UINT8 TempCommBuffer[sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE)];
499 UINT8 *CommBuffer;
500 UINTN CommSize;
501
502 DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib RestoreAllLockBoxInPlace - Enter\n"));
503
504 SmmCommunication = LockBoxGetSmmCommProtocol ();
505 if (SmmCommunication == NULL) {
506 return EFI_NOT_STARTED;
507 }
508
509 //
510 // Prepare parameter
511 //
512 CommBuffer = LockBoxGetSmmCommBuffer ();
513 if (CommBuffer == NULL) {
514 CommBuffer = &TempCommBuffer[0];
515 }
516 CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
517 CopyMem (&CommHeader->HeaderGuid, &gEfiSmmLockBoxCommunicationGuid, sizeof(gEfiSmmLockBoxCommunicationGuid));
518 CommHeader->MessageLength = sizeof(*LockBoxParameterRestoreAllInPlace);
519
520 LockBoxParameterRestoreAllInPlace = (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
521 LockBoxParameterRestoreAllInPlace->Header.Command = EFI_SMM_LOCK_BOX_COMMAND_RESTORE_ALL_IN_PLACE;
522 LockBoxParameterRestoreAllInPlace->Header.DataLength = sizeof(*LockBoxParameterRestoreAllInPlace);
523 LockBoxParameterRestoreAllInPlace->Header.ReturnStatus = (UINT64)-1;
524
525 //
526 // Send command
527 //
528 CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE);
529 Status = SmmCommunication->Communicate (
530 SmmCommunication,
531 &CommBuffer[0],
532 &CommSize
533 );
534 ASSERT_EFI_ERROR (Status);
535
536 Status = (EFI_STATUS)LockBoxParameterRestoreAllInPlace->Header.ReturnStatus;
537
538 DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib RestoreAllLockBoxInPlace - Exit (%r)\n", Status));
539
540 //
541 // Done
542 //
543 return Status;
544 }
545