Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum class type {
- User = 0x60,
- Gate = 0x8E,
- Trap = 0xEF,
- };
- struct [[gnu::packed]] idt_entry {
- std::uint16_t offset_low = 0;
- std::uint16_t code_segment = 0;
- std::uint8_t ist = 0;
- std::uint8_t attributes = 0;
- std::uint16_t offset_mid = 0;
- std::uint32_t offset_high = 0;
- std::uint32_t zero = 0;
- idt_entry() = default;
- idt_entry(std::uintptr_t handler, uint8_t ist, type attributes)
- : offset_low(static_cast<uint16_t>(handler)),
- code_segment(gdt::Kernel_Code * 8),
- ist(ist),
- attributes(static_cast<uint8_t>(attributes)),
- offset_mid(static_cast<uint16_t>(handler >> 16)),
- offset_high(static_cast<uint32_t>(handler >> 32)),
- zero(0) {}
- };
- struct [[gnu::packed, gnu::aligned(0x10)]] idt {
- enum { Length = 256 };
- // standard STl array
- std::array<idt_entry, Length> entries{};
- idt() {}
- };
- struct [[gnu::packed]] idt_descriptor {
- std::uint16_t limit;
- std::uint64_t base;
- idt_descriptor(std::uint16_t limit, std::uint64_t base)
- : limit(limit), base(base) {}
- idt_descriptor(idt& _idt)
- : limit(sizeof(idt) - 1),
- base(reinterpret_cast<std::uint64_t>(&_idt)) {}
- void load() { asm volatile("lidt %0" ::"memory"(*this)); }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement