18#define RC_NV_ReadPublic_nvIndex (TPM_RC_H + TPM_RC_1)
20#define RC_NV_DefineSpace_authHandle (TPM_RC_H + TPM_RC_1)
21#define RC_NV_DefineSpace_auth (TPM_RC_P + TPM_RC_1)
22#define RC_NV_DefineSpace_publicInfo (TPM_RC_P + TPM_RC_2)
24#define RC_NV_UndefineSpace_authHandle (TPM_RC_H + TPM_RC_1)
25#define RC_NV_UndefineSpace_nvIndex (TPM_RC_H + TPM_RC_2)
27#define RC_NV_Read_authHandle (TPM_RC_H + TPM_RC_1)
28#define RC_NV_Read_nvIndex (TPM_RC_H + TPM_RC_2)
29#define RC_NV_Read_size (TPM_RC_P + TPM_RC_1)
30#define RC_NV_Read_offset (TPM_RC_P + TPM_RC_2)
32#define RC_NV_Write_authHandle (TPM_RC_H + TPM_RC_1)
33#define RC_NV_Write_nvIndex (TPM_RC_H + TPM_RC_2)
34#define RC_NV_Write_data (TPM_RC_P + TPM_RC_1)
35#define RC_NV_Write_offset (TPM_RC_P + TPM_RC_2)
39 TPMI_RH_NV_INDEX NvIndex;
50 TPMI_RH_PROVISION AuthHandle;
51 UINT32 AuthSessionSize;
59 UINT32 AuthSessionSize;
65 TPMI_RH_PROVISION AuthHandle;
66 TPMI_RH_NV_INDEX NvIndex;
67 UINT32 AuthSessionSize;
73 UINT32 AuthSessionSize;
79 TPMI_RH_NV_AUTH AuthHandle;
80 TPMI_RH_NV_INDEX NvIndex;
81 UINT32 AuthSessionSize;
89 UINT32 AuthSessionSize;
96 TPMI_RH_NV_AUTH AuthHandle;
97 TPMI_RH_NV_INDEX NvIndex;
98 UINT32 AuthSessionSize;
106 UINT32 AuthSessionSize;
112 TPMI_RH_NV_AUTH AuthHandle;
113 TPMI_RH_NV_INDEX NvIndex;
114 UINT32 AuthSessionSize;
120 UINT32 AuthSessionSize;
126 TPMI_RH_NV_AUTH AuthHandle;
127 TPMI_RH_NV_INDEX NvIndex;
128 UINT32 AuthSessionSize;
134 UINT32 AuthSessionSize;
140 TPMI_RH_PROVISION AuthHandle;
141 UINT32 AuthSessionSize;
147 UINT32 AuthSessionSize;
153 TPMI_RH_NV_AUTH AuthHandle;
154 TPMI_RH_NV_INDEX NvIndex;
155 UINT32 AuthSessionSize;
163 UINT32 AuthSessionSize;
183 IN TPMI_RH_NV_INDEX NvIndex,
191 UINT32 SendBufferSize;
192 UINT32 RecvBufferSize;
201 SendBuffer.Header.tag =
SwapBytes16 (TPM_ST_NO_SESSIONS);
202 SendBuffer.Header.commandCode =
SwapBytes32 (TPM_CC_NV_ReadPublic);
206 SendBufferSize = (UINT32)
sizeof (SendBuffer);
207 SendBuffer.Header.paramSize =
SwapBytes32 (SendBufferSize);
212 RecvBufferSize =
sizeof (RecvBuffer);
213 Status =
Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
214 if (EFI_ERROR (Status)) {
219 DEBUG ((DEBUG_ERROR,
"Tpm2NvReadPublic - RecvBufferSize Error - %x\n", RecvBufferSize));
220 return EFI_DEVICE_ERROR;
223 ResponseCode =
SwapBytes32 (RecvBuffer.Header.responseCode);
224 if (ResponseCode != TPM_RC_SUCCESS) {
225 DEBUG ((DEBUG_ERROR,
"Tpm2NvReadPublic - responseCode - %x\n",
SwapBytes32 (RecvBuffer.Header.responseCode)));
228 switch (ResponseCode) {
232 case TPM_RC_HANDLE + RC_NV_ReadPublic_nvIndex:
233 return EFI_NOT_FOUND;
234 case TPM_RC_VALUE + RC_NV_ReadPublic_nvIndex:
235 return EFI_INVALID_PARAMETER;
237 return EFI_DEVICE_ERROR;
241 DEBUG ((DEBUG_ERROR,
"Tpm2NvReadPublic - RecvBufferSize Error - %x\n", RecvBufferSize));
242 return EFI_NOT_FOUND;
248 NvPublicSize =
SwapBytes16 (RecvBuffer.NvPublic.size);
250 DEBUG ((DEBUG_ERROR,
"Tpm2NvReadPublic - NvPublic.size error %x\n", NvPublicSize));
251 return EFI_DEVICE_ERROR;
256 DEBUG ((DEBUG_ERROR,
"Tpm2NvReadPublic - NvNameSize error %x\n", NvNameSize));
257 return EFI_DEVICE_ERROR;
260 if (RecvBufferSize !=
sizeof (
TPM2_RESPONSE_HEADER) +
sizeof (UINT16) + NvPublicSize +
sizeof (UINT16) + NvNameSize) {
261 DEBUG ((DEBUG_ERROR,
"Tpm2NvReadPublic - RecvBufferSize Error - NvPublicSize %x\n", RecvBufferSize));
262 return EFI_NOT_FOUND;
268 CopyMem (NvPublic, &RecvBuffer.NvPublic, sizeof (UINT16) + NvPublicSize);
269 NvPublic->size = NvPublicSize;
270 NvPublic->nvPublic.nvIndex =
SwapBytes32 (NvPublic->nvPublic.nvIndex);
271 NvPublic->nvPublic.nameAlg =
SwapBytes16 (NvPublic->nvPublic.nameAlg);
273 NvPublic->nvPublic.authPolicy.size =
SwapBytes16 (NvPublic->nvPublic.authPolicy.size);
274 Buffer = (UINT8 *)&RecvBuffer.NvPublic.nvPublic.authPolicy;
275 Buffer += sizeof (UINT16) + NvPublic->nvPublic.authPolicy.size;
278 CopyMem (NvName->name, (UINT8 *)&RecvBuffer + sizeof (
TPM2_RESPONSE_HEADER) +
sizeof (UINT16) + NvPublicSize +
sizeof (UINT16), NvNameSize);
279 NvName->size = NvNameSize;
301 IN TPMI_RH_PROVISION AuthHandle,
310 UINT32 SendBufferSize;
311 UINT32 RecvBufferSize;
314 UINT32 SessionInfoSize;
320 SendBuffer.Header.tag =
SwapBytes16 (TPM_ST_SESSIONS);
321 SendBuffer.Header.commandCode =
SwapBytes32 (TPM_CC_NV_DefineSpace);
327 Buffer = (UINT8 *)&SendBuffer.AuthSession;
331 Buffer += SessionInfoSize;
332 SendBuffer.AuthSessionSize =
SwapBytes32 (SessionInfoSize);
338 Buffer +=
sizeof (UINT16);
339 CopyMem (Buffer, Auth->buffer, Auth->size);
340 Buffer += Auth->size;
345 NvPublicSize = NvPublic->size;
348 Buffer +=
sizeof (UINT16);
350 Buffer +=
sizeof (UINT32);
352 Buffer +=
sizeof (UINT16);
354 Buffer +=
sizeof (UINT32);
356 Buffer +=
sizeof (UINT16);
357 CopyMem (Buffer, NvPublic->nvPublic.authPolicy.buffer, NvPublic->nvPublic.authPolicy.size);
358 Buffer += NvPublic->nvPublic.authPolicy.size;
360 Buffer +=
sizeof (UINT16);
362 SendBufferSize = (UINT32)(Buffer - (UINT8 *)&SendBuffer);
363 SendBuffer.Header.paramSize =
SwapBytes32 (SendBufferSize);
368 RecvBufferSize =
sizeof (RecvBuffer);
369 Status =
Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
370 if (EFI_ERROR (Status)) {
375 DEBUG ((DEBUG_ERROR,
"Tpm2NvDefineSpace - RecvBufferSize Error - %x\n", RecvBufferSize));
376 Status = EFI_DEVICE_ERROR;
380 ResponseCode =
SwapBytes32 (RecvBuffer.Header.responseCode);
381 if (ResponseCode != TPM_RC_SUCCESS) {
382 DEBUG ((DEBUG_ERROR,
"Tpm2NvDefineSpace - responseCode - %x\n",
SwapBytes32 (RecvBuffer.Header.responseCode)));
385 switch (ResponseCode) {
389 case TPM_RC_SIZE + RC_NV_DefineSpace_publicInfo:
390 case TPM_RC_SIZE + RC_NV_DefineSpace_auth:
391 Status = EFI_BAD_BUFFER_SIZE;
393 case TPM_RC_ATTRIBUTES:
394 case TPM_RC_ATTRIBUTES + RC_NV_DefineSpace_publicInfo:
395 Status = EFI_UNSUPPORTED;
397 case TPM_RC_ATTRIBUTES + RC_NV_DefineSpace_authHandle:
398 Status = EFI_INVALID_PARAMETER;
400 case TPM_RC_NV_DEFINED:
401 Status = EFI_ALREADY_STARTED;
403 case TPM_RC_VALUE + RC_NV_DefineSpace_publicInfo:
404 case TPM_RC_VALUE + RC_NV_DefineSpace_authHandle:
405 Status = EFI_INVALID_PARAMETER;
407 case TPM_RC_NV_SPACE:
408 Status = EFI_OUT_OF_RESOURCES;
411 Status = EFI_DEVICE_ERROR;
419 ZeroMem (&SendBuffer,
sizeof (SendBuffer));
420 ZeroMem (&RecvBuffer,
sizeof (RecvBuffer));
438 IN TPMI_RH_PROVISION AuthHandle,
439 IN TPMI_RH_NV_INDEX NvIndex,
446 UINT32 SendBufferSize;
447 UINT32 RecvBufferSize;
449 UINT32 SessionInfoSize;
455 SendBuffer.Header.tag =
SwapBytes16 (TPM_ST_SESSIONS);
456 SendBuffer.Header.commandCode =
SwapBytes32 (TPM_CC_NV_UndefineSpace);
464 Buffer = (UINT8 *)&SendBuffer.AuthSession;
468 Buffer += SessionInfoSize;
469 SendBuffer.AuthSessionSize =
SwapBytes32 (SessionInfoSize);
471 SendBufferSize = (UINT32)(Buffer - (UINT8 *)&SendBuffer);
472 SendBuffer.Header.paramSize =
SwapBytes32 (SendBufferSize);
477 RecvBufferSize =
sizeof (RecvBuffer);
478 Status =
Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
479 if (EFI_ERROR (Status)) {
484 DEBUG ((DEBUG_ERROR,
"Tpm2NvUndefineSpace - RecvBufferSize Error - %x\n", RecvBufferSize));
485 Status = EFI_DEVICE_ERROR;
489 ResponseCode =
SwapBytes32 (RecvBuffer.Header.responseCode);
490 if (ResponseCode != TPM_RC_SUCCESS) {
491 DEBUG ((DEBUG_ERROR,
"Tpm2NvUndefineSpace - responseCode - %x\n",
SwapBytes32 (RecvBuffer.Header.responseCode)));
494 switch (ResponseCode) {
498 case TPM_RC_ATTRIBUTES:
499 case TPM_RC_ATTRIBUTES + RC_NV_UndefineSpace_nvIndex:
500 Status = EFI_UNSUPPORTED;
502 case TPM_RC_NV_AUTHORIZATION:
503 Status = EFI_SECURITY_VIOLATION;
505 case TPM_RC_HANDLE + RC_NV_UndefineSpace_nvIndex:
506 Status = EFI_NOT_FOUND;
508 case TPM_RC_HANDLE + RC_NV_UndefineSpace_authHandle:
509 Status = EFI_INVALID_PARAMETER;
511 case TPM_RC_VALUE + RC_NV_UndefineSpace_authHandle:
512 case TPM_RC_VALUE + RC_NV_UndefineSpace_nvIndex:
513 Status = EFI_INVALID_PARAMETER;
516 Status = EFI_DEVICE_ERROR;
524 ZeroMem (&SendBuffer,
sizeof (SendBuffer));
525 ZeroMem (&RecvBuffer,
sizeof (RecvBuffer));
546 IN TPMI_RH_NV_AUTH AuthHandle,
547 IN TPMI_RH_NV_INDEX NvIndex,
557 UINT32 SendBufferSize;
558 UINT32 RecvBufferSize;
560 UINT32 SessionInfoSize;
566 SendBuffer.Header.tag =
SwapBytes16 (TPM_ST_SESSIONS);
567 SendBuffer.Header.commandCode =
SwapBytes32 (TPM_CC_NV_Read);
575 Buffer = (UINT8 *)&SendBuffer.AuthSession;
579 Buffer += SessionInfoSize;
580 SendBuffer.AuthSessionSize =
SwapBytes32 (SessionInfoSize);
583 Buffer +=
sizeof (UINT16);
585 Buffer +=
sizeof (UINT16);
587 SendBufferSize = (UINT32)(Buffer - (UINT8 *)&SendBuffer);
588 SendBuffer.Header.paramSize =
SwapBytes32 (SendBufferSize);
593 RecvBufferSize =
sizeof (RecvBuffer);
594 Status =
Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
595 if (EFI_ERROR (Status)) {
600 DEBUG ((DEBUG_ERROR,
"Tpm2NvRead - RecvBufferSize Error - %x\n", RecvBufferSize));
601 Status = EFI_DEVICE_ERROR;
605 ResponseCode =
SwapBytes32 (RecvBuffer.Header.responseCode);
606 if (ResponseCode != TPM_RC_SUCCESS) {
607 DEBUG ((DEBUG_ERROR,
"Tpm2NvRead - responseCode - %x\n", ResponseCode));
610 switch (ResponseCode) {
614 case TPM_RC_NV_AUTHORIZATION:
615 Status = EFI_SECURITY_VIOLATION;
617 case TPM_RC_NV_LOCKED:
618 Status = EFI_ACCESS_DENIED;
620 case TPM_RC_NV_RANGE:
621 Status = EFI_BAD_BUFFER_SIZE;
623 case TPM_RC_NV_UNINITIALIZED:
624 Status = EFI_NOT_READY;
626 case TPM_RC_HANDLE + RC_NV_Read_nvIndex:
627 Status = EFI_NOT_FOUND;
629 case TPM_RC_HANDLE + RC_NV_Read_authHandle:
630 Status = EFI_INVALID_PARAMETER;
632 case TPM_RC_VALUE + RC_NV_Read_nvIndex:
633 case TPM_RC_VALUE + RC_NV_Read_authHandle:
634 Status = EFI_INVALID_PARAMETER;
636 case TPM_RC_BAD_AUTH + RC_NV_Read_authHandle + TPM_RC_S:
637 Status = EFI_INVALID_PARAMETER;
639 case TPM_RC_AUTH_UNAVAILABLE:
640 Status = EFI_INVALID_PARAMETER;
642 case TPM_RC_AUTH_FAIL + RC_NV_Read_authHandle + TPM_RC_S:
643 Status = EFI_INVALID_PARAMETER;
645 case TPM_RC_ATTRIBUTES + RC_NV_Read_authHandle + TPM_RC_S:
646 Status = EFI_UNSUPPORTED;
649 Status = EFI_DEVICE_ERROR;
660 OutData->size =
SwapBytes16 (RecvBuffer.Data.size);
661 if (OutData->size > MAX_DIGEST_BUFFER) {
662 DEBUG ((DEBUG_ERROR,
"Tpm2NvRead - OutData->size error %x\n", OutData->size));
663 Status = EFI_DEVICE_ERROR;
667 CopyMem (OutData->buffer, &RecvBuffer.Data.buffer, OutData->size);
673 ZeroMem (&SendBuffer,
sizeof (SendBuffer));
674 ZeroMem (&RecvBuffer,
sizeof (RecvBuffer));
694 IN TPMI_RH_NV_AUTH AuthHandle,
695 IN TPMI_RH_NV_INDEX NvIndex,
704 UINT32 SendBufferSize;
705 UINT32 RecvBufferSize;
707 UINT32 SessionInfoSize;
713 SendBuffer.Header.tag =
SwapBytes16 (TPM_ST_SESSIONS);
714 SendBuffer.Header.commandCode =
SwapBytes32 (TPM_CC_NV_Write);
722 Buffer = (UINT8 *)&SendBuffer.AuthSession;
726 Buffer += SessionInfoSize;
727 SendBuffer.AuthSessionSize =
SwapBytes32 (SessionInfoSize);
730 Buffer +=
sizeof (UINT16);
731 CopyMem (Buffer, InData->buffer, InData->size);
732 Buffer += InData->size;
734 Buffer +=
sizeof (UINT16);
736 SendBufferSize = (UINT32)(Buffer - (UINT8 *)&SendBuffer);
737 SendBuffer.Header.paramSize =
SwapBytes32 (SendBufferSize);
742 RecvBufferSize =
sizeof (RecvBuffer);
743 Status =
Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
744 if (EFI_ERROR (Status)) {
749 DEBUG ((DEBUG_ERROR,
"Tpm2NvWrite - RecvBufferSize Error - %x\n", RecvBufferSize));
750 Status = EFI_DEVICE_ERROR;
754 ResponseCode =
SwapBytes32 (RecvBuffer.Header.responseCode);
755 if (ResponseCode != TPM_RC_SUCCESS) {
756 DEBUG ((DEBUG_ERROR,
"Tpm2NvWrite - responseCode - %x\n", ResponseCode));
759 switch (ResponseCode) {
763 case TPM_RC_ATTRIBUTES:
764 Status = EFI_UNSUPPORTED;
766 case TPM_RC_NV_AUTHORIZATION:
767 Status = EFI_SECURITY_VIOLATION;
769 case TPM_RC_NV_LOCKED:
770 Status = EFI_ACCESS_DENIED;
772 case TPM_RC_NV_RANGE:
773 Status = EFI_BAD_BUFFER_SIZE;
775 case TPM_RC_HANDLE + RC_NV_Write_nvIndex:
776 Status = EFI_NOT_FOUND;
778 case TPM_RC_HANDLE + RC_NV_Write_authHandle:
779 Status = EFI_INVALID_PARAMETER;
781 case TPM_RC_VALUE + RC_NV_Write_nvIndex:
782 case TPM_RC_VALUE + RC_NV_Write_authHandle:
783 Status = EFI_INVALID_PARAMETER;
785 case TPM_RC_BAD_AUTH + RC_NV_Write_authHandle + TPM_RC_S:
786 Status = EFI_INVALID_PARAMETER;
788 case TPM_RC_AUTH_UNAVAILABLE:
789 Status = EFI_INVALID_PARAMETER;
791 case TPM_RC_AUTH_FAIL + RC_NV_Write_authHandle + TPM_RC_S:
792 Status = EFI_INVALID_PARAMETER;
794 case TPM_RC_ATTRIBUTES + RC_NV_Write_authHandle + TPM_RC_S:
795 Status = EFI_UNSUPPORTED;
798 Status = EFI_DEVICE_ERROR;
806 ZeroMem (&SendBuffer,
sizeof (SendBuffer));
807 ZeroMem (&RecvBuffer,
sizeof (RecvBuffer));
825 IN TPMI_RH_NV_AUTH AuthHandle,
826 IN TPMI_RH_NV_INDEX NvIndex,
833 UINT32 SendBufferSize;
834 UINT32 RecvBufferSize;
836 UINT32 SessionInfoSize;
842 SendBuffer.Header.tag =
SwapBytes16 (TPM_ST_SESSIONS);
843 SendBuffer.Header.commandCode =
SwapBytes32 (TPM_CC_NV_ReadLock);
851 Buffer = (UINT8 *)&SendBuffer.AuthSession;
855 Buffer += SessionInfoSize;
856 SendBuffer.AuthSessionSize =
SwapBytes32 (SessionInfoSize);
858 SendBufferSize = (UINT32)(Buffer - (UINT8 *)&SendBuffer);
859 SendBuffer.Header.paramSize =
SwapBytes32 (SendBufferSize);
864 RecvBufferSize =
sizeof (RecvBuffer);
865 Status =
Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
866 if (EFI_ERROR (Status)) {
871 DEBUG ((DEBUG_ERROR,
"Tpm2NvReadLock - RecvBufferSize Error - %x\n", RecvBufferSize));
872 Status = EFI_DEVICE_ERROR;
876 ResponseCode =
SwapBytes32 (RecvBuffer.Header.responseCode);
877 if (ResponseCode != TPM_RC_SUCCESS) {
878 DEBUG ((DEBUG_ERROR,
"Tpm2NvReadLock - responseCode - %x\n",
SwapBytes32 (RecvBuffer.Header.responseCode)));
881 switch (ResponseCode) {
886 Status = EFI_DEVICE_ERROR;
894 ZeroMem (&SendBuffer,
sizeof (SendBuffer));
895 ZeroMem (&RecvBuffer,
sizeof (RecvBuffer));
913 IN TPMI_RH_NV_AUTH AuthHandle,
914 IN TPMI_RH_NV_INDEX NvIndex,
921 UINT32 SendBufferSize;
922 UINT32 RecvBufferSize;
924 UINT32 SessionInfoSize;
930 SendBuffer.Header.tag =
SwapBytes16 (TPM_ST_SESSIONS);
931 SendBuffer.Header.commandCode =
SwapBytes32 (TPM_CC_NV_WriteLock);
939 Buffer = (UINT8 *)&SendBuffer.AuthSession;
943 Buffer += SessionInfoSize;
944 SendBuffer.AuthSessionSize =
SwapBytes32 (SessionInfoSize);
946 SendBufferSize = (UINT32)(Buffer - (UINT8 *)&SendBuffer);
947 SendBuffer.Header.paramSize =
SwapBytes32 (SendBufferSize);
952 RecvBufferSize =
sizeof (RecvBuffer);
953 Status =
Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
954 if (EFI_ERROR (Status)) {
959 DEBUG ((DEBUG_ERROR,
"Tpm2NvWriteLock - RecvBufferSize Error - %x\n", RecvBufferSize));
960 Status = EFI_DEVICE_ERROR;
964 ResponseCode =
SwapBytes32 (RecvBuffer.Header.responseCode);
965 if (ResponseCode != TPM_RC_SUCCESS) {
966 DEBUG ((DEBUG_ERROR,
"Tpm2NvWriteLock - responseCode - %x\n",
SwapBytes32 (RecvBuffer.Header.responseCode)));
969 switch (ResponseCode) {
974 Status = EFI_DEVICE_ERROR;
982 ZeroMem (&SendBuffer,
sizeof (SendBuffer));
983 ZeroMem (&RecvBuffer,
sizeof (RecvBuffer));
1000 IN TPMI_RH_PROVISION AuthHandle,
1007 UINT32 SendBufferSize;
1008 UINT32 RecvBufferSize;
1010 UINT32 SessionInfoSize;
1011 TPM_RC ResponseCode;
1016 SendBuffer.Header.tag =
SwapBytes16 (TPM_ST_SESSIONS);
1017 SendBuffer.Header.commandCode =
SwapBytes32 (TPM_CC_NV_GlobalWriteLock);
1024 Buffer = (UINT8 *)&SendBuffer.AuthSession;
1028 Buffer += SessionInfoSize;
1029 SendBuffer.AuthSessionSize =
SwapBytes32 (SessionInfoSize);
1031 SendBufferSize = (UINT32)(Buffer - (UINT8 *)&SendBuffer);
1032 SendBuffer.Header.paramSize =
SwapBytes32 (SendBufferSize);
1037 RecvBufferSize =
sizeof (RecvBuffer);
1038 Status =
Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
1039 if (EFI_ERROR (Status)) {
1044 DEBUG ((DEBUG_ERROR,
"Tpm2NvGlobalWriteLock - RecvBufferSize Error - %x\n", RecvBufferSize));
1045 Status = EFI_DEVICE_ERROR;
1049 ResponseCode =
SwapBytes32 (RecvBuffer.Header.responseCode);
1050 if (ResponseCode != TPM_RC_SUCCESS) {
1051 DEBUG ((DEBUG_ERROR,
"Tpm2NvGlobalWriteLock - responseCode - %x\n",
SwapBytes32 (RecvBuffer.Header.responseCode)));
1054 switch (ResponseCode) {
1055 case TPM_RC_SUCCESS:
1059 Status = EFI_DEVICE_ERROR;
1067 ZeroMem (&SendBuffer,
sizeof (SendBuffer));
1068 ZeroMem (&RecvBuffer,
sizeof (RecvBuffer));
1087 IN TPMI_RH_NV_AUTH AuthHandle,
1088 IN TPMI_RH_NV_INDEX NvIndex,
1096 UINT32 SendBufferSize;
1097 UINT32 RecvBufferSize;
1099 UINT32 SessionInfoSize;
1100 TPM_RC ResponseCode;
1105 SendBuffer.Header.tag =
SwapBytes16 (TPM_ST_SESSIONS);
1106 SendBuffer.Header.commandCode =
SwapBytes32 (TPM_CC_NV_Extend);
1114 Buffer = (UINT8 *)&SendBuffer.AuthSession;
1118 Buffer += SessionInfoSize;
1119 SendBuffer.AuthSessionSize =
SwapBytes32 (SessionInfoSize);
1122 Buffer +=
sizeof (UINT16);
1123 CopyMem (Buffer, InData->buffer, InData->size);
1124 Buffer += InData->size;
1126 SendBufferSize = (UINT32)(Buffer - (UINT8 *)&SendBuffer);
1127 SendBuffer.Header.paramSize =
SwapBytes32 (SendBufferSize);
1132 RecvBufferSize =
sizeof (RecvBuffer);
1133 Status =
Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
1134 if (EFI_ERROR (Status)) {
1139 DEBUG ((DEBUG_ERROR,
"Tpm2NvExtend - RecvBufferSize Error - %x\n", RecvBufferSize));
1140 Status = EFI_DEVICE_ERROR;
1144 ResponseCode =
SwapBytes32 (RecvBuffer.Header.responseCode);
1145 if (ResponseCode != TPM_RC_SUCCESS) {
1146 DEBUG ((DEBUG_ERROR,
"Tpm2NvExtend - responseCode - %x\n", ResponseCode));
1149 switch (ResponseCode) {
1150 case TPM_RC_SUCCESS:
1153 case TPM_RC_ATTRIBUTES:
1154 Status = EFI_UNSUPPORTED;
1156 case TPM_RC_NV_AUTHORIZATION:
1157 Status = EFI_SECURITY_VIOLATION;
1159 case TPM_RC_NV_LOCKED:
1160 Status = EFI_ACCESS_DENIED;
1163 Status = EFI_DEVICE_ERROR;
1171 ZeroMem (&SendBuffer,
sizeof (SendBuffer));
1172 ZeroMem (&RecvBuffer,
sizeof (RecvBuffer));
UINT16 EFIAPI SwapBytes16(IN UINT16 Value)
UINT16 EFIAPI ReadUnaligned16(IN CONST UINT16 *Buffer)
UINT32 EFIAPI SwapBytes32(IN UINT32 Value)
UINT32 EFIAPI WriteUnaligned32(OUT UINT32 *Buffer, IN UINT32 Value)
UINT16 EFIAPI WriteUnaligned16(OUT UINT16 *Buffer, IN UINT16 Value)
UINT32 EFIAPI ReadUnaligned32(IN CONST UINT32 *Buffer)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define DEBUG(Expression)
UINT32 EFIAPI CopyAuthSessionCommand(IN TPMS_AUTH_COMMAND *AuthSessionIn OPTIONAL, OUT UINT8 *AuthSessionOut)
EFI_STATUS EFIAPI Tpm2SubmitCommand(IN UINT32 InputParameterBlockSize, IN UINT8 *InputParameterBlock, IN OUT UINT32 *OutputParameterBlockSize, IN UINT8 *OutputParameterBlock)
EFI_STATUS EFIAPI Tpm2NvDefineSpace(IN TPMI_RH_PROVISION AuthHandle, IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL, IN TPM2B_AUTH *Auth, IN TPM2B_NV_PUBLIC *NvPublic)
EFI_STATUS EFIAPI Tpm2NvGlobalWriteLock(IN TPMI_RH_PROVISION AuthHandle, IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL)
EFI_STATUS EFIAPI Tpm2NvWriteLock(IN TPMI_RH_NV_AUTH AuthHandle, IN TPMI_RH_NV_INDEX NvIndex, IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL)
EFI_STATUS EFIAPI Tpm2NvRead(IN TPMI_RH_NV_AUTH AuthHandle, IN TPMI_RH_NV_INDEX NvIndex, IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL, IN UINT16 Size, IN UINT16 Offset, IN OUT TPM2B_MAX_BUFFER *OutData)
EFI_STATUS EFIAPI Tpm2NvExtend(IN TPMI_RH_NV_AUTH AuthHandle, IN TPMI_RH_NV_INDEX NvIndex, IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL, IN TPM2B_MAX_BUFFER *InData)
EFI_STATUS EFIAPI Tpm2NvReadLock(IN TPMI_RH_NV_AUTH AuthHandle, IN TPMI_RH_NV_INDEX NvIndex, IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL)
EFI_STATUS EFIAPI Tpm2NvUndefineSpace(IN TPMI_RH_PROVISION AuthHandle, IN TPMI_RH_NV_INDEX NvIndex, IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL)
EFI_STATUS EFIAPI Tpm2NvReadPublic(IN TPMI_RH_NV_INDEX NvIndex, OUT TPM2B_NV_PUBLIC *NvPublic, OUT TPM2B_NAME *NvName)
EFI_STATUS EFIAPI Tpm2NvWrite(IN TPMI_RH_NV_AUTH AuthHandle, IN TPMI_RH_NV_INDEX NvIndex, IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL, IN TPM2B_MAX_BUFFER *InData, IN UINT16 Offset)