A function to easily extract properties that are represented as a
64-bit integer.  I'll be needing this in at least two little projects
that I'm working on.

ok?

P.S. Those two little projects are EFI Runtime Services and DVFS support.

Index: dev/ofw/fdt.c
===================================================================
RCS file: /cvs/src/sys/dev/ofw/fdt.c,v
retrieving revision 1.21
diff -u -p -r1.21 fdt.c
--- dev/ofw/fdt.c       17 Nov 2017 20:30:43 -0000      1.21
+++ dev/ofw/fdt.c       26 Dec 2017 16:15:55 -0000
@@ -878,6 +878,19 @@ OF_getpropintarray(int handle, char *pro
        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)
 {
Index: dev/ofw/openfirm.h
===================================================================
RCS file: /cvs/src/sys/dev/ofw/openfirm.h,v
retrieving revision 1.14
diff -u -p -r1.14 openfirm.h
--- dev/ofw/openfirm.h  12 Mar 2017 11:44:42 -0000      1.14
+++ dev/ofw/openfirm.h  26 Dec 2017 16:15:55 -0000
@@ -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);

Reply via email to