Skip to content

Commit

Permalink
x86_64: log timer frequency when setting up local APIC
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Sep 11, 2024
1 parent 81865d2 commit 3294a0b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/platform/x86_64/apic/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ int apicTimerInit() {

KDEBUG("local APIC frequency is %d MHz\n", apicFrequency / 1000 / 1000);

// ensure the hardware can go at least twice as fast as the software
if(apicFrequency < (PLATFORM_TIMER_FREQUENCY*2)) {
KERROR("local APIC frequency is not high enough to use as main timing source\n");
for(;;) platformHalt();
}

KDEBUG("setting up system timer at %d kHz\n", PLATFORM_TIMER_FREQUENCY / 1000);

// set up the local APIC timer in periodic mode and allocate interrupt 0xFE for it
lapicWrite(LAPIC_LVT_TIMER, LAPIC_TIMER_PERIODIC | LAPIC_LVT_MASK | LAPIC_TIMER_IRQ);
lapicWrite(LAPIC_TIMER_DIVIDE, LAPIC_TIMER_DIVIDER_1);
Expand Down

0 comments on commit 3294a0b

Please sign in to comment.