summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2014-05-30 13:53:37 +0000
committerhselasky <hselasky@FreeBSD.org>2014-05-30 13:53:37 +0000
commitafb3e04ca9ce825c4cf25bb55aaf6c04dd22dd51 (patch)
tree8834fd794b123d8c0e0d88b68449044f90e6d8f2
parentb66cd7ed715f39d8072d3e15f86ac7e583c98489 (diff)
downloadFreeBSD-src-afb3e04ca9ce825c4cf25bb55aaf6c04dd22dd51.zip
FreeBSD-src-afb3e04ca9ce825c4cf25bb55aaf6c04dd22dd51.tar.gz
Fix delay() function in the BERI loader code.
Reviewed by: brooks @ Sponsored by: DARPA, AFRL
-rw-r--r--sys/boot/mips/beri/loader/main.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/sys/boot/mips/beri/loader/main.c b/sys/boot/mips/beri/loader/main.c
index 81d3248..2354614 100644
--- a/sys/boot/mips/beri/loader/main.c
+++ b/sys/boot/mips/beri/loader/main.c
@@ -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;
-
- t = cp0_count_get() + usecs * 100;
- while (cp0_count_get() < t);
+ uint32_t delta;
+ uint32_t curr;
+ uint32_t last;
+
+ last = cp0_count_get();
+ while (usecs > 0) {
+ curr = cp0_count_get();
+ delta = curr - last;
+ while (usecs > 0 && delta >= 100) {
+ usecs--;
+ last += 100;
+ delta -= 100;
+ }
+ }
}
OpenPOWER on IntegriCloud