pda.h revision 3e1498c4c4b379780bdb998bd68e5d581beec811
1/****************************************************************************
2 ****************************************************************************
3 ***
4 ***   This header was automatically generated from a Linux kernel header
5 ***   of the same name, to make information necessary for userspace to
6 ***   call into the kernel available to libc.  It contains only constants,
7 ***   structures, and macros generated from the original header, and thus,
8 ***   contains no copyrightable information.
9 ***
10 ****************************************************************************
11 ****************************************************************************/
12#ifndef X86_64_PDA_H
13#define X86_64_PDA_H
14
15#ifndef __ASSEMBLY__
16#include <linux/stddef.h>
17#include <linux/types.h>
18#include <linux/cache.h>
19#include <asm/page.h>
20
21struct x8664_pda {
22 struct task_struct *pcurrent;
23 unsigned long data_offset;
24 unsigned long kernelstack;
25 unsigned long oldrsp;
26 int irqcount;
27 int cpunumber;
28 char *irqstackptr;
29 int nodenumber;
30 unsigned int __softirq_pending;
31 unsigned int __nmi_count;
32 short mmu_state;
33 short isidle;
34 struct mm_struct *active_mm;
35 unsigned apic_timer_irqs;
36 unsigned irq0_irqs;
37 unsigned irq_resched_count;
38 unsigned irq_call_count;
39 unsigned irq_tlb_count;
40 unsigned irq_thermal_count;
41 unsigned irq_threshold_count;
42 unsigned irq_spurious_count;
43} ____cacheline_aligned_in_smp;
44
45#define cpu_pda(i) (_cpu_pda[i])
46
47#define pda_offset(field) offsetof(struct x8664_pda, field)
48
49#define pda_to_op(op,field,val) do {   typedef typeof(_proxy_pda.field) T__;   if (0) { T__ tmp__; tmp__ = (val); }     switch (sizeof(_proxy_pda.field)) {   case 2:   asm(op "w %1,%%gs:%c2" :   "+m" (_proxy_pda.field) :   "ri" ((T__)val),   "i"(pda_offset(field)));   break;   case 4:   asm(op "l %1,%%gs:%c2" :   "+m" (_proxy_pda.field) :   "ri" ((T__)val),   "i" (pda_offset(field)));   break;   case 8:   asm(op "q %1,%%gs:%c2":   "+m" (_proxy_pda.field) :   "ri" ((T__)val),   "i"(pda_offset(field)));   break;   default:   __bad_pda_field();   }   } while (0)
50
51#define pda_from_op(op,field) ({   typeof(_proxy_pda.field) ret__;   switch (sizeof(_proxy_pda.field)) {   case 2:   asm(op "w %%gs:%c1,%0" :   "=r" (ret__) :   "i" (pda_offset(field)),   "m" (_proxy_pda.field));   break;   case 4:   asm(op "l %%gs:%c1,%0":   "=r" (ret__):   "i" (pda_offset(field)),   "m" (_proxy_pda.field));   break;   case 8:   asm(op "q %%gs:%c1,%0":   "=r" (ret__) :   "i" (pda_offset(field)),   "m" (_proxy_pda.field));   break;   default:   __bad_pda_field();   }   ret__; })
52
53#define read_pda(field) pda_from_op("mov",field)
54#define write_pda(field,val) pda_to_op("mov",field,val)
55#define add_pda(field,val) pda_to_op("add",field,val)
56#define sub_pda(field,val) pda_to_op("sub",field,val)
57#define or_pda(field,val) pda_to_op("or",field,val)
58
59#define test_and_clear_bit_pda(bit,field) ({   int old__;   asm volatile("btr %2,%%gs:%c3\n\tsbbl %0,%0"   : "=r" (old__), "+m" (_proxy_pda.field)   : "dIr" (bit), "i" (pda_offset(field)) : "memory");   old__;  })
60
61#endif
62
63#define PDA_STACKOFFSET (5*8)
64
65#endif
66