time.c revision 176348
11984Scsgr/*- 229146Speter * Copyright (c) 2000 Benno Rice 31984Scsgr * Copyright (c) 2007 Semihalf, Rafal Jaworowski <raj@semihalf.com> 41984Scsgr * All rights reserved. 51989Scsgr * 629146Speter * Redistribution and use in source and binary forms, with or without 729146Speter * modification, are permitted provided that the following conditions 829146Speter * are met: 94454Sbde * 1. Redistributions of source code must retain the above copyright 104454Sbde * notice, this list of conditions and the following disclaimer. 1129146Speter * 2. Redistributions in binary form must reproduce the above copyright 1229146Speter * notice, this list of conditions and the following disclaimer in the 1329146Speter * documentation and/or other materials provided with the distribution. 1429146Speter * 151989Scsgr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 161984Scsgr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 174246Sphk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 181984Scsgr * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 194246Sphk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 204246Sphk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 211984Scsgr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2229146Speter * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2329146Speter * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2429146Speter * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2529146Speter * SUCH DAMAGE. 261989Scsgr */ 271989Scsgr 284246Sphk#include <sys/cdefs.h> 291989Scsgr__FBSDID("$FreeBSD: head/sys/boot/uboot/lib/time.c 176348 2008-02-16 22:13:11Z marcel $"); 308870Srgrimes 314454Sbde#include <stand.h> 324454Sbde 334454Sbde/* 344454Sbde * Return the time in seconds since the beginning of the day. 352045Scsgr */ 362045Scsgrtime_t 3729146Spetertime(time_t *tloc) 384454Sbde{ 3929146Speter int secs; 4029146Speter 4129146Speter secs = ub_get_timer(0) / 1000; 4229146Speter if (tloc) 4329146Speter *tloc = secs; 4429146Speter 454454Sbde return secs; 464454Sbde} 474454Sbde 482155Scsgrint 492155Scsgrgetsecs() 504454Sbde{ 514454Sbde return (time(NULL)); 524454Sbde} 534454Sbde 541989Scsgr/* 552155Scsgr * Use U-Boot udelay() function to wait for a given microseconds period 561989Scsgr */ 571984Scsgrvoid 58delay(int usecs) 59{ 60 ub_udelay(usecs); 61} 62