This commit was manufactured by cvs2svn to create branch
[linux-2.6.git] / include / asm-i386 / netdump.h
1 #ifndef _ASM_I386_NETDUMP_H
2 #define _ASM_I386_NETDUMP_H
3
4 /*
5  * linux/include/asm-i386/netdump.h
6  *
7  * Copyright (c) 2003, 2004 Red Hat, Inc. All rights reserved.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2, or (at your option)
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  *
23  */
24
25 #ifdef __KERNEL__
26
27 #include <asm/irq.h>
28
29 extern int page_is_ram (unsigned long);
30 const static int platform_supports_netdump = 1;
31 extern union irq_ctx *netdump_irq_ctx;
32
33 #define platform_timestamp(x) rdtscll(x)
34
35 #define platform_fix_regs()                                             \
36 {                                                                       \
37        unsigned long esp;                                               \
38        unsigned short ss;                                               \
39        esp = (unsigned long) ((char *)regs + sizeof (struct pt_regs));  \
40        ss = __KERNEL_DS;                                                \
41        if (regs->xcs & 3) {                                             \
42                esp = regs->esp;                                         \
43                ss = regs->xss & 0xffff;                                 \
44        }                                                                \
45        myregs = *regs;                                                  \
46        myregs.esp = esp;                                                \
47        myregs.xss = (myregs.xss & 0xffff0000) | ss;                     \
48 };
49
50 static inline void platform_init_stack(void **stackptr)
51 {
52         *stackptr = (void *)kmalloc(sizeof(union irq_ctx), GFP_KERNEL);
53         if (*stackptr)
54                 memset(*stackptr, 0, sizeof(union irq_ctx));
55         else
56                 printk(KERN_WARNING
57                        "netdump: unable to allocate separate stack\n");
58 }
59
60 static inline void platform_start_netdump(void *stackptr, struct pt_regs *regs)
61 {
62         u32 *dsp;
63         union irq_ctx * curctx;
64         union irq_ctx * dumpctx;
65
66         if (!stackptr)
67                 netpoll_netdump(regs);
68         else {
69                 curctx = (union irq_ctx *) current_thread_info();
70                 dumpctx = (union irq_ctx *) stackptr;
71
72                 /* build the stack frame on the IRQ stack */
73                 dsp = (u32*) ((char*)dumpctx + sizeof(*dumpctx));
74                 dumpctx->tinfo.task = curctx->tinfo.task;
75                 dumpctx->tinfo.real_stack = curctx->tinfo.real_stack;
76                 dumpctx->tinfo.virtual_stack = curctx->tinfo.virtual_stack;
77                 dumpctx->tinfo.previous_esp = current_stack_pointer();
78
79                 *--dsp = (u32) regs;
80
81                 asm volatile(
82                         "       xchgl   %%ebx,%%esp     \n"
83                         "       call    netpoll_netdump \n"
84                         "       xchgl   %%ebx,%%esp     \n"
85                         : : "b"(dsp) :  "memory", "cc", "edx", "ecx"
86                 );
87         }
88 }
89
90 #define platform_cleanup_stack(stackptr)        \
91 do {                                            \
92         if (stackptr)                           \
93                 kfree(stackptr);                \
94 } while (0)
95
96 #define platform_max_pfn() (num_physpages)
97
98 #endif /* __KERNEL__ */
99
100 #endif /* _ASM_I386_NETDUMP_H */