OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (C) 2011 Infineon Technologies |
| 3 * |
| 4 * Authors: |
| 5 * |
| 6 * Device driver for TCG/TCPA TPM (trusted platform module). |
| 7 * Specifications at www.trustedcomputinggroup.org |
| 8 * |
| 9 * It is based on the Linux kernel driver tpm.c from Leendert van |
| 10 * Dorn, Dave Safford, Reiner Sailer, and Kyleen Hall. |
| 11 * |
| 12 * This program is free software; you can redistribute it and/or |
| 13 * modify it under the terms of the GNU General Public License as |
| 14 * published by the Free Software Foundation, version 2 of the |
| 15 * License. |
| 16 * |
| 17 */ |
| 18 |
| 19 #ifndef _TPM_H_ |
| 20 #define _TPM_H_ |
| 21 |
| 22 #include "compatibility.h" |
| 23 |
| 24 enum tpm_timeout { |
| 25 TPM_TIMEOUT = 5, /* msecs */ |
| 26 }; |
| 27 |
| 28 /* Index of fields in TPM command buffer */ |
| 29 #define TPM_CMD_SIZE_BYTE 2 |
| 30 #define TPM_CMD_ORDINAL_BYTE 6 |
| 31 |
| 32 /* Index of Count field in TPM response buffer */ |
| 33 #define TPM_RSP_SIZE_BYTE 2 |
| 34 #define TPM_RSP_RC_BYTE 6 |
| 35 |
| 36 struct tpm_chip; |
| 37 |
| 38 struct tpm_vendor_specific { |
| 39 const u8 req_complete_mask; |
| 40 const u8 req_complete_val; |
| 41 const u8 req_canceled; |
| 42 |
| 43 int irq; |
| 44 |
| 45 int (*recv) (struct tpm_chip *, u8 *, size_t); |
| 46 int (*send) (struct tpm_chip *, u8 *, size_t); |
| 47 void (*cancel) (struct tpm_chip *); |
| 48 u8(*status) (struct tpm_chip *); |
| 49 int locality; |
| 50 unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* jiffies */ |
| 51 unsigned long duration[3]; /* jiffies */ |
| 52 |
| 53 int (*init) (struct device *); |
| 54 }; |
| 55 |
| 56 struct tpm_chip { |
| 57 int is_open; |
| 58 struct tpm_vendor_specific vendor; |
| 59 }; |
| 60 |
| 61 struct tpm_input_header { |
| 62 __be16 tag; |
| 63 __be32 length; |
| 64 __be32 ordinal; |
| 65 } __attribute__ ((packed)); |
| 66 |
| 67 struct tpm_output_header { |
| 68 __be16 tag; |
| 69 __be32 length; |
| 70 __be32 return_code; |
| 71 } __attribute__ ((packed)); |
| 72 |
| 73 struct timeout_t { |
| 74 __be32 a; |
| 75 __be32 b; |
| 76 __be32 c; |
| 77 __be32 d; |
| 78 } __attribute__ ((packed)); |
| 79 |
| 80 struct duration_t { |
| 81 __be32 tpm_short; |
| 82 __be32 tpm_medium; |
| 83 __be32 tpm_long; |
| 84 } __attribute__ ((packed)); |
| 85 |
| 86 typedef union { |
| 87 struct timeout_t timeout; |
| 88 struct duration_t duration; |
| 89 } cap_t; |
| 90 |
| 91 struct tpm_getcap_params_in { |
| 92 __be32 cap; |
| 93 __be32 subcap_size; |
| 94 __be32 subcap; |
| 95 } __attribute__ ((packed)); |
| 96 |
| 97 struct tpm_getcap_params_out { |
| 98 __be32 cap_size; |
| 99 cap_t cap; |
| 100 } __attribute__ ((packed)); |
| 101 |
| 102 typedef union { |
| 103 struct tpm_input_header in; |
| 104 struct tpm_output_header out; |
| 105 } tpm_cmd_header; |
| 106 |
| 107 typedef union { |
| 108 struct tpm_getcap_params_out getcap_out; |
| 109 struct tpm_getcap_params_in getcap_in; |
| 110 } tpm_cmd_params; |
| 111 |
| 112 struct tpm_cmd_t { |
| 113 tpm_cmd_header header; |
| 114 tpm_cmd_params params; |
| 115 } __attribute__ ((packed)); |
| 116 |
| 117 |
| 118 /* ---------- Interface for tpm_tis_i2c ------------ */ |
| 119 |
| 120 extern struct tpm_chip *tpm_register_hardware(struct device *, |
| 121 const struct tpm_vendor_specific |
| 122 *); |
| 123 |
| 124 |
| 125 /* ---------- Interface for TDDL ------------------- */ |
| 126 |
| 127 /* |
| 128 * Returns < 0 on error, 0 on success. |
| 129 */ |
| 130 extern int tpm_open(void); |
| 131 |
| 132 extern void tpm_close(void); |
| 133 |
| 134 /* |
| 135 * Transmit bufsiz bytes out of buf to TPM and get results back in buf, too. |
| 136 * Returns < 0 on error, 0 on success. |
| 137 */ |
| 138 extern ssize_t tpm_transmit(const unsigned char *buf, size_t bufsiz); |
| 139 |
| 140 #endif |
OLD | NEW |