aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLv Zheng <lv.zheng@intel.com>2015-12-03 10:43:14 +0800
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-12-15 00:17:44 +0100
commit836d0830188a97d5c73e8eb514f346a857c086b9 (patch)
treec2eb9b87cdf6a5096e8d3bf2d1418717b2023a10 /include
parenttools/power/acpi: Add userspace AML interface support (diff)
downloadlinux-dev-836d0830188a97d5c73e8eb514f346a857c086b9.tar.xz
linux-dev-836d0830188a97d5c73e8eb514f346a857c086b9.zip
ACPI / debugger: Add module support for ACPI debugger
This patch converts AML debugger into a loadable module. Note that, it implements driver unloading at the level dependent on the module reference count. Which means if ACPI debugger is being used by a userspace program, "rmmod acpi_dbg" should result in failure. Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/acpi.h71
-rw-r--r--include/linux/acpi_dbg.h52
2 files changed, 71 insertions, 52 deletions
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 1991aea2ec4c..a03a05474527 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -37,6 +37,8 @@
#include <linux/list.h>
#include <linux/mod_devicetable.h>
#include <linux/dynamic_debug.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
@@ -119,6 +121,75 @@ typedef int (*acpi_tbl_table_handler)(struct acpi_table_header *table);
typedef int (*acpi_tbl_entry_handler)(struct acpi_subtable_header *header,
const unsigned long end);
+/* Debugger support */
+
+struct acpi_debugger_ops {
+ int (*create_thread)(acpi_osd_exec_callback function, void *context);
+ ssize_t (*write_log)(const char *msg);
+ ssize_t (*read_cmd)(char *buffer, size_t length);
+ int (*wait_command_ready)(bool single_step, char *buffer, size_t length);
+ int (*notify_command_complete)(void);
+};
+
+struct acpi_debugger {
+ const struct acpi_debugger_ops *ops;
+ struct module *owner;
+ struct mutex lock;
+};
+
+#ifdef CONFIG_ACPI_DEBUGGER
+int __init acpi_debugger_init(void);
+int acpi_register_debugger(struct module *owner,
+ const struct acpi_debugger_ops *ops);
+void acpi_unregister_debugger(const struct acpi_debugger_ops *ops);
+int acpi_debugger_create_thread(acpi_osd_exec_callback function, void *context);
+ssize_t acpi_debugger_write_log(const char *msg);
+ssize_t acpi_debugger_read_cmd(char *buffer, size_t buffer_length);
+int acpi_debugger_wait_command_ready(void);
+int acpi_debugger_notify_command_complete(void);
+#else
+static inline int acpi_debugger_init(void)
+{
+ return -ENODEV;
+}
+
+static inline int acpi_register_debugger(struct module *owner,
+ const struct acpi_debugger_ops *ops)
+{
+ return -ENODEV;
+}
+
+static inline void acpi_unregister_debugger(const struct acpi_debugger_ops *ops)
+{
+}
+
+static inline int acpi_debugger_create_thread(acpi_osd_exec_callback function,
+ void *context)
+{
+ return -ENODEV;
+}
+
+static inline int acpi_debugger_write_log(const char *msg)
+{
+ return -ENODEV;
+}
+
+static inline int acpi_debugger_read_cmd(char *buffer, u32 buffer_length)
+{
+ return -ENODEV;
+}
+
+static inline int acpi_debugger_wait_command_ready(void)
+{
+ return -ENODEV;
+}
+
+static inline int acpi_debugger_notify_command_complete(void)
+{
+ return -ENODEV;
+}
+#endif
+
#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
void acpi_initrd_override(void *data, size_t size);
#else
diff --git a/include/linux/acpi_dbg.h b/include/linux/acpi_dbg.h
deleted file mode 100644
index 60f3887ed816..000000000000
--- a/include/linux/acpi_dbg.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * ACPI AML interfacing support
- *
- * Copyright (C) 2015, Intel Corporation
- * Authors: Lv Zheng <lv.zheng@intel.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#ifndef _LINUX_ACPI_DBG_H
-#define _LINUX_ACPI_DBG_H
-
-#include <linux/acpi.h>
-
-#ifdef CONFIG_ACPI_DEBUGGER
-int __init acpi_aml_init(void);
-int acpi_aml_create_thread(acpi_osd_exec_callback function, void *context);
-ssize_t acpi_aml_write_log(const char *msg);
-ssize_t acpi_aml_read_cmd(char *buffer, size_t buffer_length);
-int acpi_aml_wait_command_ready(void);
-int acpi_aml_notify_command_complete(void);
-#else
-static int inline acpi_aml_init(void)
-{
- return 0;
-}
-static inline int acpi_aml_create_thread(acpi_osd_exec_callback function,
- void *context)
-{
- return -ENODEV;
-}
-static inline int acpi_aml_write_log(const char *msg)
-{
- return -ENODEV;
-}
-static inline int acpi_aml_read_cmd(char *buffer, u32 buffer_length)
-{
- return -ENODEV;
-}
-static inline int acpi_aml_wait_command_ready(void)
-{
- return -ENODEV;
-}
-static inline int acpi_aml_notify_command_complete(void)
-{
- return -ENODEV;
-}
-#endif
-
-#endif /* _LINUX_ACPI_DBG_H */