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