Blame view

include/linux/pstore_ram.h 3.82 KB
9c92ab619   Thomas Gleixner   treewide: Replace...
1
  /* SPDX-License-Identifier: GPL-2.0-only */
cddb8751c   Anton Vorontsov   staging: android:...
2
3
4
5
  /*
   * Copyright (C) 2010 Marco Stornelli <marco.stornelli@gmail.com>
   * Copyright (C) 2011 Kees Cook <keescook@chromium.org>
   * Copyright (C) 2011 Google, Inc.
cddb8751c   Anton Vorontsov   staging: android:...
6
   */
1894a253d   Anton Vorontsov   ramoops: Move to ...
7
8
  #ifndef __LINUX_PSTORE_RAM_H__
  #define __LINUX_PSTORE_RAM_H__
c3b92ce9e   Kyungmin Park   ramoops: use the ...
9

5bf6d1b92   Mark Salyzyn   pstore/pmsg: drop...
10
  #include <linux/compiler.h>
cddb8751c   Anton Vorontsov   staging: android:...
11
  #include <linux/device.h>
5bf6d1b92   Mark Salyzyn   pstore/pmsg: drop...
12
  #include <linux/init.h>
cddb8751c   Anton Vorontsov   staging: android:...
13
14
  #include <linux/kernel.h>
  #include <linux/list.h>
f0f23e546   Joel Fernandes (Google)   pstore: Map PSTOR...
15
  #include <linux/pstore.h>
cddb8751c   Anton Vorontsov   staging: android:...
16
  #include <linux/types.h>
cddb8751c   Anton Vorontsov   staging: android:...
17

663deb478   Joel Fernandes   pstore: Allow prz...
18
19
20
21
22
23
  /*
   * Choose whether access to the RAM zone requires locking or not.  If a zone
   * can be written to from different CPUs like with ftrace for example, then
   * PRZ_FLAG_NO_LOCK is used. For all other cases, locking is required.
   */
  #define PRZ_FLAG_NO_LOCK	BIT(0)
c208f7d4b   Kees Cook   pstore/ram: Add k...
24
25
26
27
  /*
   * If a PRZ should only have a single-boot lifetime, this marks it as
   * getting wiped after its contents get copied out after boot.
   */
7684bd334   Peng Wang   pstore: Avoid dup...
28
  #define PRZ_FLAG_ZAP_OLD	BIT(1)
663deb478   Joel Fernandes   pstore: Allow prz...
29

cddb8751c   Anton Vorontsov   staging: android:...
30
  struct persistent_ram_buffer;
67a101f57   Anton Vorontsov   pstore: Headers s...
31
  struct rs_control;
cddb8751c   Anton Vorontsov   staging: android:...
32

c31ad081e   Arve Hjønnevåg   pstore/ram: Allow...
33
34
35
36
37
  struct persistent_ram_ecc_info {
  	int block_size;
  	int ecc_size;
  	int symsize;
  	int poly;
f2531f197   Kees Cook   pstore/ram: Do no...
38
  	uint16_t *par;
c31ad081e   Arve Hjønnevåg   pstore/ram: Allow...
39
  };
c208f7d4b   Kees Cook   pstore/ram: Add k...
40
41
42
43
44
45
46
  /**
   * struct persistent_ram_zone - Details of a persistent RAM zone (PRZ)
   *                              used as a pstore backend
   *
   * @paddr:	physical address of the mapped RAM area
   * @size:	size of mapping
   * @label:	unique name of this PRZ
f0f23e546   Joel Fernandes (Google)   pstore: Map PSTOR...
47
   * @type:	frontend type for this PRZ
c208f7d4b   Kees Cook   pstore/ram: Add k...
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
   * @flags:	holds PRZ_FLAGS_* bits
   *
   * @buffer_lock:
   *	locks access to @buffer "size" bytes and "start" offset
   * @buffer:
   *	pointer to actual RAM area managed by this PRZ
   * @buffer_size:
   *	bytes in @buffer->data (not including any trailing ECC bytes)
   *
   * @par_buffer:
   *	pointer into @buffer->data containing ECC bytes for @buffer->data
   * @par_header:
   *	pointer into @buffer->data containing ECC bytes for @buffer header
   *	(i.e. all fields up to @data)
   * @rs_decoder:
   *	RSLIB instance for doing ECC calculations
   * @corrected_bytes:
   *	ECC corrected bytes accounting since boot
   * @bad_blocks:
   *	ECC uncorrectable bytes accounting since boot
   * @ecc_info:
   *	ECC configuration details
   *
   * @old_log:
   *	saved copy of @buffer->data prior to most recent wipe
   * @old_log_size:
   *	bytes contained in @old_log
   *
   */
