Skip to content

Commit

Permalink
Merge pull request #2 from gierens/descriptor-typo
Browse files Browse the repository at this point in the history
fix(ymir/arch/x86/idt): correct GateDescriptor typo
  • Loading branch information
smallkirby authored Dec 30, 2024
2 parents 334c4a7 + 88873fe commit 6869abf
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ymir/arch/x86/idt.zig
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const gdt = @import("gdt.zig");
/// Maximum number of gates in the IDT.
pub const max_num_gates = 256;
/// Interrupt Descriptor Table.
var idt: [max_num_gates]GateDesriptor align(4096) = [_]GateDesriptor{std.mem.zeroes(GateDesriptor)} ** max_num_gates;
var idt: [max_num_gates]GateDescriptor align(4096) = [_]GateDescriptor{std.mem.zeroes(GateDescriptor)} ** max_num_gates;
/// IDT Register.
var idtr = IdtRegister{
.limit = @sizeOf(@TypeOf(idt)) - 1,
Expand All @@ -69,7 +69,7 @@ pub fn setGate(
gate_type: GateType,
offset: Isr,
) void {
idt[index] = GateDesriptor{
idt[index] = GateDescriptor{
.offset_low = @truncate(@intFromPtr(&offset)),
.seg_selector = gdt.kernel_cs_index << 3,
.gate_type = gate_type,
Expand All @@ -80,7 +80,7 @@ pub fn setGate(
}

/// Entry in the Interrupt Descriptor Table.
pub const GateDesriptor = packed struct(u128) {
pub const GateDescriptor = packed struct(u128) {
/// Lower 16 bits of the offset to the ISR.
offset_low: u16,
/// Segment Selector that must point to a valid code segment in the GDT.
Expand All @@ -105,14 +105,14 @@ pub const GateDesriptor = packed struct(u128) {
/// Reserved.
_reserved3: u32 = 0,

pub fn offset(self: GateDesriptor) u64 {
pub fn offset(self: GateDescriptor) u64 {
return @as(u64, self.offset_high) << 32 | @as(u64, self.offset_middle) << 16 | @as(u64, self.offset_low);
}
};

const IdtRegister = packed struct {
limit: u16,
base: *[max_num_gates]GateDesriptor,
base: *[max_num_gates]GateDescriptor,
};

/// Gate type of the gate descriptor in IDT.
Expand All @@ -128,7 +128,7 @@ pub const GateType = enum(u4) {
const testing = std.testing;

test "gate descriptor" {
const gate = GateDesriptor{
const gate = GateDescriptor{
.offset_low = 0x1234,
.seg_selector = 0x5678,
.gate_type = .Interrupt64,
Expand Down

0 comments on commit 6869abf

Please sign in to comment.