4 * Copyright (C) 2011 Google, Inc.
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
17 #ifndef __LINUX_PSTORE_RAM_H__
18 #define __LINUX_PSTORE_RAM_H__
20 #include <linux/compiler.h>
21 #include <linux/device.h>
22 #include <linux/init.h>
23 #include <linux/kernel.h>
24 #include <linux/list.h>
25 #include <linux/pstore.h>
26 #include <linux/types.h>
29 * Choose whether access to the RAM zone requires locking or not. If a zone
30 * can be written to from different CPUs like with ftrace for example, then
31 * PRZ_FLAG_NO_LOCK is used. For all other cases, locking is required.
33 #define PRZ_FLAG_NO_LOCK BIT(0)
35 * If a PRZ should only have a single-boot lifetime, this marks it as
36 * getting wiped after its contents get copied out after boot.
38 #define PRZ_FLAG_ZAP_OLD BIT(1)
40 struct persistent_ram_buffer;
43 struct persistent_ram_ecc_info {
52 * struct persistent_ram_zone - Details of a persistent RAM zone (PRZ)
53 * used as a pstore backend
55 * @paddr: physical address of the mapped RAM area
56 * @size: size of mapping
57 * @label: unique name of this PRZ
58 * @type: frontend type for this PRZ
59 * @flags: holds PRZ_FLAGS_* bits
62 * locks access to @buffer "size" bytes and "start" offset
64 * pointer to actual RAM area managed by this PRZ
66 * bytes in @buffer->data (not including any trailing ECC bytes)
69 * pointer into @buffer->data containing ECC bytes for @buffer->data
71 * pointer into @buffer->data containing ECC bytes for @buffer header
72 * (i.e. all fields up to @data)
74 * RSLIB instance for doing ECC calculations
76 * ECC corrected bytes accounting since boot
78 * ECC uncorrectable bytes accounting since boot
80 * ECC configuration details
83 * saved copy of @buffer->data prior to most recent wipe
85 * bytes contained in @old_log
88 struct persistent_ram_zone {
93 enum pstore_type_id type;
96 raw_spinlock_t buffer_lock;
97 struct persistent_ram_buffer *buffer;
102 struct rs_control *rs_decoder;
105 struct persistent_ram_ecc_info ecc_info;
111 struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
112 u32 sig, struct persistent_ram_ecc_info *ecc_info,
113 unsigned int memtype, u32 flags, char *label);
114 void persistent_ram_free(struct persistent_ram_zone *prz);
115 void persistent_ram_zap(struct persistent_ram_zone *prz);
117 int persistent_ram_write(struct persistent_ram_zone *prz, const void *s,
119 int persistent_ram_write_user(struct persistent_ram_zone *prz,
120 const void __user *s, unsigned int count);
122 void persistent_ram_save_old(struct persistent_ram_zone *prz);
123 size_t persistent_ram_old_size(struct persistent_ram_zone *prz);
124 void *persistent_ram_old(struct persistent_ram_zone *prz);
125 void persistent_ram_free_old(struct persistent_ram_zone *prz);
126 ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz,
127 char *str, size_t len);
130 * Ramoops platform data
131 * @mem_size memory size for ramoops
132 * @mem_address physical memory address to contain ramoops
135 #define RAMOOPS_FLAG_FTRACE_PER_CPU BIT(0)
137 struct ramoops_platform_data {
138 unsigned long mem_size;
139 phys_addr_t mem_address;
140 unsigned int mem_type;
141 unsigned long record_size;
142 unsigned long console_size;
143 unsigned long ftrace_size;
144 unsigned long pmsg_size;
147 struct persistent_ram_ecc_info ecc_info;