Home | History | Annotate | Download | only in x86
      1 /**
      2  * @file op_apic.h
      3  * x86 apic, nmi, perf counter declaration
      4  *
      5  * @remark Copyright 2002 OProfile authors
      6  * @remark Read the file COPYING
      7  *
      8  * @author John Levon
      9  * @author Philippe Elie
     10  * @author Dave Jones
     11  * @author Graydon Hoare
     12  */
     13 
     14 #ifndef OP_APIC_H
     15 #define OP_APIC_H
     16 
     17 #include "apic_compat.h"
     18 
     19 #define NMI_GATE_TYPE 14
     20 #define NMI_VECTOR_NUM 2
     21 #define NMI_DPL_LEVEL 0
     22 
     23 
     24 /* copied from kernel 2.4.19 : arch/i386/traps.c */
     25 
     26 struct gate_struct {
     27 	u32 a;
     28 	u32 b;
     29 } __attribute__((packed));
     30 
     31 #define _set_gate(gate_addr, type, dpl, addr) \
     32 do { \
     33 	int __d0, __d1; \
     34 	__asm__ __volatile__ ("movw %%dx, %%ax\n\t" \
     35 	"movw %4, %%dx\n\t" \
     36 	"movl %%eax, %0\n\t" \
     37 	"movl %%edx, %1" \
     38 	:"=m" (*((long *) (gate_addr))), \
     39 	 "=m" (*(1+(long *) (gate_addr))), "=&a" (__d0), "=&d" (__d1) \
     40 	:"i" ((short) (0x8000+(dpl << 13)+(type << 8))), \
     41 	 "3" ((char *) (addr)), "2" (__KERNEL_CS << 16)); \
     42 } while (0)
     43 
     44 #define SET_NMI_GATE	\
     45 	_set_gate(&descr.base[NMI_VECTOR_NUM], NMI_GATE_TYPE, NMI_DPL_LEVEL, &op_nmi);
     46 
     47 #define store_idt(addr) \
     48 	do { \
     49 		__asm__ __volatile__ ("sidt %0" \
     50 			: "=m" (addr) \
     51 			: : "memory"); \
     52 	} while (0)
     53 
     54 struct _descr {
     55 	u16 limit;
     56 	struct gate_struct * base;
     57 } __attribute__((__packed__));
     58 
     59 void lvtpc_apic_setup(void * dummy);
     60 void lvtpc_apic_restore(void * dummy);
     61 int apic_setup(void);
     62 void apic_restore(void);
     63 void install_nmi(void);
     64 void restore_nmi(void);
     65 
     66 void fixmap_setup(void);
     67 void fixmap_restore(void);
     68 
     69 asmlinkage void op_nmi(void);
     70 
     71 #endif /* OP_APIC_H */
     72