Stefan Reinauer | 7cb01e0 | 2013-08-29 16:05:02 -0700 | [diff] [blame] | 1 | /* |
Stefan Reinauer | d518c7a | 2013-11-04 17:38:32 -0800 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
| 3 | * |
Stefan Reinauer | 7cb01e0 | 2013-08-29 16:05:02 -0700 | [diff] [blame] | 4 | * Copyright 2011 Google Inc. |
| 5 | * |
Stefan Reinauer | d518c7a | 2013-11-04 17:38:32 -0800 | [diff] [blame] | 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
Stefan Reinauer | 7cb01e0 | 2013-08-29 16:05:02 -0700 | [diff] [blame] | 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Stefan Reinauer | 7cb01e0 | 2013-08-29 16:05:02 -0700 | [diff] [blame] | 14 | */ |
| 15 | |
Stefan Reinauer | d518c7a | 2013-11-04 17:38:32 -0800 | [diff] [blame] | 16 | #ifndef TPM_H_ |
| 17 | #define TPM_H_ |
Stefan Reinauer | 7cb01e0 | 2013-08-29 16:05:02 -0700 | [diff] [blame] | 18 | |
| 19 | #include <stddef.h> |
| 20 | #include <stdint.h> |
| 21 | |
Stefan Reinauer | 7cb01e0 | 2013-08-29 16:05:02 -0700 | [diff] [blame] | 22 | /* |
| 23 | * tis_init() |
| 24 | * |
| 25 | * Initialize the TPM device. Returns 0 on success or -1 on |
| 26 | * failure (in case device probing did not succeed). |
| 27 | */ |
| 28 | int tis_init(void); |
| 29 | |
| 30 | /* |
| 31 | * tis_open() |
| 32 | * |
| 33 | * Requests access to locality 0 for the caller. After all commands have been |
| 34 | * completed the caller is supposed to call tis_close(). |
| 35 | * |
| 36 | * Returns 0 on success, -1 on failure. |
| 37 | */ |
| 38 | int tis_open(void); |
| 39 | |
| 40 | /* |
| 41 | * tis_close() |
| 42 | * |
| 43 | * terminate the currect session with the TPM by releasing the locked |
| 44 | * locality. Returns 0 on success of -1 on failure (in case lock |
| 45 | * removal did not succeed). |
| 46 | */ |
| 47 | int tis_close(void); |
| 48 | |
| 49 | /* |
| 50 | * tis_sendrecv() |
| 51 | * |
| 52 | * Send the requested data to the TPM and then try to get its response |
| 53 | * |
| 54 | * @sendbuf - buffer of the data to send |
| 55 | * @send_size size of the data to send |
| 56 | * @recvbuf - memory to save the response to |
| 57 | * @recv_len - pointer to the size of the response buffer |
| 58 | * |
| 59 | * Returns 0 on success (and places the number of response bytes at recv_len) |
| 60 | * or -1 on failure. |
| 61 | */ |
Stefan Reinauer | d518c7a | 2013-11-04 17:38:32 -0800 | [diff] [blame] | 62 | int tis_sendrecv(const u8 *sendbuf, size_t send_size, u8 *recvbuf, |
Stefan Reinauer | 7cb01e0 | 2013-08-29 16:05:02 -0700 | [diff] [blame] | 63 | size_t *recv_len); |
| 64 | |
Vladimir Serbinenko | 0e90dae | 2015-05-18 10:29:06 +0200 | [diff] [blame] | 65 | void init_tpm(int s3resume); |
| 66 | |
Stefan Reinauer | d518c7a | 2013-11-04 17:38:32 -0800 | [diff] [blame] | 67 | #endif /* TPM_H_ */ |