ia64/xen-unstable

view linux-2.6-xen-sparse/drivers/char/tpm/tpm_nopci.h @ 7169:dd87869f877c

Allow adjustment of the size of TPM transfer buffers
to the size that a lower-layer driver supports.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Oct 03 15:05:37 2005 +0100 (2005-10-03)
parents 06d84bf87159
children
line source
1 /*
2 * Copyright (C) 2004 IBM Corporation
3 *
4 * Authors:
5 * Leendert van Doorn <leendert@watson.ibm.com>
6 * Dave Safford <safford@watson.ibm.com>
7 * Reiner Sailer <sailer@watson.ibm.com>
8 * Kylene Hall <kjhall@us.ibm.com>
9 *
10 * Maintained by: <tpmdd_devel@lists.sourceforge.net>
11 *
12 * Device driver for TCG/TCPA TPM (trusted platform module).
13 * Specifications at www.trustedcomputinggroup.org
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation, version 2 of the
18 * License.
19 *
20 */
21 #include <linux/module.h>
22 #include <linux/version.h>
23 #include <linux/pci.h>
24 #include <linux/delay.h>
25 #include <linux/miscdevice.h>
27 enum {
28 TPM_TIMEOUT = 5, /* msecs */
29 TPM_NUM_ATTR = 4
30 };
32 /* TPM addresses */
33 enum {
34 TPM_ADDR = 0x4E,
35 TPM_DATA = 0x4F
36 };
38 /*
39 * Chip num is this value or a valid tpm idx in lower two bytes of chip_id
40 */
41 enum tpm_chip_num {
42 TPM_ANY_NUM = 0xFFFF,
43 };
45 #define TPM_CHIP_NUM_MASK 0x0000ffff
47 extern ssize_t tpm_show_pubek(struct device *, char *);
48 extern ssize_t tpm_show_pcrs(struct device *, char *);
49 extern ssize_t tpm_show_caps(struct device *, char *);
50 extern ssize_t tpm_store_cancel(struct device *, const char *, size_t);
52 #define TPM_DEVICE_ATTRS { \
53 __ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL), \
54 __ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL), \
55 __ATTR(caps, S_IRUGO, tpm_show_caps, NULL), \
56 __ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel) }
58 struct tpm_chip;
60 struct tpm_vendor_specific {
61 u8 req_complete_mask;
62 u8 req_complete_val;
63 u8 req_canceled;
64 u16 base; /* TPM base address */
65 u32 buffersize; /* The device's requested buffersize */
67 int (*recv) (struct tpm_chip *, u8 *, size_t);
68 int (*send) (struct tpm_chip *, u8 *, size_t);
69 void (*cancel) (struct tpm_chip *);
70 u8(*status) (struct tpm_chip *);
71 struct miscdevice miscdev;
72 struct device_attribute attr[TPM_NUM_ATTR];
73 };
75 struct tpm_chip {
76 struct device *dev; /* PCI device stuff */
78 int dev_num; /* /dev/tpm# */
79 int num_opens; /* only one allowed */
80 int time_expired;
82 /* Data passed to and from the tpm via the read/write calls */
83 u8 *data_buffer;
84 atomic_t data_pending;
85 atomic_t data_position;
86 struct semaphore buffer_mutex;
88 struct timer_list user_read_timer; /* user needs to claim result */
89 struct semaphore tpm_mutex; /* tpm is processing */
91 struct tpm_vendor_specific *vendor;
93 struct list_head list;
94 };
96 static inline int tpm_read_index(int index)
97 {
98 outb(index, TPM_ADDR);
99 return inb(TPM_DATA) & 0xFF;
100 }
102 static inline void tpm_write_index(int index, int value)
103 {
104 outb(index, TPM_ADDR);
105 outb(value & 0xFF, TPM_DATA);
106 }
108 extern void tpm_time_expired(unsigned long);
109 extern int tpm_lpc_bus_init(struct pci_dev *, u16);
111 extern int tpm_register_hardware_nopci(struct device *,
112 struct tpm_vendor_specific *);
113 extern void tpm_remove_hardware(struct device *);
114 extern int tpm_open(struct inode *, struct file *);
115 extern int tpm_release(struct inode *, struct file *);
116 extern ssize_t tpm_write(struct file *, const char __user *, size_t,
117 loff_t *);
118 extern ssize_t tpm_read(struct file *, char __user *, size_t, loff_t *);
119 extern int tpm_pcr_extend(u32 chip_id, int pcr_idx, const u8* hash);
120 extern int tpm_pcr_read( u32 chip_id, int pcr_idx, u8* res_buf, int res_buf_size );
122 extern int tpm_pm_suspend(struct pci_dev *, u32);
123 extern int tpm_pm_resume(struct pci_dev *);
125 /* internal kernel interface */
126 extern ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
127 size_t bufsiz);
128 extern struct tpm_chip *tpm_chip_lookup(int chip_num);