aboutsummaryrefslogtreecommitdiff
path: root/include/opal-dump.h
blob: 866d11aba855146e739fb45d5f685f5ca52174b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// SPDX-License-Identifier: Apache-2.0
/* Copyright 2013-2015 IBM Corp. */

#ifndef __OPAL_DUMP_H
#define __OPAL_DUMP_H

/*
 * Dump region ids
 *
 * 0x01 - 0x3F : OPAL
 * 0x40 - 0x7F : Reserved for future use
 * 0x80 - 0xFF : Kernel
 *
 */
#define DUMP_REGION_OPAL_START		0x01
#define DUMP_REGION_OPAL_END		0x3F
#define DUMP_REGION_HOST_START		OPAL_DUMP_REGION_HOST_START
#define DUMP_REGION_HOST_END		OPAL_DUMP_REGION_HOST_END

#define DUMP_REGION_CONSOLE	0x01
#define DUMP_REGION_HBRT_LOG	0x02
#define DUMP_REGION_OPAL_MEMORY	0x03
#define DUMP_REGION_KERNEL	0x80

/* Mainstore memory to be captured by FSP SYSDUMP */
#define DUMP_TYPE_SYSDUMP		0xF5
/* Mainstore memory to preserve during IPL */
#define DUMP_TYPE_MPIPL			0x00

/*
 *  Memory Dump Source Table
 *
 * Format of this table is same as Memory Dump Source Table (MDST)
 * defined in HDAT spec.
 */
struct mdst_table {
	__be64	addr;
	uint8_t	data_region;	/* DUMP_REGION_* */
	uint8_t dump_type;	/* DUMP_TYPE_* */
	__be16	reserved;
	__be32	size;
} __packed;

/* Memory dump destination table (MDDT) */
struct mddt_table {
	__be64	addr;
	uint8_t	data_region;
	uint8_t dump_type;
	__be16	reserved;
	__be32	size;
} __packed;

/*
 * Memory dump result table (MDRT)
 *
 * List of the memory ranges that have been included in the dump. This table is
 * filled by hostboot and passed to OPAL on second boot. OPAL/payload will use
 * this table to extract the dump.
 */
struct mdrt_table {
	__be64	src_addr;
	__be64	dest_addr;
	uint8_t	data_region;
	uint8_t dump_type;
	__be16	reserved;
	__be32	size;
	__be64	padding;
} __packed;

/*
 * Processor Dump Area
 *
 * This contains the information needed for having processor
 * state captured during a platform dump.
 */
struct proc_dump_area {
	__be32	thread_size;	/* Size of each thread register entry */
#define PROC_DUMP_AREA_FORMAT_P9	0x1	/* P9 format */
	uint8_t	version;	/* P9 - 0x1 */
	uint8_t	reserved[11];
	__be64	alloc_addr;	/* Destination memory to place register data */
	__be32	reserved2;
	__be32	alloc_size;	/* Allocated size */
	__be64	dest_addr;	/* Destination address */
	__be32	reserved3;
	__be32	act_size;	/* Actual data size */
} __packed;

struct proc_reg_data_hdr {
	/* PIR value of the thread */
	__be32	pir;
	/* 0x00 - 0x0F - The corresponding stop state of the core */
	uint8_t	core_state;
	uint8_t	reserved[3];

	uint32_t offset;	/* Offset to Register Entries array */
	uint32_t ecnt;		/* Number of entries */
	uint32_t esize;		/* Alloc size of each array entry in bytes */
	uint32_t eactsz;	/* Actual size of each array entry in bytes */
} __packed;

/* Architected register data content */
#define ARCH_REG_TYPE_GPR	0x01
#define ARCH_REG_TYPE_SPR	0x02
struct proc_reg_data {
	uint32_t reg_type;	/* ARCH_REG_TYPE_* */
	uint32_t reg_num;
	uint64_t reg_val;
} __packed;

/* Metadata to capture before triggering MPIPL */
struct mpipl_metadata {
	/* Crashing PIR is required to create OPAL dump */
	uint32_t	crashing_pir;
	/* Kernel expects OPAL to presrve tag and pass it back via OPAL API */
	uint64_t	kernel_tag;
	/* Post MPIPL kernel boot memory size */
	uint64_t	boot_mem_size;
} __packed;

/* init opal dump */
extern void opal_mpipl_init(void);

/* Save metadata before triggering MPIPL */
void opal_mpipl_save_crashing_pir(void);

#endif	/* __OPAL_DUMP_H */