From 2e72ff404b31aa2fff4e36d6b01965d67fd97037 Mon Sep 17 00:00:00 2001 From: kettenis Date: Wed, 27 Dec 2017 11:40:14 +0000 Subject: [PATCH] Implement OF_getpropint64(). ok jca@, tom@, patrick@, visa@ --- sys/dev/ofw/fdt.c | 15 ++++++++++++++- sys/dev/ofw/openfirm.h | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/sys/dev/ofw/fdt.c b/sys/dev/ofw/fdt.c index 82ef499d921..a45f1066e9e 100644 --- a/sys/dev/ofw/fdt.c +++ b/sys/dev/ofw/fdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdt.c,v 1.21 2017/11/17 20:30:43 kettenis Exp $ */ +/* $OpenBSD: fdt.c,v 1.22 2017/12/27 11:40:14 kettenis Exp $ */ /* * Copyright (c) 2009 Dariusz Swiderski @@ -878,6 +878,19 @@ OF_getpropintarray(int handle, char *prop, uint32_t *buf, int buflen) return len; } +uint64_t +OF_getpropint64(int handle, char *prop, uint64_t defval) +{ + uint64_t val; + int len; + + len = OF_getprop(handle, prop, &val, sizeof(val)); + if (len != sizeof(val)) + return defval; + + return betoh64(val); +} + int OF_nextprop(int handle, char *prop, void *nextprop) { diff --git a/sys/dev/ofw/openfirm.h b/sys/dev/ofw/openfirm.h index 39dff872259..45f8086d047 100644 --- a/sys/dev/ofw/openfirm.h +++ b/sys/dev/ofw/openfirm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: openfirm.h,v 1.14 2017/03/12 11:44:42 kettenis Exp $ */ +/* $OpenBSD: openfirm.h,v 1.15 2017/12/27 11:40:14 kettenis Exp $ */ /* $NetBSD: openfirm.h,v 1.1 1996/09/30 16:35:10 ws Exp $ */ /* @@ -50,6 +50,7 @@ int OF_getproplen(int handle, char *prop); int OF_getprop(int handle, char *prop, void *buf, int buflen); uint32_t OF_getpropint(int handle, char *, uint32_t); int OF_getpropintarray(int, char *, uint32_t *, int); +uint64_t OF_getpropint64(int handle, char *, uint64_t); int OF_setprop(int, char *, const void *, int); int OF_nextprop(int, char *, void *); int OF_finddevice(char *name); -- 2.20.1