From owner-svn-src-all@FreeBSD.ORG Fri May 30 13:53:37 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DAC68887; Fri, 30 May 2014 13:53:37 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C84F5288B; Fri, 30 May 2014 13:53:37 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4UDrbqH075852; Fri, 30 May 2014 13:53:37 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4UDrboI075851; Fri, 30 May 2014 13:53:37 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201405301353.s4UDrboI075851@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 30 May 2014 13:53:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r266885 - head/sys/boot/mips/beri/loader X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 May 2014 13:53:37 -0000 Author: hselasky Date: Fri May 30 13:53:37 2014 New Revision: 266885 URL: http://svnweb.freebsd.org/changeset/base/266885 Log: Fix delay() function in the BERI loader code. Reviewed by: brooks @ Sponsored by: DARPA, AFRL Modified: head/sys/boot/mips/beri/loader/main.c Modified: head/sys/boot/mips/beri/loader/main.c ============================================================================== --- head/sys/boot/mips/beri/loader/main.c Fri May 30 13:45:20 2014 (r266884) +++ head/sys/boot/mips/beri/loader/main.c Fri May 30 13:53:37 2014 (r266885) @@ -215,13 +215,25 @@ time(time_t *tloc) } /* - * Delay - presumably in usecs? + * Delay - in usecs + * + * NOTE: We are assuming that the CPU is running at 100MHz. */ void delay(int usecs) { - register_t t; + uint32_t delta; + uint32_t curr; + uint32_t last; - t = cp0_count_get() + usecs * 100; - while (cp0_count_get() < t); + last = cp0_count_get(); + while (usecs > 0) { + curr = cp0_count_get(); + delta = curr - last; + while (usecs > 0 && delta >= 100) { + usecs--; + last += 100; + delta -= 100; + } + } }