Changeset 844

Show
Ignore:
Timestamp:
10/01/07 17:49:21 (14 months ago)
Author:
michael
Message:

RDTSC delay and inclusion of asm/msr.h removed

Location:
trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/config.h.in

    r843 r844  
    1212/* Define to 1 if you have the <asm/io.h> header file. */ 
    1313#undef HAVE_ASM_IO_H 
    14  
    15 /* Define to 1 if you have the <asm/msr.h> header file. */ 
    16 #undef HAVE_ASM_MSR_H 
    1714 
    1815/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. 
  • trunk/configure

    r843 r844  
    79917991   else 
    79927992      GRAPHIC="yes" 
     7993      KEYPAD="yes" 
    79937994      DRIVERS="$DRIVERS drv_X11.o" 
    79947995      if test "x$ac_x_libraries" = "x"; then 
     
    1140811409 
    1140911410 
    11410 for ac_header in asm/msr.h 
    11411 do 
    11412 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` 
    11413 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then 
    11414   { echo "$as_me:$LINENO: checking for $ac_header" >&5 
    11415 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } 
    11416 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then 
    11417   echo $ECHO_N "(cached) $ECHO_C" >&6 
    11418 fi 
    11419 ac_res=`eval echo '${'$as_ac_Header'}'` 
    11420          { echo "$as_me:$LINENO: result: $ac_res" >&5 
    11421 echo "${ECHO_T}$ac_res" >&6; } 
    11422 else 
    11423   # Is the header compilable? 
    11424 { echo "$as_me:$LINENO: checking $ac_header usability" >&5 
    11425 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } 
    11426 cat >conftest.$ac_ext <<_ACEOF 
    11427 /* confdefs.h.  */ 
    11428 _ACEOF 
    11429 cat confdefs.h >>conftest.$ac_ext 
    11430 cat >>conftest.$ac_ext <<_ACEOF 
    11431 /* end confdefs.h.  */ 
    11432 $ac_includes_default 
    11433 #include <$ac_header> 
    11434 _ACEOF 
    11435 rm -f conftest.$ac_objext 
    11436 if { (ac_try="$ac_compile" 
    11437 case "(($ac_try" in 
    11438   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 
    11439   *) ac_try_echo=$ac_try;; 
    11440 esac 
    11441 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 
    11442   (eval "$ac_compile") 2>conftest.er1 
    11443   ac_status=$? 
    11444   grep -v '^ *+' conftest.er1 >conftest.err 
    11445   rm -f conftest.er1 
    11446   cat conftest.err >&5 
    11447   echo "$as_me:$LINENO: \$? = $ac_status" >&5 
    11448   (exit $ac_status); } && { 
    11449    test -z "$ac_c_werror_flag" || 
    11450    test ! -s conftest.err 
    11451        } && test -s conftest.$ac_objext; then 
    11452   ac_header_compiler=yes 
    11453 else 
    11454   echo "$as_me: failed program was:" >&5 
    11455 sed 's/^/| /' conftest.$ac_ext >&5 
    11456  
    11457   ac_header_compiler=no 
    11458 fi 
    11459  
    11460 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 
    11461 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 
    11462 echo "${ECHO_T}$ac_header_compiler" >&6; } 
    11463  
    11464 # Is the header present? 
    11465 { echo "$as_me:$LINENO: checking $ac_header presence" >&5 
    11466 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } 
    11467 cat >conftest.$ac_ext <<_ACEOF 
    11468 /* confdefs.h.  */ 
    11469 _ACEOF 
    11470 cat confdefs.h >>conftest.$ac_ext 
    11471 cat >>conftest.$ac_ext <<_ACEOF 
    11472 /* end confdefs.h.  */ 
    11473 #include <$ac_header> 
    11474 _ACEOF 
    11475 if { (ac_try="$ac_cpp conftest.$ac_ext" 
    11476 case "(($ac_try" in 
    11477   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 
    11478   *) ac_try_echo=$ac_try;; 
    11479 esac 
    11480 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 
    11481   (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 
    11482   ac_status=$? 
    11483   grep -v '^ *+' conftest.er1 >conftest.err 
    11484   rm -f conftest.er1 
    11485   cat conftest.err >&5 
    11486   echo "$as_me:$LINENO: \$? = $ac_status" >&5 
    11487   (exit $ac_status); } >/dev/null && { 
    11488    test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || 
    11489    test ! -s conftest.err 
    11490        }; then 
    11491   ac_header_preproc=yes 
    11492 else 
    11493   echo "$as_me: failed program was:" >&5 
    11494 sed 's/^/| /' conftest.$ac_ext >&5 
    11495  
    11496   ac_header_preproc=no 
    11497 fi 
    11498  
    11499 rm -f conftest.err conftest.$ac_ext 
    11500 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 
    11501 echo "${ECHO_T}$ac_header_preproc" >&6; } 
    11502  
    11503 # So?  What about this header? 
    11504 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in 
    11505   yes:no: ) 
    11506     { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 
    11507 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} 
    11508     { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 
    11509 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} 
    11510     ac_header_preproc=yes 
    11511     ;; 
    11512   no:yes:* ) 
    11513     { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 
    11514 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} 
    11515     { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5 
    11516 echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;} 
    11517     { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 
    11518 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} 
    11519     { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5 
    11520 echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;} 
    11521     { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 
    11522 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} 
    11523     { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 
    11524 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} 
    11525     ( cat <<\_ASBOX 
    11526 ## ---------------------------------------------------- ## 
    11527 ## Report this to lcd4linux-users@lists.sourceforge.net ## 
    11528 ## ---------------------------------------------------- ## 
    11529 _ASBOX 
    11530      ) | sed "s/^/$as_me: WARNING:     /" >&2 
    11531     ;; 
    11532 esac 
    11533 { echo "$as_me:$LINENO: checking for $ac_header" >&5 
    11534 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } 
    11535 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then 
    11536   echo $ECHO_N "(cached) $ECHO_C" >&6 
    11537 else 
    11538   eval "$as_ac_Header=\$ac_header_preproc" 
    11539 fi 
    11540 ac_res=`eval echo '${'$as_ac_Header'}'` 
    11541          { echo "$as_me:$LINENO: result: $ac_res" >&5 
    11542 echo "${ECHO_T}$ac_res" >&6; } 
    11543  
    11544 fi 
    11545 if test `eval echo '${'$as_ac_Header'}'` = yes; then 
    11546   cat >>confdefs.h <<_ACEOF 
    11547 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 
    11548 _ACEOF 
    11549  
    11550 fi 
    11551  
    11552 done 
    11553  
    11554  
    1155511411# Checks for typedefs, structures, and compiler characteristics. 
    1155611412{ echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 
  • trunk/configure.in

    r840 r844  
    103103AC_CHECK_HEADERS(asm/io.h) 
    104104AC_CHECK_HEADERS(linux/parport.h linux/ppdev.h) 
    105 AC_CHECK_HEADERS(asm/msr.h) 
    106105 
    107106# Checks for typedefs, structures, and compiler characteristics. 
  • trunk/drivers.m4

    r843 r844  
    532532   else 
    533533      GRAPHIC="yes" 
     534      KEYPAD="yes" 
    534535      DRIVERS="$DRIVERS drv_X11.o" 
    535536      if test "x$ac_x_libraries" = "x"; then 
  • trunk/udelay.c

    r840 r844  
    5656#include <sys/time.h> 
    5757 
    58 #ifdef HAVE_ASM_MSR_H 
    59 typedef u_int32_t u32; 
    60 typedef u_int64_t u64; 
    61 #define __KERNEL__ 
    62 #include <asm/msr.h> 
    63 #undef __KERNEL__ 
    64 #endif 
    65  
    6658 
    6759#include "debug.h" 
     
    7163 
    7264 
    73 static unsigned int ticks_per_usec = 0; 
    74  
    75  
    76 static void getCPUinfo(int *hasTSC, double *MHz) 
    77 { 
    78     int fd; 
    79     char buffer[4096], *p; 
    80  
    81     *hasTSC = 0; 
    82     *MHz = -1; 
    83  
    84     fd = open("/proc/cpuinfo", O_RDONLY); 
    85     if (fd == -1) { 
    86   error("udelay: open(/proc/cpuinfo) failed: %s", strerror(errno)); 
    87   return; 
    88     } 
    89     if (read(fd, &buffer, sizeof(buffer) - 1) == -1) { 
    90   error("udelay: read(/proc/cpuinfo) failed: %s", strerror(errno)); 
    91   close(fd); 
    92   return; 
    93     } 
    94     close(fd); 
    95  
    96     p = strstr(buffer, "flags"); 
    97     if (p == NULL) { 
    98   info("udelay: /proc/cpuinfo has no 'flags' line"); 
    99     } else { 
    100   p = strstr(p, "tsc"); 
    101   if (p == NULL) { 
    102       info("udelay: CPU does not support Time Stamp Counter"); 
    103   } else { 
    104       info("udelay: CPU supports Time Stamp Counter"); 
    105       *hasTSC = 1; 
    106   } 
    107     } 
    108  
    109     p = strstr(buffer, "cpu MHz"); 
    110     if (p == NULL) { 
    111   info("udelay: /proc/cpuinfo has no 'cpu MHz' line"); 
    112     } else { 
    113   if (sscanf(p + 7, " : %lf", MHz) != 1) { 
    114       error("udelay: parse(/proc/cpuinfo) failed: unknown 'cpu MHz' format"); 
    115       *MHz = -1; 
    116   } else { 
    117       info("udelay: CPU runs at %f MHz", *MHz); 
    118   } 
    119     } 
    120  
    121 } 
    122  
    12365 
    12466void udelay_init(void) 
    12567{ 
    126 #ifdef HAVE_ASM_MSR_H 
    127  
    128     int tsc; 
    129     double mhz; 
    130  
    131     getCPUinfo(&tsc, &mhz); 
    132  
    133     if (tsc && mhz > 0.0) { 
    134   ticks_per_usec = ceil(mhz); 
    135   info("udelay: using TSC delay loop, %u ticks per microsecond", ticks_per_usec); 
    136     } else 
    137 #else 
    138     error("udelay: The file 'include/asm/msr.h' was missing at compile time."); 
    139     error("udelay: Even if your CPU supports TSC, it will not be used!"); 
    140     error("udelay: You *really* should install msr.h and recompile LCD4linux!"); 
    141 #endif 
    142     { 
    143   ticks_per_usec = 0; 
    144   info("udelay: using gettimeofday() delay loop"); 
    145     } 
     68    info("udelay: using gettimeofday() delay loop"); 
    14669} 
    14770 
     
    17699{ 
    177100 
    178 #ifdef HAVE_ASM_MSR_H 
     101    struct timeval now, end; 
    179102 
    180     if (ticks_per_usec) { 
     103    gettimeofday(&end, NULL); 
     104    end.tv_usec += (nsec + 999) / 1000; 
     105    while (end.tv_usec > 1000000) { 
     106  end.tv_usec -= 1000000; 
     107  end.tv_sec++; 
     108    } 
    181109 
    182   unsigned int t1, t2; 
    183   unsigned long tsc; 
    184  
    185   tsc = (nsec * ticks_per_usec + 999) / 1000; 
    186  
    187   rdtscl(t1); 
    188   do { 
    189       rep_nop(); 
    190       rdtscl(t2); 
    191   } while ((t2 - t1) < tsc); 
    192  
    193     } else 
    194 #endif 
    195  
    196     { 
    197   struct timeval now, end; 
    198  
    199   gettimeofday(&end, NULL); 
    200   end.tv_usec += (nsec + 999) / 1000; 
    201   while (end.tv_usec > 1000000) { 
    202       end.tv_usec -= 1000000; 
    203       end.tv_sec++; 
    204   } 
    205  
    206   do { 
    207       rep_nop(); 
    208       gettimeofday(&now, NULL); 
    209   } while (now.tv_sec == end.tv_sec ? now.tv_usec < end.tv_usec : now.tv_sec < end.tv_sec); 
    210     } 
     110    do { 
     111  rep_nop(); 
     112  gettimeofday(&now, NULL); 
     113    } while (now.tv_sec == end.tv_sec ? now.tv_usec < end.tv_usec : now.tv_sec < end.tv_sec); 
    211114}