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.

311 lines
12 KiB

  1. /*** ctxt.h - AML context structures and definitions
  2. *
  3. * Copyright (c) 1996,1997 Microsoft Corporation
  4. * Author: Michael Tsang (MikeTs)
  5. * Created 06/13/97
  6. *
  7. * MODIFICATION HISTORY
  8. */
  9. #ifndef _CTXT_H
  10. #define _CTXT_H
  11. /*** Type and Structure definitions
  12. */
  13. typedef struct _ctxt CTXT, *PCTXT, **PPCTXT;
  14. typedef struct _heap HEAP, *PHEAP;
  15. typedef NTSTATUS (LOCAL *PFNPARSE)(PCTXT, PVOID, NTSTATUS);
  16. typedef NTSTATUS (LOCAL *PFN)();
  17. typedef struct _framehdr
  18. {
  19. ULONG dwSig; //frame object signature
  20. ULONG dwLen; //frame object length
  21. ULONG dwfFrame; //frame flags
  22. PFNPARSE pfnParse; //frame object parse function
  23. } FRAMEHDR, *PFRAMEHDR;
  24. #define FRAMEF_STAGE_MASK 0x0000000f
  25. #define FRAMEF_CONTEXT_MASK 0xffff0000
  26. typedef struct _post
  27. {
  28. FRAMEHDR FrameHdr; //frame header
  29. ULONG_PTR uipData1; //data1
  30. ULONG_PTR uipData2; //data2
  31. POBJDATA pdataResult; //points to result object
  32. } POST, *PPOST;
  33. #define SIG_POST 'TSOP'
  34. typedef struct _scope
  35. {
  36. FRAMEHDR FrameHdr; //frame header
  37. PUCHAR pbOpEnd; //points to the end of scope
  38. PUCHAR pbOpRet; //points to return address of scope
  39. PNSOBJ pnsPrevScope; //points to previous scope
  40. POBJOWNER pownerPrev; //points to previous object owner
  41. PHEAP pheapPrev; //points to previous heap
  42. POBJDATA pdataResult; //points to result object
  43. } SCOPE, *PSCOPE;
  44. #define SIG_SCOPE 'POCS'
  45. #define SCOPEF_FIRST_TERM 0x00010000
  46. typedef struct _call
  47. {
  48. FRAMEHDR FrameHdr; //frame header
  49. struct _call *pcallPrev; //points to previous call frame
  50. POBJOWNER pownerPrev; //points to previous object owner
  51. PNSOBJ pnsMethod; //points to method object
  52. int iArg; //next argument to be parsed
  53. int icArgs; //number of arguments
  54. POBJDATA pdataArgs; //points to the argument array
  55. OBJDATA Locals[MAX_NUM_LOCALS]; //arrays of locals
  56. POBJDATA pdataResult; //points to result object
  57. } CALL, *PCALL;
  58. #define SIG_CALL 'LLAC'
  59. #define CALLF_NEED_MUTEX 0x00010000
  60. #define CALLF_ACQ_MUTEX 0x00020000
  61. #define CALLF_INVOKE_CALL 0x00040000
  62. typedef struct _nestedctxt
  63. {
  64. FRAMEHDR FrameHdr; //frame header
  65. PNSOBJ pnsObj; //points to current object of evaluation
  66. PNSOBJ pnsScope; //points to current scope
  67. OBJDATA Result; //to hold result data
  68. PFNACB pfnAsyncCallBack; //async completion callback function
  69. POBJDATA pdataCallBack; //points to return data of eval.
  70. PVOID pvContext; //context data for async callback
  71. ULONG dwfPrevCtxt; //save previous context flags
  72. struct _nestedctxt *pnctxtPrev; //save previous nested context frame
  73. } NESTEDCTXT, *PNESTEDCTXT;
  74. #define SIG_NESTEDCTXT 'XTCN'
  75. typedef struct _term
  76. {
  77. FRAMEHDR FrameHdr; //frame header
  78. PUCHAR pbOpTerm; //points to opcode of this term
  79. PUCHAR pbOpEnd; //points to the end of the term
  80. PUCHAR pbScopeEnd; //points to the end of the scope
  81. PAMLTERM pamlterm; //points to AMLTERM for this term
  82. PNSOBJ pnsObj; //to store object created by this term
  83. int iArg; //next argument to be parsed
  84. int icArgs; //number of arguments
  85. POBJDATA pdataArgs; //points to the argument array
  86. POBJDATA pdataResult; //points to result object
  87. } TERM, *PTERM;
  88. #define SIG_TERM 'MRET'
  89. typedef struct _package
  90. {
  91. FRAMEHDR FrameHdr; //frame header
  92. PPACKAGEOBJ ppkgobj; //points to the package object
  93. int iElement; //next element to parse
  94. PUCHAR pbOpEnd; //points to package end
  95. } PACKAGE, *PPACKAGE;
  96. #define SIG_PACKAGE 'FGKP'
  97. typedef struct _acquire
  98. {
  99. FRAMEHDR FrameHdr; //frame header
  100. PMUTEXOBJ pmutex; //points to the mutex object data
  101. USHORT wTimeout; //timeout value
  102. POBJDATA pdataResult; //points to result object
  103. } ACQUIRE, *PACQUIRE;
  104. #define SIG_ACQUIRE 'FQCA'
  105. #define ACQF_NEED_GLOBALLOCK 0x00010000
  106. #define ACQF_HAVE_GLOBALLOCK 0x00020000
  107. #define ACQF_SET_RESULT 0x00040000
  108. typedef struct _accfieldunit
  109. {
  110. FRAMEHDR FrameHdr; //frame header
  111. POBJDATA pdataObj; //points to field unit object data
  112. POBJDATA pdata; //points to source/result object
  113. } ACCFIELDUNIT, *PACCFIELDUNIT;
  114. #define SIG_ACCFIELDUNIT 'UFCA'
  115. #define AFUF_READFIELDUNIT 0x00010000
  116. #define AFUF_HAVE_GLOBALLOCK 0x00020000
  117. typedef struct _wrfieldloop
  118. {
  119. FRAMEHDR FrameHdr; //frame header
  120. POBJDATA pdataObj; //points to object to be written
  121. PFIELDDESC pfd; //points to FieldDesc
  122. PUCHAR pbBuff; //points to source buffer
  123. ULONG dwBuffSize; //source buffer size
  124. ULONG dwDataInc; //data write increment
  125. } WRFIELDLOOP, *PWRFIELDLOOP;
  126. #define SIG_WRFIELDLOOP 'LFRW'
  127. typedef struct _accfieldobj
  128. {
  129. FRAMEHDR FrameHdr; //frame header
  130. POBJDATA pdataObj; //object to be read
  131. PUCHAR pbBuff; //points to target buffer
  132. PUCHAR pbBuffEnd; //points to target buffer end
  133. ULONG dwAccSize; //access size
  134. ULONG dwcAccesses; //number of accesses
  135. ULONG dwDataMask; //data mask
  136. int iLBits; //number of left bits
  137. int iRBits; //number of right bits
  138. int iAccess; //index to number of accesses
  139. ULONG dwData; //temp. data
  140. FIELDDESC fd;
  141. } ACCFIELDOBJ, *PACCFIELDOBJ;
  142. #define SIG_ACCFIELDOBJ 'OFCA'
  143. typedef struct _preservewrobj
  144. {
  145. FRAMEHDR FrameHdr; //frame header
  146. POBJDATA pdataObj; //object to be read
  147. ULONG dwWriteData; //data to be written
  148. ULONG dwPreserveMask; //preserve bit mask
  149. ULONG dwReadData; //temp data read
  150. } PRESERVEWROBJ, *PPRESERVEWROBJ;
  151. #define SIG_PRESERVEWROBJ 'ORWP'
  152. typedef struct _wrcookacc
  153. {
  154. FRAMEHDR FrameHdr; //frame header
  155. PNSOBJ pnsBase; //points to opregion object
  156. PRSACCESS prsa; //points to RSACCESS
  157. ULONG dwAddr; //region space address
  158. ULONG dwSize; //size of access
  159. ULONG dwData; //data to be written
  160. ULONG dwDataMask; //data mask
  161. ULONG dwDataTmp; //temp. data
  162. BOOLEAN fPreserve; //TRUE if need preserve bits
  163. } WRCOOKACC, *PWRCOOKACC;
  164. #define SIG_WRCOOKACC 'ACRW'
  165. typedef struct _sleep
  166. {
  167. FRAMEHDR FrameHdr; //frame header
  168. LIST_ENTRY ListEntry; //to link the sleep requests together
  169. LARGE_INTEGER SleepTime; //wake up time
  170. PCTXT Context; //points to current context
  171. } SLEEP, *PSLEEP;
  172. #define SIG_SLEEP 'PELS'
  173. typedef struct _resource
  174. {
  175. ULONG dwResType;
  176. struct _ctxt *pctxtOwner;
  177. PVOID pvResObj;
  178. LIST list;
  179. } RESOURCE, *PRESOURCE;
  180. #define RESTYPE_MUTEX 1
  181. typedef struct _heapobjhdr
  182. {
  183. ULONG dwSig; //heap object signature
  184. ULONG dwLen; //heap object length;
  185. PHEAP pheap; //points to beginning of heap
  186. LIST list; //links all free heap blocks
  187. } HEAPOBJHDR, *PHEAPOBJHDR;
  188. struct _heap
  189. {
  190. ULONG dwSig; //heap signature
  191. PUCHAR pbHeapEnd; //points to end of heap block
  192. PHEAP pheapHead; //points to head of heap chain
  193. PHEAP pheapNext; //points to next heap block
  194. PUCHAR pbHeapTop; //points to the last free heap block
  195. PLIST plistFreeHeap; //points to the free heap block list
  196. HEAPOBJHDR Heap; //beginning of heap memory
  197. };
  198. #define SIG_HEAP 'PAEH'
  199. struct _ctxt
  200. {
  201. ULONG dwSig; //signature "CTXT"
  202. PUCHAR pbCtxtEnd; //points to end of context block
  203. LIST listCtxt; //links all allocated context
  204. LIST listQueue; //links for queuing context
  205. PPLIST pplistCtxtQueue; //points to queue head pointer
  206. PLIST plistResources; //links all owned resources
  207. ULONG dwfCtxt; //context flags
  208. PNSOBJ pnsObj; //points to current object of evaluation
  209. PNSOBJ pnsScope; //points to current scope
  210. POBJOWNER powner; //points to current object owner
  211. PCALL pcall; //points to current call frame
  212. PNESTEDCTXT pnctxt; //points to current nest ctxt frame
  213. ULONG dwSyncLevel; //current sync level for mutexs
  214. PUCHAR pbOp; //AML code pointer
  215. OBJDATA Result; //to hold result data
  216. PFNACB pfnAsyncCallBack; //async completion callback function
  217. POBJDATA pdataCallBack; //points to return data of eval.
  218. PVOID pvContext; //context data for async callback
  219. // #ifdef DEBUGGER
  220. // LARGE_INTEGER Timestamp;
  221. // #endif
  222. KTIMER Timer; //timeout timer if context is blocked
  223. KDPC Dpc; //DPC hook for the context
  224. PHEAP pheapCurrent; //current heap
  225. CTXTDATA CtxtData; //context data
  226. HEAP LocalHeap; //Local heap
  227. };
  228. #define SIG_CTXT 'TXTC'
  229. #define CTXTF_TIMER_PENDING 0x00000001
  230. #define CTXTF_TIMER_DISPATCH 0x00000002
  231. #define CTXTF_TIMEOUT 0x00000004
  232. #define CTXTF_READY 0x00000008
  233. #define CTXTF_RUNNING 0x00000010
  234. #define CTXTF_NEED_CALLBACK 0x00000020
  235. #define CTXTF_IN_READYQ 0x00000040
  236. #define CTXTF_NEST_EVAL 0x00000080
  237. #define CTXTF_ASYNC_EVAL 0x00000100
  238. typedef struct _ctxtq
  239. {
  240. ULONG dwfCtxtQ;
  241. PKTHREAD pkthCurrent;
  242. PCTXT pctxtCurrent;
  243. PLIST plistCtxtQ;
  244. ULONG dwmsTimeSliceLength;
  245. ULONG dwmsTimeSliceInterval;
  246. PFNAA pfnPauseCallback;
  247. PVOID PauseCBContext;
  248. MUTEX mutCtxtQ;
  249. KTIMER Timer;
  250. KDPC DpcStartTimeSlice;
  251. KDPC DpcExpireTimeSlice;
  252. WORK_QUEUE_ITEM WorkItem;
  253. } CTXTQ, *PCTXTQ;
  254. #define CQF_TIMESLICE_EXPIRED 0x00000001
  255. #define CQF_WORKITEM_SCHEDULED 0x00000002
  256. #define CQF_FLUSHING 0x00000004
  257. #define CQF_PAUSED 0x00000008
  258. typedef struct _syncevent
  259. {
  260. NTSTATUS rcCompleted;
  261. PCTXT pctxt;
  262. KEVENT Event;
  263. } SYNCEVENT, *PSYNCEVENT;
  264. typedef struct _restart
  265. {
  266. PCTXT pctxt;
  267. WORK_QUEUE_ITEM WorkItem;
  268. } RESTART, *PRESTART;
  269. #endif //ifndef _CTXT_H