x86: introduce fill_ldt
[linux-2.6.git] / include / asm-x86 / desc.h
1 #ifndef _ASM_DESC_H_
2 #define _ASM_DESC_H_
3
4 #ifndef __ASSEMBLY__
5 #include <asm/desc_defs.h>
6 #include <asm/ldt.h>
7
8 static inline void fill_ldt(struct desc_struct *desc, struct user_desc *info)
9 {
10         desc->limit0 = info->limit & 0x0ffff;
11         desc->base0 = info->base_addr & 0x0000ffff;
12
13         desc->base1 = (info->base_addr & 0x00ff0000) >> 16;
14         desc->type = (info->read_exec_only ^ 1) << 1;
15         desc->type |= info->contents << 2;
16         desc->s = 1;
17         desc->dpl = 0x3;
18         desc->p = info->seg_not_present ^ 1;
19         desc->limit = (info->limit & 0xf0000) >> 16;
20         desc->avl = info->useable;
21         desc->d = info->seg_32bit;
22         desc->g = info->limit_in_pages;
23         desc->base2 = (info->base_addr & 0xff000000) >> 24;
24 }
25
26 #endif
27
28 #ifdef CONFIG_X86_32
29 # include "desc_32.h"
30 #else
31 # include "desc_64.h"
32 #endif
33
34 #endif