IO APIC and GPF exception
Posted: Tue Mar 12, 2019 8:32 am
Hey!
I configured LAPIC, IO APIC, IDT, RTC and Keyboard.
Up to now everything seems to working great but... only when there is only one I/O Redirection Table entry
IO APIC configuration (nasm style):
LAPIC configuration (nasm style):
If both entrys are enabled in IO APIC, it is possible to catch General Protection Fault exception :/ and I don't know where to look at
I configured LAPIC, IO APIC, IDT, RTC and Keyboard.
Up to now everything seems to working great but... only when there is only one I/O Redirection Table entry
IO APIC configuration (nasm style):
Code: Select all
mov rdi, qword [kernel_ioapic_base_address]
; keyboard
mov dword [edi + 0x0000], 0x12 ; IRQ1 low
mov dword [edi + 0x0010], 0x20 + 0x01 ; IDT descriptor/vector 33
mov dword [edi + 0x0000], 0x13 ; IRQ1 high
mov dword [edi + 0x0010], 0x00
; rtc
mov dword [edi + 0x0000], 0x20 ; IRQ8 low
mov dword [edi + 0x0010], 0x20 + 0x08 ; IDT descriptor/vector 40
mov dword [edi + 0x0000], 0x21 ; IRQ8 high
mov dword [edi + 0x0010], 0x00
; PIC interrupts are masked
; all above has the same configuration
; delivery mode (fixed)
; destination mode (physical destination)
; delivery status (relaxed)
; pin polarity (active high)
; trigger mode (edge)
; mask (interrupt enabled)
; destination (apic id 0, so only BSP core will receive this interrupts at now)
Code: Select all
mov rsi, qword [kernel_lapic_table_address]
; task priority
mov dword [rsi + 0x0080], 0x00000000
; flat mode
mov dword [rsi + 0x00E0], 0xFFFFFFFF
; target cpu
mov dword [rsi + 0x00D0], 0x01000000
; enable lapic, spurious vector
mov eax, dword [rsi + 0x00F0]
or eax, 100000000b | 011111111b
mov dword [rsi + 0x00F0], eax
; unmask interrupts
mov eax, dword [rsi + 0x0320]
and eax, ~0x00010000
mov dword [rsi + 0x0320], eax