acobject.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:14k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /******************************************************************************
  2.  *
  3.  * Name: acobject.h - Definition of acpi_operand_object  (Internal object only)
  4.  *       $Revision: 93 $
  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 _ACOBJECT_H
  25. #define _ACOBJECT_H
  26. /*
  27.  * The acpi_operand_object  is used to pass AML operands from the dispatcher
  28.  * to the interpreter, and to keep track of the various handlers such as
  29.  * address space handlers and notify handlers.  The object is a constant
  30.  * size in order to allow them to be cached and reused.
  31.  *
  32.  * All variants of the acpi_operand_object  are defined with the same
  33.  * sequence of field types, with fields that are not used in a particular
  34.  * variant being named "Reserved".  This is not strictly necessary, but
  35.  * may in some circumstances simplify understanding if these structures
  36.  * need to be displayed in a debugger having limited (or no) support for
  37.  * union types.  It also simplifies some debug code in Dump_table() which
  38.  * dumps multi-level values: fetching Buffer.Pointer suffices to pick up
  39.  * the value or next level for any of several types.
  40.  */
  41. /******************************************************************************
  42.  *
  43.  * Common Descriptors
  44.  *
  45.  *****************************************************************************/
  46. /*
  47.  * Common area for all objects.
  48.  *
  49.  * Data_type is used to differentiate between internal descriptors, and MUST
  50.  * be the first byte in this structure.
  51.  */
  52. #define ACPI_OBJECT_COMMON_HEADER           /* SIZE/ALIGNMENT: 32-bits plus trailing 8-bit flag */
  53. u8                          data_type;          /* To differentiate various internal objs */
  54. u8                          type;               /* acpi_object_type */
  55. u16                         reference_count;    /* For object deletion management */
  56. u8                          flags; 
  57. /* Defines for flag byte above */
  58. #define AOPOBJ_STATIC_ALLOCATION    0x1
  59. #define AOPOBJ_STATIC_POINTER       0x2
  60. #define AOPOBJ_DATA_VALID           0x4
  61. #define AOPOBJ_ZERO_CONST           0x4
  62. #define AOPOBJ_INITIALIZED          0x8
  63. /*
  64.  * Common bitfield for the field objects
  65.  * "Field Datum"    -- a datum from the actual field object
  66.  * "Buffer Datum"   -- a datum from a user buffer, read from or to be written to the field
  67.  */
  68. #define ACPI_COMMON_FIELD_INFO              /* SIZE/ALIGNMENT: 24 bits + three 32-bit values */
  69. u8                          access_flags;
  70. u16                         bit_length;         /* Length of field in bits */
  71. u32                         base_byte_offset;   /* Byte offset within containing object */
  72. u8                          access_bit_width;   /* Read/Write size in bits (from ASL Access_type)*/
  73. u8                          access_byte_width;  /* Read/Write size in bytes */
  74. u8                          update_rule;        /* How neighboring field bits are handled */
  75. u8                          lock_rule;          /* Global Lock: 1 = "Must Lock" */
  76. u8                          start_field_bit_offset;/* Bit offset within first field datum (0-63) */
  77. u8                          datum_valid_bits;   /* Valid bit in first "Field datum" */
  78. u8                          end_field_valid_bits; /* Valid bits in the last "field datum" */
  79. u8                          end_buffer_valid_bits; /* Valid bits in the last "buffer datum" */
  80. u32                         value;              /* Value to store into the Bank or Index register */
  81. /* Access flag bits */
  82. #define AFIELD_SINGLE_DATUM         0x1
  83. /*
  84.  * Fields common to both Strings and Buffers
  85.  */
  86. #define ACPI_COMMON_BUFFER_INFO 
  87. u32                         length;
  88. /******************************************************************************
  89.  *
  90.  * Individual Object Descriptors
  91.  *
  92.  *****************************************************************************/
  93. typedef struct /* COMMON */
  94. {
  95. ACPI_OBJECT_COMMON_HEADER
  96. } ACPI_OBJECT_COMMON;
  97. typedef struct /* CACHE_LIST */
  98. {
  99. ACPI_OBJECT_COMMON_HEADER
  100. union acpi_operand_obj      *next;              /* Link for object cache and internal lists*/
  101. } ACPI_OBJECT_CACHE_LIST;
  102. typedef struct /* NUMBER - has value */
  103. {
  104. ACPI_OBJECT_COMMON_HEADER
  105. acpi_integer                value;
  106. } ACPI_OBJECT_INTEGER;
  107. typedef struct /* STRING - has length and pointer - Null terminated, ASCII characters only */
  108. {
  109. ACPI_OBJECT_COMMON_HEADER
  110. ACPI_COMMON_BUFFER_INFO
  111. NATIVE_CHAR                 *pointer;           /* String value in AML stream or in allocated space */
  112. } ACPI_OBJECT_STRING;
  113. typedef struct /* BUFFER - has length and pointer - not null terminated */
  114. {
  115. ACPI_OBJECT_COMMON_HEADER
  116. ACPI_COMMON_BUFFER_INFO
  117. u8                          *pointer;           /* Buffer value in AML stream or in allocated space */
  118. } ACPI_OBJECT_BUFFER;
  119. typedef struct /* PACKAGE - has count, elements, next element */
  120. {
  121. ACPI_OBJECT_COMMON_HEADER
  122. u32                         count;              /* # of elements in package */
  123. union acpi_operand_obj      **elements;         /* Array of pointers to Acpi_objects */
  124. union acpi_operand_obj      **next_element;     /* used only while initializing */
  125. } ACPI_OBJECT_PACKAGE;
  126. typedef struct /* DEVICE - has handle and notification handler/context */
  127. {
  128. ACPI_OBJECT_COMMON_HEADER
  129. union acpi_operand_obj      *sys_handler;        /* Handler for system notifies */
  130. union acpi_operand_obj      *drv_handler;        /* Handler for driver notifies */
  131. union acpi_operand_obj      *addr_handler;       /* Handler for Address space */
  132. } ACPI_OBJECT_DEVICE;
  133. typedef struct /* EVENT */
  134. {
  135. ACPI_OBJECT_COMMON_HEADER
  136. void                        *semaphore;
  137. } ACPI_OBJECT_EVENT;
  138. #define INFINITE_CONCURRENCY        0xFF
  139. typedef struct /* METHOD */
  140. {
  141. ACPI_OBJECT_COMMON_HEADER
  142. u8                          method_flags;
  143. u8                          param_count;
  144. u32                         aml_length;
  145. void                        *semaphore;
  146. u8                          *aml_start;
  147. u8                          concurrency;
  148. u8                          thread_count;
  149. acpi_owner_id               owning_id;
  150. } ACPI_OBJECT_METHOD;
  151. typedef struct acpi_obj_mutex /* MUTEX */
  152. {
  153. ACPI_OBJECT_COMMON_HEADER
  154. u16                         sync_level;
  155. u16                         acquisition_depth;
  156. void                        *semaphore;
  157. void                        *owner;
  158. union acpi_operand_obj      *prev;              /* Link for list of acquired mutexes */
  159. union acpi_operand_obj      *next;              /* Link for list of acquired mutexes */
  160. } ACPI_OBJECT_MUTEX;
  161. typedef struct /* REGION */
  162. {
  163. ACPI_OBJECT_COMMON_HEADER
  164. u8                          space_id;
  165. u32                         length;
  166. ACPI_PHYSICAL_ADDRESS       address;
  167. union acpi_operand_obj      *extra;             /* Pointer to executable AML (in region definition) */
  168. union acpi_operand_obj      *addr_handler;      /* Handler for system notifies */
  169. acpi_namespace_node         *node;              /* containing object */
  170. union acpi_operand_obj      *next;
  171. } ACPI_OBJECT_REGION;
  172. typedef struct /* POWER RESOURCE - has Handle and notification handler/context*/
  173. {
  174. ACPI_OBJECT_COMMON_HEADER
  175. u32                         system_level;
  176. u32                         resource_order;
  177. union acpi_operand_obj      *sys_handler;       /* Handler for system notifies */
  178. union acpi_operand_obj      *drv_handler;       /* Handler for driver notifies */
  179. } ACPI_OBJECT_POWER_RESOURCE;
  180. typedef struct /* PROCESSOR - has Handle and notification handler/context*/
  181. {
  182. ACPI_OBJECT_COMMON_HEADER
  183. u32                         proc_id;
  184. u32                         length;
  185. ACPI_IO_ADDRESS             address;
  186. union acpi_operand_obj      *sys_handler;       /* Handler for system notifies */
  187. union acpi_operand_obj      *drv_handler;       /* Handler for driver notifies */
  188. union acpi_operand_obj      *addr_handler;      /* Handler for Address space */
  189. } ACPI_OBJECT_PROCESSOR;
  190. typedef struct /* THERMAL ZONE - has Handle and Handler/Context */
  191. {
  192. ACPI_OBJECT_COMMON_HEADER
  193. union acpi_operand_obj      *sys_handler;       /* Handler for system notifies */
  194. union acpi_operand_obj      *drv_handler;       /* Handler for driver notifies */
  195. union acpi_operand_obj      *addr_handler;      /* Handler for Address space */
  196. } ACPI_OBJECT_THERMAL_ZONE;
  197. /*
  198.  * Fields.  All share a common header/info field.
  199.  */
  200. typedef struct /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */
  201. {
  202. ACPI_OBJECT_COMMON_HEADER
  203. ACPI_COMMON_FIELD_INFO
  204. union acpi_operand_obj      *region_obj;        /* Containing Operation Region object */
  205.  /* (REGION/BANK fields only) */
  206. } ACPI_OBJECT_FIELD_COMMON;
  207. typedef struct /* REGION FIELD */
  208. {
  209. ACPI_OBJECT_COMMON_HEADER
  210. ACPI_COMMON_FIELD_INFO
  211. union acpi_operand_obj      *region_obj;        /* Containing Op_region object */
  212. } ACPI_OBJECT_REGION_FIELD;
  213. typedef struct /* BANK FIELD */
  214. {
  215. ACPI_OBJECT_COMMON_HEADER
  216. ACPI_COMMON_FIELD_INFO
  217. union acpi_operand_obj      *region_obj;        /* Containing Op_region object */
  218. union acpi_operand_obj      *bank_register_obj; /* Bank_select Register object */
  219. } ACPI_OBJECT_BANK_FIELD;
  220. typedef struct /* INDEX FIELD */
  221. {
  222. ACPI_OBJECT_COMMON_HEADER
  223. ACPI_COMMON_FIELD_INFO
  224. /*
  225.  * No "Region_obj" pointer needed since the Index and Data registers
  226.  * are each field definitions unto themselves.
  227.  */
  228. union acpi_operand_obj      *index_obj;         /* Index register */
  229. union acpi_operand_obj      *data_obj;          /* Data register */
  230. } ACPI_OBJECT_INDEX_FIELD;
  231. /* The Buffer_field is different in that it is part of a Buffer, not an Op_region */
  232. typedef struct /* BUFFER FIELD */
  233. {
  234. ACPI_OBJECT_COMMON_HEADER
  235. ACPI_COMMON_FIELD_INFO
  236. union acpi_operand_obj      *extra;             /* Pointer to executable AML (in field definition) */
  237. acpi_namespace_node         *node;              /* Parent (containing) object node */
  238. union acpi_operand_obj      *buffer_obj;        /* Containing Buffer object */
  239. } ACPI_OBJECT_BUFFER_FIELD;
  240. /*
  241.  * Handlers
  242.  */
  243. typedef struct /* NOTIFY HANDLER */
  244. {
  245. ACPI_OBJECT_COMMON_HEADER
  246. acpi_namespace_node         *node;               /* Parent device */
  247. acpi_notify_handler         handler;
  248. void                        *context;
  249. } ACPI_OBJECT_NOTIFY_HANDLER;
  250. /* Flags for address handler */
  251. #define ADDR_HANDLER_DEFAULT_INSTALLED  0x1
  252. typedef struct /* ADDRESS HANDLER */
  253. {
  254. ACPI_OBJECT_COMMON_HEADER
  255. u8                          space_id;
  256. u16                         hflags;
  257. acpi_adr_space_handler      handler;
  258. acpi_namespace_node         *node;              /* Parent device */
  259. void                        *context;
  260. acpi_adr_space_setup        setup;
  261. union acpi_operand_obj      *region_list;       /* regions using this handler */
  262. union acpi_operand_obj      *next;
  263. } ACPI_OBJECT_ADDR_HANDLER;
  264. /*
  265.  * The Reference object type is used for these opcodes:
  266.  * Arg[0-6], Local[0-7], Index_op, Name_op, Zero_op, One_op, Ones_op, Debug_op
  267.  */
  268. typedef struct /* Reference - Local object type */
  269. {
  270. ACPI_OBJECT_COMMON_HEADER
  271. u8                          target_type;        /* Used for Index_op */
  272. u16                         opcode;
  273. u32                         offset;             /* Used for Arg_op, Local_op, and Index_op */
  274. void                        *object;            /* Name_op=>HANDLE to obj, Index_op=>acpi_operand_object */
  275. acpi_namespace_node         *node;
  276. union acpi_operand_obj      **where;
  277. } ACPI_OBJECT_REFERENCE;
  278. /*
  279.  * Extra object is used as additional storage for types that
  280.  * have AML code in their declarations (Term_args) that must be
  281.  * evaluated at run time.
  282.  *
  283.  * Currently: Region and Field_unit types
  284.  */
  285. typedef struct /* EXTRA */
  286. {
  287. ACPI_OBJECT_COMMON_HEADER
  288. u8                          byte_fill1;
  289. u16                         word_fill1;
  290. u32                         aml_length;
  291. u8                          *aml_start;
  292. acpi_namespace_node         *method_REG;        /* _REG method for this region (if any) */
  293. void                        *region_context;    /* Region-specific data */
  294. } ACPI_OBJECT_EXTRA;
  295. /******************************************************************************
  296.  *
  297.  * acpi_operand_object  Descriptor - a giant union of all of the above
  298.  *
  299.  *****************************************************************************/
  300. typedef union acpi_operand_obj
  301. {
  302. ACPI_OBJECT_COMMON          common;
  303. ACPI_OBJECT_CACHE_LIST      cache;
  304. ACPI_OBJECT_INTEGER         integer;
  305. ACPI_OBJECT_STRING          string;
  306. ACPI_OBJECT_BUFFER          buffer;
  307. ACPI_OBJECT_PACKAGE         package;
  308. ACPI_OBJECT_BUFFER_FIELD    buffer_field;
  309. ACPI_OBJECT_DEVICE          device;
  310. ACPI_OBJECT_EVENT           event;
  311. ACPI_OBJECT_METHOD          method;
  312. ACPI_OBJECT_MUTEX           mutex;
  313. ACPI_OBJECT_REGION          region;
  314. ACPI_OBJECT_POWER_RESOURCE  power_resource;
  315. ACPI_OBJECT_PROCESSOR       processor;
  316. ACPI_OBJECT_THERMAL_ZONE    thermal_zone;
  317. ACPI_OBJECT_FIELD_COMMON    common_field;
  318. ACPI_OBJECT_REGION_FIELD    field;
  319. ACPI_OBJECT_BANK_FIELD      bank_field;
  320. ACPI_OBJECT_INDEX_FIELD     index_field;
  321. ACPI_OBJECT_REFERENCE       reference;
  322. ACPI_OBJECT_NOTIFY_HANDLER  notify_handler;
  323. ACPI_OBJECT_ADDR_HANDLER    addr_handler;
  324. ACPI_OBJECT_EXTRA           extra;
  325. } acpi_operand_object;
  326. #endif /* _ACOBJECT_H */