xref: /linux/drivers/acpi/acpica/acnamesp.h (revision 005438a8eef063495ac059d128eea71b58de50e5)
1 /******************************************************************************
2  *
3  * Name: acnamesp.h - Namespace subcomponent prototypes and defines
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2015, Intel Corp.
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 #ifndef __ACNAMESP_H__
45 #define __ACNAMESP_H__
46 
47 /* To search the entire name space, pass this as search_base */
48 
49 #define ACPI_NS_ALL                 ((acpi_handle)0)
50 
51 /*
52  * Elements of acpi_ns_properties are bit significant
53  * and should be one-to-one with values of acpi_object_type
54  */
55 #define ACPI_NS_NORMAL              0
56 #define ACPI_NS_NEWSCOPE            1	/* a definition of this type opens a name scope */
57 #define ACPI_NS_LOCAL               2	/* suppress search of enclosing scopes */
58 
59 /* Flags for acpi_ns_lookup, acpi_ns_search_and_enter */
60 
61 #define ACPI_NS_NO_UPSEARCH         0
62 #define ACPI_NS_SEARCH_PARENT       0x01
63 #define ACPI_NS_DONT_OPEN_SCOPE     0x02
64 #define ACPI_NS_NO_PEER_SEARCH      0x04
65 #define ACPI_NS_ERROR_IF_FOUND      0x08
66 #define ACPI_NS_PREFIX_IS_SCOPE     0x10
67 #define ACPI_NS_EXTERNAL            0x20
68 #define ACPI_NS_TEMPORARY           0x40
69 #define ACPI_NS_OVERRIDE_IF_FOUND   0x80
70 
71 /* Flags for acpi_ns_walk_namespace */
72 
73 #define ACPI_NS_WALK_NO_UNLOCK      0
74 #define ACPI_NS_WALK_UNLOCK         0x01
75 #define ACPI_NS_WALK_TEMP_NODES     0x02
76 
77 /* Object is not a package element */
78 
79 #define ACPI_NOT_PACKAGE_ELEMENT    ACPI_UINT32_MAX
80 
81 /* Always emit warning message, not dependent on node flags */
82 
83 #define ACPI_WARN_ALWAYS            0
84 
85 /*
86  * nsinit - Namespace initialization
87  */
88 acpi_status acpi_ns_initialize_objects(void);
89 
90 acpi_status acpi_ns_initialize_devices(void);
91 
92 /*
93  * nsload -  Namespace loading
94  */
95 acpi_status acpi_ns_load_namespace(void);
96 
97 acpi_status
98 acpi_ns_load_table(u32 table_index, struct acpi_namespace_node *node);
99 
100 /*
101  * nswalk - walk the namespace
102  */
103 acpi_status
104 acpi_ns_walk_namespace(acpi_object_type type,
105 		       acpi_handle start_object,
106 		       u32 max_depth,
107 		       u32 flags,
108 		       acpi_walk_callback descending_callback,
109 		       acpi_walk_callback ascending_callback,
110 		       void *context, void **return_value);
111 
112 struct acpi_namespace_node *acpi_ns_get_next_node(struct acpi_namespace_node
113 						  *parent,
114 						  struct acpi_namespace_node
115 						  *child);
116 
117 struct acpi_namespace_node *acpi_ns_get_next_node_typed(acpi_object_type type,
118 							struct
119 							acpi_namespace_node
120 							*parent,
121 							struct
122 							acpi_namespace_node
123 							*child);
124 
125 /*
126  * nsparse - table parsing
127  */
128 acpi_status
129 acpi_ns_parse_table(u32 table_index, struct acpi_namespace_node *start_node);
130 
131 acpi_status
132 acpi_ns_one_complete_parse(u32 pass_number,
133 			   u32 table_index,
134 			   struct acpi_namespace_node *start_node);
135 
136 /*
137  * nsaccess - Top-level namespace access
138  */
139 acpi_status acpi_ns_root_initialize(void);
140 
141 acpi_status
142 acpi_ns_lookup(union acpi_generic_state *scope_info,
143 	       char *name,
144 	       acpi_object_type type,
145 	       acpi_interpreter_mode interpreter_mode,
146 	       u32 flags,
147 	       struct acpi_walk_state *walk_state,
148 	       struct acpi_namespace_node **ret_node);
149 
150 /*
151  * nsalloc - Named object allocation/deallocation
152  */
153 struct acpi_namespace_node *acpi_ns_create_node(u32 name);
154 
155 void acpi_ns_delete_node(struct acpi_namespace_node *node);
156 
157 void acpi_ns_remove_node(struct acpi_namespace_node *node);
158 
159 void
160 acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_handle);
161 
162 void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id);
163 
164 void acpi_ns_detach_object(struct acpi_namespace_node *node);
165 
166 void acpi_ns_delete_children(struct acpi_namespace_node *parent);
167 
168 int acpi_ns_compare_names(char *name1, char *name2);
169 
170 /*
171  * nsconvert - Dynamic object conversion routines
172  */
173 acpi_status
174 acpi_ns_convert_to_integer(union acpi_operand_object *original_object,
175 			   union acpi_operand_object **return_object);
176 
177 acpi_status
178 acpi_ns_convert_to_string(union acpi_operand_object *original_object,
179 			  union acpi_operand_object **return_object);
180 
181 acpi_status
182 acpi_ns_convert_to_buffer(union acpi_operand_object *original_object,
183 			  union acpi_operand_object **return_object);
184 
185 acpi_status
186 acpi_ns_convert_to_unicode(union acpi_operand_object *original_object,
187 			   union acpi_operand_object **return_object);
188 
189 acpi_status
190 acpi_ns_convert_to_resource(union acpi_operand_object *original_object,
191 			    union acpi_operand_object **return_object);
192 
193 /*
194  * nsdump - Namespace dump/print utilities
195  */
196 #ifdef	ACPI_FUTURE_USAGE
197 void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth);
198 #endif				/* ACPI_FUTURE_USAGE */
199 
200 void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level);
201 
202 void
203 acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component);
204 
205 void acpi_ns_print_pathname(u32 num_segments, char *pathname);
206 
207 acpi_status
208 acpi_ns_dump_one_object(acpi_handle obj_handle,
209 			u32 level, void *context, void **return_value);
210 
211 #ifdef	ACPI_FUTURE_USAGE
212 void
213 acpi_ns_dump_objects(acpi_object_type type,
214 		     u8 display_type,
215 		     u32 max_depth,
216 		     acpi_owner_id owner_id, acpi_handle start_handle);
217 
218 void
219 acpi_ns_dump_object_paths(acpi_object_type type,
220 			  u8 display_type,
221 			  u32 max_depth,
222 			  acpi_owner_id owner_id, acpi_handle start_handle);
223 #endif				/* ACPI_FUTURE_USAGE */
224 
225 /*
226  * nseval - Namespace evaluation functions
227  */
228 acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info);
229 
230 void acpi_ns_exec_module_code_list(void);
231 
232 /*
233  * nsarguments - Argument count/type checking for predefined/reserved names
234  */
235 void
236 acpi_ns_check_argument_count(char *pathname,
237 			     struct acpi_namespace_node *node,
238 			     u32 user_param_count,
239 			     const union acpi_predefined_info *info);
240 
241 void
242 acpi_ns_check_acpi_compliance(char *pathname,
243 			      struct acpi_namespace_node *node,
244 			      const union acpi_predefined_info *predefined);
245 
246 void acpi_ns_check_argument_types(struct acpi_evaluate_info *info);
247 
248 /*
249  * nspredef - Return value checking for predefined/reserved names
250  */
251 acpi_status
252 acpi_ns_check_return_value(struct acpi_namespace_node *node,
253 			   struct acpi_evaluate_info *info,
254 			   u32 user_param_count,
255 			   acpi_status return_status,
256 			   union acpi_operand_object **return_object);
257 
258 acpi_status
259 acpi_ns_check_object_type(struct acpi_evaluate_info *info,
260 			  union acpi_operand_object **return_object_ptr,
261 			  u32 expected_btypes, u32 package_index);
262 
263 /*
264  * nsprepkg - Validation of predefined name packages
265  */
266 acpi_status
267 acpi_ns_check_package(struct acpi_evaluate_info *info,
268 		      union acpi_operand_object **return_object_ptr);
269 
270 /*
271  * nsnames - Name and Scope manipulation
272  */
273 u32 acpi_ns_opens_scope(acpi_object_type type);
274 
275 acpi_status
276 acpi_ns_build_external_path(struct acpi_namespace_node *node,
277 			    acpi_size size, char *name_buffer);
278 
279 char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node);
280 
281 char *acpi_ns_name_of_current_scope(struct acpi_walk_state *walk_state);
282 
283 acpi_status
284 acpi_ns_handle_to_pathname(acpi_handle target_handle,
285 			   struct acpi_buffer *buffer);
286 
287 u8
288 acpi_ns_pattern_match(struct acpi_namespace_node *obj_node, char *search_for);
289 
290 acpi_status
291 acpi_ns_get_node(struct acpi_namespace_node *prefix_node,
292 		 const char *external_pathname,
293 		 u32 flags, struct acpi_namespace_node **out_node);
294 
295 acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node);
296 
297 /*
298  * nsobject - Object management for namespace nodes
299  */
300 acpi_status
301 acpi_ns_attach_object(struct acpi_namespace_node *node,
302 		      union acpi_operand_object *object, acpi_object_type type);
303 
304 union acpi_operand_object *acpi_ns_get_attached_object(struct
305 						       acpi_namespace_node
306 						       *node);
307 
308 union acpi_operand_object *acpi_ns_get_secondary_object(union
309 							acpi_operand_object
310 							*obj_desc);
311 
312 acpi_status
313 acpi_ns_attach_data(struct acpi_namespace_node *node,
314 		    acpi_object_handler handler, void *data);
315 
316 acpi_status
317 acpi_ns_detach_data(struct acpi_namespace_node *node,
318 		    acpi_object_handler handler);
319 
320 acpi_status
321 acpi_ns_get_attached_data(struct acpi_namespace_node *node,
322 			  acpi_object_handler handler, void **data);
323 
324 /*
325  * nsrepair - General return object repair for all
326  * predefined methods/objects
327  */
328 acpi_status
329 acpi_ns_simple_repair(struct acpi_evaluate_info *info,
330 		      u32 expected_btypes,
331 		      u32 package_index,
332 		      union acpi_operand_object **return_object_ptr);
333 
334 acpi_status
335 acpi_ns_wrap_with_package(struct acpi_evaluate_info *info,
336 			  union acpi_operand_object *original_object,
337 			  union acpi_operand_object **obj_desc_ptr);
338 
339 acpi_status
340 acpi_ns_repair_null_element(struct acpi_evaluate_info *info,
341 			    u32 expected_btypes,
342 			    u32 package_index,
343 			    union acpi_operand_object **return_object_ptr);
344 
345 void
346 acpi_ns_remove_null_elements(struct acpi_evaluate_info *info,
347 			     u8 package_type,
348 			     union acpi_operand_object *obj_desc);
349 
350 /*
351  * nsrepair2 - Return object repair for specific
352  * predefined methods/objects
353  */
354 acpi_status
355 acpi_ns_complex_repairs(struct acpi_evaluate_info *info,
356 			struct acpi_namespace_node *node,
357 			acpi_status validate_status,
358 			union acpi_operand_object **return_object_ptr);
359 
360 /*
361  * nssearch - Namespace searching and entry
362  */
363 acpi_status
364 acpi_ns_search_and_enter(u32 entry_name,
365 			 struct acpi_walk_state *walk_state,
366 			 struct acpi_namespace_node *node,
367 			 acpi_interpreter_mode interpreter_mode,
368 			 acpi_object_type type,
369 			 u32 flags, struct acpi_namespace_node **ret_node);
370 
371 acpi_status
372 acpi_ns_search_one_scope(u32 entry_name,
373 			 struct acpi_namespace_node *node,
374 			 acpi_object_type type,
375 			 struct acpi_namespace_node **ret_node);
376 
377 void
378 acpi_ns_install_node(struct acpi_walk_state *walk_state,
379 		     struct acpi_namespace_node *parent_node,
380 		     struct acpi_namespace_node *node, acpi_object_type type);
381 
382 /*
383  * nsutils - Utility functions
384  */
385 acpi_object_type acpi_ns_get_type(struct acpi_namespace_node *node);
386 
387 u32 acpi_ns_local(acpi_object_type type);
388 
389 void
390 acpi_ns_print_node_pathname(struct acpi_namespace_node *node, const char *msg);
391 
392 acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info);
393 
394 void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info);
395 
396 acpi_status
397 acpi_ns_internalize_name(const char *dotted_name, char **converted_name);
398 
399 acpi_status
400 acpi_ns_externalize_name(u32 internal_name_length,
401 			 const char *internal_name,
402 			 u32 * converted_name_length, char **converted_name);
403 
404 struct acpi_namespace_node *acpi_ns_validate_handle(acpi_handle handle);
405 
406 void acpi_ns_terminate(void);
407 
408 #endif				/* __ACNAMESP_H__ */
409