a0921e96375807c18e78b531cbd3efce49b88d6e
[linux-2.6.git] / include / asm-i386 / dump.h
1 /*
2  * Kernel header file for Linux crash dumps.
3  *
4  * Created by: Matt Robinson (yakker@sgi.com)
5  *
6  * Copyright 1999 Silicon Graphics, Inc. All rights reserved.
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>
17 #include <asm/page.h>
18 #include <linux/threads.h>
19 #include <linux/mm.h>
20
21 /* definitions */
22 #define DUMP_ASM_MAGIC_NUMBER   0xdeaddeadULL   /* magic number            */
23 #define DUMP_ASM_VERSION_NUMBER 0x3     /* version number          */
24
25 /* max number of cpus */
26 #define DUMP_MAX_NUM_CPUS 32
27
28 /*
29  * Structure: __dump_header_asm
30  *  Function: This is the header for architecture-specific stuff.  It
31  *            follows right after the dump header.
32  */
33 struct __dump_header_asm {
34         /* the dump magic number -- unique to verify dump is valid */
35         u64             dha_magic_number;
36
37         /* the version number of this dump */
38         u32             dha_version;
39
40         /* the size of this header (in case we can't read it) */
41         u32             dha_header_size;
42
43         /* the esp for i386 systems */
44         u32             dha_esp;
45
46         /* the eip for i386 systems */
47         u32             dha_eip;
48
49         /* the dump registers */
50         struct pt_regs  dha_regs;
51
52         /* smp specific */
53         u32             dha_smp_num_cpus;
54         u32             dha_dumping_cpu;
55         struct pt_regs  dha_smp_regs[DUMP_MAX_NUM_CPUS];
56         u32             dha_smp_current_task[DUMP_MAX_NUM_CPUS];
57         u32             dha_stack[DUMP_MAX_NUM_CPUS];
58         u32             dha_stack_ptr[DUMP_MAX_NUM_CPUS];
59 } __attribute__((packed));
60
61 #ifdef __KERNEL__
62
63 extern struct __dump_header_asm dump_header_asm;
64
65 #ifdef CONFIG_SMP
66 extern cpumask_t irq_affinity[];
67 extern int (*dump_ipi_function_ptr)(struct pt_regs *);
68 extern void dump_send_ipi(void);
69 #else
70 #define dump_send_ipi() do { } while(0)
71 #endif
72
73 static inline void get_current_regs(struct pt_regs *regs)
74 {
75         __asm__ __volatile__("movl %%ebx,%0" : "=m"(regs->ebx));
76         __asm__ __volatile__("movl %%ecx,%0" : "=m"(regs->ecx));
77         __asm__ __volatile__("movl %%edx,%0" : "=m"(regs->edx));
78         __asm__ __volatile__("movl %%esi,%0" : "=m"(regs->esi));
79         __asm__ __volatile__("movl %%edi,%0" : "=m"(regs->edi));
80         __asm__ __volatile__("movl %%ebp,%0" : "=m"(regs->ebp));
81         __asm__ __volatile__("movl %%eax,%0" : "=m"(regs->eax));
82         __asm__ __volatile__("movl %%esp,%0" : "=m"(regs->esp));
83         __asm__ __volatile__("movw %%ss, %%ax;" :"=a"(regs->xss));
84         __asm__ __volatile__("movw %%cs, %%ax;" :"=a"(regs->xcs));
85         __asm__ __volatile__("movw %%ds, %%ax;" :"=a"(regs->xds));
86         __asm__ __volatile__("movw %%es, %%ax;" :"=a"(regs->xes));
87         __asm__ __volatile__("pushfl; popl %0" :"=m"(regs->eflags));
88         regs->eip = (unsigned long)current_text_addr();
89 }
90
91 #endif /* __KERNEL__ */
92
93 #endif /* _ASM_DUMP_H */