2 * acpi_system.c - ACPI System Driver ($Revision: 63 $)
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26 #include <linux/proc_fs.h>
27 #include <linux/seq_file.h>
28 #include <linux/init.h>
29 #include <asm/uaccess.h>
31 #include <acpi/acpi_drivers.h>
34 #define _COMPONENT ACPI_SYSTEM_COMPONENT
35 ACPI_MODULE_NAME ("acpi_system")
37 #define ACPI_SYSTEM_CLASS "system"
38 #define ACPI_SYSTEM_DRIVER_NAME "ACPI System Driver"
39 #define ACPI_SYSTEM_DEVICE_NAME "System"
40 #define ACPI_SYSTEM_FILE_INFO "info"
41 #define ACPI_SYSTEM_FILE_EVENT "event"
42 #define ACPI_SYSTEM_FILE_DSDT "dsdt"
43 #define ACPI_SYSTEM_FILE_FADT "fadt"
45 extern FADT_DESCRIPTOR acpi_fadt
;
47 /* --------------------------------------------------------------------------
49 -------------------------------------------------------------------------- */
52 acpi_system_read_info (struct seq_file
*seq
, void *offset
)
54 ACPI_FUNCTION_TRACE("acpi_system_read_info");
56 seq_printf(seq
, "version: %x\n", ACPI_CA_VERSION
);
60 static int acpi_system_info_open_fs(struct inode
*inode
, struct file
*file
)
62 return single_open(file
, acpi_system_read_info
, PDE(inode
)->data
);
65 static struct file_operations acpi_system_info_ops
= {
66 .open
= acpi_system_info_open_fs
,
69 .release
= single_release
,
72 static ssize_t
acpi_system_read_dsdt (struct file
*, char __user
*, size_t, loff_t
*);
74 static struct file_operations acpi_system_dsdt_ops
= {
75 .read
= acpi_system_read_dsdt
,
79 acpi_system_read_dsdt (
85 acpi_status status
= AE_OK
;
86 struct acpi_buffer dsdt
= {ACPI_ALLOCATE_BUFFER
, NULL
};
89 ACPI_FUNCTION_TRACE("acpi_system_read_dsdt");
91 status
= acpi_get_table(ACPI_TABLE_DSDT
, 1, &dsdt
);
92 if (ACPI_FAILURE(status
))
93 return_VALUE(-ENODEV
);
95 res
= simple_read_from_buffer(buffer
, count
, ppos
,
96 dsdt
.pointer
, dsdt
.length
);
97 acpi_os_free(dsdt
.pointer
);
103 static ssize_t
acpi_system_read_fadt (struct file
*, char __user
*, size_t, loff_t
*);
105 static struct file_operations acpi_system_fadt_ops
= {
106 .read
= acpi_system_read_fadt
,
110 acpi_system_read_fadt (
116 acpi_status status
= AE_OK
;
117 struct acpi_buffer fadt
= {ACPI_ALLOCATE_BUFFER
, NULL
};
120 ACPI_FUNCTION_TRACE("acpi_system_read_fadt");
122 status
= acpi_get_table(ACPI_TABLE_FADT
, 1, &fadt
);
123 if (ACPI_FAILURE(status
))
124 return_VALUE(-ENODEV
);
126 res
= simple_read_from_buffer(buffer
, count
, ppos
,
127 fadt
.pointer
, fadt
.length
);
128 acpi_os_free(fadt
.pointer
);
134 static int __init
acpi_system_init (void)
136 struct proc_dir_entry
*entry
;
140 ACPI_FUNCTION_TRACE("acpi_system_init");
146 name
= ACPI_SYSTEM_FILE_INFO
;
147 entry
= create_proc_entry(name
,
148 S_IRUGO
, acpi_root_dir
);
152 entry
->proc_fops
= &acpi_system_info_ops
;
156 name
= ACPI_SYSTEM_FILE_DSDT
;
157 entry
= create_proc_entry(name
, S_IRUSR
, acpi_root_dir
);
159 entry
->proc_fops
= &acpi_system_dsdt_ops
;
164 name
= ACPI_SYSTEM_FILE_FADT
;
165 entry
= create_proc_entry(name
, S_IRUSR
, acpi_root_dir
);
167 entry
->proc_fops
= &acpi_system_fadt_ops
;
175 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
176 "Unable to create '%s' proc fs entry\n", name
));
178 remove_proc_entry(ACPI_SYSTEM_FILE_FADT
, acpi_root_dir
);
179 remove_proc_entry(ACPI_SYSTEM_FILE_DSDT
, acpi_root_dir
);
180 remove_proc_entry(ACPI_SYSTEM_FILE_INFO
, acpi_root_dir
);
187 subsys_initcall(acpi_system_init
);