7d3ece8bfb616b452165078d661373e0722fce20
[muen/linux.git] / arch / x86 / 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_X86_A_OUT_CORE_H
13 #define _ASM_X86_A_OUT_CORE_H
14
15 #ifdef __KERNEL__
16 #ifdef CONFIG_X86_32
17
18 #include <linux/user.h>
19 #include <linux/elfcore.h>
20 #include <linux/mm_types.h>
21
22 #include <asm/debugreg.h>
23
24 /*
25  * fill in the user structure for an a.out core dump
26  */
27 static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump)
28 {
29 /* changed the size calculations - should hopefully work better. lbt */
30         dump->magic = CMAGIC;
31         dump->start_code = 0;
32         dump->start_stack = regs->sp & ~(PAGE_SIZE - 1);
33         dump->u_tsize = ((unsigned long)current->mm->end_code) >> PAGE_SHIFT;
34         dump->u_dsize = ((unsigned long)(current->mm->brk + (PAGE_SIZE - 1)))
35                         >> PAGE_SHIFT;
36         dump->u_dsize -= dump->u_tsize;
37         dump->u_ssize = 0;
38         aout_dump_debugregs(dump);
39
40         if (dump->start_stack < TASK_SIZE)
41                 dump->u_ssize = ((unsigned long)(TASK_SIZE - dump->start_stack))
42                                 >> PAGE_SHIFT;
43
44         dump->regs.bx = regs->bx;
45         dump->regs.cx = regs->cx;
46         dump->regs.dx = regs->dx;
47         dump->regs.si = regs->si;
48         dump->regs.di = regs->di;
49         dump->regs.bp = regs->bp;
50         dump->regs.ax = regs->ax;
51         dump->regs.ds = (u16)regs->ds;
52         dump->regs.es = (u16)regs->es;
53         dump->regs.fs = (u16)regs->fs;
54         dump->regs.gs = get_user_gs(regs);
55         dump->regs.orig_ax = regs->orig_ax;
56         dump->regs.ip = regs->ip;
57         dump->regs.cs = (u16)regs->cs;
58         dump->regs.flags = regs->flags;
59         dump->regs.sp = regs->sp;
60         dump->regs.ss = (u16)regs->ss;
61
62         dump->u_fpvalid = dump_fpu(regs, &dump->i387);
63 }
64
65 #endif /* CONFIG_X86_32 */
66 #endif /* __KERNEL__ */
67 #endif /* _ASM_X86_A_OUT_CORE_H */