1/*
2 * Kernel header file for Linux crash dumps.
3 *
4 * Created by: Todd Inglett <tinglett@vnet.ibm.com>
5 *
6 * Copyright 2002 International Business Machines
7 *
8 * This code is released under version 2 of the GNU GPL.
9 */
10
11/* This header file holds the architecture specific crash dump header */
12#ifndef _ASM_DUMP_H
13#define _ASM_DUMP_H
14
15/* necessary header files */
16#include <asm/ptrace.h>                          /* for pt_regs             */
17#include <linux/threads.h>
18
19/* definitions */
20#define DUMP_ASM_MAGIC_NUMBER     0xdeaddeadULL  /* magic number            */
21#define DUMP_ASM_VERSION_NUMBER   0x1            /* version number          */
22
23
24/*
25 * Structure: dump_header_asm_t
26 *  Function: This is the header for architecture-specific stuff.  It
27 *            follows right after the dump header.
28 */
29typedef struct _dump_header_asm_s {
30
31        /* the dump magic number -- unique to verify dump is valid */
32        uint64_t             dha_magic_number;
33
34        /* the version number of this dump */
35        uint32_t             dha_version;
36
37        /* the size of this header (in case we can't read it) */
38        uint32_t             dha_header_size;
39
40	/* the dump registers */
41	struct pt_regs       dha_regs;
42
43	/* smp specific */
44	uint32_t	     dha_smp_num_cpus;
45	int		     dha_dumping_cpu;
46	struct pt_regs	     dha_smp_regs[NR_CPUS];
47	void *		     dha_smp_current_task[NR_CPUS];
48	void *		     dha_stack[NR_CPUS];
49} dump_header_asm_t;
50
51#ifdef __KERNEL__
52static inline void get_current_regs(struct pt_regs *regs)
53{
54	__asm__ __volatile__ (
55		"std	0,0(%0)\n"
56		"std	1,8(%0)\n"
57		"std	2,16(%0)\n"
58		"std	3,24(%0)\n"
59		"std	4,32(%0)\n"
60		"std	5,40(%0)\n"
61		"std	6,48(%0)\n"
62		"std	7,56(%0)\n"
63		"std	8,64(%0)\n"
64		"std	9,72(%0)\n"
65		"std	10,80(%0)\n"
66		"std	11,88(%0)\n"
67		"std	12,96(%0)\n"
68		"std	13,104(%0)\n"
69		"std	14,112(%0)\n"
70		"std	15,120(%0)\n"
71		"std	16,128(%0)\n"
72		"std	17,136(%0)\n"
73		"std	18,144(%0)\n"
74		"std	19,152(%0)\n"
75		"std	20,160(%0)\n"
76		"std	21,168(%0)\n"
77		"std	22,176(%0)\n"
78		"std	23,184(%0)\n"
79		"std	24,192(%0)\n"
80		"std	25,200(%0)\n"
81		"std	26,208(%0)\n"
82		"std	27,216(%0)\n"
83		"std	28,224(%0)\n"
84		"std	29,232(%0)\n"
85		"std	30,240(%0)\n"
86		"std	31,248(%0)\n"
87		"mfmsr	0\n"
88		"std	0, 264(%0)\n"
89		"mfctr	0\n"
90		"std	0, 280(%0)\n"
91		"mflr	0\n"
92		"std	0, 288(%0)\n"
93		"bl	1f\n"
94	"1:	 mflr	5\n"
95		"std	5, 256(%0)\n"
96		"mtlr	0\n"
97		"mfxer	0\n"
98		"std	0, 296(%0)\n"
99			      : : "b" (&regs));
100}
101
102extern volatile int dump_in_progress;
103extern dump_header_asm_t dump_header_asm;
104
105#ifdef CONFIG_SMP
106extern void dump_send_ipi(int (*dump_ipi_callback)(struct pt_regs *));
107#else
108#define dump_send_ipi()
109#endif
110#endif /* __KERNEL__ */
111
112#endif /* _ASM_DUMP_H */
113