1 /*
2  * Copyright (c) 2009 Corey Tabaka
3  * Copyright (c) 2014 Intel Corporation
4  *
5  * Use of this source code is governed by a MIT-style
6  * license that can be found in the LICENSE file or at
7  * https://opensource.org/licenses/MIT
8  */
9 #pragma once
10 
11 /*
12  * System Selectors
13  */
14 #define NULL_SELECTOR       0x00
15 
16 /********* x86 selectors *********/
17 #define CODE_SELECTOR       0x08
18 #define DATA_SELECTOR       0x10
19 #define USER_CODE_32_SELECTOR   0x18
20 #define USER_DATA_32_SELECTOR   0x20
21 
22 /******* x86-64 selectors ********/
23 #define CODE_64_SELECTOR    0x28
24 #define STACK_64_SELECTOR   0x30
25 #define USER_CODE_64_SELECTOR   0x38
26 #define USER_DATA_64_SELECTOR   0x40
27 
28 #define TSS_SELECTOR        0x48
29 
30 /*
31  * Descriptor Types
32  */
33 #define SEG_TYPE_TSS        0x9
34 #define SEG_TYPE_TSS_BUSY   0xb
35 #define SEG_TYPE_TASK_GATE  0x5
36 #define SEG_TYPE_INT_GATE   0xe     // 32 bit
37 #define SEG_TYPE_DATA_RW    0x2
38 #define SEG_TYPE_CODE_RW    0xa
39 
40 #ifndef ASSEMBLY
41 
42 #include <sys/types.h>
43 
44 typedef uint16_t seg_sel_t;
45 
46 void set_global_desc(seg_sel_t sel, void *base, uint32_t limit,
47                      uint8_t present, uint8_t ring, uint8_t sys, uint8_t type, uint8_t gran, uint8_t bits);
48 
49 #endif
50