Chameleon

Chameleon Commit Details

Date:2015-03-13 18:08:21 (5 years 8 months ago)
Author:zenith432
Commit:2632
Parents: 2631
Message:Protect timing code in scan_cpu() from interrupts, use bios for sleep()
Changes:
M/branches/zenith432/i386/libsaio/cpu.c
M/branches/zenith432/i386/libsaio/biosfn.c

File differences

branches/zenith432/i386/libsaio/cpu.c
261261
262262
263263
264
264265
265266
266267
......
512513
513514
514515
516
517
518
515519
516520
517521
......
806810
807811
808812
813
814
809815
810816
811817
uint8_tcurrcoef= 0;
uint8_tmaxdiv= 0;
uint8_tmaxcoef= 0;
uint8_tpic0_mask;
const char*newratio;
charstr[128];
p->CPU.Features |= CPU_FEATURE_HTT;
}
pic0_mask = inb(0x21U);
outb(0x21U, 0xFFU); // mask PIC0 interrupts for duration of timing tests
tscFrequency = measure_tsc_frequency();
DBG("cpu freq classic = 0x%016llx\n", tscFrequency);
// if usual method failed
#endif
outb(0x21U, pic0_mask); // restore PIC0 interrupts
p->CPU.MaxCoef = maxcoef;
p->CPU.MaxDiv = maxdiv;
p->CPU.CurrCoef = currcoef;
branches/zenith432/i386/libsaio/biosfn.c
10181018
10191019
10201020
1021
1022
1023
1024
1021
10251022
1026
1023
1024
10271025
1028
1029
1030
1026
1027
1028
1029
10311030
10321031
10331032
void sleep(int n)
{
// FIXME: doesn't handle midnight wraparound
unsigned int endtime = (time18() + 18*n);
#ifdef __i386__
while (time18() < endtime)
while (n >= 2048)
{
__asm__ volatile ("rep; nop");
delay(2048000000);
n -= 2048;
}
#else
while (time18() < endtime);
#endif
if (n > 0)
{
delay(n * 1000000);
}
}

Archive Download the corresponding diff file

Revision: 2632