From 8cd1f0b28c845bda4d97b010fc213f6164ce80e8 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Sun, 12 Apr 2009 22:17:53 +0000 Subject: Implement /dev/mdesc, a device to read the machine description on sun4v (virtual) machines. --- sys/arch/sparc64/include/conf.h | 4 ++-- sys/arch/sparc64/sparc64/openprom.c | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) (limited to 'sys/arch/sparc64') 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 #include #include +#include #include #include @@ -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. -- cgit v1.2.3