1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
4 * Copyright (c) 2023 Rockchip Electronics Co., Ltd.
5 */
6
7 #ifndef __RK_MINIDUMP_H
8 #define __RK_MINIDUMP_H
9
10 #include <linux/types.h>
11
12 #define MD_MAX_NAME_LENGTH 16
13 /* md_region - Minidump table entry
14 * @name: Entry name, Minidump will dump binary with this name.
15 * @id: Entry ID, used only for SDI dumps.
16 * @virt_addr: Address of the entry.
17 * @phys_addr: Physical address of the entry to dump.
18 * @size: Number of byte to dump from @address location
19 * it should be 4 byte aligned.
20 */
21 struct md_region {
22 char name[MD_MAX_NAME_LENGTH];
23 u32 id;
24 u64 virt_addr;
25 u64 phys_addr;
26 u64 size;
27 };
28
29 #if IS_REACHABLE(CONFIG_ROCKCHIP_MINIDUMP)
30 /*
31 * Register an entry in Minidump table
32 * Returns:
33 * region number: entry position in minidump table.
34 * Negative error number on failures.
35 */
36 int rk_minidump_add_region(const struct md_region *entry);
37 int rk_minidump_remove_region(const struct md_region *entry);
38 /*
39 * Update registered region address in Minidump table.
40 * It does not hold any locks, so strictly serialize the region updates.
41 * Returns:
42 * Zero: on successfully update
43 * Negetive error number on failures.
44 */
45 int rk_minidump_update_region(int regno, const struct md_region *entry);
46 bool rk_minidump_enabled(void);
47 void rk_minidump_update_cpu_regs(struct pt_regs *regs);
48 #else
rk_minidump_add_region(const struct md_region * entry)49 static inline int rk_minidump_add_region(const struct md_region *entry)
50 {
51 /* Return quietly, if minidump is not supported */
52 return 0;
53 }
rk_minidump_remove_region(const struct md_region * entry)54 static inline int rk_minidump_remove_region(const struct md_region *entry)
55 {
56 return 0;
57 }
rk_minidump_update_region(int regno,const struct md_region * entry)58 static inline int rk_minidump_update_region(int regno, const struct md_region *entry)
59 {
60 return 0;
61 }
rk_minidump_enabled(void)62 static inline bool rk_minidump_enabled(void) { return false; }
rk_minidump_update_cpu_regs(struct pt_regs * regs)63 static inline void rk_minidump_update_cpu_regs(struct pt_regs *regs) { return; }
64 #endif
65
66 extern void rk_md_flush_dcache_area(void *addr, size_t len);
67 #endif /* __RK_MINIDUMP_H */
68