changeset 441f446c76f6 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=441f446c76f6
description:
X86: Fix the time keeping of the Local APIC timer.
diffstat:
1 file changed, 19 insertions(+), 12 deletions(-)
src/arch/x86/interrupts.cc | 31 +++++++++++++++++++------------
diffs (53 lines):
diff -r 02e0e93d1ba7 -r 441f446c76f6 src/arch/x86/interrupts.cc
--- a/src/arch/x86/interrupts.cc Sun Feb 01 00:29:07 2009 -0800
+++ b/src/arch/x86/interrupts.cc Sun Feb 01 00:30:11 2009 -0800
@@ -344,10 +344,19 @@
break;
case APIC_CURRENT_COUNT:
{
- assert(clock);
- uint32_t val = regs[reg] - curTick / clock;
- val /= (16 * divideFromConf(regs[APIC_DIVIDE_CONFIGURATION]));
- return val;
+ if (apicTimerEvent.scheduled()) {
+ assert(clock);
+ // Compute how many m5 ticks happen per count.
+ uint64_t ticksPerCount = clock *
+ divideFromConf(regs[APIC_DIVIDE_CONFIGURATION]);
+ // Compute how many m5 ticks are left.
+ uint64_t val = apicTimerEvent.when() - curTick;
+ // Turn that into a count.
+ val = (val + ticksPerCount - 1) / ticksPerCount;
+ return val;
+ } else {
+ return 0;
+ }
}
default:
break;
@@ -441,19 +450,17 @@
{
assert(clock);
newVal = bits(val, 31, 0);
- uint32_t newCount = newVal *
- (divideFromConf(regs[APIC_DIVIDE_CONFIGURATION]) * 16);
- regs[APIC_CURRENT_COUNT] = newCount + curTick / clock;
- // Find out how long a "tick" of the timer should take.
- Tick timerTick = 16 * clock;
+ // Compute how many timer ticks we're being programmed for.
+ uint64_t newCount = newVal *
+ (divideFromConf(regs[APIC_DIVIDE_CONFIGURATION]));
// Schedule on the edge of the next tick plus the new count.
- Tick offset = curTick % timerTick;
+ Tick offset = curTick % clock;
if (offset) {
reschedule(apicTimerEvent,
- curTick + (newCount + 1) * timerTick - offset, true);
+ curTick + (newCount + 1) * clock - offset, true);
} else {
reschedule(apicTimerEvent,
- curTick + newCount * timerTick, true);
+ curTick + newCount * clock, true);
}
}
break;
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev