xref: /linux/include/linux/pstore.h (revision c950fd6f201aea649932898206a850f0a7f25603)
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>
2767a101f5SAnton Vorontsov #include <linux/mutex.h>
2867a101f5SAnton Vorontsov #include <linux/types.h>
2967a101f5SAnton Vorontsov #include <linux/spinlock.h>
3067a101f5SAnton Vorontsov #include <linux/errno.h>
313d6d8d20SKees Cook 
32ca01d6ddSTony Luck /* types */
33ca01d6ddSTony Luck enum pstore_type_id {
34ca01d6ddSTony Luck 	PSTORE_TYPE_DMESG	= 0,
35ca01d6ddSTony Luck 	PSTORE_TYPE_MCE		= 1,
36f29e5956SAnton Vorontsov 	PSTORE_TYPE_CONSOLE	= 2,
37060287b8SAnton Vorontsov 	PSTORE_TYPE_FTRACE	= 3,
3869020eeaSAruna Balakrishnaiah 	/* PPC64 partition types */
3969020eeaSAruna Balakrishnaiah 	PSTORE_TYPE_PPC_RTAS	= 4,
40f33f748cSAruna Balakrishnaiah 	PSTORE_TYPE_PPC_OF	= 5,
41a5e4797bSAruna Balakrishnaiah 	PSTORE_TYPE_PPC_COMMON	= 6,
429d5438f4SMark Salyzyn 	PSTORE_TYPE_PMSG	= 7,
43ae011d2eSHari Bathini 	PSTORE_TYPE_PPC_OPAL	= 8,
44ca01d6ddSTony Luck 	PSTORE_TYPE_UNKNOWN	= 255
45ca01d6ddSTony Luck };
46ca01d6ddSTony Luck 
4767a101f5SAnton Vorontsov struct module;
4867a101f5SAnton Vorontsov 
49ca01d6ddSTony Luck struct pstore_info {
50ca01d6ddSTony Luck 	struct module	*owner;
51ca01d6ddSTony Luck 	char		*name;
52abd4d558SDon Zickus 	spinlock_t	buf_lock;	/* serialize access to 'buf' */
53ca01d6ddSTony Luck 	char		*buf;
54ca01d6ddSTony Luck 	size_t		bufsize;
55f6f82851SKees Cook 	struct mutex	read_mutex;	/* serialize open/read/close */
56df36ac1bSLuck, Tony 	int		flags;
5706cf91b4SChen Gong 	int		(*open)(struct pstore_info *psi);
5806cf91b4SChen Gong 	int		(*close)(struct pstore_info *psi);
598d38d74bSChen Gong 	ssize_t		(*read)(u64 *id, enum pstore_type_id *type,
60755d4fe4SSeiji Aguchi 			int *count, struct timespec *time, char **buf,
618cfc8ddcSGeliang Tang 			bool *compressed, ssize_t *ecc_notice_size,
628cfc8ddcSGeliang Tang 			struct pstore_info *psi);
633d6d8d20SKees Cook 	int		(*write)(enum pstore_type_id type,
643d6d8d20SKees Cook 			enum kmsg_dump_reason reason, u64 *id,
65b3b515bbSAruna Balakrishnaiah 			unsigned int part, int count, bool compressed,
666bbbca73SAruna Balakrishnaiah 			size_t size, struct pstore_info *psi);
67897dba02SAnton Vorontsov 	int		(*write_buf)(enum pstore_type_id type,
68897dba02SAnton Vorontsov 			enum kmsg_dump_reason reason, u64 *id,
69b3b515bbSAruna Balakrishnaiah 			unsigned int part, const char *buf, bool compressed,
706bbbca73SAruna Balakrishnaiah 			size_t size, struct pstore_info *psi);
7156280682SMatthew Garrett 	int		(*erase)(enum pstore_type_id type, u64 id,
72755d4fe4SSeiji Aguchi 			int count, struct timespec time,
73755d4fe4SSeiji Aguchi 			struct pstore_info *psi);
74638c1fd3SMatthew Garrett 	void		*data;
75ca01d6ddSTony Luck };
76ca01d6ddSTony Luck 
77*c950fd6fSNamhyung Kim #define PSTORE_FLAGS_DMESG	(1 << 0)
78*c950fd6fSNamhyung Kim #define PSTORE_FLAGS_FRAGILE	PSTORE_FLAGS_DMESG
79*c950fd6fSNamhyung Kim #define PSTORE_FLAGS_CONSOLE	(1 << 1)
80*c950fd6fSNamhyung Kim #define PSTORE_FLAGS_FTRACE	(1 << 2)
81*c950fd6fSNamhyung Kim #define PSTORE_FLAGS_PMSG	(1 << 3)
82*c950fd6fSNamhyung Kim 
83*c950fd6fSNamhyung Kim #define PSTORE_FLAGS_ALL	((1 << 4) - 1)
84df36ac1bSLuck, Tony 
85ca01d6ddSTony Luck extern int pstore_register(struct pstore_info *);
86ee1d2674SGeliang Tang extern void pstore_unregister(struct pstore_info *);
879f244e9cSSeiji Aguchi extern bool pstore_cannot_block_path(enum kmsg_dump_reason reason);
88ca01d6ddSTony Luck 
89ca01d6ddSTony Luck #endif /*_LINUX_PSTORE_H*/
90