From: Len Brown <len.brown@intel.com>
To: linux-acpi@vger.kernel.org
Cc: Zhang Rui <rui.zhang@intel.com>, Len Brown <len.brown@intel.com>
Subject: [PATCH 77/77] ACPI: Populate /sys/firmware/acpi/tables/
Date: Sun, 22 Jul 2007 05:15:02 -0400 [thread overview]
Message-ID: <11850957822419-git-send-email-len.brown@intel.com> (raw)
Message-ID: <d4c5f047ae2a33296774e41abc2ac5c89283f736.1185095456.git.len.brown@intel.com> (raw)
In-Reply-To: <11850957811573-git-send-email-len.brown@intel.com>
In-Reply-To: <a1f0eff21edac1bd87e397f56c4258b9611b5a50.1185095456.git.len.brown@intel.com>
From: Zhang Rui <rui.zhang@intel.com>
The file name is the signature, such as DSDT,
and the contents are the binary table image.
Some tables, such as the SSDT, can have multiple instances.
If just one, the file is SSDT, but if 3 instances,
for example, it will be SSDT1, SSDT2, SSDT3
All static tables (besides teh RSDP and RSDT themselves
are exported. Dynamic tables, such as SSDT op-regions that
are not declared in the RSDT, will be added in a subsequent patch.
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
---
drivers/acpi/system.c | 165 ++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 144 insertions(+), 21 deletions(-)
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index 83a8d30..edee280 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -39,15 +39,12 @@ ACPI_MODULE_NAME("system");
#define ACPI_SYSTEM_CLASS "system"
#define ACPI_SYSTEM_DEVICE_NAME "System"
-#define ACPI_SYSTEM_FILE_INFO "info"
-#define ACPI_SYSTEM_FILE_EVENT "event"
-#define ACPI_SYSTEM_FILE_DSDT "dsdt"
-#define ACPI_SYSTEM_FILE_FADT "fadt"
/*
* Make ACPICA version work as module param
*/
-static int param_get_acpica_version(char *buffer, struct kernel_param *kp) {
+static int param_get_acpica_version(char *buffer, struct kernel_param *kp)
+{
int result;
result = sprintf(buffer, "%x", ACPI_CA_VERSION);
@@ -58,9 +55,126 @@ static int param_get_acpica_version(char *buffer, struct kernel_param *kp) {
module_param_call(acpica_version, NULL, param_get_acpica_version, NULL, 0444);
/* --------------------------------------------------------------------------
+ FS Interface (/sys)
+ -------------------------------------------------------------------------- */
+static LIST_HEAD(acpi_table_attr_list);
+static struct kobject tables_kobj;
+
+struct acpi_table_attr {
+ struct bin_attribute attr;
+ char name[8];
+ int instance;
+ struct list_head node;
+};
+
+static ssize_t acpi_table_show(struct kobject *kobj,
+ struct bin_attribute *bin_attr, char *buf,
+ loff_t offset, size_t count)
+{
+ struct acpi_table_attr *table_attr =
+ container_of(bin_attr, struct acpi_table_attr, attr);
+ struct acpi_table_header *table_header = NULL;
+ acpi_status status;
+ ssize_t ret_count = count;
+
+ status =
+ acpi_get_table(table_attr->name, table_attr->instance,
+ &table_header);
+ if (ACPI_FAILURE(status))
+ return -ENODEV;
+
+ if (offset >= table_header->length) {
+ ret_count = 0;
+ goto end;
+ }
+
+ if (offset + ret_count > table_header->length)
+ ret_count = table_header->length - offset;
+
+ memcpy(buf, ((char *)table_header) + offset, ret_count);
+
+ end:
+ return ret_count;
+}
+
+static void acpi_table_attr_init(struct acpi_table_attr *table_attr,
+ struct acpi_table_header *table_header)
+{
+ struct acpi_table_header *header = NULL;
+ struct acpi_table_attr *attr = NULL;
+
+ memcpy(table_attr->name, table_header->signature, ACPI_NAME_SIZE);
+
+ list_for_each_entry(attr, &acpi_table_attr_list, node) {
+ if (!memcmp(table_header->signature, attr->name,
+ ACPI_NAME_SIZE))
+ if (table_attr->instance < attr->instance)
+ table_attr->instance = attr->instance;
+ }
+ table_attr->instance++;
+
+ if (table_attr->instance > 1 || (table_attr->instance == 1 &&
+ !acpi_get_table(table_header->
+ signature, 2,
+ &header)))
+ sprintf(table_attr->name + 4, "%d", table_attr->instance);
+
+ table_attr->attr.size = 0;
+ table_attr->attr.read = acpi_table_show;
+ table_attr->attr.attr.name = table_attr->name;
+ table_attr->attr.attr.mode = 0444;
+ table_attr->attr.attr.owner = THIS_MODULE;
+
+ return;
+}
+
+static int acpi_system_sysfs_init(void)
+{
+ struct acpi_table_attr *table_attr;
+ struct acpi_table_header *table_header = NULL;
+ int table_index = 0;
+ int result;
+
+ tables_kobj.parent = &acpi_subsys.kobj;
+ kobject_set_name(&tables_kobj, "tables");
+ result = kobject_register(&tables_kobj);
+ if (result)
+ return result;
+
+ do {
+ result = acpi_get_table_by_index(table_index, &table_header);
+ if (!result) {
+ table_index++;
+ table_attr = NULL;
+ table_attr =
+ kzalloc(sizeof(struct acpi_table_attr), GFP_KERNEL);
+ if (!table_attr)
+ return -ENOMEM;
+
+ acpi_table_attr_init(table_attr, table_header);
+ result =
+ sysfs_create_bin_file(&tables_kobj,
+ &table_attr->attr);
+ if (result) {
+ kfree(table_attr);
+ return result;
+ } else
+ list_add_tail(&table_attr->node,
+ &acpi_table_attr_list);
+ }
+ } while (!result);
+
+ return 0;
+}
+
+/* --------------------------------------------------------------------------
FS Interface (/proc)
-------------------------------------------------------------------------- */
#ifdef CONFIG_ACPI_PROCFS
+#define ACPI_SYSTEM_FILE_INFO "info"
+#define ACPI_SYSTEM_FILE_EVENT "event"
+#define ACPI_SYSTEM_FILE_DSDT "dsdt"
+#define ACPI_SYSTEM_FILE_FADT "fadt"
static int acpi_system_read_info(struct seq_file *seq, void *offset)
{
@@ -80,7 +194,6 @@ static const struct file_operations acpi_system_info_ops = {
.llseek = seq_lseek,
.release = single_release,
};
-#endif
static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t,
loff_t *);
@@ -97,13 +210,11 @@ acpi_system_read_dsdt(struct file *file,
struct acpi_table_header *dsdt = NULL;
ssize_t res;
-
status = acpi_get_table(ACPI_SIG_DSDT, 1, &dsdt);
if (ACPI_FAILURE(status))
return -ENODEV;
- res = simple_read_from_buffer(buffer, count, ppos,
- dsdt, dsdt->length);
+ res = simple_read_from_buffer(buffer, count, ppos, dsdt, dsdt->length);
return res;
}
@@ -123,28 +234,21 @@ acpi_system_read_fadt(struct file *file,
struct acpi_table_header *fadt = NULL;
ssize_t res;
-
status = acpi_get_table(ACPI_SIG_FADT, 1, &fadt);
if (ACPI_FAILURE(status))
return -ENODEV;
- res = simple_read_from_buffer(buffer, count, ppos,
- fadt, fadt->length);
+ res = simple_read_from_buffer(buffer, count, ppos, fadt, fadt->length);
return res;
}
-static int __init acpi_system_init(void)
+static int acpi_system_procfs_init(void)
{
struct proc_dir_entry *entry;
int error = 0;
char *name;
-
- if (acpi_disabled)
- return 0;
-
-#ifdef CONFIG_ACPI_PROCFS
/* 'info' [R] */
name = ACPI_SYSTEM_FILE_INFO;
entry = create_proc_entry(name, S_IRUGO, acpi_root_dir);
@@ -153,7 +257,6 @@ static int __init acpi_system_init(void)
else {
entry->proc_fops = &acpi_system_info_ops;
}
-#endif
/* 'dsdt' [R] */
name = ACPI_SYSTEM_FILE_DSDT;
@@ -177,12 +280,32 @@ static int __init acpi_system_init(void)
Error:
remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir);
remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir);
-#ifdef CONFIG_ACPI_PROCFS
remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_root_dir);
-#endif
error = -EFAULT;
goto Done;
}
+#else
+static int acpi_system_procfs_init(void)
+{
+ return 0;
+}
+#endif
+
+static int __init acpi_system_init(void)
+{
+ int result = 0;
+
+ if (acpi_disabled)
+ return 0;
+
+ result = acpi_system_procfs_init();
+ if (result)
+ return result;
+
+ result = acpi_system_sysfs_init();
+
+ return result;
+}
subsys_initcall(acpi_system_init);
--
1.5.3.rc2.22.g69a9b
next prev parent reply other threads:[~2007-07-22 9:16 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-22 9:13 ACPI patches for 2.6.23 Len Brown
2007-07-22 9:13 ` [PATCH 01/77] ACPI: battery: make internal names consistent with battery "state" Len Brown
2007-07-22 9:13 ` Len Brown
2007-07-22 9:13 ` [PATCH 02/77] ACPI: Cache battery status instead of re-evaluating AML Len Brown
2007-07-22 9:13 ` Len Brown
2007-07-22 9:13 ` [PATCH 03/77] ACPI: battery: Lindent Len Brown
2007-07-22 9:13 ` Len Brown
2007-07-22 9:13 ` [PATCH 04/77] process reading battery status hangs Len Brown
2007-07-22 9:13 ` Len Brown
2007-07-22 9:13 ` [PATCH 05/77] ACPI: video: output switch sysfs support Len Brown
2007-07-22 9:13 ` Len Brown
2007-07-22 9:13 ` [PATCH 06/77] ACPI: dock: cleanup the uid patch Len Brown
2007-07-22 9:13 ` Len Brown
2007-07-22 9:13 ` [PATCH 07/77] ACPI: dock: fix opps after dock driver fails to initialize Len Brown
2007-07-22 9:13 ` Len Brown
2007-07-22 9:13 ` [PATCH 08/77] ACPI: dock: use dynamically allocated platform device Len Brown
2007-07-22 9:13 ` Len Brown
2007-07-22 9:13 ` [PATCH 09/77] ACPI: dock: add immediate_undock option Len Brown
2007-07-22 9:13 ` Len Brown
2007-07-22 9:13 ` [PATCH 10/77] ACPI: dock: unsuppress uevents Len Brown
2007-07-22 9:13 ` Len Brown
2007-07-22 9:13 ` [PATCH 11/77] ACPI: dock: send envp with uevent Len Brown
2007-07-22 9:13 ` Len Brown
2007-07-22 9:13 ` [PATCH 12/77] ACPI: bay: unsuppress uevents Len Brown
2007-07-22 9:13 ` Len Brown
2007-07-22 9:13 ` [PATCH 13/77] ACPI: battery: syntax cleanup Len Brown
2007-07-22 9:13 ` Len Brown
2007-07-22 9:13 ` [PATCH 14/77] ACPI: add ACPI 3.0 _TPC _TSS _PTC throttling support Len Brown
2007-07-22 9:13 ` Len Brown
2007-07-22 9:14 ` [PATCH 15/77] ACPI: Lindent processor throttling code Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 16/77] ACPI: bay: send envp with uevent Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 17/77] ACPI: Remove Dell Optiplex GX240 from the ACPI blacklist Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 18/77] ACPI: disable _OSI(Linux) by default Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 19/77] ACPI: Discard invalid elements in _PSS package Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 20/77] ACPI: asus_acpi: Do not load if no device has been found Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 21/77] ACPI: update MAINTAINERS for EC and battery Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 22/77] ACPI EC: Re-factor EC space handler to avoid using label/goto for cycle Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 23/77] ACPI EC: drop usage of ACPI_DEBUG_PRINT as too heavy weight Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 24/77] ACPI EC: Add support for non-AML EC query handlers Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 25/77] ACPI: sbs: probe smart battery vis SMBus controller Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 26/77] ACPI: static Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 27/77] " Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 28/77] ACPI: delete cmdline documentation for deleted hotkey code Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 29/77] ACPI video: Don't export sysfs backlight interface if query _BCL fail Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 30/77] ACPI: Use menuconfig objects Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 32/77] ACPICA: Update _OSI string list Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 33/77] ACPICA: Changes for Cygwin compatibility Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 34/77] ACPICA: Fixed possible corruption of global GPE list Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 35/77] ACPICA: Clear reserved fields for incoming ACPI 1.0 FADTs Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 36/77] ACPI: Export events via generic netlink Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 37/77] ACPI: netlink: remove unnecessary EXPORT_SYMBOL Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 38/77] ACPI: dock: fix oops when _DCK evaluation fails Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 39/77] ACPICA: fix memory leak in acpi_ev_pci_config_region_setup() error path Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 40/77] ACPI: Enable C3 even when PM2_control is zero Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 41/77] ACPI: thinkpad-acpi: add DMI-based modalias Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 42/77] ACPI: thinkpad-acpi: remove all uneeded initializers Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 43/77] ACPI: thinkpad-acpi: update information on T43 thermal sensor 0xc1 Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 44/77] ACPI: thinkpad-acpi: enable more hotkeys Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 45/77] ACPI: thinkpad-acpi: export hotkey maximum masks Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 46/77] ACPI: thinkpad-acpi: export to sysfs the state of the radio slider switch Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 47/77] ACPI: thinkpad-acpi: checkpoint sysfs interface version due to hotkey Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 48/77] ACPI: thinkpad-acpi: update CMOS commands documentation Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 49/77] ACPI: thinkpad-acpi: register input device Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 50/77] ACPI: thinkpad-acpi: add input device support to hotkey subdriver Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 51/77] ACPI: thinkpad-acpi: make the input event mode the default Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 52/77] ACPI: thinkpad-acpi: add power-management handler capability Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 53/77] ACPI: thinkpad-acpi: export EV_SW SW_RADIO events Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 54/77] ACPI: thinkpad-acpi: checkpoint sysfs interface version due to input layer Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 55/77] ACPI: thinkpad-acpi: rename pci HID constant Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 56/77] ACPI: thinkpad_acpi: use bool for boolean parameters Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 57/77] ACPI: thinkpad-acpi: store ThinkPad model information Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 58/77] ACPI: thinkpad-acpi: allow use of CMOS NVRAM for brightness control Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 59/77] ACPI: thinkpad-acpi: react to Lenovo ThinkPad differences in hot key Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 60/77] ACPI: thinkpad-acpi: make sure DSDT TMPx readings don't return +128 Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 61/77] ACPI: thinkpad-acpi: make EC-based thermal readings non-experimental Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 62/77] ACPI: thinkpad-acpi: bump up version to 0.15 Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 63/77] ACPI: thinkpad-acpi: add locking to brightness subdriver Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 64/77] sony-laptop: add new SNC handlers Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 65/77] sony-laptop: map wireless switch events to KEY_WLAN Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 66/77] sony-laptop: Add support for recent Vaios Fn keys (C series for now) Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 67/77] sony-laptop: Invoke _INI for SNC devices that provide it Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 68/77] sony-laptop: Make the driver use MSC_SCAN and a setkeycode and getkeycode key table Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 69/77] sony-laptop: Add Vaio FE to the special init sequence Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 70/77] sony-laptop: Fix event reading in sony-laptop Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 71/77] ACPI: drivers/acpi/pci_link.c: lower printk severity Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 72/77] ACPI: fix empty macros found by -Wextra Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 73/77] ACPI: export ACPI events via acpi_mc_group multicast group Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:14 ` [PATCH 74/77] ACPI: update feature-removal-schedule.txt, /sys/firmware/acpi/namespace is gone Len Brown
2007-07-22 9:14 ` Len Brown
2007-07-22 9:15 ` [PATCH 75/77] ACPI: update ACPI proc I/F removal schedule Len Brown
2007-07-22 9:15 ` Len Brown
2007-07-22 9:15 ` [PATCH 76/77] ACPI: create CONFIG_ACPI_DEBUG_FUNC_TRACE Len Brown
2007-07-22 9:15 ` Len Brown
2007-07-22 9:15 ` Len Brown [this message]
2007-07-22 9:15 ` [PATCH 77/77] ACPI: Populate /sys/firmware/acpi/tables/ Len Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11850957822419-git-send-email-len.brown@intel.com \
--to=len.brown@intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.