1176348Smarcel/*- 2176348Smarcel * Copyright (c) 2000 Benno Rice 3176348Smarcel * Copyright (c) 2007 Semihalf, Rafal Jaworowski <raj@semihalf.com> 4176348Smarcel * All rights reserved. 5176348Smarcel * 6176348Smarcel * Redistribution and use in source and binary forms, with or without 7176348Smarcel * modification, are permitted provided that the following conditions 8176348Smarcel * are met: 9176348Smarcel * 1. Redistributions of source code must retain the above copyright 10176348Smarcel * notice, this list of conditions and the following disclaimer. 11176348Smarcel * 2. Redistributions in binary form must reproduce the above copyright 12176348Smarcel * notice, this list of conditions and the following disclaimer in the 13176348Smarcel * documentation and/or other materials provided with the distribution. 14176348Smarcel * 15176348Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16176348Smarcel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17176348Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18176348Smarcel * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19176348Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20176348Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21176348Smarcel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22176348Smarcel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23176348Smarcel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24176348Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25176348Smarcel * SUCH DAMAGE. 26176348Smarcel */ 27176348Smarcel 28176348Smarcel#include <sys/cdefs.h> 29176348Smarcel__FBSDID("$FreeBSD: releng/10.3/sys/boot/uboot/lib/time.c 204318 2010-02-25 15:30:26Z raj $"); 30176348Smarcel 31176348Smarcel#include <stand.h> 32176348Smarcel 33182723Sraj#include "glue.h" 34182723Sraj 35176348Smarcel/* 36176348Smarcel * Return the time in seconds since the beginning of the day. 37176348Smarcel */ 38176348Smarceltime_t 39176348Smarceltime(time_t *tloc) 40176348Smarcel{ 41176348Smarcel int secs; 42176348Smarcel 43176348Smarcel secs = ub_get_timer(0) / 1000; 44176348Smarcel if (tloc) 45176348Smarcel *tloc = secs; 46176348Smarcel 47182723Sraj return (secs); 48176348Smarcel} 49176348Smarcel 50176348Smarcelint 51204318Srajgetsecs(void) 52176348Smarcel{ 53177108Sraj 54176348Smarcel return (time(NULL)); 55176348Smarcel} 56176348Smarcel 57176348Smarcel/* 58176348Smarcel * Use U-Boot udelay() function to wait for a given microseconds period 59176348Smarcel */ 60176348Smarcelvoid 61176348Smarceldelay(int usecs) 62176348Smarcel{ 63177108Sraj 64176348Smarcel ub_udelay(usecs); 65176348Smarcel} 66