Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

399 lines
14 KiB

  1. /*** amli.h - AML Interpreter Public Definitions
  2. *
  3. * Copyright (c) 1996,1997 Microsoft Corporation
  4. * Author: Michael Tsang (MikeTs)
  5. * Created 09/03/96
  6. *
  7. * MODIFICATION HISTORY
  8. */
  9. #ifndef _AMLI_H
  10. #define _AMLI_H
  11. #include <list.h>
  12. #ifndef _INC_NSOBJ_ONLY
  13. /*** Build Options
  14. */
  15. #if DBG
  16. #define DEBUG
  17. #define DEBUGGER
  18. #define TRACING
  19. #endif
  20. #ifdef MAXDEBUG
  21. #define TRACING
  22. #endif
  23. /*** Macros
  24. */
  25. #define AMLI_FAC_CODE 0
  26. #define NTINFO(x) (x)
  27. #define NTWARN(x) (x)
  28. #define NTERR(x) (x)
  29. #define AMLIERR(x) (x)
  30. #define STDCALL __stdcall
  31. #define AMLIAPI __cdecl
  32. #ifndef EXPORT
  33. #define EXPORT __cdecl
  34. #endif
  35. // Name space navigation macros
  36. #define NSGETPARENT(p) ((p)->pnsParent)
  37. #define NSGETFIRSTCHILD(p) ((p)->pnsFirstChild)
  38. #define NSGETPREVSIBLING(p) (((p)->pnsParent != NULL && \
  39. (p)->pnsParent->pnsFirstChild != \
  40. (p))? \
  41. (PNSOBJ)((p)->list.plistPrev): NULL)
  42. #define NSGETNEXTSIBLING(p) (((p)->pnsParent != NULL && \
  43. (p)->pnsParent->pnsFirstChild != \
  44. (PNSOBJ)((p)->list.plistNext))? \
  45. (PNSOBJ)((p)->list.plistNext): NULL)
  46. #define NSGETOBJTYPE(p) ((p)->ObjData.dwDataType)
  47. /*** Constants
  48. */
  49. // AMLI Error Codes
  50. #define AMLIERR_NONE STATUS_SUCCESS
  51. #define AMLIERR_OUT_OF_MEM STATUS_INSUFFICIENT_RESOURCES
  52. #define AMLIERR_INVALID_OPCODE STATUS_ACPI_INVALID_OPCODE
  53. #define AMLIERR_NAME_TOO_LONG STATUS_NAME_TOO_LONG
  54. #define AMLIERR_ASSERT_FAILED STATUS_ACPI_ASSERT_FAILED
  55. #define AMLIERR_INVALID_NAME STATUS_OBJECT_NAME_INVALID
  56. #define AMLIERR_OBJ_NOT_FOUND STATUS_OBJECT_NAME_NOT_FOUND
  57. #define AMLIERR_OBJ_ALREADY_EXIST STATUS_OBJECT_NAME_COLLISION
  58. #define AMLIERR_INDEX_TOO_BIG STATUS_ACPI_INVALID_INDEX
  59. #define AMLIERR_ARG_NOT_EXIST STATUS_ACPI_INVALID_ARGUMENT
  60. #define AMLIERR_FATAL STATUS_ACPI_FATAL
  61. #define AMLIERR_INVALID_SUPERNAME STATUS_ACPI_INVALID_SUPERNAME
  62. #define AMLIERR_UNEXPECTED_ARGTYPE STATUS_ACPI_INVALID_ARGTYPE
  63. #define AMLIERR_UNEXPECTED_OBJTYPE STATUS_ACPI_INVALID_OBJTYPE
  64. #define AMLIERR_UNEXPECTED_TARGETTYPE STATUS_ACPI_INVALID_TARGETTYPE
  65. #define AMLIERR_INCORRECT_NUMARG STATUS_ACPI_INCORRECT_ARGUMENT_COUNT
  66. #define AMLIERR_FAILED_ADDR_XLATE STATUS_ACPI_ADDRESS_NOT_MAPPED
  67. #define AMLIERR_INVALID_EVENTTYPE STATUS_ACPI_INVALID_EVENTTYPE
  68. #define AMLIERR_REGHANDLER_FAILED STATUS_ACPI_REG_HANDLER_FAILED
  69. #define AMLIERR_HANDLER_EXIST STATUS_ACPI_HANDLER_COLLISION
  70. #define AMLIERR_INVALID_DATA STATUS_ACPI_INVALID_DATA
  71. #define AMLIERR_INVALID_REGIONSPACE STATUS_ACPI_INVALID_REGION
  72. #define AMLIERR_INVALID_ACCSIZE STATUS_ACPI_INVALID_ACCESS_SIZE
  73. #define AMLIERR_INVALID_TABLE STATUS_ACPI_INVALID_TABLE
  74. #define AMLIERR_ACQUIREGL_FAILED STATUS_ACPI_ACQUIRE_GLOBAL_LOCK
  75. #define AMLIERR_ALREADY_INITIALIZED STATUS_ACPI_ALREADY_INITIALIZED
  76. #define AMLIERR_NOT_INITIALIZED STATUS_ACPI_NOT_INITIALIZED
  77. #define AMLIERR_MUTEX_INVALID_LEVEL STATUS_ACPI_INVALID_MUTEX_LEVEL
  78. #define AMLIERR_MUTEX_NOT_OWNED STATUS_ACPI_MUTEX_NOT_OWNED
  79. #define AMLIERR_MUTEX_NOT_OWNER STATUS_ACPI_MUTEX_NOT_OWNER
  80. #define AMLIERR_RS_ACCESS STATUS_ACPI_RS_ACCESS
  81. #define AMLIERR_STACK_OVERFLOW STATUS_ACPI_STACK_OVERFLOW
  82. #define AMLIERR_INVALID_BUFFSIZE STATUS_INVALID_BUFFER_SIZE
  83. #define AMLIERR_BUFF_TOOSMALL STATUS_BUFFER_TOO_SMALL
  84. #define AMLIERR_NOTIFY_FAILED STATUS_ACPI_FATAL
  85. // RegEventHandler constants
  86. #define EVTYPE_OPCODE 0x00000001
  87. #define EVTYPE_NOTIFY 0x00000002
  88. #define EVTYPE_FATAL 0x00000003
  89. #define EVTYPE_VALIDATE_TABLE 0x00000004
  90. #define EVTYPE_ACQREL_GLOBALLOCK 0x00000005
  91. #define EVTYPE_RS_COOKACCESS 0x00000006
  92. #define EVTYPE_RS_RAWACCESS 0x00000007
  93. #define EVTYPE_CON_MESSAGE 0x00000008
  94. #define EVTYPE_CON_PROMPT 0x00000009
  95. #define EVTYPE_CREATE 0x0000000A
  96. #define EVTYPE_DESTROYOBJ 0x0000000B
  97. #define EVTYPE_OPCODE_EX 0x0000000C
  98. // OPCODE_EX flags
  99. #define OPEXF_NOTIFY_PRE 0x00000001
  100. #define OPEXF_NOTIFY_POST 0x00000002
  101. // DESTROYOBJ events
  102. #define DESTROYOBJ_START 0x00000001
  103. #define DESTROYOBJ_REMOVE_OBJECT 0x00000002
  104. #define DESTROYOBJ_END 0x00000003
  105. #define DESTROYOBJ_CHILD_NOT_FREED 0x00000004
  106. #define DESTROYOBJ_BOGUS_PARENT 0x00000005
  107. // Notify Event Constants
  108. #define OPEVENT_DEVICE_ENUM 0x00000000
  109. #define OPEVENT_DEVICE_CHECK 0x00000001
  110. #define OPEVENT_DEVICE_WAKE 0x00000002
  111. #define OPEVENT_DEVICE_EJECT 0x00000003
  112. #define RSACCESS_READ 0
  113. #define RSACCESS_WRITE 1
  114. #define GLOBALLOCK_ACQUIRE 0
  115. #define GLOBALLOCK_RELEASE 1
  116. // dwfAMLIInit flags
  117. #define AMLIIF_INIT_BREAK 0x00000001 //break at AMLIInit completion
  118. #define AMLIIF_LOADDDB_BREAK 0x00000002 //break at LoadDDB completion
  119. #define AMLIIF_NOCHK_TABLEVER 0x80000000 //do not check table version
  120. #endif //ifndef _INC_NSOBJ_ONLY
  121. #define NAMESEG ULONG
  122. #define SUPERNAME NAMESEG
  123. // dwfFlags for AMLIGetNameSpaceObject
  124. #define NSF_LOCAL_SCOPE 0x00000001
  125. /*** Type and Structure definitions
  126. */
  127. typedef struct _ObjData OBJDATA, *POBJDATA, **PPOBJDATA;
  128. typedef struct _NSObj NSOBJ, *PNSOBJ, **PPNSOBJ;
  129. //dwDataType values
  130. typedef enum _OBJTYPES {
  131. OBJTYPE_UNKNOWN = 0,
  132. OBJTYPE_INTDATA,
  133. OBJTYPE_STRDATA,
  134. OBJTYPE_BUFFDATA,
  135. OBJTYPE_PKGDATA,
  136. OBJTYPE_FIELDUNIT,
  137. OBJTYPE_DEVICE,
  138. OBJTYPE_EVENT,
  139. OBJTYPE_METHOD,
  140. OBJTYPE_MUTEX,
  141. OBJTYPE_OPREGION,
  142. OBJTYPE_POWERRES,
  143. OBJTYPE_PROCESSOR,
  144. OBJTYPE_THERMALZONE,
  145. OBJTYPE_BUFFFIELD,
  146. OBJTYPE_DDBHANDLE,
  147. OBJTYPE_DEBUG,
  148. //These are internal object types (not to be exported to the ASL code)
  149. OBJTYPE_INTERNAL = 0x80,
  150. OBJTYPE_OBJALIAS = 0x80,
  151. OBJTYPE_DATAALIAS,
  152. OBJTYPE_BANKFIELD,
  153. OBJTYPE_FIELD,
  154. OBJTYPE_INDEXFIELD,
  155. OBJTYPE_DATA,
  156. OBJTYPE_DATAFIELD,
  157. OBJTYPE_DATAOBJ,
  158. } OBJTYPES;
  159. struct _ObjData
  160. {
  161. USHORT dwfData; //flags
  162. USHORT dwDataType; //object type
  163. union
  164. {
  165. ULONG dwRefCount; //reference count if base object
  166. POBJDATA pdataBase; //alias pointer to base object
  167. };
  168. union
  169. {
  170. ULONG dwDataValue; //data value of object 32-bit
  171. ULONG_PTR uipDataValue; //data value of object 64-bit
  172. PNSOBJ pnsAlias; //alias ptr to base obj (OBJTYPE_OBJALIAS)
  173. POBJDATA pdataAlias; //alias ptr to base obj (OBJTYPE_DATAALIAS)
  174. PVOID powner; //object owner (OBJTYPE_DDBHANDLE)
  175. };
  176. ULONG dwDataLen; //object buffer length
  177. PUCHAR pbDataBuff; //object buffer
  178. };
  179. //dwfData flags
  180. #define DATAF_BUFF_ALIAS 0x00000001
  181. #define DATAF_GLOBAL_LOCK 0x00000002
  182. #define DATAF_NSOBJ_DEFUNC 0x00000004
  183. //Predefined data values (dwDataValue)
  184. #define DATAVALUE_ZERO 0
  185. #define DATAVALUE_ONE 1
  186. #define DATAVALUE_ONES 0xffffffff
  187. struct _NSObj
  188. {
  189. LIST list; //NOTE: list must be first in structure
  190. PNSOBJ pnsParent;
  191. PNSOBJ pnsFirstChild;
  192. ULONG dwNameSeg;
  193. HANDLE hOwner;
  194. PNSOBJ pnsOwnedNext;
  195. OBJDATA ObjData;
  196. PVOID Context;
  197. ULONG dwRefCount;
  198. };
  199. typedef struct _FieldDesc
  200. {
  201. ULONG dwByteOffset;
  202. ULONG dwStartBitPos;
  203. ULONG dwNumBits;
  204. ULONG dwFieldFlags;
  205. } FIELDDESC, *PFIELDDESC;
  206. //dwFieldFlags
  207. #define FDF_FIELDFLAGS_MASK 0x000000ff
  208. #define FDF_ACCATTRIB_MASK 0x0000ff00
  209. #define FDF_BUFFER_TYPE 0x00010000
  210. #define FDF_NEEDLOCK 0x80000000
  211. typedef struct _BuffFieldObj
  212. {
  213. FIELDDESC FieldDesc;
  214. PUCHAR pbDataBuff;
  215. ULONG dwBuffLen;
  216. } BUFFFIELDOBJ, *PBUFFFIELDOBJ;
  217. typedef struct _FieldUnitObj
  218. {
  219. FIELDDESC FieldDesc;
  220. PNSOBJ pnsFieldParent;
  221. } FIELDUNITOBJ, *PFIELDUNITOBJ;
  222. typedef struct _BankFieldObj
  223. {
  224. PNSOBJ pnsBase;
  225. PNSOBJ pnsBank;
  226. ULONG dwBankValue;
  227. } BANKFIELDOBJ, *PBANKFIELDOBJ;
  228. typedef struct _FieldObj
  229. {
  230. PNSOBJ pnsBase;
  231. } FIELDOBJ, *PFIELDOBJ;
  232. typedef struct _IndexFieldObj
  233. {
  234. PNSOBJ pnsIndex;
  235. PNSOBJ pnsData;
  236. } INDEXFIELDOBJ, *PINDEXFIELDOBJ;
  237. #ifdef ASL_ASSEMBLER
  238. #define KSPIN_LOCK ULONG
  239. #endif
  240. typedef struct _OpRegionObj
  241. {
  242. ULONG_PTR uipOffset;
  243. ULONG dwLen;
  244. UCHAR bRegionSpace;
  245. UCHAR reserved[3];
  246. volatile LONG RegionBusy;
  247. KSPIN_LOCK listLock;
  248. PLIST plistWaiters;
  249. } OPREGIONOBJ, *POPREGIONOBJ;
  250. typedef struct _MutexObj
  251. {
  252. ULONG dwSyncLevel;
  253. ULONG dwcOwned;
  254. HANDLE hOwner;
  255. PLIST plistWaiters;
  256. } MUTEXOBJ, *PMUTEXOBJ;
  257. typedef struct _EventObj
  258. {
  259. ULONG dwcSignaled;
  260. PLIST plistWaiters;
  261. } EVENTOBJ, *PEVENTOBJ;
  262. typedef struct _MethodObj
  263. {
  264. MUTEXOBJ Mutex;
  265. UCHAR bMethodFlags;
  266. UCHAR abCodeBuff[ANYSIZE_ARRAY];
  267. } METHODOBJ, *PMETHODOBJ;
  268. typedef struct _PowerResObj
  269. {
  270. UCHAR bSystemLevel;
  271. UCHAR bResOrder;
  272. } POWERRESOBJ, *PPOWERRESOBJ;
  273. typedef struct _ProcessorObj
  274. {
  275. ULONG dwPBlk;
  276. ULONG dwPBlkLen;
  277. UCHAR bApicID;
  278. } PROCESSOROBJ, *PPROCESSOROBJ;
  279. typedef struct _PackageObj
  280. {
  281. ULONG dwcElements;
  282. OBJDATA adata[ANYSIZE_ARRAY];
  283. } PACKAGEOBJ, *PPACKAGEOBJ;
  284. #ifndef _INC_NSOBJ_ONLY
  285. typedef struct _ctxtdata
  286. {
  287. PVOID dwData1;
  288. PVOID dwData2;
  289. PVOID dwData3;
  290. PVOID dwData4;
  291. } CTXTDATA, *PCTXTDATA;
  292. typedef NTSTATUS (EXPORT *PFNHND)();
  293. typedef NTSTATUS (EXPORT *PFNOH)(ULONG, ULONG, PNSOBJ, ULONG);
  294. typedef NTSTATUS (EXPORT *PFNOO)(ULONG, PNSOBJ);
  295. typedef VOID (EXPORT *PFNAA)(PVOID);
  296. typedef NTSTATUS (EXPORT *PFNNH)(ULONG, ULONG, PNSOBJ, ULONG, PFNAA, PVOID);
  297. typedef NTSTATUS (EXPORT *PFNCA)(ULONG, PNSOBJ, ULONG_PTR, ULONG, PULONG, ULONG_PTR,
  298. PFNAA, PVOID);
  299. typedef NTSTATUS (EXPORT *PFNRA)(ULONG, PFIELDUNITOBJ, POBJDATA, ULONG_PTR, PFNAA,
  300. PVOID);
  301. typedef NTSTATUS (EXPORT *PFNVT)(PDSDT, ULONG_PTR);
  302. typedef NTSTATUS (EXPORT *PFNFT)(ULONG, ULONG, ULONG, ULONG_PTR, ULONG_PTR);
  303. typedef NTSTATUS (EXPORT *PFNGL)(ULONG, ULONG, ULONG_PTR, PFNAA, PVOID);
  304. typedef VOID (EXPORT *PFNCM)(PSZ, ULONG_PTR);
  305. typedef VOID (EXPORT *PFNCP)(PSZ, PSZ, ULONG, ULONG_PTR);
  306. typedef VOID (EXPORT *PFNACB)(PNSOBJ, NTSTATUS, POBJDATA, PVOID);
  307. typedef NTSTATUS (EXPORT *PFNOPEX)(ULONG, ULONG, ULONG, PNSOBJ, ULONG);
  308. typedef NTSTATUS (EXPORT *PFNDOBJ)(ULONG, PVOID, ULONG);
  309. /*** Exported function prototypes
  310. */
  311. #ifdef DEBUGGER
  312. VOID STDCALL AMLIDebugger(BOOLEAN fCallFromVxD);
  313. #endif
  314. NTSTATUS AMLIAPI AMLIInitialize(ULONG dwCtxtBlkSize, ULONG dwGlobalHeapBlkSize,
  315. ULONG dwfAMLIInit, ULONG dwmsTimeSliceLength,
  316. ULONG dwmsTimeSliceInterval, ULONG dwmsMaxCTObjs);
  317. NTSTATUS AMLIAPI AMLITerminate(VOID);
  318. NTSTATUS AMLIAPI AMLILoadDDB(PDSDT pDSDT, HANDLE *phDDB);
  319. VOID AMLIAPI AMLIUnloadDDB(HANDLE hDDB);
  320. NTSTATUS AMLIAPI AMLIGetNameSpaceObject(PSZ pszObjPath, PNSOBJ pnsScope,
  321. PPNSOBJ ppns, ULONG dwfFlags);
  322. NTSTATUS AMLIAPI AMLIGetFieldUnitRegionObj(PFIELDUNITOBJ pfu, PPNSOBJ ppns);
  323. NTSTATUS AMLIAPI AMLIEvalNameSpaceObject(PNSOBJ pns, POBJDATA pResult,
  324. int icArgs, POBJDATA pArgs);
  325. NTSTATUS AMLIAPI AMLIAsyncEvalObject(PNSOBJ pns, POBJDATA pResult, int icArgs,
  326. POBJDATA pArgs, PFNACB pfnAsynCallBack,
  327. PVOID pvContext);
  328. NTSTATUS AMLIAPI AMLINestAsyncEvalObject(PNSOBJ pns, POBJDATA pResult,
  329. int icArgs, POBJDATA pArgs,
  330. PFNACB pfnAsynCallBack,
  331. PVOID pvContext);
  332. NTSTATUS AMLIAPI AMLIEvalPackageElement(PNSOBJ pns, int iPktIndex,
  333. POBJDATA pResult);
  334. NTSTATUS AMLIAPI AMLIEvalPkgDataElement(POBJDATA pdataPkg, int iPkgIndex,
  335. POBJDATA pdataResult);
  336. VOID AMLIAPI AMLIFreeDataBuffs(POBJDATA pdata, int icData);
  337. NTSTATUS AMLIAPI AMLIRegEventHandler(ULONG dwEventType, ULONG_PTR uipEventData,
  338. PFNHND pfnHandler, ULONG_PTR uipParam);
  339. NTSTATUS AMLIAPI AMLIPauseInterpreter(PFNAA pfnCallBack, PVOID Context);
  340. VOID AMLIAPI AMLIResumeInterpreter(VOID);
  341. VOID AMLIAPI AMLIReferenceObject(PNSOBJ pnsObj);
  342. VOID AMLIAPI AMLIDereferenceObject(PNSOBJ pnsObj);
  343. NTSTATUS AMLIAPI AMLIDestroyFreedObjs(PNSOBJ pnsoObj);
  344. #ifdef DEBUGGER
  345. NTSTATUS AMLIAPI AMLIGetLastError(PSZ *ppszErrMsg);
  346. #endif
  347. #endif //ifndef _INC_NSOBJ_ONLY
  348. #endif //ifndef _AMLI_H