1 /* $MirOS: src/sys/dev/ic/tpm.h,v 1.3 2010/07/25 16:36:18 tg Exp $ */ 2 3 /*- 4 * Copyright (c) 2009 Thorsten Glaser <tg@mirbsd.org> 5 * Copyright (c) 2003 Rick Wash <rwash@citi.umich.edu> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 #ifndef TPM_H 21 #define TPM_H 22 23 struct timeout; 24 25 #define TPM_BUFFER_LEN 2048 26 27 struct tpm_softc { 28 struct device sc_dev; /* generic device info */ 29 /* device specific information */ 30 u_int8_t buffer[TPM_BUFFER_LEN]; /* memory for requests and replies */ 31 int type; /* chipset type */ 32 int wait_timeout; /* poll timeout counter */ 33 int retval; /* return value (length or error) */ 34 int len; /* size of data */ 35 struct timeout tmo; /* for polling */ 36 u_int16_t base; /* base address */ 37 uint8_t initialised; /* flag - initialised chip */ 38 uint8_t open; /* exclusive open flag */ 39 unsigned char version[4]; /* Version number */ 40 unsigned char vendor[5]; /* vendor name */ 41 enum tpm_poll_state { 42 TPM_STATE_READY = 0, 43 TPM_STATE_READ_START, 44 TPM_STATE_WAIT_FOR_DATA, 45 TPM_STATE_READ_DONE, 46 TPM_STATE_WRITE_START, 47 TPM_STATE_WRITE_BUSY, 48 TPM_STATE_WRITE_WORKING, 49 TPM_STATE_WRITE_DONE, 50 TPM_STATE_ERROR, 51 TPM_STATE_MAX 52 } state; /* interrupt poll state */ 53 }; 54 55 enum tpm_chip_type { 56 TPM_INVALID_CHIP = 0, 57 ICH2LPC, 58 ICH3LPCM, 59 ICH4LPC, 60 ICH4LPCM 61 }; 62 63 struct tpm_attach_args { 64 char *busname; 65 enum tpm_chip_type chiptype; 66 }; 67 68 int tpm_match(struct device *, void *, void *); 69 void tpm_attach(struct device *, struct device *, void *); 70 71 int tpmopen(dev_t dev, int flag, int mode, struct proc *p); 72 int tpmclose(dev_t dev, int flag, int mode, struct proc *p); 73 int tpmwrite(dev_t dev, struct uio *uio, int flags); 74 int tpmread(dev_t dev, struct uio *uio, int flags); 75 int tpmioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p); 76 77 #endif 78