1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2010 Marco Stornelli <marco.stornelli@gmail.com>
4 * Copyright (C) 2011 Kees Cook <keescook@chromium.org>
5 * Copyright (C) 2011 Google, Inc.
8 #ifndef __LINUX_PSTORE_RAM_H__
9 #define __LINUX_PSTORE_RAM_H__
11 #include <linux/compiler.h>
12 #include <linux/device.h>
13 #include <linux/init.h>
14 #include <linux/kernel.h>
15 #include <linux/list.h>
16 #include <linux/pstore.h>
17 #include <linux/types.h>
20 * Choose whether access to the RAM zone requires locking or not. If a zone
21 * can be written to from different CPUs like with ftrace for example, then
22 * PRZ_FLAG_NO_LOCK is used. For all other cases, locking is required.
24 #define PRZ_FLAG_NO_LOCK BIT(0)
26 * If a PRZ should only have a single-boot lifetime, this marks it as
27 * getting wiped after its contents get copied out after boot.
29 #define PRZ_FLAG_ZAP_OLD BIT(1)
31 struct persistent_ram_buffer;
34 struct persistent_ram_ecc_info {
43 * struct persistent_ram_zone - Details of a persistent RAM zone (PRZ)
44 * used as a pstore backend
46 * @paddr: physical address of the mapped RAM area
47 * @size: size of mapping
48 * @label: unique name of this PRZ
49 * @type: frontend type for this PRZ
50 * @flags: holds PRZ_FLAGS_* bits
53 * locks access to @buffer "size" bytes and "start" offset
55 * pointer to actual RAM area managed by this PRZ
57 * bytes in @buffer->data (not including any trailing ECC bytes)
60 * pointer into @buffer->data containing ECC bytes for @buffer->data
62 * pointer into @buffer->data containing ECC bytes for @buffer header
63 * (i.e. all fields up to @data)
65 * RSLIB instance for doing ECC calculations
67 * ECC corrected bytes accounting since boot
69 * ECC uncorrectable bytes accounting since boot
71 * ECC configuration details
74 * saved copy of @buffer->data prior to most recent wipe
76 * bytes contained in @old_log
79 struct persistent_ram_zone {
84 enum pstore_type_id type;
87 raw_spinlock_t buffer_lock;
88 struct persistent_ram_buffer *buffer;
93 struct rs_control *rs_decoder;
96 struct persistent_ram_ecc_info ecc_info;
102 struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
103 u32 sig, struct persistent_ram_ecc_info *ecc_info,
104 unsigned int memtype, u32 flags, char *label);
105 void persistent_ram_free(struct persistent_ram_zone *prz);
106 void persistent_ram_zap(struct persistent_ram_zone *prz);
108 int persistent_ram_write(struct persistent_ram_zone *prz, const void *s,
110 int persistent_ram_write_user(struct persistent_ram_zone *prz,
111 const void __user *s, unsigned int count);
113 void persistent_ram_save_old(struct persistent_ram_zone *prz);
114 size_t persistent_ram_old_size(struct persistent_ram_zone *prz);
115 void *persistent_ram_old(struct persistent_ram_zone *prz);
116 void persistent_ram_free_old(struct persistent_ram_zone *prz);
117 ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz,
118 char *str, size_t len);
121 * Ramoops platform data
122 * @mem_size memory size for ramoops
123 * @mem_address physical memory address to contain ramoops
126 #define RAMOOPS_FLAG_FTRACE_PER_CPU BIT(0)
128 struct ramoops_platform_data {
129 unsigned long mem_size;
130 phys_addr_t mem_address;
131 unsigned int mem_type;
132 unsigned long record_size;
133 unsigned long console_size;
134 unsigned long ftrace_size;
135 unsigned long pmsg_size;
138 struct persistent_ram_ecc_info ecc_info;