Initial commit to seed TPM2.0 source code directory
LICENSE file text copied from TCG library specification. README
describes the procedure used to extract source code from parts 3 and 4
of the specification.
The python scripts and part{34}.txt files will be removed in the
following commits.
Change-Id: Ie281e6e988481831f33483053455e8aff8f3f75f
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
diff --git a/Locality.c b/Locality.c
new file mode 100644
index 0000000..df1d7df
--- /dev/null
+++ b/Locality.c
@@ -0,0 +1,47 @@
+// This file was extracted from the TCG Published
+// Trusted Platform Module Library
+// Part 4: Supporting Routines
+// Family "2.0"
+// Level 00 Revision 01.16
+// October 30, 2014
+
+#include "InternalRoutines.h"
+//
+//
+// LocalityGetAttributes()
+//
+// This function will convert a locality expressed as an integer into TPMA_LOCALITY form.
+// The function returns the locality attribute.
+//
+TPMA_LOCALITY
+LocalityGetAttributes(
+ UINT8 locality // IN: locality value
+ )
+{
+ TPMA_LOCALITY locality_attributes;
+ BYTE *localityAsByte = (BYTE *)&locality_attributes;
+ MemorySet(&locality_attributes, 0, sizeof(TPMA_LOCALITY));
+ switch(locality)
+ {
+ case 0:
+ locality_attributes.TPM_LOC_ZERO = SET;
+ break;
+ case 1:
+ locality_attributes.TPM_LOC_ONE = SET;
+ break;
+ case 2:
+ locality_attributes.TPM_LOC_TWO = SET;
+ break;
+ case 3:
+ locality_attributes.TPM_LOC_THREE = SET;
+ break;
+ case 4:
+ locality_attributes.TPM_LOC_FOUR = SET;
+ break;
+ default:
+ pAssert(locality < 256 && locality > 31);
+ *localityAsByte = locality;
+ break;
+ }
+ return locality_attributes;
+}