aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2007-08-16 00:02:23 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-08-16 00:02:23 -0400
commit0fdb7f96d8c27e37ed2ca1ae5a763baf14b8fe0c (patch)
treee6ad3272da135d92929a8ea7f920baa63c973d4a /arch/sparc64
parent70b0e7a919b7961285c685a87928ed78c9fb07f0 (diff)
[SPARC64]: Allow userspace to get at the machine description.
Like the OF device tree, it's useful to let userland get at the machine description so it can pretty print the graph etc. The implementation is a simple MISC device with a read method. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64')
-rw-r--r--arch/sparc64/kernel/mdesc.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/arch/sparc64/kernel/mdesc.c b/arch/sparc64/kernel/mdesc.c
index 95059c2ec414..9f22e4ff6015 100644
--- a/arch/sparc64/kernel/mdesc.c
+++ b/arch/sparc64/kernel/mdesc.c
@@ -9,6 +9,7 @@
9#include <linux/list.h> 9#include <linux/list.h>
10#include <linux/slab.h> 10#include <linux/slab.h>
11#include <linux/mm.h> 11#include <linux/mm.h>
12#include <linux/miscdevice.h>
12 13
13#include <asm/hypervisor.h> 14#include <asm/hypervisor.h>
14#include <asm/mdesc.h> 15#include <asm/mdesc.h>
@@ -836,6 +837,43 @@ void __devinit mdesc_fill_in_cpu_data(cpumask_t mask)
836 mdesc_release(hp); 837 mdesc_release(hp);
837} 838}
838 839
840static ssize_t mdesc_read(struct file *file, char __user *buf,
841 size_t len, loff_t *offp)
842{
843 struct mdesc_handle *hp = mdesc_grab();
844 int err;
845
846 if (!hp)
847 return -ENODEV;
848
849 err = hp->handle_size;
850 if (len < hp->handle_size)
851 err = -EMSGSIZE;
852 else if (copy_to_user(buf, &hp->mdesc, hp->handle_size))
853 err = -EFAULT;
854 mdesc_release(hp);
855
856 return err;
857}
858
859static const struct file_operations mdesc_fops = {
860 .read = mdesc_read,
861 .owner = THIS_MODULE,
862};
863
864static struct miscdevice mdesc_misc = {
865 .minor = MISC_DYNAMIC_MINOR,
866 .name = "mdesc",
867 .fops = &mdesc_fops,
868};
869
870static int __init mdesc_misc_init(void)
871{
872 return misc_register(&mdesc_misc);
873}
874
875__initcall(mdesc_misc_init);
876
839void __init sun4v_mdesc_init(void) 877void __init sun4v_mdesc_init(void)
840{ 878{
841 struct mdesc_handle *hp; 879 struct mdesc_handle *hp;