forked from CHatingPython/towos
feat: add TSS
This commit is contained in:
+2
-2
@@ -6,12 +6,12 @@
|
||||
struct gdt_entry {
|
||||
u64 value;
|
||||
|
||||
constexpr gdt_entry(u32 base, u32 limit, u8 access, u8 flags)
|
||||
constexpr gdt_entry(u32 base, u32 limit, u8 access, u8 flags) noexcept
|
||||
: value((static_cast<u64>(limit & 0xFFFF) << 0) | (static_cast<u64>(base & 0xFFFFFF) << 16) |
|
||||
(static_cast<u64>(access & 0xFF) << 40) | (static_cast<u64>(limit & 0x0F) << 48) |
|
||||
(static_cast<u64>(flags & 0x0F) << 52) | (static_cast<u64>((base >> 24) & 0xFF) << 56)) {}
|
||||
|
||||
constexpr gdt_entry(u64 value)
|
||||
constexpr gdt_entry(u64 value) noexcept
|
||||
: value(value) {}
|
||||
|
||||
static gdt_entry extend(u32 baseHi) { return { baseHi }; }
|
||||
|
||||
+9
-3
@@ -1,4 +1,5 @@
|
||||
#include "gdt.hpp"
|
||||
#include "task.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
static volatile u16* const s_vga = reinterpret_cast<volatile u16*>(0xB8000);
|
||||
@@ -16,7 +17,9 @@ static inline void puts(const char* str, u8 row, u8 col) {
|
||||
s_vga[col + off + (VGA_COLS * row)] = 0x0700 | str[off];
|
||||
}
|
||||
|
||||
static constexpr gdt_entry s_gdt[5] = {
|
||||
static constexpr tss s_tss{};
|
||||
|
||||
static gdt_entry s_gdt[] = {
|
||||
// Null Descriptor
|
||||
gdt_entry{ 0, 0, 0, 0 },
|
||||
// Kernel Mode Code Segment
|
||||
@@ -40,8 +43,11 @@ static constexpr gdt_entry s_gdt[5] = {
|
||||
gdt_entry::ACCESS_P | gdt_entry::ACCESS_DPL3 | gdt_entry::ACCESS_S | gdt_entry::ACCESS_E | gdt_entry::ACCESS_RW,
|
||||
gdt_entry::FLAG_G | gdt_entry::FLAG_L },
|
||||
// Task State Segment
|
||||
// gdt_entry{ 0, 0, gdt_entry::ACCESS_P | gdt_entry::ACCESS_E | gdt_entry::ACCESS_A, 0 },
|
||||
// gdt_entry{ 0 }
|
||||
gdt_entry{ static_cast<u32>(reinterpret_cast<u64>(&s_tss) & 0xFFFFFFFF),
|
||||
sizeof(s_tss) - 1,
|
||||
gdt_entry::ACCESS_P | gdt_entry::ACCESS_E | gdt_entry::ACCESS_A,
|
||||
0 },
|
||||
gdt_entry{ static_cast<u32>(reinterpret_cast<u64>(&s_tss) >> 32) }
|
||||
};
|
||||
|
||||
extern "C" void kmain(void) {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef TSS_HPP
|
||||
#define TSS_HPP
|
||||
|
||||
#include "types.hpp"
|
||||
|
||||
struct tss {
|
||||
u32 rsv0;
|
||||
u64 rsp0;
|
||||
u64 rsp1;
|
||||
u64 rsp2;
|
||||
u64 rsv1;
|
||||
u64 ist1;
|
||||
u64 ist2;
|
||||
u64 ist3;
|
||||
u64 ist4;
|
||||
u64 ist5;
|
||||
u64 ist6;
|
||||
u64 ist7;
|
||||
u64 rsv2;
|
||||
u16 rsv3;
|
||||
u16 iopb;
|
||||
} PACKED;
|
||||
|
||||
#endif // TSS_HPP
|
||||
Reference in New Issue
Block a user