summaryrefslogtreecommitdiff
path: root/sys/arch/sparc64
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2009-04-12 22:17:53 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2009-04-12 22:17:53 +0000
commit8cd1f0b28c845bda4d97b010fc213f6164ce80e8 (patch)
tree2fc77ba6f71b32f7adac5d09a45a962defc80498 /sys/arch/sparc64
parentd19899caee6dee8305968579c9d8ab1fa131c643 (diff)
Implement /dev/mdesc, a device to read the machine description on sun4v
(virtual) machines.
Diffstat (limited to 'sys/arch/sparc64')
-rw-r--r--sys/arch/sparc64/include/conf.h4
-rw-r--r--sys/arch/sparc64/sparc64/openprom.c34
2 files changed, 35 insertions, 3 deletions
diff --git a/sys/arch/sparc64/include/conf.h b/sys/arch/sparc64/include/conf.h
index 358e74b792c..20aaab95411 100644
--- a/sys/arch/sparc64/include/conf.h
+++ b/sys/arch/sparc64/include/conf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.h,v 1.18 2008/07/07 14:46:18 kettenis Exp $ */
+/* $OpenBSD: conf.h,v 1.19 2009/04/12 22:17:52 kettenis Exp $ */
/* $NetBSD: conf.h,v 1.9 2001/03/26 12:33:26 lukem Exp $ */
/*-
@@ -38,7 +38,7 @@ cdev_decl(openprom);
/* open, close, ioctl */
#define cdev_openprom_init(c,n) { \
- dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
+ dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
(dev_type_stop((*))) nullop, 0, (dev_type_poll((*))) enodev, \
(dev_type_mmap((*))) enodev }
diff --git a/sys/arch/sparc64/sparc64/openprom.c b/sys/arch/sparc64/sparc64/openprom.c
index ac38ccc2171..06c51775fb8 100644
--- a/sys/arch/sparc64/sparc64/openprom.c
+++ b/sys/arch/sparc64/sparc64/openprom.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: openprom.c,v 1.14 2009/03/21 12:24:26 kettenis Exp $ */
+/* $OpenBSD: openprom.c,v 1.15 2009/04/12 22:17:52 kettenis Exp $ */
/* $NetBSD: openprom.c,v 1.4 2002/01/10 06:21:53 briggs Exp $ */
/*
@@ -53,6 +53,7 @@
#include <machine/openpromio.h>
#include <machine/autoconf.h>
#include <machine/conf.h>
+#include <machine/mdesc.h>
#include <dev/clock_subr.h>
#include <dev/ofw/openfirm.h>
@@ -87,6 +88,37 @@ openpromclose(dev, flags, mode, p)
return (0);
}
+int
+openpromread(dev_t dev, struct uio *uio, int flags)
+{
+#ifdef SUN4V
+ int error;
+ size_t len;
+ caddr_t v;
+
+ if (minor(dev) != 1)
+ return (ENXIO);
+
+ while (uio->uio_resid > 0) {
+ if (uio->uio_offset >= mdesc_len)
+ break;
+
+ v = mdesc + uio->uio_offset;
+ len = mdesc_len - uio->uio_offset;
+ if (len > uio->uio_resid)
+ len = uio->uio_resid;
+
+ error = uiomove(v, len, uio);
+ if (error)
+ return (error);
+ }
+
+ return (0);
+#else
+ return (ENXIO);
+#endif
+}
+
/*
* Verify target ID is valid (exists in the OPENPROM tree), as
* listed from node ID sid forward.