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 #include <linux/pstore_ram.h>
11 * Choose whether access to the RAM zone requires locking or not. If a zone
12 * can be written to from different CPUs like with ftrace for example, then
13 * PRZ_FLAG_NO_LOCK is used. For all other cases, locking is required.
15 #define PRZ_FLAG_NO_LOCK BIT(0)
17 * If a PRZ should only have a single-boot lifetime, this marks it as
18 * getting wiped after its contents get copied out after boot.
20 #define PRZ_FLAG_ZAP_OLD BIT(1)
23 * struct persistent_ram_zone - Details of a persistent RAM zone (PRZ)
24 * used as a pstore backend
26 * @paddr: physical address of the mapped RAM area
27 * @size: size of mapping
28 * @label: unique name of this PRZ
29 * @type: frontend type for this PRZ
30 * @flags: holds PRZ_FLAGS_* bits
33 * locks access to @buffer "size" bytes and "start" offset
35 * pointer to actual RAM area managed by this PRZ
37 * bytes in @buffer->data (not including any trailing ECC bytes)
40 * pointer into @buffer->data containing ECC bytes for @buffer->data
42 * pointer into @buffer->data containing ECC bytes for @buffer header
43 * (i.e. all fields up to @data)
45 * RSLIB instance for doing ECC calculations
47 * ECC corrected bytes accounting since boot
49 * ECC uncorrectable bytes accounting since boot
51 * ECC configuration details
54 * saved copy of @buffer->data prior to most recent wipe
56 * bytes contained in @old_log
59 struct persistent_ram_zone
{
64 enum pstore_type_id type
;
67 raw_spinlock_t buffer_lock
;
68 struct persistent_ram_buffer
*buffer
;
73 struct rs_control
*rs_decoder
;
76 struct persistent_ram_ecc_info ecc_info
;
82 struct persistent_ram_zone
*persistent_ram_new(phys_addr_t start
, size_t size
,
83 u32 sig
, struct persistent_ram_ecc_info
*ecc_info
,
84 unsigned int memtype
, u32 flags
, char *label
);
85 void persistent_ram_free(struct persistent_ram_zone
**_prz
);
86 void persistent_ram_zap(struct persistent_ram_zone
*prz
);
88 int persistent_ram_write(struct persistent_ram_zone
*prz
, const void *s
,
90 int persistent_ram_write_user(struct persistent_ram_zone
*prz
,
91 const void __user
*s
, unsigned int count
);
93 void persistent_ram_save_old(struct persistent_ram_zone
*prz
);
94 size_t persistent_ram_old_size(struct persistent_ram_zone
*prz
);
95 void *persistent_ram_old(struct persistent_ram_zone
*prz
);
96 void persistent_ram_free_old(struct persistent_ram_zone
*prz
);
97 ssize_t
persistent_ram_ecc_string(struct persistent_ram_zone
*prz
,
98 char *str
, size_t len
);