diff options
Diffstat (limited to 'drivers/acpi/utilities')
-rw-r--r-- | drivers/acpi/utilities/Makefile | 5 | ||||
-rw-r--r-- | drivers/acpi/utilities/utmisc.c | 148 | ||||
-rw-r--r-- | drivers/acpi/utilities/utresrc.c | 428 | ||||
-rw-r--r-- | drivers/acpi/utilities/utstate.c | 2 | ||||
-rw-r--r-- | drivers/acpi/utilities/utxface.c | 52 |
5 files changed, 470 insertions, 165 deletions
diff --git a/drivers/acpi/utilities/Makefile b/drivers/acpi/utilities/Makefile index e87108b7338a..88eff14c4894 100644 --- a/drivers/acpi/utilities/Makefile +++ b/drivers/acpi/utilities/Makefile | |||
@@ -2,7 +2,8 @@ | |||
2 | # Makefile for all Linux ACPI interpreter subdirectories | 2 | # Makefile for all Linux ACPI interpreter subdirectories |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ | 5 | obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ |
6 | utcopy.o utdelete.o utglobal.o utmath.o utobject.o utstate.o utmutex.o utobject.o utcache.o | 6 | utcopy.o utdelete.o utglobal.o utmath.o utobject.o \ |
7 | utstate.o utmutex.o utobject.o utcache.o utresrc.o | ||
7 | 8 | ||
8 | EXTRA_CFLAGS += $(ACPI_CFLAGS) | 9 | EXTRA_CFLAGS += $(ACPI_CFLAGS) |
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index e9058d4da122..2a9110c06391 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c | |||
@@ -43,7 +43,6 @@ | |||
43 | 43 | ||
44 | #include <acpi/acpi.h> | 44 | #include <acpi/acpi.h> |
45 | #include <acpi/acnamesp.h> | 45 | #include <acpi/acnamesp.h> |
46 | #include <acpi/amlresrc.h> | ||
47 | 46 | ||
48 | #define _COMPONENT ACPI_UTILITIES | 47 | #define _COMPONENT ACPI_UTILITIES |
49 | ACPI_MODULE_NAME("utmisc") | 48 | ACPI_MODULE_NAME("utmisc") |
@@ -791,153 +790,6 @@ u8 acpi_ut_generate_checksum(u8 * buffer, u32 length) | |||
791 | 790 | ||
792 | /******************************************************************************* | 791 | /******************************************************************************* |
793 | * | 792 | * |
794 | * FUNCTION: acpi_ut_get_resource_type | ||
795 | * | ||
796 | * PARAMETERS: Aml - Pointer to the raw AML resource descriptor | ||
797 | * | ||
798 | * RETURN: The Resource Type with no extraneous bits (except the | ||
799 | * Large/Small descriptor bit -- this is left alone) | ||
800 | * | ||
801 | * DESCRIPTION: Extract the Resource Type/Name from the first byte of | ||
802 | * a resource descriptor. | ||
803 | * | ||
804 | ******************************************************************************/ | ||
805 | |||
806 | u8 acpi_ut_get_resource_type(void *aml) | ||
807 | { | ||
808 | ACPI_FUNCTION_ENTRY(); | ||
809 | |||
810 | /* | ||
811 | * Byte 0 contains the descriptor name (Resource Type) | ||
812 | * Determine if this is a small or large resource | ||
813 | */ | ||
814 | if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { | ||
815 | /* Large Resource Type -- bits 6:0 contain the name */ | ||
816 | |||
817 | return (*((u8 *) aml)); | ||
818 | } else { | ||
819 | /* Small Resource Type -- bits 6:3 contain the name */ | ||
820 | |||
821 | return ((u8) (*((u8 *) aml) & ACPI_RESOURCE_NAME_SMALL_MASK)); | ||
822 | } | ||
823 | } | ||
824 | |||
825 | /******************************************************************************* | ||
826 | * | ||
827 | * FUNCTION: acpi_ut_get_resource_length | ||
828 | * | ||
829 | * PARAMETERS: Aml - Pointer to the raw AML resource descriptor | ||
830 | * | ||
831 | * RETURN: Byte Length | ||
832 | * | ||
833 | * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By | ||
834 | * definition, this does not include the size of the descriptor | ||
835 | * header or the length field itself. | ||
836 | * | ||
837 | ******************************************************************************/ | ||
838 | |||
839 | u16 acpi_ut_get_resource_length(void *aml) | ||
840 | { | ||
841 | u16 resource_length; | ||
842 | |||
843 | ACPI_FUNCTION_ENTRY(); | ||
844 | |||
845 | /* | ||
846 | * Byte 0 contains the descriptor name (Resource Type) | ||
847 | * Determine if this is a small or large resource | ||
848 | */ | ||
849 | if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { | ||
850 | /* Large Resource type -- bytes 1-2 contain the 16-bit length */ | ||
851 | |||
852 | ACPI_MOVE_16_TO_16(&resource_length, &((u8 *) aml)[1]); | ||
853 | |||
854 | } else { | ||
855 | /* Small Resource type -- bits 2:0 of byte 0 contain the length */ | ||
856 | |||
857 | resource_length = (u16) (*((u8 *) aml) & | ||
858 | ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); | ||
859 | } | ||
860 | |||
861 | return (resource_length); | ||
862 | } | ||
863 | |||
864 | /******************************************************************************* | ||
865 | * | ||
866 | * FUNCTION: acpi_ut_get_descriptor_length | ||
867 | * | ||
868 | * PARAMETERS: Aml - Pointer to the raw AML resource descriptor | ||
869 | * | ||
870 | * RETURN: Byte length | ||
871 | * | ||
872 | * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the | ||
873 | * length of the descriptor header and the length field itself. | ||
874 | * Used to walk descriptor lists. | ||
875 | * | ||
876 | ******************************************************************************/ | ||
877 | |||
878 | u32 acpi_ut_get_descriptor_length(void *aml) | ||
879 | { | ||
880 | u32 descriptor_length; | ||
881 | |||
882 | ACPI_FUNCTION_ENTRY(); | ||
883 | |||
884 | /* First get the Resource Length (Does not include header length) */ | ||
885 | |||
886 | descriptor_length = acpi_ut_get_resource_length(aml); | ||
887 | |||
888 | /* Determine if this is a small or large resource */ | ||
889 | |||
890 | if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { | ||
891 | descriptor_length += sizeof(struct aml_resource_large_header); | ||
892 | } else { | ||
893 | descriptor_length += sizeof(struct aml_resource_small_header); | ||
894 | } | ||
895 | |||
896 | return (descriptor_length); | ||
897 | } | ||
898 | |||
899 | /******************************************************************************* | ||
900 | * | ||
901 | * FUNCTION: acpi_ut_get_resource_end_tag | ||
902 | * | ||
903 | * PARAMETERS: obj_desc - The resource template buffer object | ||
904 | * | ||
905 | * RETURN: Pointer to the end tag | ||
906 | * | ||
907 | * DESCRIPTION: Find the END_TAG resource descriptor in an AML resource template | ||
908 | * | ||
909 | ******************************************************************************/ | ||
910 | |||
911 | u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc) | ||
912 | { | ||
913 | u8 *aml; | ||
914 | u8 *end_aml; | ||
915 | |||
916 | aml = obj_desc->buffer.pointer; | ||
917 | end_aml = aml + obj_desc->buffer.length; | ||
918 | |||
919 | /* Walk the resource template, one descriptor per loop */ | ||
920 | |||
921 | while (aml < end_aml) { | ||
922 | if (acpi_ut_get_resource_type(aml) == | ||
923 | ACPI_RESOURCE_NAME_END_TAG) { | ||
924 | /* Found the end_tag descriptor, all done */ | ||
925 | |||
926 | return (aml); | ||
927 | } | ||
928 | |||
929 | /* Point to the next resource descriptor */ | ||
930 | |||
931 | aml += acpi_ut_get_resource_length(aml); | ||
932 | } | ||
933 | |||
934 | /* End tag was not found */ | ||
935 | |||
936 | return (NULL); | ||
937 | } | ||
938 | |||
939 | /******************************************************************************* | ||
940 | * | ||
941 | * FUNCTION: acpi_ut_report_error | 793 | * FUNCTION: acpi_ut_report_error |
942 | * | 794 | * |
943 | * PARAMETERS: module_name - Caller's module name (for error output) | 795 | * PARAMETERS: module_name - Caller's module name (for error output) |
diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/utilities/utresrc.c new file mode 100644 index 000000000000..07a314c710d8 --- /dev/null +++ b/drivers/acpi/utilities/utresrc.c | |||
@@ -0,0 +1,428 @@ | |||
1 | /******************************************************************************* | ||
2 | * | ||
3 | * Module Name: utresrc - Resource managment utilities | ||
4 | * | ||
5 | ******************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2005, R. Byron Moore | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * 1. Redistributions of source code must retain the above copyright | ||
15 | * notice, this list of conditions, and the following disclaimer, | ||
16 | * without modification. | ||
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
18 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
19 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
20 | * including a substantially similar Disclaimer requirement for further | ||
21 | * binary redistribution. | ||
22 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
23 | * of any contributors may be used to endorse or promote products derived | ||
24 | * from this software without specific prior written permission. | ||
25 | * | ||
26 | * Alternatively, this software may be distributed under the terms of the | ||
27 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
28 | * Software Foundation. | ||
29 | * | ||
30 | * NO WARRANTY | ||
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
41 | * POSSIBILITY OF SUCH DAMAGES. | ||
42 | */ | ||
43 | |||
44 | #include <acpi/acpi.h> | ||
45 | #include <acpi/amlresrc.h> | ||
46 | |||
47 | #define _COMPONENT ACPI_UTILITIES | ||
48 | ACPI_MODULE_NAME("utmisc") | ||
49 | |||
50 | /* | ||
51 | * Base sizes of the raw AML resource descriptors, indexed by resource type. | ||
52 | * Zero indicates a reserved (and therefore invalid) resource type. | ||
53 | */ | ||
54 | const u8 acpi_gbl_resource_aml_sizes[] = { | ||
55 | /* Small descriptors */ | ||
56 | |||
57 | 0, | ||
58 | 0, | ||
59 | 0, | ||
60 | 0, | ||
61 | ACPI_AML_SIZE_SMALL(struct aml_resource_irq), | ||
62 | ACPI_AML_SIZE_SMALL(struct aml_resource_dma), | ||
63 | ACPI_AML_SIZE_SMALL(struct aml_resource_start_dependent), | ||
64 | ACPI_AML_SIZE_SMALL(struct aml_resource_end_dependent), | ||
65 | ACPI_AML_SIZE_SMALL(struct aml_resource_io), | ||
66 | ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_io), | ||
67 | 0, | ||
68 | 0, | ||
69 | 0, | ||
70 | 0, | ||
71 | ACPI_AML_SIZE_SMALL(struct aml_resource_vendor_small), | ||
72 | ACPI_AML_SIZE_SMALL(struct aml_resource_end_tag), | ||
73 | |||
74 | /* Large descriptors */ | ||
75 | |||
76 | 0, | ||
77 | ACPI_AML_SIZE_LARGE(struct aml_resource_memory24), | ||
78 | ACPI_AML_SIZE_LARGE(struct aml_resource_generic_register), | ||
79 | 0, | ||
80 | ACPI_AML_SIZE_LARGE(struct aml_resource_vendor_large), | ||
81 | ACPI_AML_SIZE_LARGE(struct aml_resource_memory32), | ||
82 | ACPI_AML_SIZE_LARGE(struct aml_resource_fixed_memory32), | ||
83 | ACPI_AML_SIZE_LARGE(struct aml_resource_address32), | ||
84 | ACPI_AML_SIZE_LARGE(struct aml_resource_address16), | ||
85 | ACPI_AML_SIZE_LARGE(struct aml_resource_extended_irq), | ||
86 | ACPI_AML_SIZE_LARGE(struct aml_resource_address64), | ||
87 | ACPI_AML_SIZE_LARGE(struct aml_resource_extended_address64) | ||
88 | }; | ||
89 | |||
90 | /* | ||
91 | * Resource types, used to validate the resource length field. | ||
92 | * The length of fixed-length types must match exactly, variable | ||
93 | * lengths must meet the minimum required length, etc. | ||
94 | * Zero indicates a reserved (and therefore invalid) resource type. | ||
95 | */ | ||
96 | static const u8 acpi_gbl_resource_types[] = { | ||
97 | /* Small descriptors */ | ||
98 | |||
99 | 0, | ||
100 | 0, | ||
101 | 0, | ||
102 | 0, | ||
103 | ACPI_SMALL_VARIABLE_LENGTH, | ||
104 | ACPI_FIXED_LENGTH, | ||
105 | ACPI_SMALL_VARIABLE_LENGTH, | ||
106 | ACPI_FIXED_LENGTH, | ||
107 | ACPI_FIXED_LENGTH, | ||
108 | ACPI_FIXED_LENGTH, | ||
109 | 0, | ||
110 | 0, | ||
111 | 0, | ||
112 | 0, | ||
113 | ACPI_VARIABLE_LENGTH, | ||
114 | ACPI_FIXED_LENGTH, | ||
115 | |||
116 | /* Large descriptors */ | ||
117 | |||
118 | 0, | ||
119 | ACPI_FIXED_LENGTH, | ||
120 | ACPI_FIXED_LENGTH, | ||
121 | 0, | ||
122 | ACPI_VARIABLE_LENGTH, | ||
123 | ACPI_FIXED_LENGTH, | ||
124 | ACPI_FIXED_LENGTH, | ||
125 | ACPI_VARIABLE_LENGTH, | ||
126 | ACPI_VARIABLE_LENGTH, | ||
127 | ACPI_VARIABLE_LENGTH, | ||
128 | ACPI_VARIABLE_LENGTH, | ||
129 | ACPI_FIXED_LENGTH | ||
130 | }; | ||
131 | |||
132 | /******************************************************************************* | ||
133 | * | ||
134 | * FUNCTION: acpi_ut_validate_resource | ||
135 | * | ||
136 | * PARAMETERS: Aml - Pointer to the raw AML resource descriptor | ||
137 | * return_index - Where the resource index is returned. NULL | ||
138 | * if the index is not required. | ||
139 | * | ||
140 | * RETURN: Status, and optionally the Index into the global resource tables | ||
141 | * | ||
142 | * DESCRIPTION: Validate an AML resource descriptor by checking the Resource | ||
143 | * Type and Resource Length. Returns an index into the global | ||
144 | * resource information/dispatch tables for later use. | ||
145 | * | ||
146 | ******************************************************************************/ | ||
147 | |||
148 | acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index) | ||
149 | { | ||
150 | u8 resource_type; | ||
151 | u8 resource_index; | ||
152 | acpi_rs_length resource_length; | ||
153 | acpi_rs_length minimum_resource_length; | ||
154 | |||
155 | ACPI_FUNCTION_ENTRY(); | ||
156 | |||
157 | /* | ||
158 | * 1) Validate the resource_type field (Byte 0) | ||
159 | */ | ||
160 | resource_type = *((u8 *) aml); | ||
161 | |||
162 | /* | ||
163 | * Byte 0 contains the descriptor name (Resource Type) | ||
164 | * Examine the large/small bit in the resource header | ||
165 | */ | ||
166 | if (resource_type & ACPI_RESOURCE_NAME_LARGE) { | ||
167 | /* Verify the large resource type (name) against the max */ | ||
168 | |||
169 | if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { | ||
170 | return (AE_AML_INVALID_RESOURCE_TYPE); | ||
171 | } | ||
172 | |||
173 | /* | ||
174 | * Large Resource Type -- bits 6:0 contain the name | ||
175 | * Translate range 0x80-0x8B to index range 0x10-0x1B | ||
176 | */ | ||
177 | resource_index = (u8) (resource_type - 0x70); | ||
178 | } else { | ||
179 | /* | ||
180 | * Small Resource Type -- bits 6:3 contain the name | ||
181 | * Shift range to index range 0x00-0x0F | ||
182 | */ | ||
183 | resource_index = (u8) | ||
184 | ((resource_type & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3); | ||
185 | } | ||
186 | |||
187 | /* Check validity of the resource type, zero indicates name is invalid */ | ||
188 | |||
189 | if (!acpi_gbl_resource_types[resource_index]) { | ||
190 | return (AE_AML_INVALID_RESOURCE_TYPE); | ||
191 | } | ||
192 | |||
193 | /* | ||
194 | * 2) Validate the resource_length field. This ensures that the length | ||
195 | * is at least reasonable, and guarantees that it is non-zero. | ||
196 | */ | ||
197 | resource_length = acpi_ut_get_resource_length(aml); | ||
198 | minimum_resource_length = acpi_gbl_resource_aml_sizes[resource_index]; | ||
199 | |||
200 | /* Validate based upon the type of resource - fixed length or variable */ | ||
201 | |||
202 | switch (acpi_gbl_resource_types[resource_index]) { | ||
203 | case ACPI_FIXED_LENGTH: | ||
204 | |||
205 | /* Fixed length resource, length must match exactly */ | ||
206 | |||
207 | if (resource_length != minimum_resource_length) { | ||
208 | return (AE_AML_BAD_RESOURCE_LENGTH); | ||
209 | } | ||
210 | break; | ||
211 | |||
212 | case ACPI_VARIABLE_LENGTH: | ||
213 | |||
214 | /* Variable length resource, length must be at least the minimum */ | ||
215 | |||
216 | if (resource_length < minimum_resource_length) { | ||
217 | return (AE_AML_BAD_RESOURCE_LENGTH); | ||
218 | } | ||
219 | break; | ||
220 | |||
221 | case ACPI_SMALL_VARIABLE_LENGTH: | ||
222 | |||
223 | /* Small variable length resource, length can be (Min) or (Min-1) */ | ||
224 | |||
225 | if ((resource_length > minimum_resource_length) || | ||
226 | (resource_length < (minimum_resource_length - 1))) { | ||
227 | return (AE_AML_BAD_RESOURCE_LENGTH); | ||
228 | } | ||
229 | break; | ||
230 | |||
231 | default: | ||
232 | |||
233 | /* Shouldn't happen (because of validation earlier), but be sure */ | ||
234 | |||
235 | return (AE_AML_INVALID_RESOURCE_TYPE); | ||
236 | } | ||
237 | |||
238 | /* Optionally return the resource table index */ | ||
239 | |||
240 | if (return_index) { | ||
241 | *return_index = resource_index; | ||
242 | } | ||
243 | |||
244 | return (AE_OK); | ||
245 | } | ||
246 | |||
247 | /******************************************************************************* | ||
248 | * | ||
249 | * FUNCTION: acpi_ut_get_resource_type | ||
250 | * | ||
251 | * PARAMETERS: Aml - Pointer to the raw AML resource descriptor | ||
252 | * | ||
253 | * RETURN: The Resource Type with no extraneous bits (except the | ||
254 | * Large/Small descriptor bit -- this is left alone) | ||
255 | * | ||
256 | * DESCRIPTION: Extract the Resource Type/Name from the first byte of | ||
257 | * a resource descriptor. | ||
258 | * | ||
259 | ******************************************************************************/ | ||
260 | |||
261 | u8 acpi_ut_get_resource_type(void *aml) | ||
262 | { | ||
263 | ACPI_FUNCTION_ENTRY(); | ||
264 | |||
265 | /* | ||
266 | * Byte 0 contains the descriptor name (Resource Type) | ||
267 | * Examine the large/small bit in the resource header | ||
268 | */ | ||
269 | if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { | ||
270 | /* Large Resource Type -- bits 6:0 contain the name */ | ||
271 | |||
272 | return (*((u8 *) aml)); | ||
273 | } else { | ||
274 | /* Small Resource Type -- bits 6:3 contain the name */ | ||
275 | |||
276 | return ((u8) (*((u8 *) aml) & ACPI_RESOURCE_NAME_SMALL_MASK)); | ||
277 | } | ||
278 | } | ||
279 | |||
280 | /******************************************************************************* | ||
281 | * | ||
282 | * FUNCTION: acpi_ut_get_resource_length | ||
283 | * | ||
284 | * PARAMETERS: Aml - Pointer to the raw AML resource descriptor | ||
285 | * | ||
286 | * RETURN: Byte Length | ||
287 | * | ||
288 | * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By | ||
289 | * definition, this does not include the size of the descriptor | ||
290 | * header or the length field itself. | ||
291 | * | ||
292 | ******************************************************************************/ | ||
293 | |||
294 | u16 acpi_ut_get_resource_length(void *aml) | ||
295 | { | ||
296 | acpi_rs_length resource_length; | ||
297 | |||
298 | ACPI_FUNCTION_ENTRY(); | ||
299 | |||
300 | /* | ||
301 | * Byte 0 contains the descriptor name (Resource Type) | ||
302 | * Examine the large/small bit in the resource header | ||
303 | */ | ||
304 | if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { | ||
305 | /* Large Resource type -- bytes 1-2 contain the 16-bit length */ | ||
306 | |||
307 | ACPI_MOVE_16_TO_16(&resource_length, &((u8 *) aml)[1]); | ||
308 | |||
309 | } else { | ||
310 | /* Small Resource type -- bits 2:0 of byte 0 contain the length */ | ||
311 | |||
312 | resource_length = (u16) (*((u8 *) aml) & | ||
313 | ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); | ||
314 | } | ||
315 | |||
316 | return (resource_length); | ||
317 | } | ||
318 | |||
319 | /******************************************************************************* | ||
320 | * | ||
321 | * FUNCTION: acpi_ut_get_resource_header_length | ||
322 | * | ||
323 | * PARAMETERS: Aml - Pointer to the raw AML resource descriptor | ||
324 | * | ||
325 | * RETURN: Length of the AML header (depends on large/small descriptor) | ||
326 | * | ||
327 | * DESCRIPTION: Get the length of the header for this resource. | ||
328 | * | ||
329 | ******************************************************************************/ | ||
330 | |||
331 | u8 acpi_ut_get_resource_header_length(void *aml) | ||
332 | { | ||
333 | ACPI_FUNCTION_ENTRY(); | ||
334 | |||
335 | /* Examine the large/small bit in the resource header */ | ||
336 | |||
337 | if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { | ||
338 | return (sizeof(struct aml_resource_large_header)); | ||
339 | } else { | ||
340 | return (sizeof(struct aml_resource_small_header)); | ||
341 | } | ||
342 | } | ||
343 | |||
344 | /******************************************************************************* | ||
345 | * | ||
346 | * FUNCTION: acpi_ut_get_descriptor_length | ||
347 | * | ||
348 | * PARAMETERS: Aml - Pointer to the raw AML resource descriptor | ||
349 | * | ||
350 | * RETURN: Byte length | ||
351 | * | ||
352 | * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the | ||
353 | * length of the descriptor header and the length field itself. | ||
354 | * Used to walk descriptor lists. | ||
355 | * | ||
356 | ******************************************************************************/ | ||
357 | |||
358 | u32 acpi_ut_get_descriptor_length(void *aml) | ||
359 | { | ||
360 | ACPI_FUNCTION_ENTRY(); | ||
361 | |||
362 | /* | ||
363 | * Get the Resource Length (does not include header length) and add | ||
364 | * the header length (depends on if this is a small or large resource) | ||
365 | */ | ||
366 | return (acpi_ut_get_resource_length(aml) + | ||
367 | acpi_ut_get_resource_header_length(aml)); | ||
368 | } | ||
369 | |||
370 | /******************************************************************************* | ||
371 | * | ||
372 | * FUNCTION: acpi_ut_get_resource_end_tag | ||
373 | * | ||
374 | * PARAMETERS: obj_desc - The resource template buffer object | ||
375 | * | ||
376 | * RETURN: Pointer to the end tag | ||
377 | * | ||
378 | * DESCRIPTION: Find the end_tag resource descriptor in an AML resource template | ||
379 | * | ||
380 | ******************************************************************************/ | ||
381 | |||
382 | acpi_status | ||
383 | acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc, | ||
384 | u8 ** end_tag) | ||
385 | { | ||
386 | acpi_status status; | ||
387 | u8 *aml; | ||
388 | u8 *end_aml; | ||
389 | |||
390 | ACPI_FUNCTION_TRACE("ut_get_resource_end_tag"); | ||
391 | |||
392 | /* Get start and end pointers */ | ||
393 | |||
394 | aml = obj_desc->buffer.pointer; | ||
395 | end_aml = aml + obj_desc->buffer.length; | ||
396 | |||
397 | /* Walk the resource template, one descriptor per iteration */ | ||
398 | |||
399 | while (aml < end_aml) { | ||
400 | /* Validate the Resource Type and Resource Length */ | ||
401 | |||
402 | status = acpi_ut_validate_resource(aml, NULL); | ||
403 | if (ACPI_FAILURE(status)) { | ||
404 | return_ACPI_STATUS(status); | ||
405 | } | ||
406 | |||
407 | /* end_tag resource indicates the end of the resource template */ | ||
408 | |||
409 | if (acpi_ut_get_resource_type(aml) == | ||
410 | ACPI_RESOURCE_NAME_END_TAG) { | ||
411 | /* Return the pointer to the end_tag */ | ||
412 | |||
413 | *end_tag = aml; | ||
414 | return_ACPI_STATUS(AE_OK); | ||
415 | } | ||
416 | |||
417 | /* | ||
418 | * Point to the next resource descriptor in the AML buffer. The | ||
419 | * descriptor length is guaranteed to be non-zero by resource | ||
420 | * validation above. | ||
421 | */ | ||
422 | aml += acpi_ut_get_descriptor_length(aml); | ||
423 | } | ||
424 | |||
425 | /* Did not find an end_tag resource descriptor */ | ||
426 | |||
427 | return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); | ||
428 | } | ||
diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/utilities/utstate.c index c1cb27583be8..6ff1d7073349 100644 --- a/drivers/acpi/utilities/utstate.c +++ b/drivers/acpi/utilities/utstate.c | |||
@@ -63,7 +63,7 @@ acpi_status | |||
63 | acpi_ut_create_pkg_state_and_push(void *internal_object, | 63 | acpi_ut_create_pkg_state_and_push(void *internal_object, |
64 | void *external_object, | 64 | void *external_object, |
65 | u16 index, | 65 | u16 index, |
66 | union acpi_generic_state ** state_list) | 66 | union acpi_generic_state **state_list) |
67 | { | 67 | { |
68 | union acpi_generic_state *state; | 68 | union acpi_generic_state *state; |
69 | 69 | ||
diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c index f06bd5e5e9d1..57adc5bc02f3 100644 --- a/drivers/acpi/utilities/utxface.c +++ b/drivers/acpi/utilities/utxface.c | |||
@@ -178,10 +178,14 @@ acpi_status acpi_enable_subsystem(u32 flags) | |||
178 | /* | 178 | /* |
179 | * Initialize ACPI Event handling (Fixed and General Purpose) | 179 | * Initialize ACPI Event handling (Fixed and General Purpose) |
180 | * | 180 | * |
181 | * NOTE: We must have the hardware AND events initialized before we can | 181 | * Note1: We must have the hardware and events initialized before we can |
182 | * execute ANY control methods SAFELY. Any control method can require | 182 | * execute any control methods safely. Any control method can require |
183 | * ACPI hardware support, so the hardware MUST be initialized before | 183 | * ACPI hardware support, so the hardware must be fully initialized before |
184 | * execution! | 184 | * any method execution! |
185 | * | ||
186 | * Note2: Fixed events are initialized and enabled here. GPEs are | ||
187 | * initialized, but cannot be enabled until after the hardware is | ||
188 | * completely initialized (SCI and global_lock activated) | ||
185 | */ | 189 | */ |
186 | if (!(flags & ACPI_NO_EVENT_INIT)) { | 190 | if (!(flags & ACPI_NO_EVENT_INIT)) { |
187 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 191 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
@@ -193,8 +197,10 @@ acpi_status acpi_enable_subsystem(u32 flags) | |||
193 | } | 197 | } |
194 | } | 198 | } |
195 | 199 | ||
196 | /* Install the SCI handler and Global Lock handler */ | 200 | /* |
197 | 201 | * Install the SCI handler and Global Lock handler. This completes the | |
202 | * hardware initialization. | ||
203 | */ | ||
198 | if (!(flags & ACPI_NO_HANDLER_INIT)) { | 204 | if (!(flags & ACPI_NO_HANDLER_INIT)) { |
199 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 205 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
200 | "[Init] Installing SCI/GL handlers\n")); | 206 | "[Init] Installing SCI/GL handlers\n")); |
@@ -205,6 +211,24 @@ acpi_status acpi_enable_subsystem(u32 flags) | |||
205 | } | 211 | } |
206 | } | 212 | } |
207 | 213 | ||
214 | /* | ||
215 | * Complete the GPE initialization for the GPE blocks defined in the FADT | ||
216 | * (GPE block 0 and 1). | ||
217 | * | ||
218 | * Note1: This is where the _PRW methods are executed for the GPEs. These | ||
219 | * methods can only be executed after the SCI and Global Lock handlers are | ||
220 | * installed and initialized. | ||
221 | * | ||
222 | * Note2: Currently, there seems to be no need to run the _REG methods | ||
223 | * before execution of the _PRW methods and enabling of the GPEs. | ||
224 | */ | ||
225 | if (!(flags & ACPI_NO_EVENT_INIT)) { | ||
226 | status = acpi_ev_install_fadt_gpes(); | ||
227 | if (ACPI_FAILURE(status)) { | ||
228 | return (status); | ||
229 | } | ||
230 | } | ||
231 | |||
208 | return_ACPI_STATUS(status); | 232 | return_ACPI_STATUS(status); |
209 | } | 233 | } |
210 | 234 | ||
@@ -230,9 +254,9 @@ acpi_status acpi_initialize_objects(u32 flags) | |||
230 | /* | 254 | /* |
231 | * Run all _REG methods | 255 | * Run all _REG methods |
232 | * | 256 | * |
233 | * NOTE: Any objects accessed | 257 | * Note: Any objects accessed by the _REG methods will be automatically |
234 | * by the _REG methods will be automatically initialized, even if they | 258 | * initialized, even if they contain executable AML (see the call to |
235 | * contain executable AML (see call to acpi_ns_initialize_objects below). | 259 | * acpi_ns_initialize_objects below). |
236 | */ | 260 | */ |
237 | if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { | 261 | if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { |
238 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 262 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
@@ -245,9 +269,9 @@ acpi_status acpi_initialize_objects(u32 flags) | |||
245 | } | 269 | } |
246 | 270 | ||
247 | /* | 271 | /* |
248 | * Initialize the objects that remain uninitialized. This | 272 | * Initialize the objects that remain uninitialized. This runs the |
249 | * runs the executable AML that may be part of the declaration of these | 273 | * executable AML that may be part of the declaration of these objects: |
250 | * objects: operation_regions, buffer_fields, Buffers, and Packages. | 274 | * operation_regions, buffer_fields, Buffers, and Packages. |
251 | */ | 275 | */ |
252 | if (!(flags & ACPI_NO_OBJECT_INIT)) { | 276 | if (!(flags & ACPI_NO_OBJECT_INIT)) { |
253 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 277 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
@@ -260,8 +284,8 @@ acpi_status acpi_initialize_objects(u32 flags) | |||
260 | } | 284 | } |
261 | 285 | ||
262 | /* | 286 | /* |
263 | * Initialize all device objects in the namespace | 287 | * Initialize all device objects in the namespace. This runs the device |
264 | * This runs the _STA and _INI methods. | 288 | * _STA and _INI methods. |
265 | */ | 289 | */ |
266 | if (!(flags & ACPI_NO_DEVICE_INIT)) { | 290 | if (!(flags & ACPI_NO_DEVICE_INIT)) { |
267 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 291 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |