[SOLVED] A question about APIC Timer
Posted: Thu Jul 25, 2013 8:22 am
I am a high school student from China who loves programming and developing. Now I am trying to develop a OS by my own. The first several steps are very easy, I successfully entered protected mode, loaded GDT, IDT and TSS, enabled paging, and initialized 8259A and PIT timer to support multi-tasks.
I want something challenge, so I started to include the support of APIC. I just read through the APIC Timer part in the Intel Manual briefly and wrote some codes. The timer did not run as I expected.
/* Initialize */
apic_write(APIC_SVR, 0x130);// 0x30 vector's handler does nothing: Only a iretd, apic_write is as same as that of Linux.
apic_write(APIC_TIMER_DCR, 0x0);// DCR=Divide Configuration Register
apic_write(APIC_TIMER_ICR, 242880);// ICR=Initial Count Register
apic_write(APIC_LVT_TIMER, 0x20020);// 0x20 is the timer interrupt handler
/* End */
In the timer interrupt handler, I just save all registers, "apic_write(APIC_EOI_REG,0);" and schedule the tasks. I expected the timer to run periodically, but it only runs once. However, when I add "apic_write(APIC_TIMER_ICR, 242880);" into my timer handler, the timer can run normally. I got really confused by this problem. Where is wrong? I think I did not miss any essential steps.
I want something challenge, so I started to include the support of APIC. I just read through the APIC Timer part in the Intel Manual briefly and wrote some codes. The timer did not run as I expected.
/* Initialize */
apic_write(APIC_SVR, 0x130);// 0x30 vector's handler does nothing: Only a iretd, apic_write is as same as that of Linux.
apic_write(APIC_TIMER_DCR, 0x0);// DCR=Divide Configuration Register
apic_write(APIC_TIMER_ICR, 242880);// ICR=Initial Count Register
apic_write(APIC_LVT_TIMER, 0x20020);// 0x20 is the timer interrupt handler
/* End */
In the timer interrupt handler, I just save all registers, "apic_write(APIC_EOI_REG,0);" and schedule the tasks. I expected the timer to run periodically, but it only runs once. However, when I add "apic_write(APIC_TIMER_ICR, 242880);" into my timer handler, the timer can run normally. I got really confused by this problem. Where is wrong? I think I did not miss any essential steps.