aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/include
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/include')
-rw-r--r--arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/gate_descriptor.hpp13
-rw-r--r--arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.hpp6
-rw-r--r--arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.hpp12
-rw-r--r--arch/x86_64/include/arch/context_switching/segment_descriptor_table/gdt_flags.hpp22
-rw-r--r--arch/x86_64/include/arch/interrupt_handling/generic_interrupt_handler.hpp28
5 files changed, 51 insertions, 30 deletions
diff --git a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/gate_descriptor.hpp b/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/gate_descriptor.hpp
index a652e0c..e677cbb 100644
--- a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/gate_descriptor.hpp
+++ b/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/gate_descriptor.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRRUPT_DESCRIPTOR_TABLE_GATE_DESCRIPTOR_HPP
-#define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRRUPT_DESCRIPTOR_TABLE_GATE_DESCRIPTOR_HPP
+#ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_GATE_DESCRIPTOR_HPP
+#define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_GATE_DESCRIPTOR_HPP
#include "arch/context_switching/interrupt_descriptor_table/idt_flags.hpp"
#include "arch/context_switching/interrupt_descriptor_table/ist_offset.hpp"
@@ -57,15 +57,14 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table
private:
// The order in private variables starts for the first variable being the rightmost bit.
- uint16_t _offset_1 = {}; ///< First part of the offset field. Represents the address of the entry point of the
- ///< Interrupt Service Routine. (0 - 15)
+ uint16_t _offset_1 = {}; ///< Lower 16 bits of handler function address (0 - 15)
segment_selector _selector = {}; ///< Segment selector (16 - 31)
ist_offset _ist = {}; ///< Interrupt Stack Table offset (32 - 39)
idt_flags _flags = {}; ///< Gate Type and Flags (40 - 47)
- uint64_t _offset_2 : 48 = {}; ///< Second part of the offset field. Represents the address of the entry point of
- ///< the Interrupt Service Routine. (48 - 95)
+ uint16_t _offset_2 = {}; ///< Middle 16 bits of handler function address (48 - 63)
+ uint32_t _offset_3 = {}; ///< Upper 32 bits of handler function address (for x86_64) (64 - 95)
uint32_t : 32; ///< Reserved field used to ensure this struct is 128 bits big (96 - 127)
};
} // namespace teachos::arch::context_switching::interrupt_descriptor_table
-#endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRRUPT_DESCRIPTOR_TABLE_GATE_DESCRIPTOR_HPP
+#endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_GATE_DESCRIPTOR_HPP
diff --git a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.hpp b/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.hpp
index dd55cd7..e2ec4c5 100644
--- a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.hpp
+++ b/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRRUPT_DESCRIPTOR_TABLE_INTERRUPT_DESCRIPTOR_TABLE_HPP
-#define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRRUPT_DESCRIPTOR_TABLE_INTERRUPT_DESCRIPTOR_TABLE_HPP
+#ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_INTERRUPT_DESCRIPTOR_TABLE_HPP
+#define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_INTERRUPT_DESCRIPTOR_TABLE_HPP
#include "arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.hpp"
@@ -15,4 +15,4 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table
} // namespace teachos::arch::context_switching::interrupt_descriptor_table
-#endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRRUPT_DESCRIPTOR_TABLE_INTERRUPT_DESCRIPTOR_TABLE_HPP
+#endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_INTERRUPT_DESCRIPTOR_TABLE_HPP
diff --git a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.hpp b/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.hpp
index d853ff0..7fe933b 100644
--- a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.hpp
+++ b/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRRUPT_DESCRIPTOR_TABLE_INTERRUPT_DESCRIPTOR_TABLE_POINTER_HPP
-#define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRRUPT_DESCRIPTOR_TABLE_INTERRUPT_DESCRIPTOR_TABLE_POINTER_HPP
+#ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_INTERRUPT_DESCRIPTOR_TABLE_POINTER_HPP
+#define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_INTERRUPT_DESCRIPTOR_TABLE_POINTER_HPP
#include "arch/context_switching/interrupt_descriptor_table/gate_descriptor.hpp"
#include "arch/stl/vector.hpp"
@@ -23,7 +23,7 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table
/**
* @brief Constructor.
*/
- interrupt_descriptor_table_pointer(uint16_t table_length, interrupt_descriptor_table * address);
+ interrupt_descriptor_table_pointer(uint16_t table_length, gate_descriptor * address);
/**
* @brief Defaulted three-way comparsion operator.
@@ -31,10 +31,10 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table
auto operator<=>(interrupt_descriptor_table_pointer const & other) const -> std::strong_ordering = default;
private:
- uint16_t table_length = {}; ///< The amount of segment descriptor entries in the global descriptor table - 1.
- interrupt_descriptor_table * address = {}; ///< Non-owning pointer to the IDT base address.
+ uint16_t table_length = {}; ///< The amount of segment descriptor entries in the global descriptor table - 1.
+ gate_descriptor * address = {}; ///< Non-owning pointer to the IDT base address.
};
} // namespace teachos::arch::context_switching::interrupt_descriptor_table
-#endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRRUPT_DESCRIPTOR_TABLE_INTERRUPT_DESCRIPTOR_TABLE_POINTER_HPP
+#endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_INTERRUPT_DESCRIPTOR_TABLE_POINTER_HPP
diff --git a/arch/x86_64/include/arch/context_switching/segment_descriptor_table/gdt_flags.hpp b/arch/x86_64/include/arch/context_switching/segment_descriptor_table/gdt_flags.hpp
index 764aec5..8217bcb 100644
--- a/arch/x86_64/include/arch/context_switching/segment_descriptor_table/gdt_flags.hpp
+++ b/arch/x86_64/include/arch/context_switching/segment_descriptor_table/gdt_flags.hpp
@@ -18,22 +18,16 @@ namespace teachos::arch::context_switching::segment_descriptor_table
*/
enum bitset : uint8_t
{
+ AVAILABLE = 1U << 0U, ///< Available for use by System software. For our purposes this is basically reserved.
LONG_MODE = 1U << 1U, ///< Defines in IA-32e mode (64-bit code and 32-bit compatability mode) if the segment
- ///< contains 64-bit code. Otherwise this bit should always be 0. Enable if instructions are
- ///< executed in 64-bit code, otherwise they are executed in compatability 32-bit mode. If bis
- ///< is set the DEFAULT_LENGTH bis needs to be 0
+ ///< contains 64-bit code. Otherwise this bit should always be 0. Enable if instructions
+ ///< are executed in 64-bit code, otherwise they are executed in compatability 32-bit mode.
+ ///< If this is set the DEFAULT_OPERAND_SIZE/BIG bit needs to be clear (0).
- // FIXME: Where does this come from, and is this value correct?
- UPPER_BOUND = 1U << 1U, ///< Specifies the upper bound of the segment for expand down data segment. Enable for 5
- ///< GiB, 4 KiB otherwise.
-
- // FIXME: Where does this come from, and is this value correct?
- STACK_POINTER_SIZE = 1U << 1U, ///< Specifies the size of the Stack Pointer (SP) for stack segments used for
- ///< implicit stack operations. Enable for 32 bit, 16 bit otherwise.
-
- // FIXME: Where does this come from, and is this value correct?
- DEFAULT_LENGTH = 1U << 1U, ///< Indicates the default length for code segments with effective addresses and
- ///< operands. Enable for 32 bit, 16 bit otherwise.
+ DEFAULT_OPERATION_SIZE =
+ 1U << 2U, ///< If clear, this is a 16-bit code segment; if set, this is a 32-bit segment.
+ BIG = 1U << 2U, ///< If set, the maximum offset size for a data segment is increased to 32-bit
+ ///< 0xffffffff. Otherwise it's the 16-bit max 0x0000ffff. Essentially the same meaning as "D".
GRANULARITY = 1U << 3U, ///< Indicates the size the Limit value in the segment descriptor is scaled by 1 Byte
///< blocks if the bit is not set or by 4 KiB blocks if the bit is set.
diff --git a/arch/x86_64/include/arch/interrupt_handling/generic_interrupt_handler.hpp b/arch/x86_64/include/arch/interrupt_handling/generic_interrupt_handler.hpp
new file mode 100644
index 0000000..9f33fa0
--- /dev/null
+++ b/arch/x86_64/include/arch/interrupt_handling/generic_interrupt_handler.hpp
@@ -0,0 +1,28 @@
+#ifndef TEACHOS_ARCH_X86_64_INTERRUPT_HANDLING_GENERIC_INTERRUPT_HANDLER_HPP
+#define TEACHOS_ARCH_X86_64_INTERRUPT_HANDLING_GENERIC_INTERRUPT_HANDLER_HPP
+
+#include <cstdint>
+
+namespace teachos::arch::interrupt_handling
+{
+ /**
+ * @brief This has been created in a rush. I think it is correct
+ *
+ * TODO: Create doxygen
+ *
+ */
+ struct interrupt_frame
+ {
+ uint64_t ip; ///< Dummy
+ uint64_t cs; ///< Dummy
+ uint64_t flags; ///< Dummy
+ uint64_t sp; ///< Dummy
+ uint64_t ss; ///< Dummy
+ };
+
+ [[gnu::interrupt]]
+ auto generic_interrupt_handler(struct interrupt_frame * frame) -> void;
+
+} // namespace teachos::arch::interrupt_handling
+
+#endif // TEACHOS_ARCH_X86_64_INTERRUPT_HANDLING_GENERIC_INTERRUPT_HANDLER_HPP