]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - include/linux/pstore_ram.h
timekeeping: Repair ktime_get_coarse*() granularity
[mirror_ubuntu-jammy-kernel.git] / include / linux / pstore_ram.h
CommitLineData
cddb8751
AV
1/*
2 * Copyright (C) 2010 Marco Stornelli <marco.stornelli@gmail.com>
3 * Copyright (C) 2011 Kees Cook <keescook@chromium.org>
4 * Copyright (C) 2011 Google, Inc.
5 *
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.
9 *
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.
14 *
15 */
16
1894a253
AV
17#ifndef __LINUX_PSTORE_RAM_H__
18#define __LINUX_PSTORE_RAM_H__
c3b92ce9 19
5bf6d1b9 20#include <linux/compiler.h>
cddb8751 21#include <linux/device.h>
5bf6d1b9 22#include <linux/init.h>
cddb8751
AV
23#include <linux/kernel.h>
24#include <linux/list.h>
f0f23e54 25#include <linux/pstore.h>
cddb8751 26#include <linux/types.h>
cddb8751 27
663deb47
JF
28/*
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.
32 */
33#define PRZ_FLAG_NO_LOCK BIT(0)
c208f7d4
KC
34/*
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.
37 */
7684bd33 38#define PRZ_FLAG_ZAP_OLD BIT(1)
663deb47 39
cddb8751 40struct persistent_ram_buffer;
67a101f5 41struct rs_control;
cddb8751 42
c31ad081
AH
43struct persistent_ram_ecc_info {
44 int block_size;
45 int ecc_size;
46 int symsize;
47 int poly;
f2531f19 48 uint16_t *par;
c31ad081
AH
49};
50
c208f7d4
KC
51/**
52 * struct persistent_ram_zone - Details of a persistent RAM zone (PRZ)
53 * used as a pstore backend
54 *
55 * @paddr: physical address of the mapped RAM area
56 * @size: size of mapping
57 * @label: unique name of this PRZ
f0f23e54 58 * @type: frontend type for this PRZ
c208f7d4
KC
59 * @flags: holds PRZ_FLAGS_* bits
60 *
61 * @buffer_lock:
62 * locks access to @buffer "size" bytes and "start" offset
63 * @buffer:
64 * pointer to actual RAM area managed by this PRZ
65 * @buffer_size:
66 * bytes in @buffer->data (not including any trailing ECC bytes)
67 *
68 * @par_buffer:
69 * pointer into @buffer->data containing ECC bytes for @buffer->data
70 * @par_header:
71 * pointer into @buffer->data containing ECC bytes for @buffer header
72 * (i.e. all fields up to @data)
73 * @rs_decoder:
74 * RSLIB instance for doing ECC calculations
75 * @corrected_bytes:
76 * ECC corrected bytes accounting since boot
77 * @bad_blocks:
78 * ECC uncorrectable bytes accounting since boot
79 * @ecc_info:
80 * ECC configuration details
81 *
82 * @old_log:
83 * saved copy of @buffer->data prior to most recent wipe
84 * @old_log_size:
85 * bytes contained in @old_log
86 *
87 */
cddb8751
AV
88struct persistent_ram_zone {
89 phys_addr_t paddr;
90 size_t size;
91 void *vaddr;
1227daa4 92 char *label;
f0f23e54 93 enum pstore_type_id type;
663deb47 94 u32 flags;
c208f7d4 95
10970449 96 raw_spinlock_t buffer_lock;
c208f7d4
KC
97 struct persistent_ram_buffer *buffer;
98 size_t buffer_size;
cddb8751 99
cddb8751
AV
100 char *par_buffer;
101 char *par_header;
102 struct rs_control *rs_decoder;
103 int corrected_bytes;
104 int bad_blocks;
c31ad081 105 struct persistent_ram_ecc_info ecc_info;
cddb8751
AV
106
107 char *old_log;
108 size_t old_log_size;
109};
110
f568f6ca 111struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
027bc8b0 112 u32 sig, struct persistent_ram_ecc_info *ecc_info,
1227daa4 113 unsigned int memtype, u32 flags, char *label);
cddb8751 114void persistent_ram_free(struct persistent_ram_zone *prz);
fce39793 115void persistent_ram_zap(struct persistent_ram_zone *prz);
cddb8751
AV
116
117int persistent_ram_write(struct persistent_ram_zone *prz, const void *s,
5bf6d1b9
MS
118 unsigned int count);
119int persistent_ram_write_user(struct persistent_ram_zone *prz,
120 const void __user *s, unsigned int count);
cddb8751 121
201e4aca 122void persistent_ram_save_old(struct persistent_ram_zone *prz);
cddb8751
AV
123size_t persistent_ram_old_size(struct persistent_ram_zone *prz);
124void *persistent_ram_old(struct persistent_ram_zone *prz);
125void persistent_ram_free_old(struct persistent_ram_zone *prz);
126ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz,
127 char *str, size_t len);
128
c3b92ce9
KP
129/*
130 * Ramoops platform data
131 * @mem_size memory size for ramoops
132 * @mem_address physical memory address to contain ramoops
133 */
134
a1cf53ac
JF
135#define RAMOOPS_FLAG_FTRACE_PER_CPU BIT(0)
136
c3b92ce9
KP
137struct ramoops_platform_data {
138 unsigned long mem_size;
764fd639 139 phys_addr_t mem_address;
027bc8b0 140 unsigned int mem_type;
3e5c4fad 141 unsigned long record_size;
b5d38e9b 142 unsigned long console_size;
a694d1b5 143 unsigned long ftrace_size;
9d5438f4 144 unsigned long pmsg_size;
6b4d2a27 145 int dump_oops;
a1cf53ac 146 u32 flags;
c31ad081 147 struct persistent_ram_ecc_info ecc_info;
c3b92ce9
KP
148};
149
150#endif