diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/acpi/system.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/acpi/system.c')
-rw-r--r-- | drivers/acpi/system.c | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c new file mode 100644 index 000000000000..8925a6ca5f87 --- /dev/null +++ b/drivers/acpi/system.c | |||
@@ -0,0 +1,187 @@ | |||
1 | /* | ||
2 | * acpi_system.c - ACPI System Driver ($Revision: 63 $) | ||
3 | * | ||
4 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> | ||
5 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> | ||
6 | * | ||
7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
8 | * | ||
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. | ||
13 | * | ||
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. | ||
18 | * | ||
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. | ||
22 | * | ||
23 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
24 | */ | ||
25 | |||
26 | #include <linux/proc_fs.h> | ||
27 | #include <linux/seq_file.h> | ||
28 | #include <linux/init.h> | ||
29 | #include <asm/uaccess.h> | ||
30 | |||
31 | #include <acpi/acpi_drivers.h> | ||
32 | |||
33 | |||
34 | #define _COMPONENT ACPI_SYSTEM_COMPONENT | ||
35 | ACPI_MODULE_NAME ("acpi_system") | ||
36 | |||
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" | ||
44 | |||
45 | extern FADT_DESCRIPTOR acpi_fadt; | ||
46 | |||
47 | /* -------------------------------------------------------------------------- | ||
48 | FS Interface (/proc) | ||
49 | -------------------------------------------------------------------------- */ | ||
50 | |||
51 | static int | ||
52 | acpi_system_read_info (struct seq_file *seq, void *offset) | ||
53 | { | ||
54 | ACPI_FUNCTION_TRACE("acpi_system_read_info"); | ||
55 | |||
56 | seq_printf(seq, "version: %x\n", ACPI_CA_VERSION); | ||
57 | return_VALUE(0); | ||
58 | } | ||
59 | |||
60 | static int acpi_system_info_open_fs(struct inode *inode, struct file *file) | ||
61 | { | ||
62 | return single_open(file, acpi_system_read_info, PDE(inode)->data); | ||
63 | } | ||
64 | |||
65 | static struct file_operations acpi_system_info_ops = { | ||
66 | .open = acpi_system_info_open_fs, | ||
67 | .read = seq_read, | ||
68 | .llseek = seq_lseek, | ||
69 | .release = single_release, | ||
70 | }; | ||
71 | |||
72 | static ssize_t acpi_system_read_dsdt (struct file*, char __user *, size_t, loff_t*); | ||
73 | |||
74 | static struct file_operations acpi_system_dsdt_ops = { | ||
75 | .read = acpi_system_read_dsdt, | ||
76 | }; | ||
77 | |||
78 | static ssize_t | ||
79 | acpi_system_read_dsdt ( | ||
80 | struct file *file, | ||
81 | char __user *buffer, | ||
82 | size_t count, | ||
83 | loff_t *ppos) | ||
84 | { | ||
85 | acpi_status status = AE_OK; | ||
86 | struct acpi_buffer dsdt = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
87 | ssize_t res; | ||
88 | |||
89 | ACPI_FUNCTION_TRACE("acpi_system_read_dsdt"); | ||
90 | |||
91 | status = acpi_get_table(ACPI_TABLE_DSDT, 1, &dsdt); | ||
92 | if (ACPI_FAILURE(status)) | ||
93 | return_VALUE(-ENODEV); | ||
94 | |||
95 | res = simple_read_from_buffer(buffer, count, ppos, | ||
96 | dsdt.pointer, dsdt.length); | ||
97 | acpi_os_free(dsdt.pointer); | ||
98 | |||
99 | return_VALUE(res); | ||
100 | } | ||
101 | |||
102 | |||
103 | static ssize_t acpi_system_read_fadt (struct file*, char __user *, size_t, loff_t*); | ||
104 | |||
105 | static struct file_operations acpi_system_fadt_ops = { | ||
106 | .read = acpi_system_read_fadt, | ||
107 | }; | ||
108 | |||
109 | static ssize_t | ||
110 | acpi_system_read_fadt ( | ||
111 | struct file *file, | ||
112 | char __user *buffer, | ||
113 | size_t count, | ||
114 | loff_t *ppos) | ||
115 | { | ||
116 | acpi_status status = AE_OK; | ||
117 | struct acpi_buffer fadt = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
118 | ssize_t res; | ||
119 | |||
120 | ACPI_FUNCTION_TRACE("acpi_system_read_fadt"); | ||
121 | |||
122 | status = acpi_get_table(ACPI_TABLE_FADT, 1, &fadt); | ||
123 | if (ACPI_FAILURE(status)) | ||
124 | return_VALUE(-ENODEV); | ||
125 | |||
126 | res = simple_read_from_buffer(buffer, count, ppos, | ||
127 | fadt.pointer, fadt.length); | ||
128 | acpi_os_free(fadt.pointer); | ||
129 | |||
130 | return_VALUE(res); | ||
131 | } | ||
132 | |||
133 | |||
134 | static int __init acpi_system_init (void) | ||
135 | { | ||
136 | struct proc_dir_entry *entry; | ||
137 | int error = 0; | ||
138 | char * name; | ||
139 | |||
140 | ACPI_FUNCTION_TRACE("acpi_system_init"); | ||
141 | |||
142 | if (acpi_disabled) | ||
143 | return_VALUE(0); | ||
144 | |||
145 | /* 'info' [R] */ | ||
146 | name = ACPI_SYSTEM_FILE_INFO; | ||
147 | entry = create_proc_entry(name, | ||
148 | S_IRUGO, acpi_root_dir); | ||
149 | if (!entry) | ||
150 | goto Error; | ||
151 | else { | ||
152 | entry->proc_fops = &acpi_system_info_ops; | ||
153 | } | ||
154 | |||
155 | /* 'dsdt' [R] */ | ||
156 | name = ACPI_SYSTEM_FILE_DSDT; | ||
157 | entry = create_proc_entry(name, S_IRUSR, acpi_root_dir); | ||
158 | if (entry) | ||
159 | entry->proc_fops = &acpi_system_dsdt_ops; | ||
160 | else | ||
161 | goto Error; | ||
162 | |||
163 | /* 'fadt' [R] */ | ||
164 | name = ACPI_SYSTEM_FILE_FADT; | ||
165 | entry = create_proc_entry(name, S_IRUSR, acpi_root_dir); | ||
166 | if (entry) | ||
167 | entry->proc_fops = &acpi_system_fadt_ops; | ||
168 | else | ||
169 | goto Error; | ||
170 | |||
171 | Done: | ||
172 | return_VALUE(error); | ||
173 | |||
174 | Error: | ||
175 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | ||
176 | "Unable to create '%s' proc fs entry\n", name)); | ||
177 | |||
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); | ||
181 | |||
182 | error = -EFAULT; | ||
183 | goto Done; | ||
184 | } | ||
185 | |||
186 | |||
187 | subsys_initcall(acpi_system_init); | ||