diff options
author | 1998-06-28 06:37:15 +0000 | |
---|---|---|
committer | 1998-06-28 06:37:15 +0000 | |
commit | 8a186018256f3535a0213c47a54c5b6d2faff32b (patch) | |
tree | ac6e6bca220e21ad27507be76bca2ab4e4135146 /sys | |
parent | Oh fun, mucking about with files used on all archs. (diff) | |
download | wireguard-openbsd-8a186018256f3535a0213c47a54c5b6d2faff32b.tar.xz wireguard-openbsd-8a186018256f3535a0213c47a54c5b6d2faff32b.zip |
make the openfirmware clock reading routine compatible with the
"typical" hardware clock read routine.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ofw/ofrtc.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/sys/dev/ofw/ofrtc.c b/sys/dev/ofw/ofrtc.c index e05cc8061d7..b85ffcaf4c4 100644 --- a/sys/dev/ofw/ofrtc.c +++ b/sys/dev/ofw/ofrtc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofrtc.c,v 1.2 1997/11/07 08:07:23 niklas Exp $ */ +/* $OpenBSD: ofrtc.c,v 1.3 1998/06/28 06:37:15 rahnds Exp $ */ /* $NetBSD: ofrtc.c,v 1.3 1996/10/13 01:38:14 christos Exp $ */ /* @@ -230,6 +230,11 @@ ofrtcwrite(dev, uio, flag) } + +/* powerpc expects clock_read data in BCD, discuss this if it is improper */ +#define TOBCD(x) (((x) / 10 * 16) + ((x) % 10)) +#define YEAR0 1900 + int OF_clock_read(int *sec, int *min, int *hour, int *day, int *mon, int *yr) @@ -239,11 +244,11 @@ OF_clock_read(int *sec, int *min, int *hour, int *day, int l; if (!(of = ofrtc_cd.cd_devs[0])) - return 0; + return 1; if ((l = OF_package_to_path(of->sc_phandle, path, sizeof path - 1)) < 0) - return 0; + return 1; if (l >= sizeof path) - return 0; + return 1; path[l] = 0; if (!(of->sc_ihandle = OF_open(path))) { @@ -251,11 +256,22 @@ OF_clock_read(int *sec, int *min, int *hour, int *day, OF_close(of->sc_ihandle); of->sc_ihandle = 0; } - return 0; + return 1; } if (OF_call_method("get-time", of->sc_ihandle, 0, 6, sec, min, hour, day, mon, yr)) - return 0; - + { return 1; + } + printf("y:%d m:%d d:%d H:%d M:%d S:%d\n", + *yr, *mon, *day, *hour, *min, *sec); + *yr -= YEAR0; /* bsd expects 0 - 200, not something like 1998 */ + *yr = TOBCD(*yr); + *mon = TOBCD(*mon); + *day = TOBCD(*day); + *hour = TOBCD(*hour); + *min = TOBCD(*min); + *sec = TOBCD(*sec); + + return 0; } |