7 * The layout of the GDT under Linux:
11 * 2 - kernel code segment
12 * 3 - kernel data segment
13 * 4 - user code segment <-- new cacheline
14 * 5 - user data segment
17 * 8 - APM BIOS support <-- new cacheline
18 * 9 - APM BIOS support
19 * 10 - APM BIOS support
20 * 11 - APM BIOS support
22 * The TSS+LDT descriptors are spread out a bit so that every CPU
23 * has an exclusive cacheline for the per-CPU TSS and LDT:
25 * 12 - CPU#0 TSS <-- new cacheline
29 * 16 - CPU#1 TSS <-- new cacheline
33 * ... NR_CPUS per-CPU TSS+LDT's if on SMP
35 * Entry into gdt where to find first TSS.
37 #define __FIRST_TSS_ENTRY 12
38 #define __FIRST_LDT_ENTRY (__FIRST_TSS_ENTRY+1)
40 #define __TSS(n) (((n)<<2) + __FIRST_TSS_ENTRY)
41 #define __LDT(n) (((n)<<2) + __FIRST_LDT_ENTRY)
48 extern struct desc_struct gdt_table
[];
49 extern struct desc_struct
*idt
, *gdt
;
51 struct Xgt_desc_struct
{
53 unsigned long address
__attribute__((packed
));
56 #define idt_descr (*(struct Xgt_desc_struct *)((char *)&idt - 2))
57 #define gdt_descr (*(struct Xgt_desc_struct *)((char *)&gdt - 2))
59 #define load_TR(n) __asm__ __volatile__("ltr %%ax"::"a" (__TSS(n)<<3))
61 #define __load_LDT(n) __asm__ __volatile__("lldt %%ax"::"a" (__LDT(n)<<3))
64 * This is the ldt that every process will get unless we need
65 * something other than this.
67 extern struct desc_struct default_ldt
[];
68 extern void set_intr_gate(unsigned int irq
, void * addr
);
69 extern void set_ldt_desc(unsigned int n
, void *addr
, unsigned int size
);
70 extern void set_tss_desc(unsigned int n
, void *addr
);
72 extern inline void clear_LDT(void)
74 int cpu
= smp_processor_id();
75 set_ldt_desc(cpu
, &default_ldt
[0], 5);
80 * load one particular LDT into the current CPU
82 extern inline void load_LDT (struct mm_struct
*mm
)
84 int cpu
= smp_processor_id();
85 void *segments
= mm
->segments
;
86 int count
= LDT_ENTRIES
;
89 segments
= &default_ldt
[0];
93 set_ldt_desc(cpu
, segments
, count
);
97 #endif /* !__ASSEMBLY__ */