I have been stuck for too long in this problem
I follow the instructions form
http://forum.osdev.org/posting.php?mode=post&f=1
and set my apic timer,and corrected some place by posting my previous question at
http://forum.osdev.org/viewtopic.php?f= ... =APIC+init
but it still does not work.
the timer has got a decreasing in CCR,and i checked the IF ,surely 1,
but noting happend,never.
i do this in bochs and the CPU emulated is Pentium 4.(i did in vmware too,but noting different).
it is in 64bit mode.so i am doubting if there are some difference in 64bit mode,such TPR,which i set to be always 0, or i got some mistake in initializing.
my code:
Code: Select all
extern i64 APIC_init(){
sys_call(0ULL,_SYSCALL_LEVEL0,init_apic);
sys_call(1ULL,_SYSCALL_SET_INT,INT_VECTOR_IRQ0,_int_handler_timer,SYS_INT_HANDLER_TYPE_INT64,0ULL,0ULL);
sys_call(0ULL,_SYSCALL_LEVEL0,set_apic_timer,0x8000,0xB0,0x00020000|INT_VECTOR_IRQ0);
return 0;
}
bits 64
align 16
init_apic:
pushf
cli
push rcx
push rsi
mov rcx,1Bh
rdmsr
and rax,0xfffffffffffff000
mov rsi,rax
mov eax,0x000001FF ;0x000001FF -> 0xFFE000F0 - enable local APIC and set spurious int vector to 0xFF
mov [rsi+0xF0],eax
mov eax,0xFFFFFFFF ;0xFFFFFFFF -> 0xFEE000E0 - set destination format register to flat model
mov [rsi+0xE0],eax
mov eax,0x00000000 ;0x00000000 -> 0xFEE00080 - set the task priority register to accept all interrupts
mov [rsi+0x80],eax
xor rax,rax
pop rsi
pop rcx
popf
ret
align 16
set_apic_timer: ;init_apic_timer(CR,DCR,LVT)
;0x0000000B -> 0xFEE003E0 - set timer to divide by 1
;0x00020040 -> 0xFEE00320 - enable timer, set periodic mode, set int vector to 0x40
;0x00000064 -> 0xFEE00380 - set initial count to 100 (and make the timer start counting)
pushf
cli
push rcx
push rsi
mov rcx,1Bh
rdmsr
and rax,0xfffffffffffff000
mov rsi,rax
pop rax ;DCR
mov [rsi+0x3E0],eax
mov [rsi+0x320],edx ;LVT
mov [rsi+0x380],edi ;CR
xor rax,rax
pop rcx
popf
ret
align 16
_int_handler_timer:
push rcx
push rsi
push rax
push rdi
mov rcx,1Bh
rdmsr
and rax,0xfffffffffffff000
mov rsi,rax
;EOI
xor rax,rax
mov [rsi+0xB0],eax
;do something
mov rcx,80*200
mov rdi,0xb8000
mov rax,0x7244
rep
stosw
pop rdi
pop rax
pop rsi
pop rcx
iretq
help!
thx