RDTSC delay and inclusion of asm/msr.h removed

git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@844 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
This commit is contained in:
michael
2007-10-01 15:49:21 +00:00
parent 354b411f9d
commit b4295fcc84
5 changed files with 14 additions and 258 deletions

View File

@@ -12,9 +12,6 @@
/* Define to 1 if you have the <asm/io.h> header file. */
#undef HAVE_ASM_IO_H
/* Define to 1 if you have the <asm/msr.h> header file. */
#undef HAVE_ASM_MSR_H
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#undef HAVE_DIRENT_H

146
configure vendored
View File

@@ -7990,6 +7990,7 @@ if test "$X11" = "yes"; then
echo "$as_me: WARNING: X11 headers or libraries not available: X11 driver disabled" >&2;}
else
GRAPHIC="yes"
KEYPAD="yes"
DRIVERS="$DRIVERS drv_X11.o"
if test "x$ac_x_libraries" = "x"; then
DRVLIBS="$DRVLIBS -lX11"
@@ -11407,151 +11408,6 @@ fi
done
for ac_header in asm/msr.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
echo $ECHO_N "(cached) $ECHO_C" >&6
fi
ac_res=`eval echo '${'$as_ac_Header'}'`
{ echo "$as_me:$LINENO: result: $ac_res" >&5
echo "${ECHO_T}$ac_res" >&6; }
else
# Is the header compilable?
{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
echo "${ECHO_T}$ac_header_compiler" >&6; }
# Is the header present?
{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
echo "${ECHO_T}$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
( cat <<\_ASBOX
## ---------------------------------------------------- ##
## Report this to lcd4linux-users@lists.sourceforge.net ##
## ---------------------------------------------------- ##
_ASBOX
) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval echo '${'$as_ac_Header'}'`
{ echo "$as_me:$LINENO: result: $ac_res" >&5
echo "${ECHO_T}$ac_res" >&6; }
fi
if test `eval echo '${'$as_ac_Header'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
# Checks for typedefs, structures, and compiler characteristics.
{ echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6; }

View File

@@ -102,7 +102,6 @@ AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h sys/vfs.h syslog.h termios.h unistd.h])
AC_CHECK_HEADERS(asm/io.h)
AC_CHECK_HEADERS(linux/parport.h linux/ppdev.h)
AC_CHECK_HEADERS(asm/msr.h)
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

View File

@@ -531,6 +531,7 @@ if test "$X11" = "yes"; then
AC_MSG_WARN(X11 headers or libraries not available: X11 driver disabled)
else
GRAPHIC="yes"
KEYPAD="yes"
DRIVERS="$DRIVERS drv_X11.o"
if test "x$ac_x_libraries" = "x"; then
DRVLIBS="$DRVLIBS -lX11"

121
udelay.c
View File

@@ -55,14 +55,6 @@
#include <string.h>
#include <sys/time.h>
#ifdef HAVE_ASM_MSR_H
typedef u_int32_t u32;
typedef u_int64_t u64;
#define __KERNEL__
#include <asm/msr.h>
#undef __KERNEL__
#endif
#include "debug.h"
#include "cfg.h"
@@ -70,79 +62,10 @@ typedef u_int64_t u64;
#include "udelay.h"
static unsigned int ticks_per_usec = 0;
static void getCPUinfo(int *hasTSC, double *MHz)
{
int fd;
char buffer[4096], *p;
*hasTSC = 0;
*MHz = -1;
fd = open("/proc/cpuinfo", O_RDONLY);
if (fd == -1) {
error("udelay: open(/proc/cpuinfo) failed: %s", strerror(errno));
return;
}
if (read(fd, &buffer, sizeof(buffer) - 1) == -1) {
error("udelay: read(/proc/cpuinfo) failed: %s", strerror(errno));
close(fd);
return;
}
close(fd);
p = strstr(buffer, "flags");
if (p == NULL) {
info("udelay: /proc/cpuinfo has no 'flags' line");
} else {
p = strstr(p, "tsc");
if (p == NULL) {
info("udelay: CPU does not support Time Stamp Counter");
} else {
info("udelay: CPU supports Time Stamp Counter");
*hasTSC = 1;
}
}
p = strstr(buffer, "cpu MHz");
if (p == NULL) {
info("udelay: /proc/cpuinfo has no 'cpu MHz' line");
} else {
if (sscanf(p + 7, " : %lf", MHz) != 1) {
error("udelay: parse(/proc/cpuinfo) failed: unknown 'cpu MHz' format");
*MHz = -1;
} else {
info("udelay: CPU runs at %f MHz", *MHz);
}
}
}
void udelay_init(void)
{
#ifdef HAVE_ASM_MSR_H
int tsc;
double mhz;
getCPUinfo(&tsc, &mhz);
if (tsc && mhz > 0.0) {
ticks_per_usec = ceil(mhz);
info("udelay: using TSC delay loop, %u ticks per microsecond", ticks_per_usec);
} else
#else
error("udelay: The file 'include/asm/msr.h' was missing at compile time.");
error("udelay: Even if your CPU supports TSC, it will not be used!");
error("udelay: You *really* should install msr.h and recompile LCD4linux!");
#endif
{
ticks_per_usec = 0;
info("udelay: using gettimeofday() delay loop");
}
info("udelay: using gettimeofday() delay loop");
}
@@ -175,37 +98,17 @@ unsigned long timing(const char *driver, const char *section, const char *name,
void ndelay(const unsigned long nsec)
{
#ifdef HAVE_ASM_MSR_H
struct timeval now, end;
if (ticks_per_usec) {
unsigned int t1, t2;
unsigned long tsc;
tsc = (nsec * ticks_per_usec + 999) / 1000;
rdtscl(t1);
do {
rep_nop();
rdtscl(t2);
} while ((t2 - t1) < tsc);
} else
#endif
{
struct timeval now, end;
gettimeofday(&end, NULL);
end.tv_usec += (nsec + 999) / 1000;
while (end.tv_usec > 1000000) {
end.tv_usec -= 1000000;
end.tv_sec++;
}
do {
rep_nop();
gettimeofday(&now, NULL);
} while (now.tv_sec == end.tv_sec ? now.tv_usec < end.tv_usec : now.tv_sec < end.tv_sec);
gettimeofday(&end, NULL);
end.tv_usec += (nsec + 999) / 1000;
while (end.tv_usec > 1000000) {
end.tv_usec -= 1000000;
end.tv_sec++;
}
do {
rep_nop();
gettimeofday(&now, NULL);
} while (now.tv_sec == end.tv_sec ? now.tv_usec < end.tv_usec : now.tv_sec < end.tv_sec);
}