1 /* $NetBSD: getsecs.c,v 1.4 2009/01/12 11:32:44 tsutsui Exp $ */ 2 3 /* extracted from netbsd:sys/arch/i386/netboot/misc.c */ 4 5 #include <sys/types.h> 6 7 #include <lib/libsa/stand.h> 8 #include <lib/libsa/net.h> 9 10 #include "libi386.h" 11 12 static inline u_long bcd2dec(u_long); 13 14 static inline u_long bcd2dec(u_long arg)15bcd2dec(u_long arg) 16 { 17 return (arg >> 4) * 10 + (arg & 0x0f); 18 } 19 20 satime_t getsecs(void)21getsecs(void) { 22 /* 23 * Return the current time in seconds 24 */ 25 26 u_long t; 27 satime_t sec; 28 29 if (biosgetrtc(&t)) 30 panic("RTC invalid"); 31 32 sec = bcd2dec(t & 0xff); 33 sec *= 60; 34 t >>= 8; 35 sec += bcd2dec(t & 0xff); 36 sec *= 60; 37 t >>= 8; 38 sec += bcd2dec(t & 0xff); 39 40 return sec; 41 } 42