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>
15 #include <linux/module.h>
17 #include <asm/setup.h>
19 struct dentry
*arch_debugfs_dir
;
20 EXPORT_SYMBOL(arch_debugfs_dir
);
22 #ifdef CONFIG_DEBUG_BOOT_PARAMS
23 struct setup_data_node
{
30 setup_data_read(struct file
*file
, char __user
*user_buf
, size_t count
,
33 struct setup_data_node
*node
= file
->private_data
;
45 if (count
> node
->len
- pos
)
46 count
= node
->len
- pos
;
47 pa
= node
->paddr
+ sizeof(struct setup_data
) + pos
;
48 pg
= pfn_to_page((pa
+ count
- 1) >> PAGE_SHIFT
);
49 if (PageHighMem(pg
)) {
50 p
= ioremap_cache(pa
, count
);
57 remain
= copy_to_user(user_buf
, p
, count
);
70 static int setup_data_open(struct inode
*inode
, struct file
*file
)
72 file
->private_data
= inode
->i_private
;
76 static const struct file_operations fops_setup_data
= {
77 .read
= setup_data_read
,
78 .open
= setup_data_open
,
82 create_setup_data_node(struct dentry
*parent
, int no
,
83 struct setup_data_node
*node
)
85 struct dentry
*d
, *type
, *data
;
89 sprintf(buf
, "%d", no
);
90 d
= debugfs_create_dir(buf
, parent
);
95 type
= debugfs_create_x32("type", S_IRUGO
, d
, &node
->type
);
100 data
= debugfs_create_file("data", S_IRUGO
, d
, node
, &fops_setup_data
);
108 debugfs_remove(type
);
115 static int __init
create_setup_data_nodes(struct dentry
*parent
)
117 struct setup_data_node
*node
;
118 struct setup_data
*data
;
124 d
= debugfs_create_dir("setup_data", parent
);
130 pa_data
= boot_params
.hdr
.setup_data
;
133 node
= kmalloc(sizeof(*node
), GFP_KERNEL
);
138 pg
= pfn_to_page((pa_data
+sizeof(*data
)-1) >> PAGE_SHIFT
);
139 if (PageHighMem(pg
)) {
140 data
= ioremap_cache(pa_data
, sizeof(*data
));
147 data
= __va(pa_data
);
150 node
->paddr
= pa_data
;
151 node
->type
= data
->type
;
152 node
->len
= data
->len
;
153 error
= create_setup_data_node(d
, no
, node
);
154 pa_data
= data
->next
;
170 static struct debugfs_blob_wrapper boot_params_blob
= {
171 .data
= &boot_params
,
172 .size
= sizeof(boot_params
),
175 static int __init
boot_params_kdebugfs_init(void)
177 struct dentry
*dbp
, *version
, *data
;
180 dbp
= debugfs_create_dir("boot_params", NULL
);
185 version
= debugfs_create_x16("version", S_IRUGO
, dbp
,
186 &boot_params
.hdr
.version
);
191 data
= debugfs_create_blob("data", S_IRUGO
, dbp
,
197 error
= create_setup_data_nodes(dbp
);
203 debugfs_remove(data
);
205 debugfs_remove(version
);
213 static int __init
arch_kdebugfs_init(void)
217 arch_debugfs_dir
= debugfs_create_dir("x86", NULL
);
218 if (!arch_debugfs_dir
)
221 #ifdef CONFIG_DEBUG_BOOT_PARAMS
222 error
= boot_params_kdebugfs_init();
227 arch_initcall(arch_kdebugfs_init
);