From: kettenis Date: Thu, 10 Jul 2008 08:58:00 +0000 (+0000) Subject: Add support for getting the time of day on the m4k. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=805f8e64c7afc20239a3342ee7baa6cec551277b;p=openbsd Add support for getting the time of day on the m4k. --- diff --git a/sys/arch/sparc64/dev/prtc.c b/sys/arch/sparc64/dev/prtc.c index a8779941b08..b7ecb8f7641 100644 --- a/sys/arch/sparc64/dev/prtc.c +++ b/sys/arch/sparc64/dev/prtc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: prtc.c,v 1.1 2008/03/13 22:46:16 kettenis Exp $ */ +/* $OpenBSD: prtc.c,v 1.2 2008/07/10 08:58:00 kettenis Exp $ */ /* * Copyright (c) 2008 Mark Kettenis @@ -29,6 +29,7 @@ #include #include +#include #include @@ -82,11 +83,18 @@ prtc_attach(struct device *parent, struct device *self, void *aux) int prtc_gettime(todr_chip_handle_t handle, struct timeval *tv) { - char cmd[32]; u_int32_t tod = 0; + char buf[32]; - snprintf(cmd, sizeof(cmd), "h# %08x unix-gettod", &tod); - OF_interpret(cmd, 0); + if (OF_getprop(findroot(), "name", buf, sizeof(buf)) > 0 && + strcmp(buf, "SUNW,SPARC-Enterprise") == 0) { + tv->tv_sec = prom_opl_get_tod(); + tv->tv_usec = 0; + return (0); + } + + snprintf(buf, sizeof(buf), "h# %08x unix-gettod", &tod); + OF_interpret(buf, 0); tv->tv_sec = tod; tv->tv_usec = 0;