Date: Fri, 30 May 2014 13:53:37 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> 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 Message-ID: <201405301353.s4UDrboI075851@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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; + } + } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405301353.s4UDrboI075851>