xref: /freebsd/stand/uboot/time.c (revision 3e15b01d6914c927e37d1699645783acf286655c)
1*9dc70af8SWarner Losh /*-
2*9dc70af8SWarner Losh  * Copyright (c) 2000 Benno Rice
3*9dc70af8SWarner Losh  * Copyright (c) 2007 Semihalf, Rafal Jaworowski <raj@semihalf.com>
4*9dc70af8SWarner Losh  * All rights reserved.
5*9dc70af8SWarner Losh  *
6*9dc70af8SWarner Losh  * Redistribution and use in source and binary forms, with or without
7*9dc70af8SWarner Losh  * modification, are permitted provided that the following conditions
8*9dc70af8SWarner Losh  * are met:
9*9dc70af8SWarner Losh  * 1. Redistributions of source code must retain the above copyright
10*9dc70af8SWarner Losh  *    notice, this list of conditions and the following disclaimer.
11*9dc70af8SWarner Losh  * 2. Redistributions in binary form must reproduce the above copyright
12*9dc70af8SWarner Losh  *    notice, this list of conditions and the following disclaimer in the
13*9dc70af8SWarner Losh  *    documentation and/or other materials provided with the distribution.
14*9dc70af8SWarner Losh  *
15*9dc70af8SWarner Losh  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16*9dc70af8SWarner Losh  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17*9dc70af8SWarner Losh  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18*9dc70af8SWarner Losh  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19*9dc70af8SWarner Losh  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20*9dc70af8SWarner Losh  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21*9dc70af8SWarner Losh  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22*9dc70af8SWarner Losh  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23*9dc70af8SWarner Losh  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24*9dc70af8SWarner Losh  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25*9dc70af8SWarner Losh  * SUCH DAMAGE.
26*9dc70af8SWarner Losh  */
27*9dc70af8SWarner Losh 
28*9dc70af8SWarner Losh #include <stand.h>
29*9dc70af8SWarner Losh #include "glue.h"
30*9dc70af8SWarner Losh 
31*9dc70af8SWarner Losh /*
32*9dc70af8SWarner Losh  * Return the time in seconds since the beginning of the day.
33*9dc70af8SWarner Losh  */
34*9dc70af8SWarner Losh time_t
time(time_t * tloc)35*9dc70af8SWarner Losh time(time_t *tloc)
36*9dc70af8SWarner Losh {
37*9dc70af8SWarner Losh 	int secs;
38*9dc70af8SWarner Losh 
39*9dc70af8SWarner Losh 	secs = ub_get_timer(0) / 1000;
40*9dc70af8SWarner Losh 	if (tloc)
41*9dc70af8SWarner Losh 		*tloc = secs;
42*9dc70af8SWarner Losh 
43*9dc70af8SWarner Losh 	return (secs);
44*9dc70af8SWarner Losh }
45*9dc70af8SWarner Losh 
46*9dc70af8SWarner Losh time_t
getsecs(void)47*9dc70af8SWarner Losh getsecs(void)
48*9dc70af8SWarner Losh {
49*9dc70af8SWarner Losh 
50*9dc70af8SWarner Losh 	return (time(NULL));
51*9dc70af8SWarner Losh }
52*9dc70af8SWarner Losh 
53*9dc70af8SWarner Losh /*
54*9dc70af8SWarner Losh  * Use U-Boot udelay() function to wait for a given microseconds period
55*9dc70af8SWarner Losh  */
56*9dc70af8SWarner Losh void
delay(int usecs)57*9dc70af8SWarner Losh delay(int usecs)
58*9dc70af8SWarner Losh {
59*9dc70af8SWarner Losh 
60*9dc70af8SWarner Losh 	ub_udelay(usecs);
61*9dc70af8SWarner Losh }
62