1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Firmware-Assisted Dump support on POWER platform (OPAL).
4  *
5  * Copyright 2019, Hari Bathini, IBM Corporation.
6  */
7 
8 #ifndef _POWERNV_OPAL_FADUMP_H
9 #define _POWERNV_OPAL_FADUMP_H
10 
11 /*
12  * OPAL FADump metadata structure format version
13  *
14  * OPAL FADump kernel metadata structure stores kernel metadata needed to
15  * register-for/process crash dump. Format version is used to keep a tab on
16  * the changes in the structure format. The changes, if any, to the format
17  * are expected to be minimal and backward compatible.
18  */
19 #define OPAL_FADUMP_VERSION			0x1
20 
21 /* Maximum number of memory regions kernel supports */
22 #define OPAL_FADUMP_MAX_MEM_REGS		128
23 
24 /*
25  * OPAL FADump kernel metadata
26  *
27  * The address of this structure will be registered with f/w for retrieving
28  * and processing during crash dump.
29  */
30 struct opal_fadump_mem_struct {
31 	u8	version;
32 	u8	reserved[3];
33 	u16	region_cnt;		/* number of regions */
34 	u16	registered_regions;	/* Regions registered for MPIPL */
35 	u64	fadumphdr_addr;
36 	struct opal_mpipl_region	rgn[OPAL_FADUMP_MAX_MEM_REGS];
37 } __packed;
38 
39 /*
40  * CPU state data
41  *
42  * CPU state data information is provided by f/w. The format for this data
43  * is defined in the HDAT spec. Version is used to keep a tab on the changes
44  * in this CPU state data format. Changes to this format are unlikely, but
45  * if there are any changes, please refer to latest HDAT specification.
46  */
47 #define HDAT_FADUMP_CPU_DATA_VER		1
48 
49 #define HDAT_FADUMP_CORE_INACTIVE		(0x0F)
50 
51 /* HDAT thread header for register entries */
52 struct hdat_fadump_thread_hdr {
53 	__be32  pir;
54 	/* 0x00 - 0x0F - The corresponding stop state of the core */
55 	u8      core_state;
56 	u8      reserved[3];
57 
58 	__be32	offset;	/* Offset to Register Entries array */
59 	__be32	ecnt;	/* Number of entries */
60 	__be32	esize;	/* Alloc size of each array entry in bytes */
61 	__be32	eactsz;	/* Actual size of each array entry in bytes */
62 } __packed;
63 
64 /* Register types populated by f/w */
65 #define HDAT_FADUMP_REG_TYPE_GPR		0x01
66 #define HDAT_FADUMP_REG_TYPE_SPR		0x02
67 
68 /* ID numbers used by f/w while populating certain registers */
69 #define HDAT_FADUMP_REG_ID_NIP			0x7D0
70 #define HDAT_FADUMP_REG_ID_MSR			0x7D1
71 #define HDAT_FADUMP_REG_ID_CCR			0x7D2
72 
73 /* HDAT register entry. */
74 struct hdat_fadump_reg_entry {
75 	__be32		reg_type;
76 	__be32		reg_num;
77 	__be64		reg_val;
78 } __packed;
79 
80 #endif /* _POWERNV_OPAL_FADUMP_H */
81