summaryrefslogtreecommitdiffstats
path: root/include/arch/x86_64/tables.h
blob: b35dd437173982cf93fed60328acf06c2611e1d2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef _JOVE_ARCH_x86_64_TABLES_H
#define _JOVE_ARCH_x86_64_TABLES_H 1

#include <stdint.h>

#define CD_SEGMENT_TYPE_ACCESSED 1
#define CD_SEGMENT_TYPE_WRITEABLE 2
#define CD_SEGMENT_TYPE_DATA_EXPAND_DOWN 4
#define CD_SEGMENT_TYPE_CODE_CONFORMING 4
#define CD_SEGMENT_TYPE_CODE 8

#define GDT_SEGMENT_TYPE_LDT 2
#define GDT_SEGMENT_TYPE_TSS_AVAIL 0b1001
#define GDT_SEGMENT_TYPE_TSS_BUSY 11

#define GDT_SEGMENT_FLAG_S (1 << 4)
#define GDT_SEGMENT_FLAG_DPL(l) (l << 5)
#define GDT_SEGMENT_FLAG_P (1 << 7)

#define GDT_SEGMENT_AVLX_AVL (1 << 4)
#define GDT_SEGMENT_AVLX_L (1 << 5)
#define GDT_SEGMENT_AVLX_DB (1 << 6)
#define GDT_SEGMENT_AVLX_G (1 << 7)

typedef struct jove_SegmentDescriptor
{
    uint16_t limit_0_15;    /* Segment limit. */
    uint16_t base_0_15;     /* Segment base. */
    uint8_t base_16_23; 
    uint8_t type_flags;
    uint8_t limit_16_19_avlx;
    uint8_t base_24_31;
}__attribute__((packed)) segment_descriptor_t;

#define IDT_IST(v) (v & 7)

#define IDT_TYPE_CALLGATE 12
#define IDT_TYPE_INT_GATE 0b1110
#define IDT_TYPE_TRAP_GATE 0b1111

#define IDT_FLAG_DPL(l) (l << 5)
#define IDT_FLAG_P (1 << 7)

typedef struct jove_InterruptGate
{
    uint16_t base_0_15;
    uint16_t cs;
    uint8_t ist;
    uint8_t type_flags;
    uint16_t base_16_31;
    uint32_t base_32_63;
    uint32_t resv;
}__attribute__((packed)) interrupt_gate_t;

#endif