| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Persistent Storage - pstore.h |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * This code is the generic layer to export data records from platform |
|---|
| 7 | 8 | * level persistent storage via a file system. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 10 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 11 | | - * published by the Free Software Foundation. |
|---|
| 12 | | - * |
|---|
| 13 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 14 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 16 | | - * GNU General Public License for more details. |
|---|
| 17 | | - * |
|---|
| 18 | | - * You should have received a copy of the GNU General Public License |
|---|
| 19 | | - * along with this program; if not, write to the Free Software |
|---|
| 20 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 21 | 9 | */ |
|---|
| 22 | 10 | #ifndef _LINUX_PSTORE_H |
|---|
| 23 | 11 | #define _LINUX_PSTORE_H |
|---|
| .. | .. |
|---|
| 32 | 20 | |
|---|
| 33 | 21 | struct module; |
|---|
| 34 | 22 | |
|---|
| 35 | | -/* pstore record types (see fs/pstore/inode.c for filename templates) */ |
|---|
| 23 | +/* |
|---|
| 24 | + * pstore record types (see fs/pstore/platform.c for pstore_type_names[]) |
|---|
| 25 | + * These values may be written to storage (see EFI vars backend), so |
|---|
| 26 | + * they are kind of an ABI. Be careful changing the mappings. |
|---|
| 27 | + */ |
|---|
| 36 | 28 | enum pstore_type_id { |
|---|
| 29 | + /* Frontend storage types */ |
|---|
| 37 | 30 | PSTORE_TYPE_DMESG = 0, |
|---|
| 38 | 31 | PSTORE_TYPE_MCE = 1, |
|---|
| 39 | 32 | PSTORE_TYPE_CONSOLE = 2, |
|---|
| 40 | 33 | PSTORE_TYPE_FTRACE = 3, |
|---|
| 41 | | - /* PPC64 partition types */ |
|---|
| 34 | + |
|---|
| 35 | + /* PPC64-specific partition types */ |
|---|
| 42 | 36 | PSTORE_TYPE_PPC_RTAS = 4, |
|---|
| 43 | 37 | PSTORE_TYPE_PPC_OF = 5, |
|---|
| 44 | 38 | PSTORE_TYPE_PPC_COMMON = 6, |
|---|
| 45 | 39 | PSTORE_TYPE_PMSG = 7, |
|---|
| 46 | 40 | PSTORE_TYPE_PPC_OPAL = 8, |
|---|
| 47 | | -#ifdef CONFIG_PSTORE_MCU_LOG |
|---|
| 48 | | - PSTORE_TYPE_MCU_LOG = 9, |
|---|
| 41 | +#ifdef CONFIG_PSTORE_BOOT_LOG |
|---|
| 42 | + PSTORE_TYPE_BOOT_LOG = 9, |
|---|
| 49 | 43 | #endif |
|---|
| 50 | | - PSTORE_TYPE_UNKNOWN = 255 |
|---|
| 44 | + |
|---|
| 45 | + /* End of the list */ |
|---|
| 46 | + PSTORE_TYPE_MAX |
|---|
| 51 | 47 | }; |
|---|
| 48 | + |
|---|
| 49 | +const char *pstore_type_to_name(enum pstore_type_id type); |
|---|
| 50 | +enum pstore_type_id pstore_name_to_type(const char *name); |
|---|
| 52 | 51 | |
|---|
| 53 | 52 | struct pstore_info; |
|---|
| 54 | 53 | /** |
|---|
| .. | .. |
|---|
| 88 | 87 | /** |
|---|
| 89 | 88 | * struct pstore_info - backend pstore driver structure |
|---|
| 90 | 89 | * |
|---|
| 91 | | - * @owner: module which is repsonsible for this backend driver |
|---|
| 90 | + * @owner: module which is responsible for this backend driver |
|---|
| 92 | 91 | * @name: name of the backend driver |
|---|
| 93 | 92 | * |
|---|
| 94 | 93 | * @buf_lock: semaphore to serialize access to @buf |
|---|
| .. | .. |
|---|
| 100 | 99 | * |
|---|
| 101 | 100 | * @read_mutex: serializes @open, @read, @close, and @erase callbacks |
|---|
| 102 | 101 | * @flags: bitfield of frontends the backend can accept writes for |
|---|
| 102 | + * @max_reason: Used when PSTORE_FLAGS_DMESG is set. Contains the |
|---|
| 103 | + * kmsg_dump_reason enum value. KMSG_DUMP_UNDEF means |
|---|
| 104 | + * "use existing kmsg_dump() filtering, based on the |
|---|
| 105 | + * printk.always_kmsg_dump boot param" (which is either |
|---|
| 106 | + * KMSG_DUMP_OOPS when false, or KMSG_DUMP_MAX when |
|---|
| 107 | + * true); see printk.always_kmsg_dump for more details. |
|---|
| 103 | 108 | * @data: backend-private pointer passed back during callbacks |
|---|
| 104 | 109 | * |
|---|
| 105 | 110 | * Callbacks: |
|---|
| .. | .. |
|---|
| 174 | 179 | */ |
|---|
| 175 | 180 | struct pstore_info { |
|---|
| 176 | 181 | struct module *owner; |
|---|
| 177 | | - char *name; |
|---|
| 182 | + const char *name; |
|---|
| 178 | 183 | |
|---|
| 179 | 184 | struct semaphore buf_lock; |
|---|
| 180 | 185 | char *buf; |
|---|
| .. | .. |
|---|
| 183 | 188 | struct mutex read_mutex; |
|---|
| 184 | 189 | |
|---|
| 185 | 190 | int flags; |
|---|
| 191 | + int max_reason; |
|---|
| 186 | 192 | void *data; |
|---|
| 187 | 193 | |
|---|
| 188 | 194 | int (*open)(struct pstore_info *psi); |
|---|
| .. | .. |
|---|
| 195 | 201 | }; |
|---|
| 196 | 202 | |
|---|
| 197 | 203 | /* Supported frontends */ |
|---|
| 198 | | -#define PSTORE_FLAGS_DMESG (1 << 0) |
|---|
| 199 | | -#define PSTORE_FLAGS_CONSOLE (1 << 1) |
|---|
| 200 | | -#define PSTORE_FLAGS_FTRACE (1 << 2) |
|---|
| 201 | | -#define PSTORE_FLAGS_PMSG (1 << 3) |
|---|
| 202 | | -#ifdef CONFIG_PSTORE_MCU_LOG |
|---|
| 203 | | -#define PSTORE_FLAGS_MCU_LOG (1 << 4) |
|---|
| 204 | +#define PSTORE_FLAGS_DMESG BIT(0) |
|---|
| 205 | +#define PSTORE_FLAGS_CONSOLE BIT(1) |
|---|
| 206 | +#define PSTORE_FLAGS_FTRACE BIT(2) |
|---|
| 207 | +#define PSTORE_FLAGS_PMSG BIT(3) |
|---|
| 208 | +#ifdef CONFIG_PSTORE_BOOT_LOG |
|---|
| 209 | +#define PSTORE_FLAGS_BOOT_LOG BIT(4) |
|---|
| 204 | 210 | #endif |
|---|
| 211 | + |
|---|
| 205 | 212 | extern int pstore_register(struct pstore_info *); |
|---|
| 206 | 213 | extern void pstore_unregister(struct pstore_info *); |
|---|
| 207 | 214 | |
|---|