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.

616 lines
17 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. buildsrc.h
  5. Abstract:
  6. This module contains the detector for the NT driver.
  7. This module makes extensive calls into the AMLI library
  8. Author:
  9. Stephane Plante (splante)
  10. Environment:
  11. NT Kernel Model Driver only
  12. Revision History:
  13. July 9, 1997 - Complete Rewrite
  14. Feb 13, 1998 - Another rewrite to make code ASYNC
  15. --*/
  16. #ifndef _BUILDSRC_H_
  17. #define _BUILDSRC_H_
  18. //
  19. // Callback function for build requests
  20. //
  21. typedef VOID ( *PACPI_BUILD_CALLBACK )(PVOID, PVOID, NTSTATUS);
  22. typedef struct _ACPI_BUILD_REQUEST {
  23. //
  24. // This is the list entry that the request is currently queued on
  25. //
  26. LIST_ENTRY ListEntry;
  27. //
  28. // We believe in signatures
  29. //
  30. ULONG Signature;
  31. //
  32. // We belive in flags
  33. //
  34. union {
  35. ULONG Flags;
  36. struct {
  37. ULONG Device:1;
  38. ULONG Sync:1;
  39. ULONG Run:1;
  40. ULONG ReleaseReference:1;
  41. ULONG Reserved1:8;
  42. ULONG ValidTarget:1;
  43. ULONG Reserved2:19;
  44. } UFlags;
  45. };
  46. //
  47. // This the current state of the request. It can only be touched
  48. // from the InterlockedXXX functions
  49. //
  50. ULONG WorkDone;
  51. //
  52. // This is the current state of the request. It can be read safely
  53. // from within any of the processing routines. It can only be written
  54. // from within the ACPIBuildProcessXXXList() functions
  55. //
  56. ULONG CurrentWorkDone;
  57. //
  58. // This is the state that we should transition to next, if we succeed
  59. // at the current state
  60. //
  61. ULONG NextWorkDone;
  62. //
  63. // This is the object associated with this request
  64. //
  65. PVOID BuildContext;
  66. //
  67. // The current status of the request
  68. //
  69. NTSTATUS Status;
  70. //
  71. // Remember what the most current control method that we ran was
  72. //
  73. PNSOBJ CurrentObject;
  74. //
  75. // We may want to have a callback..
  76. //
  77. PACPI_BUILD_CALLBACK CallBack;
  78. //
  79. // And we should have a context as well
  80. //
  81. PVOID CallBackContext;
  82. //
  83. // At this point, the contends depend on what kind of request we
  84. // are processing.
  85. //
  86. union {
  87. //
  88. // This is the structure for a device request
  89. //
  90. struct {
  91. //
  92. // Some local storage for result from an AMLI call
  93. //
  94. OBJDATA ResultData;
  95. } DeviceRequest;
  96. struct {
  97. //
  98. // We need to remember the name of the control method
  99. //
  100. union {
  101. ULONG ControlMethodName;
  102. UCHAR ControlMethodNameAsUchar[4];
  103. };
  104. //
  105. // We believe in flags while recursing
  106. //
  107. union {
  108. ULONG Flags;
  109. struct {
  110. ULONG CheckStatus:1;
  111. ULONG MarkIni:1;
  112. ULONG Recursive:1;
  113. ULONG CheckWakeCount:1;
  114. ULONG RegOn:1;
  115. ULONG RegOff:1;
  116. ULONG StopAtBridges:1;
  117. ULONG Reserved:25;
  118. } UFlags;
  119. };
  120. } RunRequest;
  121. struct {
  122. //
  123. // We need to know which list we require to be empty
  124. //
  125. PLIST_ENTRY SynchronizeListEntry;
  126. //
  127. // We can keep track of the method name that we are
  128. // trying to sync with
  129. //
  130. union {
  131. ULONG SynchronizeMethodName;
  132. UCHAR SynchronizeMethodNameAsUchar[4];
  133. };
  134. //
  135. // We believe in flags for this structure
  136. //
  137. union {
  138. ULONG Flags;
  139. struct {
  140. ULONG HasMethod:1;
  141. ULONG Reserved:31;
  142. } UFlags;
  143. };
  144. } SynchronizeRequest;
  145. };
  146. //
  147. // This is for scratch storage. Note that we use this space to
  148. // indicate which is the appropriate list that the request should
  149. // be moved onto
  150. //
  151. union {
  152. //
  153. // Keep Enough space for one integer
  154. //
  155. ULONG Integer;
  156. //
  157. // Or one string pointer
  158. //
  159. PUCHAR String;
  160. //
  161. // This is a pointer to the head of the list that this request should
  162. // be moved onto
  163. //
  164. PLIST_ENTRY TargetListEntry;
  165. };
  166. } ACPI_BUILD_REQUEST, *PACPI_BUILD_REQUEST;
  167. //
  168. // These are the flags that are used for BuildRequest
  169. //
  170. #define BUILD_REQUEST_DEVICE 0x0001
  171. #define BUILD_REQUEST_SYNC 0x0002
  172. #define BUILD_REQUEST_RUN 0x0004
  173. #define BUILD_REQUEST_RELEASE_REFERENCE 0x0008
  174. #define BUILD_REQUEST_VALID_TARGET 0x1000
  175. //
  176. // These are the flags that we use in the RunRequest case
  177. //
  178. #define RUN_REQUEST_CHECK_STATUS 0x01
  179. #define RUN_REQUEST_MARK_INI 0x02
  180. #define RUN_REQUEST_RECURSIVE 0x04
  181. #define RUN_REQUEST_CHECK_WAKE_COUNT 0x08
  182. #define RUN_REQUEST_REG_METHOD_ON 0x10
  183. #define RUN_REQUEST_REG_METHOD_OFF 0x20
  184. #define RUN_REQUEST_STOP_AT_BRIDGES 0x40
  185. //
  186. // These are the flags that we use in the SyncRequest case
  187. //
  188. #define SYNC_REQUEST_HAS_METHOD 0x1
  189. //
  190. // Prototype function pointer
  191. //
  192. typedef NTSTATUS (*PACPI_BUILD_FUNCTION)( IN PACPI_BUILD_REQUEST );
  193. //
  194. // These are variables exported from buildsrc.c
  195. //
  196. extern BOOLEAN AcpiBuildDpcRunning;
  197. extern BOOLEAN AcpiBuildFixedButtonEnumerated;
  198. extern BOOLEAN AcpiBuildWorkDone;
  199. extern KSPIN_LOCK AcpiBuildQueueLock;
  200. extern LIST_ENTRY AcpiBuildQueueList;
  201. extern LIST_ENTRY AcpiBuildPowerResourceList;
  202. extern LIST_ENTRY AcpiBuildDeviceList;
  203. extern LIST_ENTRY AcpiBuildOperationRegionList;
  204. extern LIST_ENTRY AcpiBuildRunMethodList;
  205. extern LIST_ENTRY AcpiBuildSynchronizationList;
  206. extern LIST_ENTRY AcpiBuildThermalZoneList;
  207. extern KDPC AcpiBuildDpc;
  208. extern NPAGED_LOOKASIDE_LIST BuildRequestLookAsideList;
  209. //
  210. // Because its rather annoying to base everything off the WORK_DONE_STEP_XX
  211. // defines (espacially if you have to renumber them), these defines are
  212. // used to abstract it out
  213. //
  214. #define WORK_DONE_ADR WORK_DONE_STEP_1
  215. #define WORK_DONE_ADR_OR_HID WORK_DONE_STEP_0
  216. #define WORK_DONE_CID WORK_DONE_STEP_4
  217. #define WORK_DONE_CRS WORK_DONE_STEP_16
  218. #define WORK_DONE_EJD WORK_DONE_STEP_6
  219. #define WORK_DONE_HID WORK_DONE_STEP_2
  220. #define WORK_DONE_PR0 WORK_DONE_STEP_10
  221. #define WORK_DONE_PR1 WORK_DONE_STEP_12
  222. #define WORK_DONE_PR2 WORK_DONE_STEP_14
  223. #define WORK_DONE_PRW WORK_DONE_STEP_8
  224. #define WORK_DONE_PSC WORK_DONE_STEP_18
  225. #define WORK_DONE_STA WORK_DONE_STEP_5
  226. #define WORK_DONE_UID WORK_DONE_STEP_3
  227. //
  228. // These are the function prototypes
  229. //
  230. VOID
  231. ACPIBuildCompleteCommon(
  232. IN PULONG OldWorkDone,
  233. IN ULONG NewWorkDone
  234. );
  235. VOID EXPORT
  236. ACPIBuildCompleteGeneric(
  237. IN PNSOBJ AcpiObject,
  238. IN NTSTATUS Status,
  239. IN POBJDATA ObjectData,
  240. IN PVOID Context
  241. );
  242. VOID EXPORT
  243. ACPIBuildCompleteMustSucceed(
  244. IN PNSOBJ AcpiObject,
  245. IN NTSTATUS Status,
  246. IN POBJDATA ObjectData,
  247. IN PVOID Context
  248. );
  249. VOID
  250. ACPIBuildDeviceDpc(
  251. IN PKDPC Dpc,
  252. IN PVOID DpcContext,
  253. IN PVOID SystemArgument1,
  254. IN PVOID SystemArgument2
  255. );
  256. NTSTATUS
  257. ACPIBuildDeviceExtension(
  258. IN PNSOBJ CurrentObject,
  259. IN PDEVICE_EXTENSION ParentDeviceExtension,
  260. OUT PDEVICE_EXTENSION *ReturnExtension
  261. );
  262. NTSTATUS
  263. ACPIBuildDevicePowerNodes(
  264. IN PDEVICE_EXTENSION DeviceExtension,
  265. IN PNSOBJ ResultObject,
  266. IN POBJDATA ResultData,
  267. IN DEVICE_POWER_STATE DeviceState
  268. );
  269. NTSTATUS
  270. ACPIBuildDeviceRequest(
  271. IN PDEVICE_EXTENSION DeviceExtension,
  272. IN PACPI_BUILD_CALLBACK CallBack,
  273. IN PVOID CallBackContext,
  274. IN BOOLEAN RunDPC
  275. );
  276. NTSTATUS
  277. ACPIBuildDockExtension(
  278. IN PNSOBJ CurrentObject,
  279. IN PDEVICE_EXTENSION ParentExtension
  280. );
  281. NTSTATUS
  282. ACPIBuildFilter(
  283. IN PDRIVER_OBJECT DriverObject,
  284. IN PDEVICE_EXTENSION DeviceExtension,
  285. IN PDEVICE_OBJECT PdoObject
  286. );
  287. NTSTATUS
  288. ACPIBuildFixedButtonExtension(
  289. IN PDEVICE_EXTENSION ParentExtension,
  290. IN PDEVICE_EXTENSION *ResultExtnesion
  291. );
  292. NTSTATUS
  293. ACPIBuildFlushQueue(
  294. IN PDEVICE_EXTENSION DeviceExtension
  295. );
  296. NTSTATUS
  297. ACPIBuildMissingChildren(
  298. IN PDEVICE_EXTENSION DeviceExtension
  299. );
  300. NTSTATUS
  301. ACPIBuildMissingEjectionRelations(
  302. );
  303. VOID
  304. ACPIBuildNotifyEvent(
  305. IN PVOID BuildContext,
  306. IN PVOID Context,
  307. IN NTSTATUS Status
  308. );
  309. NTSTATUS
  310. ACPIBuildPdo(
  311. IN PDRIVER_OBJECT DriverObject,
  312. IN PDEVICE_EXTENSION DeviceExtension,
  313. IN PDEVICE_OBJECT ParentPdoObject,
  314. IN BOOLEAN CreateAsFilter
  315. );
  316. NTSTATUS
  317. ACPIBuildPowerResourceExtension(
  318. IN PNSOBJ PowerResource,
  319. OUT PACPI_POWER_DEVICE_NODE *ReturnNode
  320. );
  321. NTSTATUS
  322. ACPIBuildPowerResourceRequest(
  323. IN PACPI_POWER_DEVICE_NODE PowerNode,
  324. IN PACPI_BUILD_CALLBACK CallBack,
  325. IN PVOID CallBackContext,
  326. IN BOOLEAN RunDPC
  327. );
  328. NTSTATUS
  329. ACPIBuildProcessDeviceFailure(
  330. IN PACPI_BUILD_REQUEST BuildRequest
  331. );
  332. NTSTATUS
  333. ACPIBuildProcessDeviceGenericEval(
  334. IN PACPI_BUILD_REQUEST BuildRequest
  335. );
  336. NTSTATUS
  337. ACPIBuildProcessDeviceGenericEvalStrict(
  338. IN PACPI_BUILD_REQUEST BuildRequest
  339. );
  340. NTSTATUS
  341. ACPIBuildProcessDevicePhaseAdr(
  342. IN PACPI_BUILD_REQUEST BuildRequest
  343. );
  344. NTSTATUS
  345. ACPIBuildProcessDevicePhaseAdrOrHid(
  346. IN PACPI_BUILD_REQUEST BuildRequest
  347. );
  348. NTSTATUS
  349. ACPIBuildProcessDevicePhaseCid(
  350. IN PACPI_BUILD_REQUEST BuildRequest
  351. );
  352. NTSTATUS
  353. ACPIBuildProcessDevicePhaseCrs(
  354. IN PACPI_BUILD_REQUEST BuildRequest
  355. );
  356. NTSTATUS
  357. ACPIBuildProcessDevicePhaseEjd(
  358. IN PACPI_BUILD_REQUEST BuildRequest
  359. );
  360. NTSTATUS
  361. ACPIBuildProcessDevicePhaseHid(
  362. IN PACPI_BUILD_REQUEST BuildRequest
  363. );
  364. NTSTATUS
  365. ACPIBuildProcessDevicePhasePr0(
  366. IN PACPI_BUILD_REQUEST BuildRequest
  367. );
  368. NTSTATUS
  369. ACPIBuildProcessDevicePhasePr1(
  370. IN PACPI_BUILD_REQUEST BuildRequest
  371. );
  372. NTSTATUS
  373. ACPIBuildProcessDevicePhasePr2(
  374. IN PACPI_BUILD_REQUEST BuildRequest
  375. );
  376. NTSTATUS
  377. ACPIBuildProcessDevicePhasePrw(
  378. IN PACPI_BUILD_REQUEST BuildRequest
  379. );
  380. NTSTATUS
  381. ACPIBuildProcessDevicePhasePsc(
  382. IN PACPI_BUILD_REQUEST BuildRequest
  383. );
  384. NTSTATUS
  385. ACPIBuildProcessDevicePhaseSta(
  386. IN PACPI_BUILD_REQUEST BuildRequest
  387. );
  388. NTSTATUS
  389. ACPIBuildProcessDevicePhaseUid(
  390. IN PACPI_BUILD_REQUEST BuildRequest
  391. );
  392. NTSTATUS
  393. ACPIBuildProcessGenericComplete(
  394. IN PACPI_BUILD_REQUEST BuildRequest
  395. );
  396. NTSTATUS
  397. ACPIBuildProcessGenericList(
  398. IN PLIST_ENTRY ListEntry,
  399. IN PACPI_BUILD_FUNCTION *DispatchTable
  400. );
  401. NTSTATUS
  402. ACPIBuildProcessorExtension(
  403. IN PNSOBJ ProcessorObject,
  404. IN PDEVICE_EXTENSION ParentExtension,
  405. IN PDEVICE_EXTENSION *ResultExtension,
  406. IN ULONG ProcessorIndex
  407. );
  408. NTSTATUS
  409. ACPIBuildProcessorRequest(
  410. IN PDEVICE_EXTENSION ProcessorExtension,
  411. IN PACPI_BUILD_CALLBACK CallBack,
  412. IN PVOID CallBackContext,
  413. IN BOOLEAN RunDPC
  414. );
  415. NTSTATUS
  416. ACPIBuildProcessPowerResourceFailure(
  417. IN PACPI_BUILD_REQUEST BuidlRequest
  418. );
  419. NTSTATUS
  420. ACPIBuildProcessPowerResourcePhase0(
  421. IN PACPI_BUILD_REQUEST BuildRequest
  422. );
  423. NTSTATUS
  424. ACPIBuildProcessPowerResourcePhase1(
  425. IN PACPI_BUILD_REQUEST BuildRequest
  426. );
  427. NTSTATUS
  428. ACPIBuildProcessQueueList(
  429. VOID
  430. );
  431. NTSTATUS
  432. ACPIBuildProcessRunMethodPhaseCheckBridge(
  433. IN PACPI_BUILD_REQUEST BuildRequest
  434. );
  435. NTSTATUS
  436. ACPIBuildProcessRunMethodPhaseCheckSta(
  437. IN PACPI_BUILD_REQUEST BuildRequest
  438. );
  439. NTSTATUS
  440. ACPIBuildProcessRunMethodPhaseRecurse(
  441. IN PACPI_BUILD_REQUEST BuildRequest
  442. );
  443. NTSTATUS
  444. ACPIBuildProcessRunMethodPhaseRunMethod(
  445. IN PACPI_BUILD_REQUEST BuildRequest
  446. );
  447. NTSTATUS
  448. ACPIBuildProcessSynchronizationList(
  449. IN PLIST_ENTRY ListEntry
  450. );
  451. NTSTATUS
  452. ACPIBuildProcessThermalZonePhase0(
  453. IN PACPI_BUILD_REQUEST BuildRequest
  454. );
  455. NTSTATUS
  456. ACPIBuildRegRequest(
  457. IN PDEVICE_OBJECT DeviceObject,
  458. IN PIRP Irp,
  459. IN PACPI_BUILD_CALLBACK CallBack
  460. );
  461. NTSTATUS
  462. ACPIBuildRegOffRequest(
  463. IN PDEVICE_OBJECT DeviceObject,
  464. IN PIRP Irp,
  465. IN PACPI_BUILD_CALLBACK CallBack
  466. );
  467. NTSTATUS
  468. ACPIBuildRegOnRequest(
  469. IN PDEVICE_OBJECT DeviceObject,
  470. IN PIRP Irp,
  471. IN PACPI_BUILD_CALLBACK CallBack
  472. );
  473. NTSTATUS
  474. ACPIBuildRunMethodRequest(
  475. IN PDEVICE_EXTENSION DeviceExtension,
  476. IN PACPI_BUILD_CALLBACK CallBack,
  477. IN PVOID CallBackContext,
  478. IN ULONG MethodName,
  479. IN ULONG MethodFlags,
  480. IN BOOLEAN RunDPC
  481. );
  482. NTSTATUS
  483. ACPIBuildSurpriseRemovedExtension(
  484. IN PDEVICE_EXTENSION DeviceExtension
  485. );
  486. NTSTATUS
  487. ACPIBuildSynchronizationRequest(
  488. IN PDEVICE_EXTENSION DeviceExtension,
  489. IN PACPI_BUILD_CALLBACK CallBack,
  490. IN PVOID CallBackContext,
  491. IN PLIST_ENTRY SynchronizeListEntry,
  492. IN BOOLEAN RunDPC
  493. );
  494. NTSTATUS
  495. ACPIBuildThermalZoneExtension(
  496. IN PNSOBJ ThermalObject,
  497. IN PDEVICE_EXTENSION ParentExtension,
  498. IN PDEVICE_EXTENSION *ResultExtension
  499. );
  500. NTSTATUS
  501. ACPIBuildThermalZoneRequest(
  502. IN PDEVICE_EXTENSION ThermalExtension,
  503. IN PACPI_BUILD_CALLBACK CallBack,
  504. IN PVOID CallBackContext,
  505. IN BOOLEAN RunDPC
  506. );
  507. #endif