1 /******************************************************************************
2  *
3  * Name: acnamesp.h - Namespace subcomponent prototypes and defines
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2004, 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 #ifndef __ACNAMESP_H__
45 #define __ACNAMESP_H__
46 
47 
48 /* To search the entire name space, pass this as search_base */
49 
50 #define ACPI_NS_ALL                 ((acpi_handle)0)
51 
52 /*
53  * Elements of acpi_ns_properties are bit significant
54  * and should be one-to-one with values of acpi_object_type
55  */
56 #define ACPI_NS_NORMAL              0
57 #define ACPI_NS_NEWSCOPE            1   /* a definition of this type opens a name scope */
58 #define ACPI_NS_LOCAL               2   /* suppress search of enclosing scopes */
59 
60 
61 /* Definitions of the predefined namespace names  */
62 
63 #define ACPI_UNKNOWN_NAME           (u32) 0x3F3F3F3F     /* Unknown name is  "????" */
64 #define ACPI_ROOT_NAME              (u32) 0x5F5F5F5C     /* Root name is     "\___" */
65 #define ACPI_SYS_BUS_NAME           (u32) 0x5F53425F     /* Sys bus name is  "_SB_" */
66 
67 #define ACPI_NS_ROOT_PATH           "\\"
68 #define ACPI_NS_SYSTEM_BUS          "_SB_"
69 
70 
71 /* Flags for acpi_ns_lookup, acpi_ns_search_and_enter */
72 
73 #define ACPI_NS_NO_UPSEARCH         0
74 #define ACPI_NS_SEARCH_PARENT       0x01
75 #define ACPI_NS_DONT_OPEN_SCOPE     0x02
76 #define ACPI_NS_NO_PEER_SEARCH      0x04
77 #define ACPI_NS_ERROR_IF_FOUND      0x08
78 
79 #define ACPI_NS_WALK_UNLOCK         TRUE
80 #define ACPI_NS_WALK_NO_UNLOCK      FALSE
81 
82 
83 acpi_status
84 acpi_ns_load_namespace (
85 	void);
86 
87 acpi_status
88 acpi_ns_initialize_objects (
89 	void);
90 
91 acpi_status
92 acpi_ns_initialize_devices (
93 	void);
94 
95 
96 /* Namespace init - nsxfinit */
97 
98 acpi_status
99 acpi_ns_init_one_device (
100 	acpi_handle                     obj_handle,
101 	u32                             nesting_level,
102 	void                            *context,
103 	void                            **return_value);
104 
105 acpi_status
106 acpi_ns_init_one_object (
107 	acpi_handle                     obj_handle,
108 	u32                             level,
109 	void                            *context,
110 	void                            **return_value);
111 
112 
113 acpi_status
114 acpi_ns_walk_namespace (
115 	acpi_object_type                type,
116 	acpi_handle                     start_object,
117 	u32                             max_depth,
118 	u8                              unlock_before_callback,
119 	acpi_walk_callback              user_function,
120 	void                            *context,
121 	void                            **return_value);
122 
123 struct acpi_namespace_node *
124 acpi_ns_get_next_node (
125 	acpi_object_type                type,
126 	struct acpi_namespace_node      *parent,
127 	struct acpi_namespace_node      *child);
128 
129 void
130 acpi_ns_delete_namespace_by_owner (
131 	u16                             table_id);
132 
133 
134 /* Namespace loading - nsload */
135 
136 acpi_status
137 acpi_ns_one_complete_parse (
138 	u32                             pass_number,
139 	struct acpi_table_desc          *table_desc);
140 
141 acpi_status
142 acpi_ns_parse_table (
143 	struct acpi_table_desc          *table_desc,
144 	struct acpi_namespace_node      *scope);
145 
146 acpi_status
147 acpi_ns_load_table (
148 	struct acpi_table_desc          *table_desc,
149 	struct acpi_namespace_node      *node);
150 
151 acpi_status
152 acpi_ns_load_table_by_type (
153 	acpi_table_type                 table_type);
154 
155 
156 /*
157  * Top-level namespace access - nsaccess
158  */
159 
160 acpi_status
161 acpi_ns_root_initialize (
162 	void);
163 
164 acpi_status
165 acpi_ns_lookup (
166 	union acpi_generic_state        *scope_info,
167 	char                            *name,
168 	acpi_object_type                type,
169 	acpi_interpreter_mode           interpreter_mode,
170 	u32                             flags,
171 	struct acpi_walk_state          *walk_state,
172 	struct acpi_namespace_node      **ret_node);
173 
174 
175 /*
176  * Named object allocation/deallocation - nsalloc
177  */
178 
179 struct acpi_namespace_node *
180 acpi_ns_create_node (
181 	u32                             name);
182 
183 void
184 acpi_ns_delete_node (
185 	struct acpi_namespace_node      *node);
186 
187 void
188 acpi_ns_delete_namespace_subtree (
189 	struct acpi_namespace_node      *parent_handle);
190 
191 void
192 acpi_ns_detach_object (
193 	struct acpi_namespace_node      *node);
194 
195 void
196 acpi_ns_delete_children (
197 	struct acpi_namespace_node      *parent);
198 
199 int
200 acpi_ns_compare_names (
201 	char                            *name1,
202 	char                            *name2);
203 
204 void
205 acpi_ns_remove_reference (
206 	struct acpi_namespace_node      *node);
207 
208 
209 /*
210  * Namespace modification - nsmodify
211  */
212 
213 acpi_status
214 acpi_ns_unload_namespace (
215 	acpi_handle                     handle);
216 
217 acpi_status
218 acpi_ns_delete_subtree (
219 	acpi_handle                     start_handle);
220 
221 
222 /*
223  * Namespace dump/print utilities - nsdump
224  */
225 
226 void
227 acpi_ns_dump_tables (
228 	acpi_handle                     search_base,
229 	u32                             max_depth);
230 
231 void
232 acpi_ns_dump_entry (
233 	acpi_handle                     handle,
234 	u32                             debug_level);
235 
236 void
237 acpi_ns_dump_pathname (
238 	acpi_handle                     handle,
239 	char                            *msg,
240 	u32                             level,
241 	u32                             component);
242 
243 void
244 acpi_ns_print_pathname (
245 	u32                             num_segments,
246 	char                            *pathname);
247 
248 acpi_status
249 acpi_ns_dump_one_device (
250 	acpi_handle                     obj_handle,
251 	u32                             level,
252 	void                            *context,
253 	void                            **return_value);
254 
255 void
256 acpi_ns_dump_root_devices (
257 	void);
258 
259 acpi_status
260 acpi_ns_dump_one_object (
261 	acpi_handle                     obj_handle,
262 	u32                             level,
263 	void                            *context,
264 	void                            **return_value);
265 
266 void
267 acpi_ns_dump_objects (
268 	acpi_object_type                type,
269 	u8                              display_type,
270 	u32                             max_depth,
271 	u32                             ownder_id,
272 	acpi_handle                     start_handle);
273 
274 
275 /*
276  * Namespace evaluation functions - nseval
277  */
278 
279 acpi_status
280 acpi_ns_evaluate_by_handle (
281 	struct acpi_namespace_node      *prefix_node,
282 	union acpi_operand_object       **params,
283 	union acpi_operand_object       **return_object);
284 
285 acpi_status
286 acpi_ns_evaluate_by_name (
287 	char                            *pathname,
288 	union acpi_operand_object       **params,
289 	union acpi_operand_object       **return_object);
290 
291 acpi_status
292 acpi_ns_evaluate_relative (
293 	struct acpi_namespace_node      *prefix_node,
294 	char                            *pathname,
295 	union acpi_operand_object       **params,
296 	union acpi_operand_object       **return_object);
297 
298 acpi_status
299 acpi_ns_execute_control_method (
300 	struct acpi_namespace_node      *method_node,
301 	union acpi_operand_object       **params,
302 	union acpi_operand_object       **return_obj_desc);
303 
304 acpi_status
305 acpi_ns_get_object_value (
306 	struct acpi_namespace_node      *object_node,
307 	union acpi_operand_object       **return_obj_desc);
308 
309 
310 /*
311  * Parent/Child/Peer utility functions
312  */
313 
314 acpi_name
315 acpi_ns_find_parent_name (
316 	struct acpi_namespace_node      *node_to_search);
317 
318 
319 /*
320  * Name and Scope manipulation - nsnames
321  */
322 
323 u32
324 acpi_ns_opens_scope (
325 	acpi_object_type                type);
326 
327 void
328 acpi_ns_build_external_path (
329 	struct acpi_namespace_node      *node,
330 	acpi_size                       size,
331 	char                            *name_buffer);
332 
333 char *
334 acpi_ns_get_external_pathname (
335 	struct acpi_namespace_node      *node);
336 
337 char *
338 acpi_ns_name_of_current_scope (
339 	struct acpi_walk_state          *walk_state);
340 
341 acpi_status
342 acpi_ns_handle_to_pathname (
343 	acpi_handle                     target_handle,
344 	struct acpi_buffer              *buffer);
345 
346 u8
347 acpi_ns_pattern_match (
348 	struct acpi_namespace_node      *obj_node,
349 	char                            *search_for);
350 
351 acpi_status
352 acpi_ns_get_node_by_path (
353 	char                            *external_pathname,
354 	struct acpi_namespace_node      *in_prefix_node,
355 	u32                             flags,
356 	struct acpi_namespace_node      **out_node);
357 
358 acpi_size
359 acpi_ns_get_pathname_length (
360 	struct acpi_namespace_node      *node);
361 
362 
363 /*
364  * Object management for namespace nodes - nsobject
365  */
366 
367 acpi_status
368 acpi_ns_attach_object (
369 	struct acpi_namespace_node      *node,
370 	union acpi_operand_object       *object,
371 	acpi_object_type                type);
372 
373 union acpi_operand_object *
374 acpi_ns_get_attached_object (
375 	struct acpi_namespace_node      *node);
376 
377 union acpi_operand_object *
378 acpi_ns_get_secondary_object (
379 	union acpi_operand_object       *obj_desc);
380 
381 acpi_status
382 acpi_ns_attach_data (
383 	struct acpi_namespace_node      *node,
384 	acpi_object_handler             handler,
385 	void                            *data);
386 
387 acpi_status
388 acpi_ns_detach_data (
389 	struct acpi_namespace_node      *node,
390 	acpi_object_handler             handler);
391 
392 acpi_status
393 acpi_ns_get_attached_data (
394 	struct acpi_namespace_node      *node,
395 	acpi_object_handler             handler,
396 	void                            **data);
397 
398 
399 /*
400  * Namespace searching and entry - nssearch
401  */
402 
403 acpi_status
404 acpi_ns_search_and_enter (
405 	u32                             entry_name,
406 	struct acpi_walk_state          *walk_state,
407 	struct acpi_namespace_node      *node,
408 	acpi_interpreter_mode           interpreter_mode,
409 	acpi_object_type                type,
410 	u32                             flags,
411 	struct acpi_namespace_node      **ret_node);
412 
413 acpi_status
414 acpi_ns_search_node (
415 	u32                             entry_name,
416 	struct acpi_namespace_node      *node,
417 	acpi_object_type                type,
418 	struct acpi_namespace_node      **ret_node);
419 
420 void
421 acpi_ns_install_node (
422 	struct acpi_walk_state          *walk_state,
423 	struct acpi_namespace_node      *parent_node,
424 	struct acpi_namespace_node      *node,
425 	acpi_object_type                type);
426 
427 
428 /*
429  * Utility functions - nsutils
430  */
431 
432 u8
433 acpi_ns_valid_root_prefix (
434 	char                            prefix);
435 
436 u8
437 acpi_ns_valid_path_separator (
438 	char                            sep);
439 
440 acpi_object_type
441 acpi_ns_get_type (
442 	struct acpi_namespace_node      *node);
443 
444 u32
445 acpi_ns_local (
446 	acpi_object_type                type);
447 
448 void
449 acpi_ns_report_error (
450 	char                            *module_name,
451 	u32                             line_number,
452 	u32                             component_id,
453 	char                            *internal_name,
454 	acpi_status                     lookup_status);
455 
456 void
457 acpi_ns_report_method_error (
458 	char                            *module_name,
459 	u32                             line_number,
460 	u32                             component_id,
461 	char                            *message,
462 	struct acpi_namespace_node      *node,
463 	char                            *path,
464 	acpi_status                     lookup_status);
465 
466 void
467 acpi_ns_print_node_pathname (
468 	struct acpi_namespace_node      *node,
469 	char                            *msg);
470 
471 acpi_status
472 acpi_ns_build_internal_name (
473 	struct acpi_namestring_info     *info);
474 
475 void
476 acpi_ns_get_internal_name_length (
477 	struct acpi_namestring_info     *info);
478 
479 acpi_status
480 acpi_ns_internalize_name (
481 	char                            *dotted_name,
482 	char                            **converted_name);
483 
484 acpi_status
485 acpi_ns_externalize_name (
486 	u32                             internal_name_length,
487 	char                            *internal_name,
488 	u32                             *converted_name_length,
489 	char                            **converted_name);
490 
491 struct acpi_namespace_node *
492 acpi_ns_map_handle_to_node (
493 	acpi_handle                     handle);
494 
495 acpi_handle
496 acpi_ns_convert_entry_to_handle(
497 	struct acpi_namespace_node      *node);
498 
499 void
500 acpi_ns_terminate (
501 	void);
502 
503 struct acpi_namespace_node *
504 acpi_ns_get_parent_node (
505 	struct acpi_namespace_node      *node);
506 
507 
508 struct acpi_namespace_node *
509 acpi_ns_get_next_valid_node (
510 	struct acpi_namespace_node      *node);
511 
512 
513 #endif /* __ACNAMESP_H__ */
514