Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace system {
- namespace interrupts {
- enum type {
- User = 0x60,
- Gate = 0x8E,
- Trap = 0xEF,
- };
- struct [[gnu::packed]] idt_entry {
- std::uint16_t offset_low;
- std::uint16_t code_segment;
- std::uint8_t ist;
- std::uint8_t attributes;
- std::uint16_t offset_mid;
- std::uint32_t offset_high;
- std::uint32_t zero;
- idt_entry() = default;
- idt_entry(std::uintptr_t handler, uint8_t ist, uint8_t attributes)
- : offset_low(handler),
- code_segment(0x8),
- ist(ist),
- attributes(attributes),
- offset_mid(handler >> 16),
- offset_high(handler >> 32),
- zero(0) {}
- };
- struct [[gnu::packed, gnu::aligned(0x10)]] idt {
- enum { Length = 256 };
- // standard stl array
- std::array<idt_entry, Length> entries{};
- };
- 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() { load_idt(this); }
- };
- void init();
- } // namespace interrupts
- } // namespace system
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement