[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

BOUNCE rtl@rtlinux.org: Approval required: Non-member submissionfrom [frank mori hess <fmhess@students.uiuc.edu>] (fwd)



>From owner-rtl Fri May 11 17:38:29 2001
Received: from ux12.cso.uiuc.edu (root@ux12.cso.uiuc.edu [128.174.5.106])
	by hq.fsmlabs.com (8.11.2/8.11.2) with ESMTP id f4BNcTJ08006
	for <rtl@rtlinux.org>; Fri, 11 May 2001 17:38:29 -0600
Received: from localhost (fmhess@localhost [127.0.0.1])
	by ux12.cso.uiuc.edu (8.11.0/8.11.0) with ESMTP id f4BNYLI23484
	for <rtl@rtlinux.org>; Fri, 11 May 2001 18:34:21 -0500 (CDT)
Date: Fri, 11 May 2001 18:34:20 -0500 (CDT)
From: frank mori hess <fmhess@students.uiuc.edu>
X-X-Sender:  <fmhess@ux12.cso.uiuc.edu>
To: <rtl@rtlinux.org>
Subject: Re: HRT_FROM_8254() bug
In-Reply-To: <Pine.GSO.4.31.0105102208320.29864-100000@ux12.cso.uiuc.edu>
Message-ID: <Pine.GSO.4.31.0105111827210.21138-100000@ux12.cso.uiuc.edu>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII


HRT_TO_8254() is definitely broken, and also breaks rt_get_time() in
rtl_compat.h  I fixed my problems by replacing the function in
i386/rtl_time.h with my own hacked function, which just divides a long
long by 838.

long long nano2count(long long ns)
{
	unsigned long denom = 838;	// divisor
	long ms32 = ns >> 32;	// most significant 32 bits
	unsigned long ms32rem = ms32 % denom;	// remainder of ms32/denom
	unsigned long ls32 = ns;	// least significant 32 bits
	unsigned long ls32rem = ls32 % denom;
	unsigned long big = 0xffffffff;
	unsigned long big_rem = big % denom;
	unsigned long rem_rem;

	// divide most significant bits
	ns = ms32 / denom;
	ns = ns << 32;
	// add corrections due to rounding errors
	ns += ms32rem * (big / denom) + (ms32rem * (big_rem + 1)) / denom;
	// divide least significant bits
	ns += ls32 / denom;
	// add really small correction
	rem_rem = (ms32rem * (big_rem + 1)) % denom;
	ns += (ls32rem + rem_rem) / denom;

	return ns;
}

Frank