[Linux-hls-cvs] cbs/src/include generic-time.h,NONE,1.1 i386-muldiv.h,NONE,1.1 ppc-muldiv.h,NONE,1.1
Status: Pre-Alpha
Brought to you by:
lucabe
|
From: Luca A. <lu...@us...> - 2004-08-21 13:51:38
|
Update of /cvsroot/linux-hls/cbs/src/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5943/include Modified Files: cbs.h i386-time.h Added Files: generic-time.h i386-muldiv.h ppc-muldiv.h Log Message: - Update to the new gensched interface - New "generic" timing code, based on sys_gettimeofday Index: cbs.h =================================================================== RCS file: /cvsroot/linux-hls/cbs/src/include/cbs.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** cbs.h 21 Feb 2004 13:06:37 -0000 1.1.1.1 --- cbs.h 21 Aug 2004 13:51:27 -0000 1.2 *************** *** 91,95 **** void cbs_init(void); void cbs_deinit(void); ! int cbs_get_params(int pid, unsigned long int *qs, unsigned long int *ts); ! int cbs_set_params(int pid, unsigned long int qs, unsigned long int ts); #endif /* __CBS_H__ */ --- 91,95 ---- void cbs_init(void); void cbs_deinit(void); ! int cbs_get_params(struct task_struct *p, unsigned long int *qs, unsigned long int *ts); ! int cbs_set_params(struct task_struct *p, unsigned long int qs, unsigned long int ts); #endif /* __CBS_H__ */ --- NEW FILE: i386-muldiv.h --- #ifndef __MULDIV_H__ #define __MULDIV_H__ /* This function comes from RTAI (http://www.rtai.org) */ static inline long long llimd(long long ll, int mult, int div) { __asm__ __volatile (\ "movl %%edx,%%ecx; mull %%esi; movl %%eax,%%ebx; \n\t" "movl %%ecx,%%eax; movl %%edx,%%ecx; mull %%esi; \n\t" "addl %%ecx,%%eax; adcl $0,%%edx; divl %%edi; \n\t" "movl %%eax,%%ecx; movl %%ebx,%%eax; divl %%edi; \n\t" "sal $1,%%edx; cmpl %%edx,%%edi; movl %%ecx,%%edx; \n\t" "jge 1f; addl $1,%%eax; adcl $0,%%edx; 1:" : "=A" (ll) : "A" (ll), "S" (mult), "D" (div) : "%ebx", "%ecx"); return ll; } #endif /* __MULDIV_H__ */ --- NEW FILE: ppc-muldiv.h --- #ifndef __MULDIV_H__ #define __MULDIV_H__ /* This comes from RTAI... Please, adjust the license stuff!!! */ static inline unsigned long long ullmul(unsigned long m0, unsigned long m1) { unsigned long long res; __asm__ __volatile__ ("mulhwu %0, %1, %2" : "=r" (((unsigned long *)&res)[0]) : "%r" (m0), "r" (m1)); ((unsigned long *)&res)[1] = m0 * m1; return res; } static inline unsigned long long ulldiv(unsigned long long ull, unsigned long uld, unsigned long *r) { unsigned long long q, rf; unsigned long qh, rh, ql, qf; q = 0; rf = (unsigned long long)(0xFFFFFFFF - (qf = 0xFFFFFFFF / uld) * uld) + 1ULL; while (ull >= uld) { ((unsigned long *)&q)[0] += (qh = ((unsigned long *)&ull)[0] / uld); rh = ((unsigned long *)&ull)[0] - qh * uld; q += rh * (unsigned long long)qf + (ql = ((unsigned long *)&ull)[1] / uld); ull = rh * rf + (((unsigned long *)&ull)[1] - ql * uld); } *r = ull; return q; } // returns (long long)ll = (int)ll*(int)(mult)/(int)div. static inline unsigned long long llimd(unsigned long long ull, unsigned long mult, unsigned long div) { unsigned long long low; unsigned long q, r; low = ullmul(((unsigned long *)&ull)[1], mult); q = ulldiv(ullmul(((unsigned long *)&ull)[0], mult) + ((unsigned long *)&low)[0], div, (unsigned long *)&low); low = ulldiv(low, div, &r); ((unsigned long *)&low)[0] += q; return (r + r) > div ? low + 1 : low; } #endif /* __MULDIV_H__ */ --- NEW FILE: generic-time.h --- /* * Copyright (C) 2002 Luca Abeni * This is Free Software; see GPL.txt for details */ #ifndef __TIME_H__ #include <linux/module.h> #ifndef CONFIG_GENERIC_SCHEDULER #error The Generic Scheduler is not enabled!!! #endif #include <asm/time.h> static inline unsigned long long int sched_read_clock(void) { unsigned long long int ts; struct timeval tv; do_gettimeofday(&tv); ts = (unsigned long long int)tv.tv_usec + (unsigned long long int)tv.tv_sec * 1000000LLU; return ts; } /* static inline unsigned long long int llimd(unsigned long long ull, unsigned long mult, unsigned long div); */ /* fast_gettimeoffset_quotient = 2^32 * (1 / (TSC clocks per usec)) */ static inline unsigned long long int us2clock(unsigned long u) { return u; } static inline unsigned long int clock2ms(unsigned long long int c) { unsigned long int ms; ms = llimd(c, 1, 1000); return ms; } static inline unsigned long int clock2us(unsigned long long c) { return c; } static inline unsigned long int clock2jiffies(unsigned long long c) { return llimd(c, HZ, 1000000); } #endif /* __TIME_H__ */ Index: i386-time.h =================================================================== RCS file: /cvsroot/linux-hls/cbs/src/include/i386-time.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** i386-time.h 21 Feb 2004 13:06:37 -0000 1.1.1.1 --- i386-time.h 21 Aug 2004 13:51:27 -0000 1.2 *************** *** 22,26 **** } ! static inline long long llimd(long long ll, int mult, int div); /* fast_gettimeoffset_quotient = 2^32 * (1 / (TSC clocks per usec)) */ --- 22,26 ---- } ! /* static inline long long llimd(long long ll, int mult, int div); */ /* fast_gettimeoffset_quotient = 2^32 * (1 / (TSC clocks per usec)) */ *************** *** 59,77 **** return c - llimd(tmp2, cpu_khz, 1000); } - /* This function comes from RTAI (http://www.rtai.org) */ - static inline long long llimd(long long ll, int mult, int div) - { - __asm__ __volatile (\ - "movl %%edx,%%ecx; mull %%esi; movl %%eax,%%ebx; \n\t" - "movl %%ecx,%%eax; movl %%edx,%%ecx; mull %%esi; \n\t" - "addl %%ecx,%%eax; adcl $0,%%edx; divl %%edi; \n\t" - "movl %%eax,%%ecx; movl %%ebx,%%eax; divl %%edi; \n\t" - "sal $1,%%edx; cmpl %%edx,%%edi; movl %%ecx,%%edx; \n\t" - "jge 1f; addl $1,%%eax; adcl $0,%%edx; 1:" - : "=A" (ll) - : "A" (ll), "S" (mult), "D" (div) - : "%ebx", "%ecx"); - return ll; - } - #endif /* __TIME_H__ */ --- 59,61 ---- |