acutils.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:13k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /******************************************************************************
  2.  *
  3.  * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures
  4.  *       $Revision: 117 $
  5.  *
  6.  *****************************************************************************/
  7. /*
  8.  *  Copyright (C) 2000, 2001 R. Byron Moore
  9.  *
  10.  *  This program is free software; you can redistribute it and/or modify
  11.  *  it under the terms of the GNU General Public License as published by
  12.  *  the Free Software Foundation; either version 2 of the License, or
  13.  *  (at your option) any later version.
  14.  *
  15.  *  This program is distributed in the hope that it will be useful,
  16.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  *  GNU General Public License for more details.
  19.  *
  20.  *  You should have received a copy of the GNU General Public License
  21.  *  along with this program; if not, write to the Free Software
  22.  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  23.  */
  24. #ifndef _ACUTILS_H
  25. #define _ACUTILS_H
  26. typedef
  27. acpi_status (*ACPI_PKG_CALLBACK) (
  28. u8                      object_type,
  29. acpi_operand_object     *source_object,
  30. acpi_generic_state      *state,
  31. void                    *context);
  32. acpi_status
  33. acpi_ut_walk_package_tree (
  34. acpi_operand_object     *source_object,
  35. void                    *target_object,
  36. ACPI_PKG_CALLBACK       walk_callback,
  37. void                    *context);
  38. typedef struct acpi_pkg_info
  39. {
  40. u8                      *free_space;
  41. u32                     length;
  42. u32                     object_space;
  43. u32                     num_packages;
  44. } acpi_pkg_info;
  45. #define REF_INCREMENT       (u16) 0
  46. #define REF_DECREMENT       (u16) 1
  47. #define REF_FORCE_DELETE    (u16) 2
  48. /* Acpi_ut_dump_buffer */
  49. #define DB_BYTE_DISPLAY     1
  50. #define DB_WORD_DISPLAY     2
  51. #define DB_DWORD_DISPLAY    4
  52. #define DB_QWORD_DISPLAY    8
  53. /* Global initialization interfaces */
  54. void
  55. acpi_ut_init_globals (
  56. void);
  57. void
  58. acpi_ut_terminate (
  59. void);
  60. /*
  61.  * Ut_init - miscellaneous initialization and shutdown
  62.  */
  63. acpi_status
  64. acpi_ut_hardware_initialize (
  65. void);
  66. acpi_status
  67. acpi_ut_subsystem_shutdown (
  68. void);
  69. acpi_status
  70. acpi_ut_validate_fadt (
  71. void);
  72. /*
  73.  * Ut_global - Global data structures and procedures
  74.  */
  75. #ifdef ACPI_DEBUG
  76. NATIVE_CHAR *
  77. acpi_ut_get_mutex_name (
  78. u32                     mutex_id);
  79. NATIVE_CHAR *
  80. acpi_ut_get_type_name (
  81. u32                     type);
  82. NATIVE_CHAR *
  83. acpi_ut_get_region_name (
  84. u8                      space_id);
  85. #endif
  86. u8
  87. acpi_ut_hex_to_ascii_char (
  88. acpi_integer            integer,
  89. u32                     position);
  90. u8
  91. acpi_ut_valid_object_type (
  92. u32                     type);
  93. acpi_owner_id
  94. acpi_ut_allocate_owner_id (
  95. u32                     id_type);
  96. /*
  97.  * Ut_clib - Local implementations of C library functions
  98.  */
  99. #ifndef ACPI_USE_SYSTEM_CLIBRARY
  100. u32
  101. acpi_ut_strlen (
  102. const NATIVE_CHAR       *string);
  103. NATIVE_CHAR *
  104. acpi_ut_strcpy (
  105. NATIVE_CHAR             *dst_string,
  106. const NATIVE_CHAR       *src_string);
  107. NATIVE_CHAR *
  108. acpi_ut_strncpy (
  109. NATIVE_CHAR             *dst_string,
  110. const NATIVE_CHAR       *src_string,
  111. NATIVE_UINT             count);
  112. u32
  113. acpi_ut_strncmp (
  114. const NATIVE_CHAR       *string1,
  115. const NATIVE_CHAR       *string2,
  116. NATIVE_UINT             count);
  117. u32
  118. acpi_ut_strcmp (
  119. const NATIVE_CHAR       *string1,
  120. const NATIVE_CHAR       *string2);
  121. NATIVE_CHAR *
  122. acpi_ut_strcat (
  123. NATIVE_CHAR             *dst_string,
  124. const NATIVE_CHAR       *src_string);
  125. NATIVE_CHAR *
  126. acpi_ut_strncat (
  127. NATIVE_CHAR             *dst_string,
  128. const NATIVE_CHAR       *src_string,
  129. NATIVE_UINT             count);
  130. u32
  131. acpi_ut_strtoul (
  132. const NATIVE_CHAR       *string,
  133. NATIVE_CHAR             **terminator,
  134. u32                     base);
  135. NATIVE_CHAR *
  136. acpi_ut_strstr (
  137. NATIVE_CHAR             *string1,
  138. NATIVE_CHAR             *string2);
  139. void *
  140. acpi_ut_memcpy (
  141. void                    *dest,
  142. const void              *src,
  143. NATIVE_UINT             count);
  144. void *
  145. acpi_ut_memset (
  146. void                    *dest,
  147. NATIVE_UINT             value,
  148. NATIVE_UINT             count);
  149. u32
  150. acpi_ut_to_upper (
  151. u32                     c);
  152. u32
  153. acpi_ut_to_lower (
  154. u32                     c);
  155. #endif /* ACPI_USE_SYSTEM_CLIBRARY */
  156. /*
  157.  * Ut_copy - Object construction and conversion interfaces
  158.  */
  159. acpi_status
  160. acpi_ut_build_simple_object(
  161. acpi_operand_object     *obj,
  162. acpi_object             *user_obj,
  163. u8                      *data_space,
  164. u32                     *buffer_space_used);
  165. acpi_status
  166. acpi_ut_build_package_object (
  167. acpi_operand_object     *obj,
  168. u8                      *buffer,
  169. u32                     *space_used);
  170. acpi_status
  171. acpi_ut_copy_iobject_to_eobject (
  172. acpi_operand_object     *obj,
  173. acpi_buffer             *ret_buffer);
  174. acpi_status
  175. acpi_ut_copy_esimple_to_isimple(
  176. acpi_object             *user_obj,
  177. acpi_operand_object     **return_obj);
  178. acpi_status
  179. acpi_ut_copy_eobject_to_iobject (
  180. acpi_object             *obj,
  181. acpi_operand_object     **internal_obj);
  182. acpi_status
  183. acpi_ut_copy_isimple_to_isimple (
  184. acpi_operand_object     *source_obj,
  185. acpi_operand_object     *dest_obj);
  186. acpi_status
  187. acpi_ut_copy_ipackage_to_ipackage (
  188. acpi_operand_object     *source_obj,
  189. acpi_operand_object     *dest_obj,
  190. acpi_walk_state         *walk_state);
  191. /*
  192.  * Ut_create - Object creation
  193.  */
  194. acpi_status
  195. acpi_ut_update_object_reference (
  196. acpi_operand_object     *object,
  197. u16                     action);
  198. /*
  199.  * Ut_debug - Debug interfaces
  200.  */
  201. void
  202. acpi_ut_init_stack_ptr_trace (
  203. void);
  204. void
  205. acpi_ut_track_stack_ptr (
  206. void);
  207. void
  208. acpi_ut_trace (
  209. u32                     line_number,
  210. acpi_debug_print_info   *dbg_info);
  211. void
  212. acpi_ut_trace_ptr (
  213. u32                     line_number,
  214. acpi_debug_print_info   *dbg_info,
  215. void                    *pointer);
  216. void
  217. acpi_ut_trace_u32 (
  218. u32                     line_number,
  219. acpi_debug_print_info   *dbg_info,
  220. u32                     integer);
  221. void
  222. acpi_ut_trace_str (
  223. u32                     line_number,
  224. acpi_debug_print_info   *dbg_info,
  225. NATIVE_CHAR             *string);
  226. void
  227. acpi_ut_exit (
  228. u32                     line_number,
  229. acpi_debug_print_info   *dbg_info);
  230. void
  231. acpi_ut_status_exit (
  232. u32                     line_number,
  233. acpi_debug_print_info   *dbg_info,
  234. acpi_status             status);
  235. void
  236. acpi_ut_value_exit (
  237. u32                     line_number,
  238. acpi_debug_print_info   *dbg_info,
  239. acpi_integer            value);
  240. void
  241. acpi_ut_ptr_exit (
  242. u32                     line_number,
  243. acpi_debug_print_info   *dbg_info,
  244. u8                      *ptr);
  245. void
  246. acpi_ut_report_info (
  247. NATIVE_CHAR             *module_name,
  248. u32                     line_number,
  249. u32                     component_id);
  250. void
  251. acpi_ut_report_error (
  252. NATIVE_CHAR             *module_name,
  253. u32                     line_number,
  254. u32                     component_id);
  255. void
  256. acpi_ut_report_warning (
  257. NATIVE_CHAR             *module_name,
  258. u32                     line_number,
  259. u32                     component_id);
  260. void
  261. acpi_ut_dump_buffer (
  262. u8                      *buffer,
  263. u32                     count,
  264. u32                     display,
  265. u32                     component_id);
  266. void
  267. acpi_ut_debug_print (
  268. u32                     requested_debug_level,
  269. u32                     line_number,
  270. acpi_debug_print_info   *dbg_info,
  271. char                    *format,
  272. ...) ACPI_PRINTF_LIKE_FUNC;
  273. void
  274. acpi_ut_debug_print_raw (
  275. u32                     requested_debug_level,
  276. u32                     line_number,
  277. acpi_debug_print_info   *dbg_info,
  278. char                    *format,
  279. ...) ACPI_PRINTF_LIKE_FUNC;
  280. /*
  281.  * Ut_delete - Object deletion
  282.  */
  283. void
  284. acpi_ut_delete_internal_obj (
  285. acpi_operand_object     *object);
  286. void
  287. acpi_ut_delete_internal_package_object (
  288. acpi_operand_object     *object);
  289. void
  290. acpi_ut_delete_internal_simple_object (
  291. acpi_operand_object     *object);
  292. acpi_status
  293. acpi_ut_delete_internal_object_list (
  294. acpi_operand_object     **obj_list);
  295. /*
  296.  * Ut_eval - object evaluation
  297.  */
  298. /* Method name strings */
  299. #define METHOD_NAME__HID        "_HID"
  300. #define METHOD_NAME__UID        "_UID"
  301. #define METHOD_NAME__ADR        "_ADR"
  302. #define METHOD_NAME__STA        "_STA"
  303. #define METHOD_NAME__REG        "_REG"
  304. #define METHOD_NAME__SEG        "_SEG"
  305. #define METHOD_NAME__BBN        "_BBN"
  306. #define METHOD_NAME__PRT        "_PRT"
  307. acpi_status
  308. acpi_ut_evaluate_numeric_object (
  309. NATIVE_CHAR             *object_name,
  310. acpi_namespace_node     *device_node,
  311. acpi_integer            *address);
  312. acpi_status
  313. acpi_ut_execute_HID (
  314. acpi_namespace_node     *device_node,
  315. acpi_device_id          *hid);
  316. acpi_status
  317. acpi_ut_execute_STA (
  318. acpi_namespace_node     *device_node,
  319. u32                     *status_flags);
  320. acpi_status
  321. acpi_ut_execute_UID (
  322. acpi_namespace_node     *device_node,
  323. acpi_device_id          *uid);
  324. /*
  325.  * Ut_mutex - mutual exclusion interfaces
  326.  */
  327. acpi_status
  328. acpi_ut_mutex_initialize (
  329. void);
  330. void
  331. acpi_ut_mutex_terminate (
  332. void);
  333. acpi_status
  334. acpi_ut_create_mutex (
  335. ACPI_MUTEX_HANDLE       mutex_id);
  336. acpi_status
  337. acpi_ut_delete_mutex (
  338. ACPI_MUTEX_HANDLE       mutex_id);
  339. acpi_status
  340. acpi_ut_acquire_mutex (
  341. ACPI_MUTEX_HANDLE       mutex_id);
  342. acpi_status
  343. acpi_ut_release_mutex (
  344. ACPI_MUTEX_HANDLE       mutex_id);
  345. /*
  346.  * Ut_object - internal object create/delete/cache routines
  347.  */
  348. acpi_operand_object  *
  349. acpi_ut_create_internal_object_dbg (
  350. NATIVE_CHAR             *module_name,
  351. u32                     line_number,
  352. u32                     component_id,
  353. acpi_object_type8       type);
  354. void *
  355. acpi_ut_allocate_object_desc_dbg (
  356. NATIVE_CHAR             *module_name,
  357. u32                     line_number,
  358. u32                     component_id);
  359. #define acpi_ut_create_internal_object(t) acpi_ut_create_internal_object_dbg (_THIS_MODULE,__LINE__,_COMPONENT,t)
  360. #define acpi_ut_allocate_object_desc()  acpi_ut_allocate_object_desc_dbg (_THIS_MODULE,__LINE__,_COMPONENT)
  361. void
  362. acpi_ut_delete_object_desc (
  363. acpi_operand_object     *object);
  364. u8
  365. acpi_ut_valid_internal_object (
  366. void                    *object);
  367. /*
  368.  * Ut_ref_cnt - Object reference count management
  369.  */
  370. void
  371. acpi_ut_add_reference (
  372. acpi_operand_object     *object);
  373. void
  374. acpi_ut_remove_reference (
  375. acpi_operand_object     *object);
  376. /*
  377.  * Ut_size - Object size routines
  378.  */
  379. acpi_status
  380. acpi_ut_get_simple_object_size (
  381. acpi_operand_object     *obj,
  382. u32                     *obj_length);
  383. acpi_status
  384. acpi_ut_get_package_object_size (
  385. acpi_operand_object     *obj,
  386. u32                     *obj_length);
  387. acpi_status
  388. acpi_ut_get_object_size(
  389. acpi_operand_object     *obj,
  390. u32                     *obj_length);
  391. /*
  392.  * Ut_state - Generic state creation/cache routines
  393.  */
  394. void
  395. acpi_ut_push_generic_state (
  396. acpi_generic_state      **list_head,
  397. acpi_generic_state      *state);
  398. acpi_generic_state *
  399. acpi_ut_pop_generic_state (
  400. acpi_generic_state      **list_head);
  401. acpi_generic_state *
  402. acpi_ut_create_generic_state (
  403. void);
  404. acpi_generic_state *
  405. acpi_ut_create_update_state (
  406. acpi_operand_object     *object,
  407. u16                     action);
  408. acpi_generic_state *
  409. acpi_ut_create_pkg_state (
  410. void                    *internal_object,
  411. void                    *external_object,
  412. u16                     index);
  413. acpi_status
  414. acpi_ut_create_update_state_and_push (
  415. acpi_operand_object     *object,
  416. u16                     action,
  417. acpi_generic_state      **state_list);
  418. acpi_status
  419. acpi_ut_create_pkg_state_and_push (
  420. void                    *internal_object,
  421. void                    *external_object,
  422. u16                     index,
  423. acpi_generic_state      **state_list);
  424. acpi_generic_state *
  425. acpi_ut_create_control_state (
  426. void);
  427. void
  428. acpi_ut_delete_generic_state (
  429. acpi_generic_state      *state);
  430. void
  431. acpi_ut_delete_generic_state_cache (
  432. void);
  433. void
  434. acpi_ut_delete_object_cache (
  435. void);
  436. /*
  437.  * utmisc
  438.  */
  439. acpi_status
  440. acpi_ut_divide (
  441. acpi_integer            *in_dividend,
  442. acpi_integer            *in_divisor,
  443. acpi_integer            *out_quotient,
  444. acpi_integer            *out_remainder);
  445. acpi_status
  446. acpi_ut_short_divide (
  447. acpi_integer            *in_dividend,
  448. u32                     divisor,
  449. acpi_integer            *out_quotient,
  450. u32                     *out_remainder);
  451. u8
  452. acpi_ut_valid_acpi_name (
  453. u32                     name);
  454. u8
  455. acpi_ut_valid_acpi_character (
  456. NATIVE_CHAR             character);
  457. NATIVE_CHAR *
  458. acpi_ut_strupr (
  459. NATIVE_CHAR             *src_string);
  460. acpi_status
  461. acpi_ut_resolve_package_references (
  462. acpi_operand_object     *obj_desc);
  463. #ifdef ACPI_DEBUG
  464. void
  465. acpi_ut_display_init_pathname (
  466. acpi_handle             obj_handle,
  467. char                    *path);
  468. #endif
  469. /*
  470.  * Utalloc - memory allocation and object caching
  471.  */
  472. void *
  473. acpi_ut_acquire_from_cache (
  474. u32                     list_id);
  475. void
  476. acpi_ut_release_to_cache (
  477. u32                     list_id,
  478. void                    *object);
  479. void
  480. acpi_ut_delete_generic_cache (
  481. u32                     list_id);
  482. /* Debug Memory allocation functions */
  483. void *
  484. acpi_ut_allocate (
  485. u32                     size,
  486. u32                     component,
  487. NATIVE_CHAR             *module,
  488. u32                     line);
  489. void *
  490. acpi_ut_callocate (
  491. u32                     size,
  492. u32                     component,
  493. NATIVE_CHAR             *module,
  494. u32                     line);
  495. void
  496. acpi_ut_free (
  497. void                    *address,
  498. u32                     component,
  499. NATIVE_CHAR             *module,
  500. u32                     line);
  501. #ifdef ACPI_DBG_TRACK_ALLOCATIONS
  502. void
  503. acpi_ut_dump_allocation_info (
  504. void);
  505. void
  506. acpi_ut_dump_allocations (
  507. u32                     component,
  508. NATIVE_CHAR             *module);
  509. #endif
  510. #endif /* _ACUTILS_H */