| OLD | NEW |
| 1 /* Software-Based Trusted Platform Module (TPM) Emulator for OpenBSD | 1 /* Software-based Trusted Platform Module (TPM) Emulator |
| 2 * Copyright (C) 2004-2010 Mario Strasser <mast@gmx.net> |
| 2 * Copyright (C) 2007 Sebastian Schuetz <sebastian_schuetz@genua.de> | 3 * Copyright (C) 2007 Sebastian Schuetz <sebastian_schuetz@genua.de> |
| 3 * Copyright (C) 2007 Mario Strasser <mast@gmx.net>, | |
| 4 * Swiss Federal Institute of Technology (ETH) Zurich | |
| 5 * | 4 * |
| 6 * This program is free software; you can redistribute it and/or modify | 5 * This module is free software; you can redistribute it and/or modify |
| 7 * it under the terms of the GNU General Public License as published | 6 * it under the terms of the GNU General Public License as published |
| 8 * by the Free Software Foundation; either version 2 of the License, | 7 * by the Free Software Foundation; either version 2 of the License, |
| 9 * or (at your option) any later version. | 8 * or (at your option) any later version. |
| 10 * | 9 * |
| 11 * This program is distributed in the hope that it will be useful, | 10 * This module is distributed in the hope that it will be useful, |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 * GNU General Public License for more details. | 13 * GNU General Public License for more details. |
| 15 * | 14 * |
| 16 * $Id$ | 15 * $Id$ |
| 17 */ | 16 */ |
| 18 | 17 |
| 19 #ifndef _TPM_DEV_HEADER_ | 18 #ifndef _TPM_DEV_HEADER_ |
| 20 #define _TPM_DEV_HEADER_ | 19 #define _TPM_DEV_HEADER_ |
| 21 | 20 |
| 21 #include "config.h" |
| 22 |
| 22 #define cdev_tpm_init(c,n) { \ | 23 #define cdev_tpm_init(c,n) { \ |
| 23 dev_init(c,n,open),dev_init(c,n,close),dev_init(c,n,read), \ | 24 dev_init(c,n,open),dev_init(c,n,close),dev_init(c,n,read), \ |
| 24 dev_init(c,n,write), dev_init(c,n,ioctl),(dev_type_stop((*))) lkmenodev, \ | 25 dev_init(c,n,write), dev_init(c,n,ioctl),(dev_type_stop((*))) lkmenodev, \ |
| 25 0,(dev_type_poll((*))) lkmenodev,(dev_type_mmap((*))) lkmenodev } | 26 0,(dev_type_poll((*))) lkmenodev,(dev_type_mmap((*))) lkmenodev } |
| 26 | 27 |
| 27 | 28 |
| 28 /* This code is from linux_module.c */ | 29 /* This code is from linux_module.c */ |
| 29 | 30 |
| 30 /* module state */ | 31 /* module state */ |
| 31 static uint32_t module_state; | 32 static uint32_t module_state; |
| 32 static struct socket *tpmd_sock = NULL; | 33 static struct socket *tpmd_sock = NULL; |
| 33 static struct mbuf *nm = NULL; | 34 static struct mbuf *nm = NULL; |
| 34 static struct simplelock slock; | 35 static struct simplelock slock; |
| 35 | 36 |
| 36 char tpmd_socket_name[] = "/var/tpm/tpmd_socket:0"; | 37 char tpmd_socket_name[] = TPM_SOCKET_NAME; |
| 37 | 38 |
| 38 #define TPM_MODULE_NAME "tpm_dev" | 39 #define TPM_MODULE_NAME "tpm_dev" |
| 39 #define TPM_STATE_IS_OPEN 0 | 40 #define TPM_STATE_IS_OPEN 0 |
| 40 | 41 |
| 41 | 42 |
| 42 #ifdef DEBUG | 43 #ifdef DEBUG |
| 43 #define debug(fmt, ...) printf("%s %s:%d: Debug: " fmt "\n", \ | 44 #define debug(fmt, ...) printf("%s %s:%d: Debug: " fmt "\n", \ |
| 44 TPM_MODULE_NAME, __FILE__, __LINE__, ## __VA_ARGS__) | 45 TPM_MODULE_NAME, __FILE__, __LINE__, ## __VA_ARGS__) |
| 45 #else | 46 #else |
| 46 #define debug(fmt, ...) | 47 #define debug(fmt, ...) |
| 47 #endif | 48 #endif |
| 48 #define error(fmt, ...) printf("%s %s:%d: Error: " fmt "\n", \ | 49 #define error(fmt, ...) printf("%s %s:%d: Error: " fmt "\n", \ |
| 49 TPM_MODULE_NAME, __FILE__, __LINE__, ## __VA_ARGS__) | 50 TPM_MODULE_NAME, __FILE__, __LINE__, ## __VA_ARGS__) |
| 50 | 51 |
| 51 #endif /* _TPM_DEV_HEADER_ */ | 52 #endif /* _TPM_DEV_HEADER_ */ |
| OLD | NEW |