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.

550 lines
20 KiB

  1. //-------------------------------------------------------------------
  2. // This is abstract class for generic device
  3. // Specific devices should use it as a parent device
  4. // Author: Sergey Ivanov
  5. // Log:
  6. // 08/11/99 - implemented
  7. //-------------------------------------------------------------------
  8. #ifndef __DEVICE__
  9. #define __DEVICE__
  10. #include "generic.h"
  11. enum DEVSTATE
  12. {
  13. STOPPED, // device stopped
  14. WORKING, // started and working
  15. PENDINGSTOP, // stop pending
  16. PENDINGREMOVE, // remove pending
  17. SURPRISEREMOVED, // removed by surprise
  18. REMOVED, // removed
  19. };
  20. // Remove eventually previous declaration!...
  21. typedef enum _DEVICE_PNP_STATE {
  22. NOT_STARTED = 0, // Not started yet
  23. STARTED, // Device has received the START_DEVICE IRP
  24. STOP_PENDING, // Device has received the QUERY_STOP IRP
  25. _STOPPED_, // Device has received the STOP_DEVICE IRP
  26. REMOVE_PENDING, // Device has received the QUERY_REMOVE IRP
  27. SURPRISE_REMOVE_PENDING, // Device has received the SURPRISE_REMOVE IRP
  28. DELETED // Device has received the REMOVE_DEVICE IRP
  29. } DEVICE_PNP_STATE;
  30. enum POWERSTATE
  31. {
  32. POWERON, // power on, device in D0 state
  33. POWEROFFPENDING, // power off operation is pending
  34. POWEROFF, // power off, device in D3 state
  35. IDLEOFF, // power off due to idle detection
  36. };
  37. typedef struct _PPOWER_CONTEXT_
  38. {
  39. PKEVENT powerEvent;
  40. NTSTATUS status;
  41. } POWER_CONTEXT,*PPOWER_CONTEXT;
  42. #define INITIALIZE_PNP_STATE() \
  43. this->m_DevicePnPState = NOT_STARTED;\
  44. this->m_PreviousPnPState = NOT_STARTED
  45. #define SET_NEW_PNP_STATE(__state_) \
  46. this->m_PreviousPnPState = this->m_DevicePnPState;\
  47. this->m_DevicePnPState = (_state_)
  48. #define RESTORE_PREVIOUS_PNP_STATE() \
  49. this->m_DevicePnPState = this->m_PreviousPnPState
  50. #define IS_DEVICE_PNP_STATE(_state_) \
  51. (this->m_DevicePnPState == _state_)
  52. #define DEVICE_SURPRISE_REMOVAL_OK 1
  53. #define PNPTABSIZE IRP_MN_QUERY_LEGACY_BUS_INFORMATION+1
  54. #define POWERTABSIZE IRP_MN_QUERY_POWER+1
  55. #define STATETABSIZE REMOVED+1
  56. #define SYSTEM_POWER_TAB_NAMESIZE 8
  57. #define DEVICE_POWER_TAB_NAMESIZE 6
  58. typedef enum PENDING_REQUEST_TYPE
  59. {
  60. OPEN_REQUEST = 0,
  61. CLOSE_REQUEST,
  62. READ_REQUEST,
  63. WRITE_REQUEST,
  64. IOCTL_REQUEST,
  65. PNP_REQUEST,
  66. POWER_REQUEST,
  67. SYSTEM_REQUEST,
  68. FLUSH_REQUEST,
  69. CLEAN_REQUEST,
  70. START_IO_REQUEST
  71. } PENDING_REQUEST_TYPE;
  72. class CPendingIRP
  73. {
  74. public:
  75. NTSTATUS m_Status;
  76. SAFE_DESTRUCTORS();
  77. virtual VOID dispose(){self_delete();};
  78. public:
  79. LIST_ENTRY entry;
  80. PENDING_REQUEST_TYPE Type;
  81. PDEVICE_OBJECT DeviceObject;
  82. PIRP Irp;
  83. public:
  84. CPendingIRP(PIRP Irp,PENDING_REQUEST_TYPE rt = OPEN_REQUEST,
  85. PDEVICE_OBJECT tdo = NULL,PFILE_OBJECT tfo = NULL):
  86. Irp(Irp), Type(rt), DeviceObject(tdo)
  87. {
  88. };
  89. };
  90. // ABSTRUCT class
  91. // This is main interface from system to the device.
  92. // Specific devices should implement the interface to support system requests.
  93. class CDevice;
  94. class CSystem;
  95. class CIrp;
  96. class CEvent;
  97. class CPower;
  98. class CDebug;
  99. class CLock;
  100. class CMemory;
  101. class CIoPacket;
  102. class CThread;
  103. typedef struct _REMOVE_LOCK
  104. {
  105. LONG usage; // reference count
  106. BOOLEAN removing; // true if removal is pending
  107. KEVENT evRemove; // event to wait on
  108. } REMOVE_LOCK, *PREMOVE_LOCK;
  109. class CDevice;
  110. #pragma PAGEDCODE
  111. class CDevice
  112. {
  113. public:
  114. NTSTATUS m_Status;
  115. SAFE_DESTRUCTORS();
  116. public:
  117. ULONG m_Type;
  118. // Support for the linked list of devices...
  119. LIST_ENTRY entry;
  120. protected:
  121. LONG m_Usage; // use count on this device
  122. static ULONG DeviceNumber; // Device instance number
  123. UNICODE_STRING m_Ifname;
  124. CUString* m_DeviceObjectName;
  125. UCHAR m_VendorName[MAXIMUM_ATTR_STRING_LENGTH];
  126. USHORT m_VendorNameLength;
  127. UCHAR m_DeviceType[MAXIMUM_ATTR_STRING_LENGTH];
  128. USHORT m_DeviceTypeLength;
  129. BOOL m_Started; // Set TRUE if device started, FALSE if stopped
  130. BOOL m_Openned; // Set TRUE if device openned, FALSE if closed
  131. BOOL m_Added; // Set TRUE if device was added to system, FALSE if it is not
  132. BOOL m_SurprizeRemoved;
  133. REMOVE_LOCK m_RemoveLock;
  134. BOOL m_RestartActiveThread;
  135. KEVENT m_evEnabled; // event to wait on after device was disabled
  136. // Event to signal device Idle state
  137. //KMUTEX IdleState;=========== It will be much better!!!!!!!!!
  138. KEVENT IdleState;
  139. // Capabilities structure and device flags to handle
  140. DEVICE_CAPABILITIES m_DeviceCapabilities;
  141. ULONG m_Flags;
  142. // Power management constants
  143. PULONG m_Idle; // idle counter pointer
  144. ULONG Idle_conservation;
  145. ULONG Idle_performance;
  146. DEVICE_POWER_STATE m_CurrentDevicePowerState;
  147. DEVICE_POWER_STATE m_PowerDownLevel;
  148. PIRP m_PowerIrp;
  149. BOOL m_EnabledForWakeup;
  150. //Current device state
  151. DEVSTATE m_DeviceState;
  152. // Will be used for canceled request
  153. DEVSTATE m_DevicePreviousState;
  154. // Next members will remove previous two (eventually)...
  155. DEVICE_PNP_STATE m_PreviousPnPState;
  156. DEVICE_PNP_STATE m_DevicePnPState;
  157. CSystem* system;
  158. CIrp* irp;
  159. CEvent* event;
  160. CPower* power;
  161. CDebug* debug;
  162. CLock* lock;
  163. CMemory* memory;
  164. // Support for asynchronous communications
  165. CThread* IoThread;
  166. LONG DevicePoolingInterval;
  167. LONG Write_To_Read_Delay;
  168. LONG Power_WTR_Delay;// Delay at power command
  169. LONG DeviceCommandTimeout;// Timeout for the device commands
  170. GUID InterfaceClassGuid;
  171. BOOL m_DeviceInterfaceRegistered;
  172. ULONG CardState;
  173. // --------- ASYNCHRONOUS REQUESTS SUPPORT FUNCTIONS ----------------------------
  174. // This group of functions will allow to create asynchronous
  175. // communications with the driver.
  176. // It includes -
  177. // - functions to mark our Irp as pending and to include it into
  178. // our device requests queue (makeRequestPending());
  179. // - to extract next Irp from the device queue (startNextPendingRequest())
  180. // and to start device specific Irp processing (startIoRequest())
  181. // - getIoRequestsQueue() allows devices to verify device queue state.
  182. // It is completely is up to specific device how to manage the device queue and
  183. // to make synchronous or asynchronous Irp processing.
  184. // For expl. device can create specific thread to process Irps.
  185. // More than this - some devices can deside to make asyncronous communications only
  186. // for specific (time consuming) device request while processing others syschronously.
  187. //
  188. // cancelPendingIrp() will cancel current Irp and remove corresponding IoRequest from
  189. // IoRequestQueue.
  190. protected:
  191. CLinkedList<CPendingIRP>* m_IoRequests; // Clients' IO requests
  192. // Support for dynamic device connections
  193. PIRP m_OpenSessionIrp;
  194. public:
  195. virtual CLinkedList<CPendingIRP>* getIoRequestsQueue() = 0;
  196. virtual VOID cancelPendingIrp(PIRP Irp) = 0;
  197. virtual NTSTATUS cancelPendingRequest(CPendingIRP* IrpReq) = 0;
  198. virtual NTSTATUS cancelAllPendingRequests() = 0;
  199. virtual NTSTATUS makeRequestPending(PIRP Irp_request,PDEVICE_OBJECT toDeviceObject,PENDING_REQUEST_TYPE Type) = 0;
  200. // Next functions will be called by Irp processing thread.
  201. // Checks if request queue is empty and if it is NOT - starts next request...
  202. virtual NTSTATUS startNextPendingRequest() = 0;
  203. // Device specific function which processes pending requests...
  204. // It will be redefied by specific devices.
  205. virtual NTSTATUS startIoRequest(CPendingIRP*) = 0;
  206. // --------- ASYNCHRONOUS REQUESTS SUPPORT FUNCTIONS ----------------------------
  207. public:
  208. CDevice()
  209. {
  210. m_Type = GRCLASS_DEVICE;
  211. m_Openned = FALSE;
  212. m_Added = FALSE;
  213. // At begining device is at stop state
  214. m_DevicePreviousState = STOPPED;
  215. m_DeviceState = STOPPED;
  216. m_SurprizeRemoved = FALSE;
  217. m_RestartActiveThread = FALSE;
  218. m_DeviceInterfaceRegistered = FALSE;
  219. m_ParentDeviceObject = NULL;
  220. DevicePoolingInterval = 500;// 0.5s better for detection
  221. set_Default_WTR_Delay(); //1ms corrects "0 bytes" problem
  222. Power_WTR_Delay = 1; //1ms should be OK...
  223. DeviceCommandTimeout = 60000;// 60sec
  224. m_IoRequests = NULL;
  225. DBG_PRINT(" New Device %8.8lX was created...\n",this);
  226. }; // Default pooling interval
  227. BOOL PnPfcntab[PNPTABSIZE];
  228. BOOL Powerfcntab[POWERTABSIZE];
  229. #ifdef DEBUG
  230. PCHAR PnPfcnname[PNPTABSIZE];
  231. PCHAR Powerfcnname[POWERTABSIZE];
  232. PCHAR Powersysstate[SYSTEM_POWER_TAB_NAMESIZE];
  233. PCHAR Powerdevstate[DEVICE_POWER_TAB_NAMESIZE];
  234. PCHAR statenames[STATETABSIZE];
  235. #endif // DEBUG
  236. protected:
  237. virtual ~CDevice(){};
  238. // Complete current request with given information
  239. virtual NTSTATUS completeDeviceRequest(PIRP Irp, NTSTATUS status, ULONG info) {return STATUS_SUCCESS;};
  240. VOID activatePnPHandler(LONG HandlerID)
  241. {
  242. if (HandlerID >= arraysize(PnPfcntab)) return;
  243. PnPfcntab[HandlerID] = TRUE;
  244. };
  245. VOID disActivatePnPHandler(LONG HandlerID)
  246. {
  247. if (HandlerID >= arraysize(PnPfcntab)) return;
  248. PnPfcntab[HandlerID] = FALSE;
  249. };
  250. public:
  251. virtual CDevice* create(VOID) {return NULL;};
  252. virtual VOID addRef(){refcount++;};
  253. virtual VOID removeRef(){if(refcount) refcount--;};
  254. virtual LONG getRefCount(){ return refcount;};
  255. virtual VOID markAsOpenned(){ m_Openned = TRUE;};
  256. virtual VOID markAsClosed() { m_Openned = FALSE;};
  257. virtual BOOL isOpenned() { return m_Openned;};
  258. virtual VOID setDeviceState(DEVSTATE state)
  259. {
  260. m_DevicePreviousState = m_DeviceState;
  261. m_DeviceState = state;
  262. };
  263. virtual DEVSTATE getDeviceState(){return m_DeviceState;};
  264. virtual VOID restoreDeviceState(){m_DeviceState = m_DevicePreviousState;};
  265. virtual getObjectType(){return m_Type;};
  266. virtual ULONG getCardState(){return CardState;};
  267. virtual VOID setCardState(ULONG state){CardState = state;};
  268. // Call this function instead of destructor.
  269. // It will assure safety device removal.
  270. virtual VOID dispose() {};
  271. // Checks if device object is still valid.
  272. virtual BOOL checkValid() {return FALSE;};
  273. // Next methods should be defined by ALL clients...
  274. virtual BOOL createDeviceObjects() {return FALSE;};
  275. virtual VOID removeDeviceObjects() {};
  276. virtual VOID initializeRemoveLock() {};
  277. virtual NTSTATUS acquireRemoveLock() {return STATUS_SUCCESS;};
  278. virtual VOID releaseRemoveLock() {};
  279. virtual VOID releaseRemoveLockAndWait() {};
  280. virtual BOOL isDeviceLocked() {return FALSE;};
  281. virtual VOID setBusy() {};
  282. virtual VOID setIdle() {};
  283. virtual NTSTATUS waitForIdle() {return STATUS_SUCCESS;};
  284. virtual NTSTATUS waitForIdleAndBlock() {return STATUS_SUCCESS;};
  285. //virtual NTSTATUS add(PDRIVER_OBJECT Driver,PDEVICE_OBJECT PnpDeviceObject) {};
  286. virtual NTSTATUS add(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT pPdo) {return STATUS_UNSUCCESSFUL;};
  287. PDEVICE_OBJECT getSystemObject(){return m_DeviceObject;};
  288. PDEVICE_OBJECT getPhysicalObject(){return m_PhysicalDeviceObject;};
  289. PDEVICE_OBJECT getLowerDriver(){return m_pLowerDeviceObject;};
  290. UNICODE_STRING* getDeviceInterfaceName(){return &m_Ifname;};
  291. GUID* getDeviceInterfaceGUID(){return &InterfaceClassGuid;};
  292. BOOL isDeviceInterfaceRegistered(){return m_DeviceInterfaceRegistered;};
  293. virtual BOOL registerDeviceInterface(const GUID* Guid) {return FALSE;};
  294. virtual VOID unregisterDeviceInterface(UNICODE_STRING* InterfaceName) {};
  295. CUString* getDeviceName(){return m_DeviceObjectName;};
  296. ULONG getDeviceNumber(){ULONG ID = DeviceNumber; if(ID) --ID; return ID;};
  297. ULONG incrementDeviceNumber(){ULONG ID = DeviceNumber; ++DeviceNumber; return ID;};
  298. virtual VOID remove() {};
  299. virtual VOID onDeviceStart() {};
  300. virtual VOID onDeviceStop() {};
  301. // These functions will create driver's IRPs to transfer datas.
  302. // Device stack will keep track of all active (sended to lower level)
  303. // and pending (mark as pending) IRPs...
  304. virtual NTSTATUS send(CIoPacket* Irp) {return STATUS_SUCCESS;};
  305. virtual NTSTATUS sendAndWait(CIoPacket* Irp) {return STATUS_SUCCESS;};
  306. // Functions will send request and wait for a reply...
  307. virtual NTSTATUS write(PUCHAR pRequest,ULONG RequestLength) {return STATUS_SUCCESS;};
  308. virtual NTSTATUS writeAndWait(PUCHAR pRequest,ULONG RequestLength,PUCHAR pReply,ULONG* pReplyLength) {return STATUS_SUCCESS;};
  309. virtual NTSTATUS readAndWait(PUCHAR pRequest,ULONG RequestLength,PUCHAR pReply,ULONG* pReplyLength) {return STATUS_SUCCESS;};
  310. // Interface for system requests. ..
  311. virtual NTSTATUS pnpRequest(IN PIRP Irp) {return STATUS_SUCCESS;};
  312. virtual NTSTATUS powerRequest(PIRP irp) {return STATUS_SUCCESS;};
  313. virtual NTSTATUS open(PIRP irp) {return STATUS_SUCCESS;};//Create
  314. virtual NTSTATUS close(PIRP irp) {return STATUS_SUCCESS;};
  315. virtual NTSTATUS read(PIRP irp) {return STATUS_SUCCESS;};
  316. virtual NTSTATUS write(PIRP irp) {return STATUS_SUCCESS;};
  317. virtual VOID startIo(PIRP irp){};
  318. virtual NTSTATUS deviceControl(PIRP irp) {return STATUS_SUCCESS;};
  319. virtual NTSTATUS cleanup(PIRP Irp) {return STATUS_SUCCESS;};
  320. virtual NTSTATUS flush(PIRP Irp) {return STATUS_SUCCESS;};
  321. virtual LONG getDevicePoolingInterval()
  322. {
  323. return DevicePoolingInterval;
  324. };
  325. virtual VOID setDevicePoolingInterval(LONG interval)
  326. {
  327. DevicePoolingInterval = interval;
  328. };
  329. virtual LONG getCommandTimeout()
  330. {
  331. return DeviceCommandTimeout;
  332. };
  333. virtual VOID setCommandTimeout(LONG timeout)
  334. {
  335. DeviceCommandTimeout = timeout;
  336. };
  337. // Inhereted classes will overwrite this function
  338. virtual NTSTATUS ThreadRoutine()
  339. {
  340. return STATUS_SUCCESS;
  341. };
  342. #pragma LOCKEDCODE
  343. // This is callback function for the attached threads
  344. static VOID ThreadFunction(CDevice* device)
  345. {
  346. if(device) device->ThreadRoutine();
  347. };
  348. #pragma PAGEDCODE
  349. virtual LONG get_Power_WTR_Delay()
  350. {
  351. return Power_WTR_Delay;
  352. };
  353. virtual LONG get_WTR_Delay()
  354. {
  355. return Write_To_Read_Delay;
  356. };
  357. virtual VOID set_WTR_Delay(LONG Delay)
  358. {
  359. Write_To_Read_Delay = Delay;
  360. };
  361. virtual VOID set_Default_WTR_Delay()
  362. {
  363. Write_To_Read_Delay = 1;
  364. };
  365. virtual VOID registerPowerIrp(PIRP Irp){m_PowerIrp = Irp;};
  366. virtual PIRP getPowerIrp(){return m_PowerIrp;};
  367. virtual VOID unregisterPowerIrp(){m_PowerIrp = NULL;};
  368. virtual BOOL isEnabledForWakeup(){return m_EnabledForWakeup;};
  369. virtual VOID setCurrentDevicePowerState(DEVICE_POWER_STATE state){m_CurrentDevicePowerState = state;};
  370. virtual NTSTATUS sendDeviceSetPower(DEVICE_POWER_STATE devicePower, BOOLEAN wait) = 0;
  371. virtual VOID setSurprizeRemoved(){m_SurprizeRemoved = TRUE;};
  372. virtual VOID clearSurprizeRemoved(){m_SurprizeRemoved = FALSE;};
  373. virtual BOOL isSurprizeRemoved(){ return m_SurprizeRemoved;};
  374. virtual VOID setThreadRestart(){m_RestartActiveThread = TRUE;};
  375. virtual VOID clearThreadRestart(){m_RestartActiveThread = FALSE;};
  376. virtual BOOL isRequiredThreadRestart(){ return m_RestartActiveThread;};
  377. protected:
  378. WCHAR Signature[3];
  379. PDRIVER_OBJECT m_DriverObject;
  380. // Back reference to system object
  381. PDEVICE_OBJECT m_DeviceObject;
  382. // Device object lower at stack
  383. PDEVICE_OBJECT m_pLowerDeviceObject;
  384. // Interrupt handle/object
  385. IN PKINTERRUPT m_InterruptObject;
  386. // Physical device object used at Power management
  387. PDEVICE_OBJECT m_PhysicalDeviceObject;
  388. // Will be used by child at bus to access parent
  389. PDEVICE_OBJECT m_ParentDeviceObject;
  390. protected:
  391. BOOL initialized;//Current object finished initialization
  392. LONG refcount;
  393. };
  394. #ifdef DEBUG
  395. #define INCLUDE_PNP_FUNCTIONS_NAMES() \
  396. PnPfcnname[IRP_MN_START_DEVICE] = "IRP_MN_START_DEVICE";\
  397. PnPfcnname[IRP_MN_QUERY_REMOVE_DEVICE] = "IRP_MN_QUERY_REMOVE_DEVICE";\
  398. PnPfcnname[IRP_MN_REMOVE_DEVICE] = "IRP_MN_REMOVE_DEVICE";\
  399. PnPfcnname[IRP_MN_CANCEL_REMOVE_DEVICE] = "IRP_MN_CANCEL_REMOVE_DEVICE";\
  400. PnPfcnname[IRP_MN_STOP_DEVICE] = "IRP_MN_STOP_DEVICE";\
  401. \
  402. PnPfcnname[IRP_MN_QUERY_STOP_DEVICE] = "IRP_MN_QUERY_STOP_DEVICE";\
  403. PnPfcnname[IRP_MN_CANCEL_STOP_DEVICE] = "IRP_MN_CANCEL_STOP_DEVICE";\
  404. PnPfcnname[IRP_MN_QUERY_DEVICE_RELATIONS]= "IRP_MN_QUERY_DEVICE_RELATIONS";\
  405. \
  406. PnPfcnname[IRP_MN_QUERY_INTERFACE] = "IRP_MN_QUERY_INTERFACE";\
  407. PnPfcnname[IRP_MN_QUERY_CAPABILITIES] = "IRP_MN_QUERY_CAPABILITIES";\
  408. PnPfcnname[IRP_MN_QUERY_RESOURCES] = "IRP_MN_QUERY_RESOURCES";\
  409. \
  410. PnPfcnname[IRP_MN_QUERY_RESOURCE_REQUIREMENTS] = "IRP_MN_QUERY_RESOURCE_REQUIREMENTS";\
  411. PnPfcnname[IRP_MN_QUERY_DEVICE_TEXT] = "IRP_MN_QUERY_DEVICE_TEXT";\
  412. PnPfcnname[IRP_MN_FILTER_RESOURCE_REQUIREMENTS] = "IRP_MN_FILTER_RESOURCE_REQUIREMENTS";\
  413. PnPfcnname[14] = "Unsupported PnP function";\
  414. \
  415. PnPfcnname[IRP_MN_READ_CONFIG] = "IRP_MN_READ_CONFIG";\
  416. PnPfcnname[IRP_MN_WRITE_CONFIG] = "IRP_MN_WRITE_CONFIG";\
  417. PnPfcnname[IRP_MN_EJECT] = "IRP_MN_EJECT";\
  418. \
  419. PnPfcnname[IRP_MN_SET_LOCK] = "IRP_MN_SET_LOCK";\
  420. PnPfcnname[IRP_MN_QUERY_ID] = "IRP_MN_QUERY_ID";\
  421. PnPfcnname[IRP_MN_QUERY_PNP_DEVICE_STATE] = "IRP_MN_QUERY_PNP_DEVICE_STATE";\
  422. PnPfcnname[IRP_MN_QUERY_BUS_INFORMATION] = "IRP_MN_QUERY_BUS_INFORMATION";\
  423. PnPfcnname[IRP_MN_DEVICE_USAGE_NOTIFICATION] = "IRP_MN_DEVICE_USAGE_NOTIFICATION";\
  424. PnPfcnname[IRP_MN_SURPRISE_REMOVAL] = "IRP_MN_SURPRISE_REMOVAL";\
  425. PnPfcnname[IRP_MN_QUERY_LEGACY_BUS_INFORMATION] = "IRP_MN_QUERY_LEGACY_BUS_INFORMATION";
  426. #define INCLUDE_POWER_FUNCTIONS_NAMES() \
  427. Powerfcnname[IRP_MN_WAIT_WAKE] = "IRP_MN_WAIT_WAKE";\
  428. Powerfcnname[IRP_MN_POWER_SEQUENCE] = "IRP_MN_POWER_SEQUENCE";\
  429. Powerfcnname[IRP_MN_SET_POWER] = "IRP_MN_SET_POWER";\
  430. Powerfcnname[IRP_MN_QUERY_POWER] = "IRP_MN_QUERY_POWER";\
  431. \
  432. Powersysstate[0] = "PowerSystemUnspecified";\
  433. Powersysstate[1] = "PowerSystemWorking";\
  434. Powersysstate[2] = "PowerSystemSleeping1";\
  435. Powersysstate[3] = "PowerSystemSleeping2";\
  436. Powersysstate[4] = "PowerSystemSleeping3";\
  437. Powersysstate[5] = "PowerSystemShutdown";\
  438. Powersysstate[6] = "PowerSystemMaximum";\
  439. \
  440. Powerdevstate[0] = "PowerDeviceUnspecified";\
  441. Powerdevstate[1] = "PowerDeviceD0";\
  442. Powerdevstate[2] = "PowerDeviceD1";\
  443. Powerdevstate[3] = "PowerDeviceD2";\
  444. Powerdevstate[4] = "PowerDeviceD3";\
  445. Powerdevstate[5] = "PowerDeviceMaximum";
  446. #define INCLUDE_STATE_NAMES() \
  447. statenames[0] = "STOPPED";\
  448. statenames[1] = "WORKING";\
  449. statenames[2] = "PENDINGSTOP";\
  450. statenames[3] = "PENDINGREMOVE";\
  451. statenames[4] = "SURPRISEREMOVED";\
  452. statenames[5] = "REMOVED";
  453. #else
  454. #define INCLUDE_PNP_FUNCTIONS_NAMES()
  455. #define INCLUDE_POWER_FUNCTIONS_NAMES()
  456. #define INCLUDE_STATE_NAMES()
  457. #endif // DEBUG
  458. #endif