trace_intr.h
Go to the documentation of this file.
1 #ifndef __ASM_TRACE_USER_H
2 #define __ASM_TRACE_USER_H
3 /* This file (trace_user.h) was created by Ron Rechenmacher <ron@fnal.gov> on
4  Dec 13, 1999. "TERMS AND CONDITIONS" governing this file are in the README
5  or COPYING file. If you do not have such a file, one can be obtained by
6  contacting Ron or Fermi Lab in Batavia IL, 60510, phone: 630-840-3000.
7 */
8 #define __TRACE_INTR_H_REV "\
9 $RCSfile: trace_intr.h,v $(i386)\
10 $Revision: 1.1.1.1 $\
11 $Date: 2009/10/09 20:03:00 $"
12 
13 /* NOTE: watch out when changing vector when io_apic interrupt mapping is
14  used. Ref. arch/i386/kernel/io_apic.c. Note algorithym in
15  assign_irq_vector() which is called by setup_IO_APIC_irqs() which is
16  called by setup_IO_APIC called by
17  arch/i386/kernel/smp.c:smp_boot_cpus() called by init/main.c:smp_init()
18  called by init/main.c:start_kernel()*/
19 #define TRACE_VECTOR 0x82
20 
21 #ifdef __KERNEL__ /* ------------------------------------------------------- */
22 
23 #include <linux/version.h> /* KERNEL_VERSION */
24 #include <linux/linkage.h> /* SYMBOL_NAME_STR */
25 
26 void
27 trace_interrupt_init( void );
28 
29 extern struct desc_struct idt_table[256]; /* defd in arch/i386/kernel/traps.c*/
30 
31 #define GET_ESP ({register unsigned int _r_;\
32  __asm__ __volatile__( "mov %%esp,%%eax":"=a"(_r_) );_r_;})
33 
34 #ifndef STR
35 # define __STR(x) #x
36 # define STR( x ) __STR(x)
37 #endif
38 
39 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
40 # define SYMBOL_NAME_STR(X) #X
41 #endif
42 
43 #define BUILD_TRACE_INTERRUPT( handler ) \
44 asmlinkage void trace_interrupt( void );\
45 __asm__( "\n"__ALIGN_STR"\n"\
46  SYMBOL_NAME_STR(trace_interrupt) ":\n\t"\
47  "pushl $-1\n\t"\
48  "cld\n\t" \
49  "pushl %es\n\t" \
50  "pushl %ds\n\t" \
51  "pushl %eax\n\t" \
52  "pushl %ebp\n\t" \
53  "pushl %edi\n\t" \
54  "pushl %esi\n\t" \
55  "pushl %edx\n\t" \
56  "pushl %ecx\n\t" \
57  "pushl %ebx\n\t" \
58  "movl $" STR(__KERNEL_DS) ",%edx\n\t" \
59  "movl %edx,%ds\n\t" \
60  "movl %edx,%es\n\t"\
61  "pushl %ecx\n\t"\
62  "pushl %ebx\n\t"\
63  "pushl %eax\n\t"\
64  "call "SYMBOL_NAME_STR(handler)"\n\t"\
65  "addl $12,%esp\n\t"\
66  "popl %ebx\n\t"\
67  "popl %ecx\n\t"\
68  "popl %edx\n\t"\
69  "popl %esi\n\t"\
70  "popl %edi\n\t"\
71  "popl %ebp\n\t"\
72  "popl %eax\n\t"\
73  "popl %ds\n\t"\
74  "popl %es\n\t"\
75  "addl $4,%esp\n\t"\
76  "iret\n" )
77 
78 
79 #else /* of ifdef __KERNEL__ ----------------------------------------------- */
80 
81 /******************************************************************************
82  * trace_function
83  *
84  * It is OK that this is a function call as the "if" statement in the
85  * TRACE macro is the critical item.
86  * And since we can make it a function (where everything will be organized
87  * on the stack, all we have to do is pass a pointer to the start location
88  * on the stack.
89  *
90  */
91 
92 static void
93 trace_function( struct timeval *time
94  , int tid
95  /*, int lvl
96  , char *msg*/
97  , ... )
98 {
99  va_list ap;
100 
101  va_start( ap, tid );
102  __asm__( "int %0"
103  :
104  :"i"(TRACE_VECTOR)
105  ,"a"(time)
106  ,"b"(tid)
107  ,"c"(ap) );
108 
109  va_end( ap );
110  return;
111 } /* trace_function */
112 
113 
114 #endif /* of else of ifdef __KERNEL__ ------------------------------------- */
115 
116 #endif /* __ASM_TRACE_USER_H */
static void trace_function(struct timeval *time, int tid,...)
Definition: trace_intr.h:93
#define TRACE_VECTOR
Definition: trace_intr.h:19