xref: /linux/include/linux/pstore.h (revision 06cf91b4b4aafa50ee0a94c81d2c6922a18af242)
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 
25ca01d6ddSTony Luck /* types */
26ca01d6ddSTony Luck enum pstore_type_id {
27ca01d6ddSTony Luck 	PSTORE_TYPE_DMESG	= 0,
28ca01d6ddSTony Luck 	PSTORE_TYPE_MCE		= 1,
29ca01d6ddSTony Luck 	PSTORE_TYPE_UNKNOWN	= 255
30ca01d6ddSTony Luck };
31ca01d6ddSTony Luck 
32ca01d6ddSTony Luck struct pstore_info {
33ca01d6ddSTony Luck 	struct module	*owner;
34ca01d6ddSTony Luck 	char		*name;
35ca01d6ddSTony Luck 	struct mutex	buf_mutex;	/* serialize access to 'buf' */
36ca01d6ddSTony Luck 	char		*buf;
37ca01d6ddSTony Luck 	size_t		bufsize;
38*06cf91b4SChen Gong 	int		(*open)(struct pstore_info *psi);
39*06cf91b4SChen Gong 	int		(*close)(struct pstore_info *psi);
408d38d74bSChen Gong 	ssize_t		(*read)(u64 *id, enum pstore_type_id *type,
41ca01d6ddSTony Luck 			struct timespec *time);
42ca01d6ddSTony Luck 	u64		(*write)(enum pstore_type_id type, size_t size);
43ca01d6ddSTony Luck 	int		(*erase)(u64 id);
44ca01d6ddSTony Luck };
45ca01d6ddSTony Luck 
46ca01d6ddSTony Luck #ifdef CONFIG_PSTORE
47ca01d6ddSTony Luck extern int pstore_register(struct pstore_info *);
48ca01d6ddSTony Luck extern int pstore_write(enum pstore_type_id type, char *buf, size_t size);
49ca01d6ddSTony Luck #else
50ca01d6ddSTony Luck static inline int
51ca01d6ddSTony Luck pstore_register(struct pstore_info *psi)
52ca01d6ddSTony Luck {
53ca01d6ddSTony Luck 	return -ENODEV;
54ca01d6ddSTony Luck }
55ca01d6ddSTony Luck static inline int
56ca01d6ddSTony Luck pstore_write(enum pstore_type_id type, char *buf, size_t size)
57ca01d6ddSTony Luck {
58ca01d6ddSTony Luck 	return -ENODEV;
59ca01d6ddSTony Luck }
60ca01d6ddSTony Luck #endif
61ca01d6ddSTony Luck 
62ca01d6ddSTony Luck #endif /*_LINUX_PSTORE_H*/
63