Started setting up threads for user-space execution.
[marionette.git] / kernel / gdt.h
blob3df2bc7d037ffab465cf206e907c716bd874ac42
1 /*
2 * Copyright (c) 2008 Joshua Phillips. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
15 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
21 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
23 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
25 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #ifndef GDT_H
30 #define GDT_H
32 #include "stdint.h"
34 // Segment selectors - these correspond to entries
35 // in the GDT (in gdt.c)
36 #define SEG_DPL0_CODE 0x08 // Kernel-level code
37 #define SEG_DPL0_DATA 0x10 // Kernel-level data
38 #define SEG_DPL3_CODE 0x1B // User-level code
39 #define SEG_DPL3_DATA 0x23 // User-level data
40 #define SEG_DPL3_TSS 0x2B // User-level TSS
42 // The structure of the Task State Segment
43 struct tss {
44 uint16_t prev, res0;
45 uint32_t esp0;
46 uint16_t ss0, res1;
47 uint32_t esp1;
48 uint16_t ss1, res2;
49 uint32_t esp2;
50 uint16_t ss2, res3;
51 uint32_t cr3, eip, eflags, eax, ecx, edx, ebx, esp, ebp, esi, edi;
52 uint16_t es, res4, cs, res5, ss, res6, ds, res7, fs, res8, gs, res9;
53 uint16_t ldt, res10, debug_trap, iomap_base;
56 // Main initialization function for the GDT
57 void gdt_init(void **p_gdt);
59 #endif