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.

287 lines
8.8 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. pch.h
  5. Abstract:
  6. Precompiled Header for UnAssembler DLL
  7. Author:
  8. Based on code by Mike Tsang (MikeTs)
  9. Stephane Plante (Splante)
  10. Environment:
  11. User mode only
  12. Revision History:
  13. --*/
  14. #ifndef _PCH_H
  15. #define _PCH_H
  16. #include <nt.h>
  17. #include <ntrtl.h>
  18. #include <nturtl.h>
  19. #include <zwapi.h>
  20. #include <stdio.h> //for FILE *
  21. #include <string.h> //for _stricmp
  22. #include <stdlib.h> //for malloc
  23. #include <memory.h> //for memset
  24. #include <ctype.h> //for isspace
  25. #include <windef.h>
  26. #include <windows.h>
  27. #include <imagehlp.h>
  28. #ifndef LOCAL
  29. #define LOCAL __cdecl
  30. #endif
  31. #ifndef EXPORT
  32. #define EXPORT __cdecl
  33. #endif
  34. //
  35. // We are compliant with Spec Version 1.00
  36. //
  37. #define SPEC_VER 100
  38. #include "acpitabl.h"
  39. #include "list.h"
  40. #include "aml.h"
  41. //
  42. // Constants
  43. //
  44. // String constants
  45. #define STR_PROGDESC "ACPI Source Language Assembler"
  46. #define STR_COPYRIGHT "Copyright (c) 1996,1997 Microsoft Corporation"
  47. #define STR_MS "MSFT"
  48. // Misc. constants
  49. #define NAMESEG_BLANK 0x5f5f5f5f // "____"
  50. #define NAMESEG_ROOT 0x5f5f5f5c // "\___"
  51. #define NAMESEG ULONG
  52. #define SUPERNAME NAMESEG
  53. #define NSF_LOCAL_SCOPE 0x00000001
  54. // Implementation constants
  55. #define MAX_STRING_LEN 199
  56. #define MAX_NAME_LEN 1599 //approx. 255*4 + 254 + 255
  57. #define MAX_NAMECODE_LEN 1300 //approx. 255*4 + 2 + 255
  58. #define MAX_MSG_LEN 127
  59. #define MAX_ARGS 7
  60. #define MAX_PACKAGE_LEN 0x0fffffff
  61. // Term classes
  62. #define TC_PNP_MACRO 0x00100000
  63. #define TC_REF_OBJECT 0x00200000
  64. #define TC_FIELD_MACRO 0x00400000
  65. #define TC_DATA_OBJECT 0x00800000
  66. #define TC_NAMED_OBJECT 0x01000000
  67. #define TC_NAMESPACE_MODIFIER 0x02000000
  68. #define TC_OPCODE_TYPE1 0x04000000
  69. #define TC_OPCODE_TYPE2 0x08000000
  70. #define TC_CONST_NAME 0x10000000
  71. #define TC_SHORT_NAME 0x20000000
  72. #define TC_COMPILER_DIRECTIVE 0x40000000
  73. #define TC_KEYWORD 0x80000000
  74. #define TC_OPCODE (TC_OPCODE_TYPE1 | TC_OPCODE_TYPE2 | \
  75. TC_SHORT_NAME | TC_CONST_NAME | TC_DATA_OBJECT)
  76. #define TC_OPCODE_TERM (TC_OPCODE_TYPE1 | TC_OPCODE_TYPE2 | \
  77. TC_SHORT_NAME | TC_CONST_NAME | \
  78. TC_DATA_OBJECT | TC_NAMED_OBJECT | \
  79. TC_NAMESPACE_MODIFIER)
  80. // Term flags
  81. #define TF_ACTION_FLIST 0x00000001
  82. #define TF_ACTION_VLIST 0x00000002
  83. #define TF_PACKAGE_LEN 0x00000004
  84. #define TF_CHECKNAME_EXIST 0x00000008
  85. #define TF_FIELD_MACRO TC_FIELD_MACRO
  86. #define TF_DATA_OBJECT TC_DATA_OBJECT
  87. #define TF_NAMED_OBJECT TC_NAMED_OBJECT
  88. #define TF_NAMESPACE_MODIFIER TC_NAMESPACE_MODIFIER
  89. #define TF_OPCODE_TYPE1 TC_OPCODE_TYPE1
  90. #define TF_OPCODE_TYPE2 TC_OPCODE_TYPE2
  91. #define TF_CONST_NAME TC_CONST_NAME
  92. #define TF_SHORT_NAME TC_SHORT_NAME
  93. #define TF_COMPILER_DIRECTIVE TC_COMPILER_DIRECTIVE
  94. #define TF_KEYWORD TC_KEYWORD
  95. #define TF_PNP_MACRO TC_PNP_MACRO
  96. #define TF_OBJECT_LIST (TC_NAMED_OBJECT | TC_NAMESPACE_MODIFIER)
  97. #define TF_CODE_LIST (TC_OPCODE_TYPE1 | TC_OPCODE_TYPE2)
  98. #define TF_DATA_LIST 0x00010000
  99. #define TF_FIELD_LIST 0x00020000
  100. #define TF_BYTE_LIST 0x00040000
  101. #define TF_DWORD_LIST 0x00080000
  102. #define TF_PACKAGE_LIST (TC_DATA_OBJECT | TC_SHORT_NAME | \
  103. TC_CONST_NAME)
  104. #define TF_ALL_LISTS (TF_DATA_OBJECT | TF_NAMED_OBJECT | \
  105. TF_NAMESPACE_MODIFIER | TF_OPCODE_TYPE1 | \
  106. TF_OPCODE_TYPE2 | TF_SHORT_NAME | \
  107. TF_CONST_NAME | TF_COMPILER_DIRECTIVE | \
  108. TF_DATA_LIST | TF_PACKAGE_LIST | \
  109. TF_FIELD_LIST | TF_PNP_MACRO | TF_BYTE_LIST |\
  110. TF_DWORD_LIST)
  111. // Code flags
  112. #define CF_MISSING_ARG 0x00000001
  113. #define CF_PARSING_FIXEDLIST 0x00000002
  114. #define CF_PARSING_VARLIST 0x00000004
  115. // NS flags
  116. #define NSF_EXIST_OK 0x00010000
  117. #define NSF_EXIST_ERR 0x00020000
  118. // Data types
  119. #define CODETYPE_UNKNOWN 0
  120. #define CODETYPE_ASLTERM 1
  121. #define CODETYPE_NAME 2
  122. #define CODETYPE_DATAOBJ 3
  123. #define CODETYPE_FIELDOBJ 4
  124. #define CODETYPE_INTEGER 5
  125. #define CODETYPE_STRING 6
  126. #define CODETYPE_KEYWORD 7
  127. #define CODETYPE_USERTERM 8
  128. #define CODETYPE_QWORD 9
  129. // NameSpace object types
  130. #define NSTYPE_UNKNOWN 'U'
  131. #define NSTYPE_SCOPE 'S'
  132. #define NSTYPE_FIELDUNIT 'F'
  133. #define NSTYPE_DEVICE 'D'
  134. #define NSTYPE_EVENT 'E'
  135. #define NSTYPE_METHOD 'M'
  136. #define NSTYPE_MUTEX 'X'
  137. #define NSTYPE_OPREGION 'O'
  138. #define NSTYPE_POWERRES 'P'
  139. #define NSTYPE_PROCESSOR 'C'
  140. #define NSTYPE_THERMALZONE 'T'
  141. #define NSTYPE_OBJALIAS 'A'
  142. #define NSTYPE_BUFFFIELD 'B'
  143. #define OBJTYPE_PRIVATE 0xf0
  144. #define OBJTYPE_PNP_RES (OBJTYPE_PRIVATE + 0x00)
  145. #define OBJTYPE_RES_FIELD (OBJTYPE_PRIVATE + 0x01)
  146. // Opcode classes
  147. #define OPCLASS_INVALID 0
  148. #define OPCLASS_DATA_OBJ 1
  149. #define OPCLASS_NAME_OBJ 2
  150. #define OPCLASS_CONST_OBJ 3
  151. #define OPCLASS_CODE_OBJ 4
  152. #define OPCLASS_ARG_OBJ 5
  153. #define OPCLASS_LOCAL_OBJ 6
  154. //dwfData flags
  155. #define DATAF_BUFF_ALIAS 0x00000001
  156. #define DATAF_GLOBAL_LOCK 0x00000002
  157. //dwDataType values
  158. #define OBJTYPE_UNKNOWN 0x00
  159. #define OBJTYPE_INTDATA 0x01
  160. #define OBJTYPE_STRDATA 0x02
  161. #define OBJTYPE_BUFFDATA 0x03
  162. #define OBJTYPE_PKGDATA 0x04
  163. #define OBJTYPE_FIELDUNIT 0x05
  164. #define OBJTYPE_DEVICE 0x06
  165. #define OBJTYPE_EVENT 0x07
  166. #define OBJTYPE_METHOD 0x08
  167. #define OBJTYPE_MUTEX 0x09
  168. #define OBJTYPE_OPREGION 0x0a
  169. #define OBJTYPE_POWERRES 0x0b
  170. #define OBJTYPE_PROCESSOR 0x0c
  171. #define OBJTYPE_THERMALZONE 0x0d
  172. #define OBJTYPE_BUFFFIELD 0x0e
  173. #define OBJTYPE_DDBHANDLE 0x0f
  174. //These are internal object types (not to be exported to the ASL code)
  175. #define OBJTYPE_INTERNAL 0x80
  176. #define OBJTYPE_DEBUG (OBJTYPE_INTERNAL + 0x00)
  177. #define OBJTYPE_OBJALIAS (OBJTYPE_INTERNAL + 0x01)
  178. #define OBJTYPE_DATAALIAS (OBJTYPE_INTERNAL + 0x02)
  179. #define OBJTYPE_BANKFIELD (OBJTYPE_INTERNAL + 0x03)
  180. #define OBJTYPE_FIELD (OBJTYPE_INTERNAL + 0x04)
  181. #define OBJTYPE_INDEXFIELD (OBJTYPE_INTERNAL + 0x05)
  182. #define OBJTYPE_DATA (OBJTYPE_INTERNAL + 0x06)
  183. #define OBJTYPE_DATAFIELD (OBJTYPE_INTERNAL + 0x07)
  184. #define OBJTYPE_DATAOBJ (OBJTYPE_INTERNAL + 0x08)
  185. //Predefined data values (dwDataValue)
  186. #define DATAVALUE_ZERO 0
  187. #define DATAVALUE_ONE 1
  188. #define DATAVALUE_ONES 0xffffffff
  189. //
  190. // Macros
  191. //
  192. #define MEMALLOC(n) malloc(n)
  193. #define MEMFREE(p) free(p)
  194. //
  195. // Type definitions
  196. //
  197. typedef int (LOCAL *PFNTERM)(PUCHAR, BOOL);
  198. typedef struct _ObjData
  199. {
  200. ULONG Flags; //flags
  201. ULONG Alias; //ref count if base obj,
  202. // points to base obj if alias obj
  203. ULONG DataType; //object type
  204. ULONG DataValue; //object value
  205. ULONG DataLen; //object buffer length
  206. PUCHAR DataBuff; //object buffer
  207. } OBJDATA, *POBJDATA, **PPOBJDATA;
  208. typedef struct _NSObj
  209. {
  210. LIST List; //NOTE: list must be first in structure
  211. struct _NSObj *ParentObject;
  212. struct _NSObj *FirstChild;
  213. ULONG Signature;
  214. ULONG NameSeg;
  215. HANDLE Owner;
  216. struct _NSObj *OwnedNext;
  217. OBJDATA ObjectData;
  218. ULONG Context;
  219. } NSOBJ, *PNSOBJ, **PPNSOBJ;
  220. #define SIG_NSOBJ 'SNTM'
  221. typedef struct _aslterm
  222. {
  223. PUCHAR ID;
  224. LONG LongID;
  225. ULONG TermClass;
  226. ULONG TermData;
  227. ULONG OpCode;
  228. PUCHAR UnAsmArgTypes;
  229. PUCHAR ArgTypes;
  230. PUCHAR ArgActions;
  231. ULONG Flags;
  232. PFNTERM Term;
  233. } ASLTERM, *PASLTERM;
  234. typedef struct _opmap
  235. {
  236. UCHAR ExtendedOpCode;
  237. UCHAR OpCodeClass;
  238. } OPMAP, *POPMAP;
  239. #include "data.h"
  240. #include "debug.h"
  241. #include "namespac.h"
  242. #include "parsearg.h"
  243. #include "unasm.h"
  244. #endif //ifndef _ASLP_H