blob: b15ca6e76f3dc500ef652d3ad1fb4b5a70eb82b7 [file] [log] [blame]
Stefan Reinauer7cb01e02013-08-29 16:05:02 -07001/*
Stefan Reinauerd518c7a2013-11-04 17:38:32 -08002 * This file is part of the coreboot project.
3 *
Stefan Reinauer7cb01e02013-08-29 16:05:02 -07004 * Copyright 2011 Google Inc.
5 *
Stefan Reinauerd518c7a2013-11-04 17:38:32 -08006 * 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 Reinauer7cb01e02013-08-29 16:05:02 -07009 *
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 Reinauer7cb01e02013-08-29 16:05:02 -070014 */
15
Stefan Reinauerd518c7a2013-11-04 17:38:32 -080016#ifndef TPM_H_
17#define TPM_H_
Stefan Reinauer7cb01e02013-08-29 16:05:02 -070018
19#include <stddef.h>
20#include <stdint.h>
21
Stefan Reinauer7cb01e02013-08-29 16:05:02 -070022/*
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 */
28int 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 */
38int 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 */
47int 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 Reinauerd518c7a2013-11-04 17:38:32 -080062int tis_sendrecv(const u8 *sendbuf, size_t send_size, u8 *recvbuf,
Stefan Reinauer7cb01e02013-08-29 16:05:02 -070063 size_t *recv_len);
64
Vladimir Serbinenko0e90dae2015-05-18 10:29:06 +020065void init_tpm(int s3resume);
66
Stefan Reinauerd518c7a2013-11-04 17:38:32 -080067#endif /* TPM_H_ */