blob: f41e2086c645a357419be6e5694a6b787a1d2294 [file] [log] [blame]
Colin Crossc6725282012-03-07 17:34:32 -08001/*
2 * Copyright (C) 2011 Google, Inc.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#ifndef __LINUX_PERSISTENT_RAM_H__
16#define __LINUX_PERSISTENT_RAM_H__
17
Colin Cross404a6042012-03-07 17:34:34 -080018#include <linux/device.h>
Colin Crossc6725282012-03-07 17:34:32 -080019#include <linux/kernel.h>
Colin Cross404a6042012-03-07 17:34:34 -080020#include <linux/list.h>
Colin Crossc6725282012-03-07 17:34:32 -080021#include <linux/types.h>
22
23struct persistent_ram_buffer;
24
Colin Cross404a6042012-03-07 17:34:34 -080025struct persistent_ram_descriptor {
26 const char *name;
27 phys_addr_t size;
28};
29
30struct persistent_ram {
31 phys_addr_t start;
32 phys_addr_t size;
33
34 int num_descs;
35 struct persistent_ram_descriptor *descs;
36
37 struct list_head node;
38};
39
Colin Crossc6725282012-03-07 17:34:32 -080040struct persistent_ram_zone {
41 struct list_head node;
Colin Cross404a6042012-03-07 17:34:34 -080042 void *vaddr;
Colin Crossc6725282012-03-07 17:34:32 -080043 struct persistent_ram_buffer *buffer;
44 size_t buffer_size;
Colin Cross9cc05ad2012-03-07 17:34:33 -080045
46 /* ECC correction */
47 bool ecc;
Colin Crossc6725282012-03-07 17:34:32 -080048 char *par_buffer;
49 char *par_header;
50 struct rs_control *rs_decoder;
51 int corrected_bytes;
52 int bad_blocks;
Colin Cross9cc05ad2012-03-07 17:34:33 -080053 int ecc_block_size;
54 int ecc_size;
55 int ecc_symsize;
56 int ecc_poly;
57
Colin Crossc6725282012-03-07 17:34:32 -080058 char *old_log;
59 size_t old_log_size;
60 size_t old_log_footer_size;
61 bool early;
62};
63
Colin Cross404a6042012-03-07 17:34:34 -080064int persistent_ram_early_init(struct persistent_ram *ram);
65
66struct persistent_ram_zone *persistent_ram_init_ringbuffer(struct device *dev,
67 bool ecc);
Colin Crossc6725282012-03-07 17:34:32 -080068
69int persistent_ram_write(struct persistent_ram_zone *prz, const void *s,
70 unsigned int count);
71
72size_t persistent_ram_old_size(struct persistent_ram_zone *prz);
73void *persistent_ram_old(struct persistent_ram_zone *prz);
74void persistent_ram_free_old(struct persistent_ram_zone *prz);
75ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz,
76 char *str, size_t len);
77
78#endif