-
Notifications
You must be signed in to change notification settings - Fork 0
/
k-asm.h
172 lines (172 loc) · 4.65 KB
/
k-asm.h
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#define COLOR_ERROR 0xC000
#define CONSOLE_ADDR 0xB8000
#define CONSOLE_COLUMNS 80
#define CONSOLE_ROWS 25
#define CR0_AM 0x00040000
#define CR0_CD 0x40000000
#define CR0_EM 0x00000004
#define CR0_ET 0x00000010
#define CR0_MP 0x00000002
#define CR0_NE 0x00000020
#define CR0_NW 0x20000000
#define CR0_PE 0x00000001
#define CR0_PG 0x80000000
#define CR0_TS 0x00000008
#define CR0_WP 0x00010000
#define CR4_DE 0x00000008
#define CR4_OSFXSR 0x00000200
#define CR4_PAE 0x00000020
#define CR4_PCE 0x00000100
#define CR4_PGE 0x00000080
#define CR4_PSE 0x00000010
#define CR4_VMXE 0x00004000
#define EFLAGS_AC 0x00040000
#define EFLAGS_AF 0x00000010
#define EFLAGS_CF 0x00000001
#define EFLAGS_DF 0x00000400
#define EFLAGS_ID 0x00200000
#define EFLAGS_IF 0x00000200
#define EFLAGS_IOPL_0 0x00000000
#define EFLAGS_IOPL_1 0x00001000
#define EFLAGS_IOPL_2 0x00002000
#define EFLAGS_IOPL_3 0x00003000
#define EFLAGS_IOPL_MASK 0x00003000
#define EFLAGS_NT 0x00004000
#define EFLAGS_OF 0x00000800
#define EFLAGS_PF 0x00000004
#define EFLAGS_RF 0x00010000
#define EFLAGS_SF 0x00000080
#define EFLAGS_TF 0x00000100
#define EFLAGS_VIF 0x00080000
#define EFLAGS_VIP 0x00100000
#define EFLAGS_VM 0x00020000
#define EFLAGS_ZF 0x00000040
#define IA32_APIC_BASE_ENABLED 0x800
#define IA32_EFER_LME 0x100
#define IA32_EFER_NXE 0x800
#define IA32_EFER_SCE 0x1
#define INT_AC 17
#define INT_BP 3
#define INT_DB 1
#define INT_DE 0
#define INT_DF 8
#define INT_GP 13
#define INT_IRQ 32
#define INT_MC 18
#define INT_NM 2
#define INT_NP 11
#define INT_OF 4
#define INT_PF 14
#define INT_SS 12
#define INT_TS 10
#define INT_UD 6
#define IRQ_ERROR 19
#define IRQ_KEYBOARD 1
#define IRQ_SPURIOUS 31
#define IRQ_TIMER 0
#define KERNEL_STACK_TOP 0x80000
#define KERNEL_START_ADDR 0x40000
#define KEYBOARD_DATAREG 0x60
#define KEYBOARD_STATUSREG 0x64
#define KEYBOARD_STATUS_READY 0x01
#define KEY_DELETE 0311
#define KEY_DOWN 0302
#define KEY_END 0305
#define KEY_HOME 0304
#define KEY_INSERT 0310
#define KEY_LEFT 0303
#define KEY_PAGEDOWN 0307
#define KEY_PAGEUP 0306
#define KEY_RIGHT 0301
#define KEY_UP 0300
#define MEMSIZE_PHYSICAL 0x200000
#define MEMSIZE_VIRTUAL 0x300000
#define MSR_IA32_APIC_BASE 0x1B
#define MSR_IA32_EFER 0xC0000080
#define MSR_IA32_FMASK 0xC0000084
#define MSR_IA32_FS_BASE 0xC0000100
#define MSR_IA32_GS_BASE 0xC0000101
#define MSR_IA32_KERNEL_GS_BASE 0xC0000102
#define MSR_IA32_LSTAR 0xC0000082
#define MSR_IA32_MTRR_BASE 0x200
#define MSR_IA32_MTRR_CAP 0xFE
#define MSR_IA32_MTRR_DEF_TYPE 0x2FF
#define MSR_IA32_MTRR_FIX16K_80000 0x258
#define MSR_IA32_MTRR_FIX16K_A0000 0x259
#define MSR_IA32_MTRR_FIX4K_C0000 0x268
#define MSR_IA32_MTRR_FIX64K_00000 0x250
#define MSR_IA32_STAR 0xC0000081
#define NPROC 16
#define PAGEINDEXBITS 9
#define PAGEOFFBITS 12
#define PA_IOHIGHEND 0x0000000100000000
#define PA_IOHIGHMIN 0x00000000C0000000
#define PA_IOLOWEND 0x0000000000100000
#define PA_IOLOWMIN 0x00000000000A0000
#define PFERR_PRESENT 0x1
#define PFERR_USER 0x4
#define PFERR_WRITE 0x2
#define PROCINIT_ALLOW_PROGRAMMED_IO 0x01
#define PROCINIT_DISABLE_INTERRUPTS 0x02
#define PROC_START_ADDR 0x100000
#define PTE_A 0x20
#define PTE_D 0x40
#define PTE_OS1 0x200
#define PTE_OS2 0x400
#define PTE_OS3 0x800
#define PTE_P 0x1
#define PTE_PAMASK 0x000FFFFFFFFFF000
#define PTE_PCD 0x10
#define PTE_PS 0x80
#define PTE_PS_PAMASK 0x000FFFFFFFFFE000
#define PTE_PWT 0x8
#define PTE_PWU 0x7
#define PTE_U 0x4
#define PTE_W 0x2
#define PTE_XD 0x8000000000000000
#define P_BLOCKED 2
#define P_BROKEN 3
#define P_FREE 0
#define P_RUNNABLE 1
#define P_SLEPT 4
#define RAND_MAX 0x7FFFFFFF
#define SEGSEL_APP_CODE 0x18
#define SEGSEL_APP_DATA 0x20
#define SEGSEL_BOOT_CODE 0x8
#define SEGSEL_KERN_CODE 0x8
#define SEGSEL_KERN_DATA 0x10
#define SEGSEL_TASKSTATE 0x28
#define STDC_HEADERS 1
#define SYSCALL_EXIT 6
#define SYSCALL_FORK 5
#define SYSCALL_GETPID 1
#define SYSCALL_KILL 7
#define SYSCALL_PAGE_ALLOC 4
#define SYSCALL_PANIC 3
#define SYSCALL_SLEEP 8
#define SYSCALL_YIELD 2
#define VA_HIGHMAX 0xFFFFFFFFFFFFFFFF
#define VA_HIGHMIN 0xFFFF800000000000
#define VA_LOWEND 0x0000800000000000
#define VA_LOWMAX 0x00007FFFFFFFFFFF
#define VA_LOWMIN 0
#define VA_NONCANONEND 0x0001000000000000
#define VA_NONCANONMAX 0x0000FFFFFFFFFFFF
#define X86GATE_CALL 0xC
#define X86GATE_INTERRUPT 0xE
#define X86GATE_TRAP 0xF
#define X86SEG_A (0x1 << 40)
#define X86SEG_C (0x4 << 40)
#define X86SEG_DB (1 << 54)
#define X86SEG_E (0x4 << 40)
#define X86SEG_G (1 << 55)
#define X86SEG_L (1 << 53)
#define X86SEG_P (1 << 47)
#define X86SEG_R (0x2 << 40)
#define X86SEG_S (1 << 44)
#define X86SEG_TSS (0x9 << 40)
#define X86SEG_W (0x2 << 40)
#define X86SEG_X (0x8 << 40)
#define X86_BDA_BASE_MEMORY_SIZE_PA 0x413
#define X86_BDA_EBDA_BASE_ADDRESS_PA 0x40E
#define X86_BDA_PA 0x400