The Pedigree Project  0.1
x64/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 
23 #include "pedigree/kernel/compiler.h"
24 #include "pedigree/kernel/processor/types.h"
25 
26 struct X64TaskStateSegment;
27 
33 {
34  public:
37  inline static X64GdtManager &instance()
38  {
39  return m_Instance;
40  }
41 
45  void initialise(size_t processorCount) INITIALISATION_ONLY;
50 
51  private:
62 
70  size_t index, uint64_t base, uint32_t limit, uint8_t flags,
71  uint8_t flags2);
75  void setTssDescriptor(size_t index, uint64_t base) INITIALISATION_ONLY;
76 
80  void
81  initialiseDoubleFaultTss(X64TaskStateSegment *pTss) INITIALISATION_ONLY;
82 
85  static void loadSegmentRegisters();
86 
89  {
91  uint16_t limit0;
93  uint16_t base0;
95  uint8_t base1;
97  uint8_t flags;
99  uint8_t flags_limit1;
101  uint8_t base2;
102  } PACKED;
103 
106  {
108  uint32_t base3;
110  uint32_t res;
111  };
112 
117 
120 };
121 
124 #endif
static X64GdtManager & instance()
Definition: x64/gdt.h:37
void initialiseTss(X64TaskStateSegment *pTss) INITIALISATION_ONLY
Definition: x64/gdt.cc:127
void setSegmentDescriptor(size_t index, uint64_t base, uint32_t limit, uint8_t flags, uint8_t flags2)
Definition: x64/gdt.cc:109
void initialise(size_t processorCount) INITIALISATION_ONLY
Definition: x64/gdt.cc:35
X64GdtManager() INITIALISATION_ONLY
Definition: x64/gdt.cc:102
static X64GdtManager m_Instance
Definition: x64/gdt.h:119
void setTssDescriptor(size_t index, uint64_t base) INITIALISATION_ONLY
Definition: x64/gdt.cc:119
X64GdtManager & operator=(const X64GdtManager &)
static void loadSegmentRegisters()
static void initialiseProcessor() INITIALISATION_ONLY
Definition: x64/gdt.cc:85
size_t m_DescriptorCount
Definition: x64/gdt.h:116
segment_descriptor * m_Gdt
Definition: x64/gdt.h:114