blob: d48c55714c7370fb70ce2a9a2117d96b8625de4f [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001/*
2 * linux/arch/arm/mach-mmp/ramdump.h
3 *
4 * Support for the Marvell PXA RAMDUMP error handling capability.
5 *
6 * Author: Anton Eidelman (anton.eidelman@marvell.com)
7 * Created: May 20, 2010
8 * Copyright: (C) Copyright 2006 Marvell International Ltd.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * publishhed by the Free Software Foundation.
13 */
14
15#ifndef _RAMDUMP_H
16#define _RAMDUMP_H
17
18#include <linux/ptrace.h> /*pt_regs*/
19
20/*
21 * Error_id values:
22 * [0xffff..0] is used for ARM die() err codes, see fault.c/trapc.c
23 */
24#define RAMDUMP_ERR_EEH_CP 0x80000000
25#define RAMDUMP_ERR_EEH_AP 0x80000100
26#define RAMDUMP_ERR_NONE 0x8FFFFFFF
27
28void ramdump_save_dynamic_context(const char *str, int err,
29 struct thread_info *thread, struct pt_regs *regs);
30void ramdump_save_panic_text(const char *str);
31void ramdump_prepare_in_advance(void);
32void ramdump_rdc_reset(void);
33void ramdump_panic(void);
34#define RAMDUMP_ERR_STR_LEN 100
35
36/* RAMFILE related definitions and functions */
37
38/* RAMFILE object descriptor */
39#define RAMFILE_PHYCONT 1 /* physical memory is continuous (kmalloc) */
40struct ramfile_desc {
41 unsigned next; /* next object (pa) or NULL */
42 unsigned payload_size; /* bytes, excluding this header */
43 unsigned flags;
44 unsigned vaddr; /* virtual start address for discontinous case */
45 unsigned vaddr_hi; /* upper 32 bit of the above, which is misaligned */
46 unsigned reserved[3];
47};
48
49int ramdump_attach_ramfile(struct ramfile_desc *desc);
50
51
52/* RDI related definitions and functions */
53enum rdi_type {
54 RDI_NONE, /* End of list */
55 RDI_CBUF, /* virtual addr, size, opt current idx/ptr; refs supported */
56 RDI_PBUF, /* physical addr, size in bytes; no refs */
57 RDI_CUST, /* Custom: no 1st level parser for this */
58};
59
60/* Attrbits: OR these: for each data word tells if it's an address or a value */
61#define RDI_ATTR_VAL(wordnum) (0<<(wordnum))
62#define RDI_ATTR_ADDR(wordnum) (1<<(wordnum))
63
64/*
65 * RDI (data item) generic object attachment:
66 * type: for unknown types rdp will just print the data words suplied;
67 * name: string used by rdp as filename, at most MAX_RDI_NAME chars;
68 * attrbits: 1 bit per data word, 0=value, 1=address of a value;
69 * Callers can assume "value" is the default (0).
70 * nwords: number of data words, max 16;
71 * unsigned long data elements follow (32-bit or 64-bit)
72 */
73int ramdump_attach_item(enum rdi_type type,
74 const char *name,
75 unsigned attrbits,
76 unsigned nwords, ...);
77
78/*
79 * Buffer (RDI_CBUF) type RDI object attachment:
80 * name: string used by rdp as filename, at most MAX_RDI_NAME chars;
81 * buf: address of the pointer to the buffer;
82 * buf_size: address of an unsigned containing buffer size;
83 * OR an address of a pointer to the buffer end;
84 * rdp will automatically figure out which;
85 * cur_ptr: address of a pointer to the current byte inside the buffer;
86 * OR an address of an unsigned containing the current byte index;
87 * OR an address of an unsigned containing the total byte count
88 * (with no wrap-around);
89 * rdp will automatically figure out which;
90 * unit: unit buf_size (and cur_ptr if is an index) are expressed in.
91 */
92static inline
93int ramdump_attach_cbuffer(const char *name,
94 void **buf,
95 unsigned *buf_size,
96 unsigned *cur_ptr,
97 unsigned unit)
98{
99 return ramdump_attach_item(RDI_CBUF, name,
100 RDI_ATTR_ADDR(0) | RDI_ATTR_ADDR(1)
101 | RDI_ATTR_ADDR(2), 4,
102 (unsigned long)buf, (unsigned long)buf_size,
103 (unsigned long)cur_ptr, (unsigned long)unit);
104}
105
106static inline
107int ramdump_attach_pbuffer(const char *name,
108 unsigned buf_physical,
109 unsigned buf_size)
110{
111 return ramdump_attach_item(RDI_PBUF, name,
112 RDI_ATTR_VAL(0) | RDI_ATTR_VAL(1), 2,
113 (unsigned)buf_physical, (unsigned)buf_size);
114}
115
116/* Configuration */
117#define RAMDUMP_PHASE_1_1 /* allow KO's to work with older kernel */
118#define RAMDUMP_RDI /* allow detecting RDI interface is present */
119
120#endif