svn commit: r266885 - head/sys/boot/mips/beri/loader

Hans Petter Selasky hselasky at FreeBSD.org
Fri May 30 13:53:37 UTC 2014


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;
+		}
+	}
 }


More information about the svn-src-head mailing list