xref: /haiku/headers/private/kernel/arch/x86/descriptors.h (revision 73ad2473e7874b3702cf5b0fdf4c81b747812ed9)
1 /*
2  * Copyright 2002-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
6  * Distributed under the terms of the NewOS License.
7  */
8 #ifndef _KERNEL_ARCH_x86_DESCRIPTORS_H
9 #define _KERNEL_ARCH_x86_DESCRIPTORS_H
10 
11 
12 #ifndef _ASSEMBLER
13 
14 
15 #include <SupportDefs.h>
16 
17 
18 struct kernel_args;
19 
20 
21 enum descriptor_privilege_levels {
22 	DPL_KERNEL = 0,
23 	DPL_USER = 3,
24 };
25 
26 enum descriptor_types {
27 	// segment types
28 	DT_CODE_EXECUTE_ONLY = 0x8,
29 	DT_CODE_ACCESSED = 0x9,
30 	DT_CODE_READABLE = 0xa,
31 	DT_CODE_CONFORM = 0xc,
32 	DT_DATA_READ_ONLY = 0x0,
33 	DT_DATA_ACCESSED = 0x1,
34 	DT_DATA_WRITEABLE = 0x2,
35 	DT_DATA_EXPANSION_DOWN = 0x4,
36 
37 	DT_TSS = 9,
38 		/* non busy, 32 bit */
39 
40 	// descriptor types
41 	DT_SYSTEM_SEGMENT = 0,
42 	DT_CODE_DATA_SEGMENT = 1,
43 };
44 
45 enum gate_types {
46 	GATE_INTERRUPT = 14,
47 	GATE_TRAP = 15,
48 };
49 
50 
51 void x86_descriptors_init(kernel_args* args);
52 void x86_descriptors_init_percpu(kernel_args* args, int cpu);
53 status_t x86_descriptors_init_post_vm(kernel_args* args);
54 
55 
56 #endif	// !_ASSEMBLER
57 
58 
59 #ifdef __x86_64__
60 #	include <arch/x86/64/descriptors.h>
61 #else
62 #	include <arch/x86/32/descriptors.h>
63 #endif
64 
65 
66 #endif	/* _KERNEL_ARCH_x86_DESCRIPTORS_H */
67