diff options
author | yfeng <yu.feng@windriver.com> | 2019-07-09 18:09:07 +0800 |
---|---|---|
committer | Andreas Fuchs <andreas.fuchs@sit.fraunhofer.de> | 2019-07-10 11:37:26 +0200 |
commit | 51dd30d413b51e180009646d5273551da9b8ab56 (patch) | |
tree | 83b6bda1f6631888f63ab2faccd2caa18c816de4 | |
parent | 7da2391547c08157ce3046f8049aa527cfb105fc (diff) | |
download | tpm2-tss-51dd30d413b51e180009646d5273551da9b8ab56.tar.gz |
[TCTI/ESYS] Enable building on VxWorks
This patch allows building on VxWorks by:
- Adding the VXWORKS makro to several places
- Pointing to a different location for poll.h on VxWorks (i.e. sys/poll.h)
- Pointing to /tpm0 instead of /dev/tpm0 for the device node (ESYS and TCTI)
- Using a 3-parameter version of open() despite O_CREAT.
VxWorks does not support a 2-parameter version. It will also check
file-permissions vs the third parameter of open().
Signed-off-by: yfeng <yu.feng@windriver.com>
-rwxr-xr-x[-rw-r--r--] | include/tss2/tss2_tcti.h | 31 | ||||
-rwxr-xr-x[-rw-r--r--] | src/tss2-esys/esys_tcti_default.c | 27 | ||||
-rwxr-xr-x[-rw-r--r--] | src/tss2-tcti/tcti-device.c | 37 |
3 files changed, 94 insertions, 1 deletions
diff --git a/include/tss2/tss2_tcti.h b/include/tss2/tss2_tcti.h index 5e4c5d40..e1a4536d 100644..100755 --- a/include/tss2/tss2_tcti.h +++ b/include/tss2/tss2_tcti.h @@ -5,6 +5,31 @@ * Copyright 2015, Andreas Fuchs @ Fraunhofer SIT * * All rights reserved. + * + * Copyright (c) 2019, Wind River Systems. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef TSS2_TCTI_H #define TSS2_TCTI_H @@ -18,8 +43,12 @@ #error Version mismatch among TSS2 header files. #endif /* TSS2_API_VERSION_1_2_1_108 */ -#if defined(__linux__) || defined(__unix__) || defined(__APPLE__) || defined (__QNXNTO__) +#if defined(__linux__) || defined(__unix__) || defined(__APPLE__) || defined (__QNXNTO__) || defined (__VXWORKS__) +#if defined (__VXWORKS__) +#include <sys/poll.h> +#else #include <poll.h> +#endif typedef struct pollfd TSS2_TCTI_POLL_HANDLE; #elif defined(_WIN32) #include <windows.h> diff --git a/src/tss2-esys/esys_tcti_default.c b/src/tss2-esys/esys_tcti_default.c index e216411b..ec758688 100644..100755 --- a/src/tss2-esys/esys_tcti_default.c +++ b/src/tss2-esys/esys_tcti_default.c @@ -2,6 +2,30 @@ /******************************************************************************* * Copyright 2017-2018, Fraunhofer SIT sponsored by Infineon Technologies AG * All rights reserved. + * Copyright (c) 2019, Wind River Systems. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ #ifdef HAVE_CONFIG_H @@ -44,6 +68,9 @@ struct { #ifdef _WIN32 { .init = Tss2_Tcti_Tbs_Init, .conf = "", .description = "Access to TBS" }, +#elif defined (__VXWORKS__) + { .init = Tss2_Tcti_Device_Init, .conf = "/tpm0", + .description = "Access to /tpm0" }, #else /* _WIN32 */ #ifdef TCTI_DEVICE { .init = Tss2_Tcti_Device_Init, .conf = "/dev/tpmrm0", diff --git a/src/tss2-tcti/tcti-device.c b/src/tss2-tcti/tcti-device.c index f136e6cc..44c9fe20 100644..100755 --- a/src/tss2-tcti/tcti-device.c +++ b/src/tss2-tcti/tcti-device.c @@ -2,6 +2,30 @@ /* * Copyright (c) 2015 - 2018 Intel Corporation * All rights reserved. + * Copyright (c) 2019, Wind River Systems. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H @@ -16,7 +40,11 @@ #include <string.h> #include <sys/stat.h> #include <sys/types.h> +#ifdef __VXWORKS__ +#include <sys/poll.h> +#else #include <poll.h> +#endif #include <unistd.h> #include "tss2_tcti.h" @@ -28,7 +56,12 @@ #define LOGMODULE tcti #include "util/log.h" +#ifdef __VXWORKS__ +#define TCTI_DEVICE_DEFAULT "/tpm0" +#else #define TCTI_DEVICE_DEFAULT "/dev/tpm0" +#endif + /* * This function wraps the "up-cast" of the opaque TCTI context type to the * type for the device TCTI context. The only safe-guard we have to ensure @@ -397,7 +430,11 @@ Tss2_Tcti_Device_Init ( memset (&tcti_common->header, 0, sizeof (tcti_common->header)); tcti_common->locality = 3; +#ifdef __VXWORKS__ + tcti_dev->fd = open (dev_path, O_RDWR, (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)); +#else tcti_dev->fd = open (dev_path, O_RDWR | O_NONBLOCK); +#endif if (tcti_dev->fd < 0) { LOG_ERROR ("Failed to open device file %s: %s", dev_path, strerror (errno)); |