ia64/xen-unstable

view linux-2.6-xen-sparse/drivers/char/tpm/tpm_nopci.h @ 7027:06d84bf87159

Merge latest xen-unstable into xen-ia64-unstable
author djm@kirby.fc.hp.com
date Thu Sep 22 11:42:01 2005 -0600 (2005-09-22)
parents 9af349b055e5 3233e7ecfa9f
children dd87869f877c b7d11c9b6be4
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 */
66 int (*recv) (struct tpm_chip *, u8 *, size_t);
67 int (*send) (struct tpm_chip *, u8 *, size_t);
68 void (*cancel) (struct tpm_chip *);
69 u8(*status) (struct tpm_chip *);
70 struct miscdevice miscdev;
71 struct device_attribute attr[TPM_NUM_ATTR];
72 };
74 struct tpm_chip {
75 struct device *dev; /* PCI device stuff */
77 int dev_num; /* /dev/tpm# */
78 int num_opens; /* only one allowed */
79 int time_expired;
81 /* Data passed to and from the tpm via the read/write calls */
82 u8 *data_buffer;
83 atomic_t data_pending;
84 atomic_t data_position;
85 struct semaphore buffer_mutex;
87 struct timer_list user_read_timer; /* user needs to claim result */
88 struct semaphore tpm_mutex; /* tpm is processing */
90 struct tpm_vendor_specific *vendor;
92 struct list_head list;
93 };
95 static inline int tpm_read_index(int index)
96 {
97 outb(index, TPM_ADDR);
98 return inb(TPM_DATA) & 0xFF;
99 }
101 static inline void tpm_write_index(int index, int value)
102 {
103 outb(index, TPM_ADDR);
104 outb(value & 0xFF, TPM_DATA);
105 }
107 extern void tpm_time_expired(unsigned long);
108 extern int tpm_lpc_bus_init(struct pci_dev *, u16);
110 extern int tpm_register_hardware_nopci(struct device *,
111 struct tpm_vendor_specific *);
112 extern void tpm_remove_hardware(struct device *);
113 extern int tpm_open(struct inode *, struct file *);
114 extern int tpm_release(struct inode *, struct file *);
115 extern ssize_t tpm_write(struct file *, const char __user *, size_t,
116 loff_t *);
117 extern ssize_t tpm_read(struct file *, char __user *, size_t, loff_t *);
118 extern int tpm_pcr_extend(u32 chip_id, int pcr_idx, const u8* hash);
119 extern int tpm_pcr_read( u32 chip_id, int pcr_idx, u8* res_buf, int res_buf_size );
121 extern int tpm_pm_suspend(struct pci_dev *, u32);
122 extern int tpm_pm_resume(struct pci_dev *);
124 /* internal kernel interface */
125 extern ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
126 size_t bufsiz);
127 extern struct tpm_chip *tpm_chip_lookup(int chip_num);