cddb8751c   Anton Vorontsov   staging: android:...
77
78
79
80
  struct persistent_ram_zone {
  	phys_addr_t paddr;
  	size_t size;
  	void *vaddr;
1227daa43   Kees Cook   pstore/ram: Clari...
81
  	char *label;
f0f23e546   Joel Fernandes (Google)   pstore: Map PSTOR...
82
  	enum pstore_type_id type;
663deb478   Joel Fernandes   pstore: Allow prz...
83
  	u32 flags;
c208f7d4b   Kees Cook   pstore/ram: Add k...
84

109704492   Joel Fernandes   pstore: Make spin...
85
  	raw_spinlock_t buffer_lock;
c208f7d4b   Kees Cook   pstore/ram: Add k...
86
87
  	struct persistent_ram_buffer *buffer;
  	size_t buffer_size;
cddb8751c   Anton Vorontsov   staging: android:...
88

cddb8751c   Anton Vorontsov   staging: android:...
89
90
91
92
93
  	char *par_buffer;
  	char *par_header;
  	struct rs_control *rs_decoder;
  	int corrected_bytes;
  	int bad_blocks;
c31ad081e   Arve Hjønnevåg   pstore/ram: Allow...
94
  	struct persistent_ram_ecc_info ecc_info;
cddb8751c   Anton Vorontsov   staging: android:...
95
96
97
98
  
  	char *old_log;
  	size_t old_log_size;
  };
f568f6ca8   Greg Kroah-Hartman   pstore: remove __...
99
  struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
027bc8b08   Tony Lindgren   pstore-ram: Allow...
100
  			u32 sig, struct persistent_ram_ecc_info *ecc_info,
1227daa43   Kees Cook   pstore/ram: Clari...
101
  			unsigned int memtype, u32 flags, char *label);
cddb8751c   Anton Vorontsov   staging: android:...
102
  void persistent_ram_free(struct persistent_ram_zone *prz);
fce397930   Anton Vorontsov   pstore/ram_core: ...
103
  void persistent_ram_zap(struct persistent_ram_zone *prz);
cddb8751c   Anton Vorontsov   staging: android:...
104
105
  
  int persistent_ram_write(struct persistent_ram_zone *prz, const void *s,
5bf6d1b92   Mark Salyzyn   pstore/pmsg: drop...
106
107
108
  			 unsigned int count);
  int persistent_ram_write_user(struct persistent_ram_zone *prz,
  			      const void __user *s, unsigned int count);
cddb8751c   Anton Vorontsov   staging: android:...
109

201e4aca5   Anton Vorontsov   pstore/ram: Shoul...
110
  void persistent_ram_save_old(struct persistent_ram_zone *prz);
cddb8751c   Anton Vorontsov   staging: android:...
111
112
113
114
115
  size_t persistent_ram_old_size(struct persistent_ram_zone *prz);
  void *persistent_ram_old(struct persistent_ram_zone *prz);
  void persistent_ram_free_old(struct persistent_ram_zone *prz);
  ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz,
  	char *str, size_t len);
c3b92ce9e   Kyungmin Park   ramoops: use the ...
116
117
118
119
120
  /*
   * Ramoops platform data
   * @mem_size	memory size for ramoops
   * @mem_address	physical memory address to contain ramoops
   */
a1cf53ac6   Joel Fernandes   ramoops: Split ft...
121
  #define RAMOOPS_FLAG_FTRACE_PER_CPU	BIT(0)
c3b92ce9e   Kyungmin Park   ramoops: use the ...
122
123
  struct ramoops_platform_data {
  	unsigned long	mem_size;
764fd639d   Wiebe, Wladislav (Nokia - DE/Ulm)   pstore: Add suppo...
124
  	phys_addr_t	mem_address;
027bc8b08   Tony Lindgren   pstore-ram: Allow...
125
  	unsigned int	mem_type;
3e5c4fadb   Sergiu Iordache   ramoops: make rec...
126
  	unsigned long	record_size;
b5d38e9bf   Anton Vorontsov   pstore/ram: Add c...
127
  	unsigned long	console_size;
a694d1b59   Anton Vorontsov   pstore/ram: Add f...
128
  	unsigned long	ftrace_size;
9d5438f46   Mark Salyzyn   pstore: Add pmsg ...
129
  	unsigned long	pmsg_size;
791205e3e   Kees Cook   pstore/ram: Intro...
130
  	int		max_reason;
a1cf53ac6   Joel Fernandes   ramoops: Split ft...
131
  	u32		flags;
c31ad081e   Arve Hjønnevåg   pstore/ram: Allow...
132
  	struct persistent_ram_ecc_info ecc_info;
c3b92ce9e   Kyungmin Park   ramoops: use the ...
133
134
135
  };
  
  #endif