tpmvar.h revision 1.4 1 1.4 maxv /* $NetBSD: tpmvar.h,v 1.4 2019/06/22 12:57:41 maxv Exp $ */
2 1.4 maxv
3 1.4 maxv /*
4 1.4 maxv * Copyright (c) 2019 The NetBSD Foundation, Inc.
5 1.4 maxv * All rights reserved.
6 1.4 maxv *
7 1.4 maxv * This code is derived from software contributed to The NetBSD Foundation
8 1.4 maxv * by Maxime Villard.
9 1.4 maxv *
10 1.4 maxv * Redistribution and use in source and binary forms, with or without
11 1.4 maxv * modification, are permitted provided that the following conditions
12 1.4 maxv * are met:
13 1.4 maxv * 1. Redistributions of source code must retain the above copyright
14 1.4 maxv * notice, this list of conditions and the following disclaimer.
15 1.4 maxv * 2. Redistributions in binary form must reproduce the above copyright
16 1.4 maxv * notice, this list of conditions and the following disclaimer in the
17 1.4 maxv * documentation and/or other materials provided with the distribution.
18 1.4 maxv *
19 1.4 maxv * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.4 maxv * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.4 maxv * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.4 maxv * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.4 maxv * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.4 maxv * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.4 maxv * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.4 maxv * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.4 maxv * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.4 maxv * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.4 maxv * POSSIBILITY OF SUCH DAMAGE.
30 1.4 maxv */
31 1.4 maxv
32 1.1 christos /*
33 1.1 christos * Copyright (c) 2008, 2009 Michael Shalayeff
34 1.4 maxv * Copyright (c) 2009, 2010 Hans-Joerg Hoexer
35 1.1 christos * All rights reserved.
36 1.1 christos *
37 1.1 christos * Permission to use, copy, modify, and distribute this software for any
38 1.1 christos * purpose with or without fee is hereby granted, provided that the above
39 1.1 christos * copyright notice and this permission notice appear in all copies.
40 1.1 christos *
41 1.1 christos * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
42 1.1 christos * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
43 1.1 christos * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
44 1.1 christos * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
45 1.1 christos * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
46 1.1 christos * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
47 1.1 christos * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
48 1.1 christos */
49 1.1 christos
50 1.4 maxv #define TPM_API_VERSION 1
51 1.4 maxv
52 1.4 maxv enum tpm_version {
53 1.4 maxv TPM_1_2,
54 1.4 maxv TPM_2_0
55 1.4 maxv };
56 1.4 maxv
57 1.4 maxv struct tpm_ioc_getinfo {
58 1.4 maxv uint32_t api_version;
59 1.4 maxv
60 1.4 maxv uint32_t tpm_version;
61 1.4 maxv uint32_t device_id;
62 1.4 maxv uint32_t device_rev;
63 1.4 maxv uint32_t device_caps;
64 1.4 maxv };
65 1.4 maxv
66 1.4 maxv #define TPM_IOC_GETINFO _IOR ('N', 0, struct tpm_ioc_getinfo)
67 1.4 maxv
68 1.4 maxv #ifdef _KERNEL
69 1.4 maxv
70 1.1 christos struct tpm_softc {
71 1.3 chs device_t sc_dev;
72 1.4 maxv enum tpm_version sc_ver;
73 1.1 christos void *sc_ih;
74 1.1 christos
75 1.4 maxv int (*sc_init)(struct tpm_softc *, int);
76 1.4 maxv int (*sc_start)(struct tpm_softc *, int);
77 1.4 maxv int (*sc_read)(struct tpm_softc *, void *, size_t, size_t *, int);
78 1.4 maxv int (*sc_write)(struct tpm_softc *, const void *, size_t);
79 1.4 maxv int (*sc_end)(struct tpm_softc *, int, int);
80 1.1 christos
81 1.1 christos bus_space_tag_t sc_bt, sc_batm;
82 1.1 christos bus_space_handle_t sc_bh, sc_bahm;
83 1.1 christos
84 1.4 maxv uint32_t sc_devid;
85 1.4 maxv uint32_t sc_rev;
86 1.4 maxv uint32_t sc_status;
87 1.4 maxv uint32_t sc_capabilities;
88 1.1 christos
89 1.1 christos int sc_flags;
90 1.1 christos #define TPM_OPEN 0x0001
91 1.1 christos
92 1.4 maxv int sc_vector;
93 1.1 christos };
94 1.1 christos
95 1.1 christos int tpm_intr(void *);
96 1.1 christos
97 1.4 maxv bool tpm12_suspend(device_t, const pmf_qual_t *);
98 1.4 maxv bool tpm12_resume(device_t, const pmf_qual_t *);
99 1.1 christos
100 1.1 christos int tpm_tis12_probe(bus_space_tag_t, bus_space_handle_t);
101 1.4 maxv int tpm_tis12_init(struct tpm_softc *, int);
102 1.1 christos int tpm_tis12_start(struct tpm_softc *, int);
103 1.2 christos int tpm_tis12_read(struct tpm_softc *, void *, size_t, size_t *, int);
104 1.2 christos int tpm_tis12_write(struct tpm_softc *, const void *, size_t);
105 1.1 christos int tpm_tis12_end(struct tpm_softc *, int, int);
106 1.1 christos
107 1.4 maxv #endif
108