1ca01d6ddSTony Luck /* 2ca01d6ddSTony Luck * Persistent Storage - pstore.h 3ca01d6ddSTony Luck * 4ca01d6ddSTony Luck * Copyright (C) 2010 Intel Corporation <tony.luck@intel.com> 5ca01d6ddSTony Luck * 6ca01d6ddSTony Luck * This code is the generic layer to export data records from platform 7ca01d6ddSTony Luck * level persistent storage via a file system. 8ca01d6ddSTony Luck * 9ca01d6ddSTony Luck * This program is free software; you can redistribute it and/or modify 10ca01d6ddSTony Luck * it under the terms of the GNU General Public License version 2 as 11ca01d6ddSTony Luck * published by the Free Software Foundation. 12ca01d6ddSTony Luck * 13ca01d6ddSTony Luck * This program is distributed in the hope that it will be useful, 14ca01d6ddSTony Luck * but WITHOUT ANY WARRANTY; without even the implied warranty of 15ca01d6ddSTony Luck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16ca01d6ddSTony Luck * GNU General Public License for more details. 17ca01d6ddSTony Luck * 18ca01d6ddSTony Luck * You should have received a copy of the GNU General Public License 19ca01d6ddSTony Luck * along with this program; if not, write to the Free Software 20ca01d6ddSTony Luck * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21ca01d6ddSTony Luck */ 22ca01d6ddSTony Luck #ifndef _LINUX_PSTORE_H 23ca01d6ddSTony Luck #define _LINUX_PSTORE_H 24ca01d6ddSTony Luck 253d6d8d20SKees Cook #include <linux/time.h> 263d6d8d20SKees Cook #include <linux/kmsg_dump.h> 273d6d8d20SKees Cook 28ca01d6ddSTony Luck /* types */ 29ca01d6ddSTony Luck enum pstore_type_id { 30ca01d6ddSTony Luck PSTORE_TYPE_DMESG = 0, 31ca01d6ddSTony Luck PSTORE_TYPE_MCE = 1, 32f29e5956SAnton Vorontsov PSTORE_TYPE_CONSOLE = 2, 33*060287b8SAnton Vorontsov PSTORE_TYPE_FTRACE = 3, 34ca01d6ddSTony Luck PSTORE_TYPE_UNKNOWN = 255 35ca01d6ddSTony Luck }; 36ca01d6ddSTony Luck 37ca01d6ddSTony Luck struct pstore_info { 38ca01d6ddSTony Luck struct module *owner; 39ca01d6ddSTony Luck char *name; 40abd4d558SDon Zickus spinlock_t buf_lock; /* serialize access to 'buf' */ 41ca01d6ddSTony Luck char *buf; 42ca01d6ddSTony Luck size_t bufsize; 43f6f82851SKees Cook struct mutex read_mutex; /* serialize open/read/close */ 4406cf91b4SChen Gong int (*open)(struct pstore_info *psi); 4506cf91b4SChen Gong int (*close)(struct pstore_info *psi); 468d38d74bSChen Gong ssize_t (*read)(u64 *id, enum pstore_type_id *type, 47f6f82851SKees Cook struct timespec *time, char **buf, 48f6f82851SKees Cook struct pstore_info *psi); 493d6d8d20SKees Cook int (*write)(enum pstore_type_id type, 503d6d8d20SKees Cook enum kmsg_dump_reason reason, u64 *id, 51b238b8faSChen Gong unsigned int part, size_t size, struct pstore_info *psi); 52897dba02SAnton Vorontsov int (*write_buf)(enum pstore_type_id type, 53897dba02SAnton Vorontsov enum kmsg_dump_reason reason, u64 *id, 54897dba02SAnton Vorontsov unsigned int part, const char *buf, size_t size, 55897dba02SAnton Vorontsov struct pstore_info *psi); 5656280682SMatthew Garrett int (*erase)(enum pstore_type_id type, u64 id, 57638c1fd3SMatthew Garrett struct pstore_info *psi); 58638c1fd3SMatthew Garrett void *data; 59ca01d6ddSTony Luck }; 60ca01d6ddSTony Luck 61*060287b8SAnton Vorontsov 62*060287b8SAnton Vorontsov #ifdef CONFIG_PSTORE_FTRACE 63*060287b8SAnton Vorontsov extern void pstore_ftrace_call(unsigned long ip, unsigned long parent_ip); 64*060287b8SAnton Vorontsov #else 65*060287b8SAnton Vorontsov static inline void pstore_ftrace_call(unsigned long ip, unsigned long parent_ip) 66*060287b8SAnton Vorontsov { } 67*060287b8SAnton Vorontsov #endif 68*060287b8SAnton Vorontsov 69ca01d6ddSTony Luck #ifdef CONFIG_PSTORE 70ca01d6ddSTony Luck extern int pstore_register(struct pstore_info *); 71ca01d6ddSTony Luck #else 72ca01d6ddSTony Luck static inline int 73ca01d6ddSTony Luck pstore_register(struct pstore_info *psi) 74ca01d6ddSTony Luck { 75ca01d6ddSTony Luck return -ENODEV; 76ca01d6ddSTony Luck } 77ca01d6ddSTony Luck #endif 78ca01d6ddSTony Luck 79ca01d6ddSTony Luck #endif /*_LINUX_PSTORE_H*/ 80