The Pedigree Project 0.1
gdt.h
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#ifndef KERNEL_PROCESSOR_X64_GDT_H
21#define KERNEL_PROCESSOR_X64_GDT_H
22#include "pedigree/kernel/compiler.h"
23#include "pedigree/kernel/processor/types.h"
24
25#include <config.h>
26
28
34 public:
37 inline static X64GdtManager& instance() {
38 return m_Instance;
39 }
40
44 void initialise(size_t processorCount) INITIALISATION_ONLY;
49
50 private:
58 X64GdtManager& operator=(const X64GdtManager&);
61
68 void setSegmentDescriptor(size_t index, uint64_t base, uint32_t limit, uint8_t flags,
69 uint8_t flags2);
73 void setTssDescriptor(size_t index, uint64_t base) INITIALISATION_ONLY;
74
78 void initialiseDoubleFaultTss(X64TaskStateSegment* pTss) INITIALISATION_ONLY;
79
82 static void loadSegmentRegisters();
83
87 uint16_t limit0;
89 uint16_t base0;
91 uint8_t base1;
93 uint8_t flags;
95 uint8_t flags_limit1;
97 uint8_t base2;
98 } PACKED;
99
103 uint32_t base3;
105 uint32_t res;
106 };
107
112
115};
116
119#endif
static X64GdtManager & instance()
Definition gdt.h:37
segment_descriptor * m_Gdt
Definition gdt.h:109
void setSegmentDescriptor(size_t index, uint64_t base, uint32_t limit, uint8_t flags, uint8_t flags2)
Definition gdt.cc:105
void initialise(size_t processorCount) INITIALISATION_ONLY
Definition gdt.cc:41
static X64GdtManager m_Instance
Definition gdt.h:114
size_t m_DescriptorCount
Definition gdt.h:111
static void loadSegmentRegisters()
static void initialiseProcessor() INITIALISATION_ONLY
Definition gdt.cc:86
void initialiseTss(X64TaskStateSegment *pTss) INITIALISATION_ONLY
Definition gdt.cc:120
void setTssDescriptor(size_t index, uint64_t base) INITIALISATION_ONLY
Definition gdt.cc:114