2 * Architecture specific debugfs files
4 * Copyright (C) 2007, Intel Corp.
5 * Huang Ying <ying.huang@intel.com>
7 * This file is released under the GPLv2.
9 #include <linux/debugfs.h>
10 #include <linux/uaccess.h>
11 #include <linux/stat.h>
12 #include <linux/init.h>
16 #include <asm/setup.h>
18 #ifdef CONFIG_DEBUG_BOOT_PARAMS
19 struct setup_data_node {
26 setup_data_read(struct file *file, char __user *user_buf, size_t count,
29 struct setup_data_node *node = file->private_data;
41 if (count > node->len - pos)
42 count = node->len - pos;
43 pa = node->paddr + sizeof(struct setup_data) + pos;
44 pg = pfn_to_page((pa + count - 1) >> PAGE_SHIFT);
45 if (PageHighMem(pg)) {
46 p = ioremap_cache(pa, count);
53 remain = copy_to_user(user_buf, p, count);
66 static int setup_data_open(struct inode *inode, struct file *file)
68 file->private_data = inode->i_private;
72 static const struct file_operations fops_setup_data = {
73 .read = setup_data_read,
74 .open = setup_data_open,
78 create_setup_data_node(struct dentry *parent, int no,
79 struct setup_data_node *node)
81 struct dentry *d, *type, *data;
85 sprintf(buf, "%d", no);
86 d = debugfs_create_dir(buf, parent);
91 type = debugfs_create_x32("type", S_IRUGO, d, &node->type);
96 data = debugfs_create_file("data", S_IRUGO, d, node, &fops_setup_data);
104 debugfs_remove(type);
111 static int __init create_setup_data_nodes(struct dentry *parent)
113 struct setup_data_node *node;
114 struct setup_data *data;
120 d = debugfs_create_dir("setup_data", parent);
126 pa_data = boot_params.hdr.setup_data;
129 node = kmalloc(sizeof(*node), GFP_KERNEL);
134 pg = pfn_to_page((pa_data+sizeof(*data)-1) >> PAGE_SHIFT);
135 if (PageHighMem(pg)) {
136 data = ioremap_cache(pa_data, sizeof(*data));
142 data = __va(pa_data);
145 node->paddr = pa_data;
146 node->type = data->type;
147 node->len = data->len;
148 error = create_setup_data_node(d, no, node);
149 pa_data = data->next;
165 static struct debugfs_blob_wrapper boot_params_blob = {
166 .data = &boot_params,
167 .size = sizeof(boot_params),
170 static int __init boot_params_kdebugfs_init(void)
172 struct dentry *dbp, *version, *data;
175 dbp = debugfs_create_dir("boot_params", NULL);
180 version = debugfs_create_x16("version", S_IRUGO, dbp,
181 &boot_params.hdr.version);
186 data = debugfs_create_blob("data", S_IRUGO, dbp,
192 error = create_setup_data_nodes(dbp);
198 debugfs_remove(data);
200 debugfs_remove(version);
208 static int __init arch_kdebugfs_init(void)
212 #ifdef CONFIG_DEBUG_BOOT_PARAMS
213 error = boot_params_kdebugfs_init();
218 arch_initcall(arch_kdebugfs_init);