ae91ea6bb3037919d111c0e47d710d2efd4d6953
[muen/linux.git] / arch / m68k / include / asm / a.out-core.h
1 /* a.out coredump register dumper
2  *
3  * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4  * Written by David Howells (dhowells@redhat.com)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public Licence
8  * as published by the Free Software Foundation; either version
9  * 2 of the Licence, or (at your option) any later version.
10  */
11
12 #ifndef _ASM_A_OUT_CORE_H
13 #define _ASM_A_OUT_CORE_H
14
15 #ifdef __KERNEL__
16
17 #include <linux/user.h>
18 #include <linux/elfcore.h>
19 #include <linux/mm_types.h>
20
21 /*
22  * fill in the user structure for an a.out core dump
23  */
24 static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump)
25 {
26         struct switch_stack *sw;
27
28 /* changed the size calculations - should hopefully work better. lbt */
29         dump->magic = CMAGIC;
30         dump->start_code = 0;
31         dump->start_stack = rdusp() & ~(PAGE_SIZE - 1);
32         dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
33         dump->u_dsize = ((unsigned long) (current->mm->brk +
34                                           (PAGE_SIZE-1))) >> PAGE_SHIFT;
35         dump->u_dsize -= dump->u_tsize;
36         dump->u_ssize = 0;
37
38         if (dump->start_stack < TASK_SIZE)
39                 dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT;
40
41         dump->u_ar0 = offsetof(struct user, regs);
42         sw = ((struct switch_stack *)regs) - 1;
43         dump->regs.d1 = regs->d1;
44         dump->regs.d2 = regs->d2;
45         dump->regs.d3 = regs->d3;
46         dump->regs.d4 = regs->d4;
47         dump->regs.d5 = regs->d5;
48         dump->regs.d6 = sw->d6;
49         dump->regs.d7 = sw->d7;
50         dump->regs.a0 = regs->a0;
51         dump->regs.a1 = regs->a1;
52         dump->regs.a2 = regs->a2;
53         dump->regs.a3 = sw->a3;
54         dump->regs.a4 = sw->a4;
55         dump->regs.a5 = sw->a5;
56         dump->regs.a6 = sw->a6;
57         dump->regs.d0 = regs->d0;
58         dump->regs.orig_d0 = regs->orig_d0;
59         dump->regs.stkadj = regs->stkadj;
60         dump->regs.sr = regs->sr;
61         dump->regs.pc = regs->pc;
62         dump->regs.fmtvec = (regs->format << 12) | regs->vector;
63         /* dump floating point stuff */
64         dump->u_fpvalid = dump_fpu (regs, &dump->m68kfp);
65 }
66
67 #endif /* __KERNEL__ */
68 #endif /* _ASM_A_OUT_CORE_H */