2 * debug.c - ACPI debug interface to userspace.
5 #include <linux/proc_fs.h>
6 #include <linux/init.h>
7 #include <linux/module.h>
8 #include <linux/kernel.h>
9 #include <linux/moduleparam.h>
10 #include <asm/uaccess.h>
11 #include <acpi/acpi_drivers.h>
12 #include <acpi/acglobal.h>
14 #define _COMPONENT ACPI_SYSTEM_COMPONENT
15 ACPI_MODULE_NAME ("debug")
17 #define ACPI_SYSTEM_FILE_DEBUG_LAYER "debug_layer"
18 #define ACPI_SYSTEM_FILE_DEBUG_LEVEL "debug_level"
20 #ifdef MODULE_PARAM_PREFIX
21 #undef MODULE_PARAM_PREFIX
24 #define MODULE_PARAM_PREFIX
25 module_param(acpi_dbg_layer
, uint
, 0400);
26 module_param(acpi_dbg_level
, uint
, 0400);
36 #define ACPI_DEBUG_INIT(v) { .name = #v, .value = v }
38 static const struct acpi_dlayer acpi_debug_layers
[] =
40 ACPI_DEBUG_INIT(ACPI_UTILITIES
),
41 ACPI_DEBUG_INIT(ACPI_HARDWARE
),
42 ACPI_DEBUG_INIT(ACPI_EVENTS
),
43 ACPI_DEBUG_INIT(ACPI_TABLES
),
44 ACPI_DEBUG_INIT(ACPI_NAMESPACE
),
45 ACPI_DEBUG_INIT(ACPI_PARSER
),
46 ACPI_DEBUG_INIT(ACPI_DISPATCHER
),
47 ACPI_DEBUG_INIT(ACPI_EXECUTER
),
48 ACPI_DEBUG_INIT(ACPI_RESOURCES
),
49 ACPI_DEBUG_INIT(ACPI_CA_DEBUGGER
),
50 ACPI_DEBUG_INIT(ACPI_OS_SERVICES
),
51 ACPI_DEBUG_INIT(ACPI_CA_DISASSEMBLER
),
52 ACPI_DEBUG_INIT(ACPI_COMPILER
),
53 ACPI_DEBUG_INIT(ACPI_TOOLS
),
56 static const struct acpi_dlevel acpi_debug_levels
[] =
58 ACPI_DEBUG_INIT(ACPI_LV_ERROR
),
59 ACPI_DEBUG_INIT(ACPI_LV_WARN
),
60 ACPI_DEBUG_INIT(ACPI_LV_INIT
),
61 ACPI_DEBUG_INIT(ACPI_LV_DEBUG_OBJECT
),
62 ACPI_DEBUG_INIT(ACPI_LV_INFO
),
64 ACPI_DEBUG_INIT(ACPI_LV_INIT_NAMES
),
65 ACPI_DEBUG_INIT(ACPI_LV_PARSE
),
66 ACPI_DEBUG_INIT(ACPI_LV_LOAD
),
67 ACPI_DEBUG_INIT(ACPI_LV_DISPATCH
),
68 ACPI_DEBUG_INIT(ACPI_LV_EXEC
),
69 ACPI_DEBUG_INIT(ACPI_LV_NAMES
),
70 ACPI_DEBUG_INIT(ACPI_LV_OPREGION
),
71 ACPI_DEBUG_INIT(ACPI_LV_BFIELD
),
72 ACPI_DEBUG_INIT(ACPI_LV_TABLES
),
73 ACPI_DEBUG_INIT(ACPI_LV_VALUES
),
74 ACPI_DEBUG_INIT(ACPI_LV_OBJECTS
),
75 ACPI_DEBUG_INIT(ACPI_LV_RESOURCES
),
76 ACPI_DEBUG_INIT(ACPI_LV_USER_REQUESTS
),
77 ACPI_DEBUG_INIT(ACPI_LV_PACKAGE
),
79 ACPI_DEBUG_INIT(ACPI_LV_ALLOCATIONS
),
80 ACPI_DEBUG_INIT(ACPI_LV_FUNCTIONS
),
81 ACPI_DEBUG_INIT(ACPI_LV_OPTIMIZATIONS
),
83 ACPI_DEBUG_INIT(ACPI_LV_MUTEX
),
84 ACPI_DEBUG_INIT(ACPI_LV_THREADS
),
85 ACPI_DEBUG_INIT(ACPI_LV_IO
),
86 ACPI_DEBUG_INIT(ACPI_LV_INTERRUPTS
),
88 ACPI_DEBUG_INIT(ACPI_LV_AML_DISASSEMBLE
),
89 ACPI_DEBUG_INIT(ACPI_LV_VERBOSE_INFO
),
90 ACPI_DEBUG_INIT(ACPI_LV_FULL_TABLES
),
91 ACPI_DEBUG_INIT(ACPI_LV_EVENTS
),
95 acpi_system_read_debug (
110 p
+= sprintf(p
, "%-25s\tHex SET\n", "Description");
112 switch ((unsigned long) data
) {
114 for (i
= 0; i
< ARRAY_SIZE(acpi_debug_layers
); i
++) {
115 p
+= sprintf(p
, "%-25s\t0x%08lX [%c]\n",
116 acpi_debug_layers
[i
].name
,
117 acpi_debug_layers
[i
].value
,
118 (acpi_dbg_layer
& acpi_debug_layers
[i
].value
) ?
121 p
+= sprintf(p
, "%-25s\t0x%08X [%c]\n", "ACPI_ALL_DRIVERS",
123 (acpi_dbg_layer
& ACPI_ALL_DRIVERS
) == ACPI_ALL_DRIVERS
?
124 '*' : (acpi_dbg_layer
& ACPI_ALL_DRIVERS
) == 0 ?
127 "--\ndebug_layer = 0x%08X (* = enabled, - = partial)\n",
131 for (i
= 0; i
< ARRAY_SIZE(acpi_debug_levels
); i
++) {
132 p
+= sprintf(p
, "%-25s\t0x%08lX [%c]\n",
133 acpi_debug_levels
[i
].name
,
134 acpi_debug_levels
[i
].value
,
135 (acpi_dbg_level
& acpi_debug_levels
[i
].value
) ?
138 p
+= sprintf(p
, "--\ndebug_level = 0x%08X (* = enabled)\n",
142 p
+= sprintf(p
, "Invalid debug option\n");
148 if (size
<= off
+count
) *eof
= 1;
151 if (size
>count
) size
= count
;
152 if (size
<0) size
= 0;
159 acpi_system_write_debug (
161 const char __user
*buffer
,
165 char debug_string
[12] = {'\0'};
167 ACPI_FUNCTION_TRACE("acpi_system_write_debug");
169 if (count
> sizeof(debug_string
) - 1)
170 return_VALUE(-EINVAL
);
172 if (copy_from_user(debug_string
, buffer
, count
))
173 return_VALUE(-EFAULT
);
175 debug_string
[count
] = '\0';
177 switch ((unsigned long) data
) {
179 acpi_dbg_layer
= simple_strtoul(debug_string
, NULL
, 0);
182 acpi_dbg_level
= simple_strtoul(debug_string
, NULL
, 0);
185 return_VALUE(-EINVAL
);
191 static int __init
acpi_debug_init(void)
193 struct proc_dir_entry
*entry
;
197 ACPI_FUNCTION_TRACE("acpi_debug_init");
202 /* 'debug_layer' [R/W] */
203 name
= ACPI_SYSTEM_FILE_DEBUG_LAYER
;
204 entry
= create_proc_read_entry(name
, S_IFREG
|S_IRUGO
|S_IWUSR
, acpi_root_dir
,
205 acpi_system_read_debug
,(void *)0);
207 entry
->write_proc
= acpi_system_write_debug
;
211 /* 'debug_level' [R/W] */
212 name
= ACPI_SYSTEM_FILE_DEBUG_LEVEL
;
213 entry
= create_proc_read_entry(name
, S_IFREG
|S_IRUGO
|S_IWUSR
, acpi_root_dir
,
214 acpi_system_read_debug
, (void *)1);
216 entry
->write_proc
= acpi_system_write_debug
;
224 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
225 "Unable to create '%s' proc fs entry\n", name
));
227 remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL
, acpi_root_dir
);
228 remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER
, acpi_root_dir
);
233 subsys_initcall(acpi_debug_init
);