Compilation Error When Trying to include TPM Header Files

Hi All,
I am trying to make use of a couple of TPM V2 APIs in the FIT Image Signature verification flow. For the same, I have tried including the TPM header files in the following manner: I'm working with the Master Branch.
diff --git a/common/image-fit-sig.c b/common/image-fit-sig.c index 63e5423c92..529da516cc 100644 --- a/common/image-fit-sig.c +++ b/common/image-fit-sig.c @@ -18,6 +18,9 @@ DECLARE_GLOBAL_DATA_PTR; #include <u-boot/rsa.h> #include <u-boot/hash-checksum.h>
+#include <tpm-common.h> +#include <tpm-v2.h> + #define IMAGE_MAX_HASHED_NODES 100
/**
However, on compiling I get the following error:
UPD include/generated/timestamp_autogenerated.h CFGCHK u-boot.cfg HOSTCC tools/aisimage.o HOSTCC tools/atmelimage.o HOSTCC tools/fit_image.o HOSTCC tools/fit_common.o HOSTCC tools/image-host.o HOSTCC tools/common/image-fit.o HOSTCC tools/image-sig-host.o HOSTCC tools/common/image-fit-sig.o HOSTCC tools/common/image-cipher.o In file included from ./tools/../common/image-fit-sig.c:21, from tools/common/image-fit-sig.c:1: include/tpm-common.h:66:2: error: unknown type name ‘u8’ 66 | u8 buf[TPM_DEV_BUFSIZE + sizeof(u8)]; /* Max buffer size + addr */ | ^~ include/tpm-common.h:66:34: error: ‘u8’ undeclared here (not in a function) 66 | u8 buf[TPM_DEV_BUFSIZE + sizeof(u8)]; /* Max buffer size + addr */ | ^~ include/tpm-common.h:131:44: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token 131 | int (*send)(struct udevice *dev, const u8 *sendbuf, size_t send_size); | ^ include/tpm-common.h:144:35: error: expected declaration specifiers or ‘...’ before ‘u8’ 144 | int (*recv)(struct udevice *dev, u8 *recvbuf, size_t max_size); | ^~ include/tpm-common.h:173:44: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token 173 | int (*xfer)(struct udevice *dev, const u8 *sendbuf, size_t send_size, | ^ include/tpm-common.h:259:44: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token 259 | int tpm_xfer(struct udevice *dev, const u8 *sendbuf, size_t send_size, | ^ In file included from ./tools/../common/image-fit-sig.c:22, from tools/common/image-fit-sig.c:1: include/tpm-v2.h:117:2: error: unknown type name ‘u16’ 117 | u16 hash; | ^~~ include/tpm-v2.h:118:2: error: expected specifier-qualifier-list before ‘u8’ 118 | u8 size_of_select; | ^~ include/tpm-v2.h:120:3: error: conflicting types for ‘__packed’ 120 | } __packed; | ^~~~~~~~ include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here 113 | } __packed; | ^~~~~~~~ include/tpm-v2.h:126:3: error: conflicting types for ‘__packed’ 126 | } __packed; | ^~~~~~~~ include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here 113 | } __packed; | ^~~~~~~~ include/tpm-v2.h:132:3: error: conflicting types for ‘__packed’ 132 | } __packed; | ^~~~~~~~ include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here 113 | } __packed; | ^~~~~~~~ include/tpm-v2.h:142:3: error: conflicting types for ‘__packed’ 142 | } __packed; | ^~~~~~~~ include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here 113 | } __packed; | ^~~~~~~~ include/tpm-v2.h:148:3: error: conflicting types for ‘__packed’ 148 | } __packed; | ^~~~~~~~ include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here 113 | } __packed; | ^~~~~~~~ include/tpm-v2.h:162:2: error: expected specifier-qualifier-list before ‘u8’ 162 | u8 digest[TPM2_SHA1_DIGEST_SIZE]; | ^~ include/tpm-v2.h:165:3: error: conflicting types for ‘__packed’ 165 | } __packed; | ^~~~~~~~ include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here 113 | } __packed; | ^~~~~~~~ include/tpm-v2.h:171:2: error: expected specifier-qualifier-list before ‘u8’ 171 | u8 sha1[TPM2_SHA1_DIGEST_SIZE]; | ^~ include/tpm-v2.h:176:3: error: conflicting types for ‘__packed’ 176 | } __packed; | ^~~~~~~~ include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here 113 | } __packed; | ^~~~~~~~ include/tpm-v2.h:185:2: error: unknown type name ‘u16’ 185 | u16 hash_alg; | ^~~ include/tpm-v2.h:187:3: error: conflicting types for ‘__packed’ 187 | } __packed; | ^~~~~~~~ include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here 113 | } __packed; | ^~~~~~~~ include/tpm-v2.h:198:3: error: conflicting types for ‘__packed’ 198 | } __packed; | ^~~~~~~~ include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here 113 | } __packed; | ^~~~~~~~ include/tpm-v2.h:214:2: error: expected specifier-qualifier-list before ‘u8’ 214 | u8 event[]; | ^~ include/tpm-v2.h:215:3: error: conflicting types for ‘__packed’ 215 | } __packed; | ^~~~~~~~ include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here 113 | } __packed; | ^~~~~~~~ include/tpm-v2.h:469:14: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token 469 | const u8 *nv_policy, size_t nv_policy_size); | ^ include/tpm-v2.h:483:16: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token 483 | const u8 *digest, u32 digest_len); | ^ make[1]: *** [scripts/Makefile.host:112: tools/common/image-fit-sig.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1804: tools] Error 2
It seems that the 'u8' and 'u16' can be circumvented by adding typedefs, however I'm not sure how files like lib/tpm-v2.c and lib/tpm_api.c include these headers without compilation error.
Please let me know if I'm missing something trivial in the above inclusions or how can I include the tpm-v2 header files?
participants (1)
-
Harshvardhan Patel