Symmetric I/O Mode

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
IanSeyler
Member
Member
Posts: 326
Joined: Mon Jul 28, 2008 9:46 am
Location: Ontario, Canada
Contact:

Symmetric I/O Mode

Post by IanSeyler »

Currently I am still using the PIC but the PIC only delivers interrupts to the BSP. I would like to ditch the PIC and go with the IO APIC instead since it can send interrupts to any available CPU Core in the system.

I have taken a look at the Intel manuals, OSDev articles, and some of the posts here but can't find a good step-by-step guide.

So far I have this:

Code: Select all

; Enable the system for Symmetric I/O Mode as per MPS 1.4
	mov al, 0x70			; Select the IMCR register
	out 0x22, al
	mov al, 0x01			; Instruct NMIs and 8259 INTs to go through APIC
	out 0x23, al
Not much there yet as I still need to figure out what to do with LINT0 and LINT1. Do I need to completely mask the PIC after this? Does the above code need to be run on each CPU Core (I would think not)? Does anyone have experience getting your own OS out of PIC Mode and into Symmetric I/O Mode?
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly
User avatar
IanSeyler
Member
Member
Posts: 326
Joined: Mon Jul 28, 2008 9:46 am
Location: Ontario, Canada
Contact:

Re: Symmetric I/O Mode

Post by IanSeyler »

I did a bit more poking around an got the timer working at the very least:

Code: Select all

	xor eax, eax
	mov rdi, [os_LocalAPICAddress]
	add rdi, 0x03E0
	stosd				; Timer: Divisor Config

	mov eax, 10000			; countdown from 10000?
	mov rdi, [os_LocalAPICAddress]
	add rdi, 0x0380
	stosd				; Timer: Initial Count

	mov eax, 0x20			; Timer: interrupt-ID
	bts eax, 17			; do periodic interrupt 
	mov rdi, [os_LocalAPICAddress]
	add rdi, 0x0320	
	stosd				; set APIC Timer's LVT
which properly triggers the int 0x20 code:

Code: Select all

apic_test:
	push rdi
	push rax

	call timer_debug	; Display a counter onscreen

	mov rdi, [os_LocalAPICAddress]
	add rdi, 0xb0
	xor eax, eax
	stosd

	pop rax
	pop rdi
	iretq
This is just APIC stuff though and I'm not that interested in the Timer. What I want to get working over the IO-APIC is the Keyboard and RTC.
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Symmetric I/O Mode

Post by Gigasoft »

Haven't got much experience with the IO APIC, but I guess you have to set the redirection table entries. In an ACPI system, ISA IRQ numbers correspond directly to GSI numbers, while in non-ACPI systems, you have to parse the MP table, as I understand it.

This stosd thing you have in your code seems awkward, by the way, when you could just do this:

Code: Select all

mov rdi, [os_LocalAPICAddress]
and dword ptr [rdi+0x3e0],0
mov dword ptr [rdi+0x380],10000
mov dword ptr [rdi+0x320],0x20020
Post Reply