Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 304 → Rev 305

/shark/trunk/oslib/ll/i386/pit.h
181,8 → 181,8
(t)->gigas += (t)->units / 1432809, \
(t)->units %= 1432809)
#define NULLPITSPEC(t) (t)->units = 0, (t)->gigas = 0
#define PITSPEC2USEC(t) ((((signed long long)((t)->units) * 1000000) / 1193182) \
+ (((signed long long)((t)->gigas) * 1000000) * 1193182))
#define PITSPEC2USEC(t) ((((t)->units * 1000) / 1197) \
+ (((t)->gigas * 1000) * 1197))
#define CPPITSPEC(a, b) (b)->units = (a)->units, (b)->gigas = (a)->gigas
END_DEF
 
#endif /* __PIT_H__ */
/shark/trunk/oslib/ll/i386/advtimer.h
31,6 → 31,8
#include <ll/i386/defs.h>
BEGIN_DEF
 
#include <ll/sys/ll/time.h>
 
/* TSC */
 
#define rdtsc(low,high) \
57,6 → 59,54
: "=A" (val) \
:: "ebx","ecx")
 
//Low level time read function
extern __inline__ void ll_read_timespec(struct timespec *tspec)
{
extern unsigned int clk_per_msec;
extern unsigned long long *ptr_init_nsec;
extern unsigned long long *ptr_init_tsc;
 
if (clk_per_msec == 0) {
NULL_TIMESPEC(tspec);
return;
}
__asm__("xorl %%eax,%%eax\n\t"
"cpuid\n\t"
"rdtsc\n\t"
"pushl %%eax\n\t"
"pushl %%edx\n\t"
"xorl %%eax,%%eax\n\t"
"cpuid\n\t"
"popl %%edx\n\t"
"popl %%eax\n\t"
"movl %4,%%ebx\n\t"
"subl (%%edi),%%eax\n\t"
"sbbl 4(%%edi),%%edx\n\t"
"movl %%edx,%%ecx\n\t"
"movl $1000000,%%edi\n\t"
"mull %%edi\n\t"
"pushl %%eax\n\t"
"movl %%ecx,%%eax\n\t"
"movl %%edx,%%ecx\n\t"
"mull %%edi\n\t"
"addl %%ecx,%%eax\n\t"
"adcl $0,%%edx\n\t"
"divl %%ebx\n\t"
"movl %%eax,%%ecx\n\t"
"popl %%eax\n\t"
"divl %%ebx\n\t"
"movl %%ecx,%%edx\n\t"
"addl (%%esi),%%eax\n\t"
"adcl 4(%%esi),%%edx\n\t"
"movl $1000000000,%%edi\n\t"
"divl %%edi\n\t"
: "=a" (tspec->tv_sec), "=d" (tspec->tv_nsec)
: "D" (ptr_init_tsc), "S" (ptr_init_nsec), "m" (clk_per_msec)
: "ebx", "ecx");
}
 
#define rdmsr(msr,val1,val2) \
__asm__ __volatile__("rdmsr" \
: "=a" (val1), "=d" (val2) \
/shark/trunk/oslib/ll/sys/ll/time.h
127,21 → 127,21
 
#if 0
#define PITSPEC2TIMESPEC(a,b) \
((b)->tv_nsec = (((signed long long)((a)->units) * 1000000) / 1193182) * 1000, \
(b)->tv_sec = ((signed long long)((a)->gigas) * 1193182) / 1000000) /*, \
(b)->tv_sec += (b)->tv_nsec / 1000000000, \
((b)->tv_nsec = (((DWORD)((a)->units) * 1000) / 1197) * 1000, \
(b)->tv_sec = ((a)->gigas * 1197) / 1000) /*, \
(b)->tv_sec += (b)->tv_nsec / 1000000000, \
(b)->tv_nsec %= 1000000000) */
#else
/*#define PITSPEC2TIMESPEC(a,b) \
((b)->tv_nsec = (((signed long long)((a)->units) * 1000000) / 1193182) * 1000, \
(b)->tv_nsec += (((signed long long)((a)->gigas) * 1193182) % 1000000) * 1000000, \
(b)->tv_sec = ((signed long long)((a)->gigas) * 1193182) / 1000000 , \
((b)->tv_nsec = (((DWORD)((a)->units) * 1000) / 1197) * 1000, \
(b)->tv_nsec += (((a)->gigas * 1197) % 1000) * 1000000, \
(b)->tv_sec = ((a)->gigas * 1197) / 1000 , \
(b)->tv_sec += (b)->tv_nsec / 1000000000, \
(b)->tv_nsec %= 1000000000)*/
#define PITSPEC2TIMESPEC(a,b) \
((b)->tv_nsec = (((signed long long)((a)->units) * 1000000) / 1193182), \
(b)->tv_nsec += (((signed long long)((a)->gigas) * 1193182) % 1000000) * 1000, \
(b)->tv_sec = ((signed long long)((a)->gigas) * 1193182) / 1000000 , \
((b)->tv_nsec = (((DWORD)((a)->units) * 1000) / 1197), \
(b)->tv_nsec += (((a)->gigas * 1197) % 1000) * 1000, \
(b)->tv_sec = ((a)->gigas * 1197) / 1000 , \
(b)->tv_sec += (b)->tv_nsec / 1000000, \
(b)->tv_nsec %= 1000000, \
(b)->tv_nsec *= 1000)
148,7 → 148,6
#endif
 
TIME ll_gettime(int mode, struct timespec *tsres);
void ll_read_timespec(struct timespec *tspec);
 
#define TIME_PTICK 1
#define TIME_EXACT 2