Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 The Chromium OS Authors. |
| 3 | * |
| 4 | * See file CREDITS for list of people who contributed to this |
| 5 | * project. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of |
| 10 | * the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 20 | * MA 02111-1307 USA |
| 21 | */ |
| 22 | |
| 23 | #ifndef __TIS_H |
| 24 | #define __TIS_H |
| 25 | |
| 26 | #include <common.h> |
| 27 | |
| 28 | /* Low-level interface to access TPM */ |
| 29 | |
| 30 | /* |
| 31 | * tis_init() |
| 32 | * |
| 33 | * Initialize the TPM device. Returns 0 on success or -1 on |
| 34 | * failure (in case device probing did not succeed). |
| 35 | */ |
| 36 | int tis_init(void); |
| 37 | |
| 38 | /* |
| 39 | * tis_open() |
| 40 | * |
| 41 | * Requests access to locality 0 for the caller. After all commands have been |
| 42 | * completed the caller is supposed to call tis_close(). |
| 43 | * |
| 44 | * Returns 0 on success, -1 on failure. |
| 45 | */ |
| 46 | int tis_open(void); |
| 47 | |
| 48 | /* |
| 49 | * tis_close() |
| 50 | * |
| 51 | * terminate the currect session with the TPM by releasing the locked |
| 52 | * locality. Returns 0 on success of -1 on failure (in case lock |
| 53 | * removal did not succeed). |
| 54 | */ |
| 55 | int tis_close(void); |
| 56 | |
| 57 | /* |
| 58 | * tis_sendrecv() |
| 59 | * |
| 60 | * Send the requested data to the TPM and then try to get its response |
| 61 | * |
| 62 | * @sendbuf - buffer of the data to send |
| 63 | * @send_size size of the data to send |
| 64 | * @recvbuf - memory to save the response to |
| 65 | * @recv_len - pointer to the size of the response buffer |
| 66 | * |
| 67 | * Returns 0 on success (and places the number of response bytes at recv_len) |
| 68 | * or -1 on failure. |
| 69 | */ |
| 70 | int tis_sendrecv(const uint8_t *sendbuf, size_t send_size, uint8_t *recvbuf, |
| 71 | size_t *recv_len); |
| 72 | |
| 73 | #endif /* __TIS_H */ |