2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* debug.c - ACPI debug interface to userspace.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/moduleparam.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <acpi/acpi_drivers.h>
|
|
|
|
#include <acpi/acglobal.h>
|
|
|
|
|
|
|
|
#define _COMPONENT ACPI_SYSTEM_COMPONENT
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_MODULE_NAME("debug")
|
2005-04-16 16:20:36 -06:00
|
|
|
#define ACPI_SYSTEM_FILE_DEBUG_LAYER "debug_layer"
|
|
|
|
#define ACPI_SYSTEM_FILE_DEBUG_LEVEL "debug_level"
|
|
|
|
#ifdef MODULE_PARAM_PREFIX
|
|
|
|
#undef MODULE_PARAM_PREFIX
|
|
|
|
#endif
|
|
|
|
#define MODULE_PARAM_PREFIX
|
2005-08-04 22:44:28 -06:00
|
|
|
module_param(acpi_dbg_layer, uint, 0400);
|
2005-04-16 16:20:36 -06:00
|
|
|
module_param(acpi_dbg_level, uint, 0400);
|
|
|
|
|
|
|
|
struct acpi_dlayer {
|
|
|
|
const char *name;
|
|
|
|
unsigned long value;
|
|
|
|
};
|
|
|
|
struct acpi_dlevel {
|
|
|
|
const char *name;
|
|
|
|
unsigned long value;
|
|
|
|
};
|
|
|
|
#define ACPI_DEBUG_INIT(v) { .name = #v, .value = v }
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
static const struct acpi_dlayer acpi_debug_layers[] = {
|
2005-04-16 16:20:36 -06:00
|
|
|
ACPI_DEBUG_INIT(ACPI_UTILITIES),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_HARDWARE),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_EVENTS),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_TABLES),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_NAMESPACE),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_PARSER),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_DISPATCHER),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_EXECUTER),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_RESOURCES),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_CA_DEBUGGER),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_OS_SERVICES),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_CA_DISASSEMBLER),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_COMPILER),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_TOOLS),
|
|
|
|
};
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
static const struct acpi_dlevel acpi_debug_levels[] = {
|
2005-04-16 16:20:36 -06:00
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_ERROR),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_WARN),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_INIT),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_DEBUG_OBJECT),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_INFO),
|
|
|
|
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_INIT_NAMES),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_PARSE),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_LOAD),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_DISPATCH),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_EXEC),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_NAMES),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_OPREGION),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_BFIELD),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_TABLES),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_VALUES),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_OBJECTS),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_RESOURCES),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_USER_REQUESTS),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_PACKAGE),
|
|
|
|
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_ALLOCATIONS),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_FUNCTIONS),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_OPTIMIZATIONS),
|
|
|
|
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_MUTEX),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_THREADS),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_IO),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_INTERRUPTS),
|
|
|
|
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_AML_DISASSEMBLE),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_VERBOSE_INFO),
|
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_FULL_TABLES),
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_DEBUG_INIT(ACPI_LV_EVENTS),
|
2005-04-16 16:20:36 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_system_read_debug(char *page,
|
|
|
|
char **start, off_t off, int count, int *eof, void *data)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
char *p = page;
|
|
|
|
int size = 0;
|
|
|
|
unsigned int i;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if (off != 0)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
p += sprintf(p, "%-25s\tHex SET\n", "Description");
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
switch ((unsigned long)data) {
|
2005-04-16 16:20:36 -06:00
|
|
|
case 0:
|
|
|
|
for (i = 0; i < ARRAY_SIZE(acpi_debug_layers); i++) {
|
|
|
|
p += sprintf(p, "%-25s\t0x%08lX [%c]\n",
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_debug_layers[i].name,
|
|
|
|
acpi_debug_layers[i].value,
|
|
|
|
(acpi_dbg_layer & acpi_debug_layers[i].
|
|
|
|
value) ? '*' : ' ');
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
p += sprintf(p, "%-25s\t0x%08X [%c]\n", "ACPI_ALL_DRIVERS",
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_ALL_DRIVERS,
|
|
|
|
(acpi_dbg_layer & ACPI_ALL_DRIVERS) ==
|
|
|
|
ACPI_ALL_DRIVERS ? '*' : (acpi_dbg_layer &
|
|
|
|
ACPI_ALL_DRIVERS) ==
|
|
|
|
0 ? ' ' : '-');
|
2005-04-16 16:20:36 -06:00
|
|
|
p += sprintf(p,
|
2005-08-04 22:44:28 -06:00
|
|
|
"--\ndebug_layer = 0x%08X (* = enabled, - = partial)\n",
|
|
|
|
acpi_dbg_layer);
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
for (i = 0; i < ARRAY_SIZE(acpi_debug_levels); i++) {
|
|
|
|
p += sprintf(p, "%-25s\t0x%08lX [%c]\n",
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_debug_levels[i].name,
|
|
|
|
acpi_debug_levels[i].value,
|
|
|
|
(acpi_dbg_level & acpi_debug_levels[i].
|
|
|
|
value) ? '*' : ' ');
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
p += sprintf(p, "--\ndebug_level = 0x%08X (* = enabled)\n",
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_dbg_level);
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
p += sprintf(p, "Invalid debug option\n");
|
|
|
|
break;
|
|
|
|
}
|
2005-08-04 22:44:28 -06:00
|
|
|
|
|
|
|
end:
|
2005-04-16 16:20:36 -06:00
|
|
|
size = (p - page);
|
2005-08-04 22:44:28 -06:00
|
|
|
if (size <= off + count)
|
|
|
|
*eof = 1;
|
2005-04-16 16:20:36 -06:00
|
|
|
*start = page + off;
|
|
|
|
size -= off;
|
2005-08-04 22:44:28 -06:00
|
|
|
if (size > count)
|
|
|
|
size = count;
|
|
|
|
if (size < 0)
|
|
|
|
size = 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_system_write_debug(struct file *file,
|
|
|
|
const char __user * buffer,
|
|
|
|
unsigned long count, void *data)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
char debug_string[12] = { '\0' };
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
|
|
|
|
if (count > sizeof(debug_string) - 1)
|
2006-06-26 22:41:40 -06:00
|
|
|
return -EINVAL;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if (copy_from_user(debug_string, buffer, count))
|
2006-06-26 22:41:40 -06:00
|
|
|
return -EFAULT;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
debug_string[count] = '\0';
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
switch ((unsigned long)data) {
|
2005-04-16 16:20:36 -06:00
|
|
|
case 0:
|
|
|
|
acpi_dbg_layer = simple_strtoul(debug_string, NULL, 0);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
acpi_dbg_level = simple_strtoul(debug_string, NULL, 0);
|
|
|
|
break;
|
|
|
|
default:
|
2006-06-26 22:41:40 -06:00
|
|
|
return -EINVAL;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2006-06-26 22:41:40 -06:00
|
|
|
return count;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static int __init acpi_debug_init(void)
|
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
struct proc_dir_entry *entry;
|
2005-04-16 16:20:36 -06:00
|
|
|
int error = 0;
|
2005-08-04 22:44:28 -06:00
|
|
|
char *name;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
|
|
|
|
if (acpi_disabled)
|
2006-06-26 22:41:40 -06:00
|
|
|
return 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* 'debug_layer' [R/W] */
|
|
|
|
name = ACPI_SYSTEM_FILE_DEBUG_LAYER;
|
2005-08-04 22:44:28 -06:00
|
|
|
entry =
|
|
|
|
create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR,
|
|
|
|
acpi_root_dir, acpi_system_read_debug,
|
|
|
|
(void *)0);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (entry)
|
|
|
|
entry->write_proc = acpi_system_write_debug;
|
|
|
|
else
|
|
|
|
goto Error;
|
|
|
|
|
|
|
|
/* 'debug_level' [R/W] */
|
|
|
|
name = ACPI_SYSTEM_FILE_DEBUG_LEVEL;
|
2005-08-04 22:44:28 -06:00
|
|
|
entry =
|
|
|
|
create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR,
|
|
|
|
acpi_root_dir, acpi_system_read_debug,
|
|
|
|
(void *)1);
|
|
|
|
if (entry)
|
2005-04-16 16:20:36 -06:00
|
|
|
entry->write_proc = acpi_system_write_debug;
|
|
|
|
else
|
|
|
|
goto Error;
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
Done:
|
2006-06-26 22:41:40 -06:00
|
|
|
return error;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
Error:
|
2005-04-16 16:20:36 -06:00
|
|
|
remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL, acpi_root_dir);
|
|
|
|
remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER, acpi_root_dir);
|
2006-06-26 21:58:43 -06:00
|
|
|
error = -ENODEV;
|
2005-04-16 16:20:36 -06:00
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
|
|
|
subsys_initcall(acpi_debug_init);
|