Added PnP and Power structures

svn path=/trunk/; revision=1795
This commit is contained in:
Casper Hornstrup 2001-04-16 00:52:12 +00:00
parent 262859736d
commit 8c8d19c080
4 changed files with 485 additions and 0 deletions

View file

@ -0,0 +1,176 @@
#ifndef __INCLUDE_DDK_PNPFUNCS_H
#define __INCLUDE_DDK_PNPFUNCS_H
#define IoInitializeRemoveLock(Lock, Tag, Maxmin, HighWater) \
IoInitializeRemoveLockEx(Lock, Tag, Maxmin, HighWater, sizeof(IO_REMOVE_LOCK))
VOID
STDCALL
IoInitializeRemoveLockEx(
IN PIO_REMOVE_LOCK Lock,
IN ULONG AllocateTag,
IN ULONG MaxLockedMinutes,
IN ULONG HighWatermark,
IN ULONG RemlockSize);
#define IoAcquireRemoveLock(RemoveLock, Tag) \
IoAcquireRemoveLockEx(RemoveLock, Tag, __FILE__, __LINE__, sizeof(IO_REMOVE_LOCK))
NTSTATUS
STDCALL
IoAcquireRemoveLockEx(
IN PIO_REMOVE_LOCK RemoveLock,
IN OPTIONAL PVOID Tag,
IN LPCSTR File,
IN ULONG Line,
IN ULONG RemlockSize);
#define IoReleaseRemoveLock(RemoveLock, Tag) \
IoReleaseRemoveLockEx(RemoveLock, Tag, sizeof (IO_REMOVE_LOCK))
VOID
STDCALL
IoReleaseRemoveLockEx(
IN PIO_REMOVE_LOCK RemoveLock,
IN PVOID Tag,
IN ULONG RemlockSize);
#define IoReleaseRemoveLockAndWait(RemoveLock, Tag) \
IoReleaseRemoveLockAndWaitEx(RemoveLock, Tag, sizeof (IO_REMOVE_LOCK))
VOID
STDCALL
IoReleaseRemoveLockAndWaitEx(
IN PIO_REMOVE_LOCK RemoveLock,
IN PVOID Tag,
IN ULONG RemlockSize);
VOID
STDCALL
IoAdjustPagingPathCount(
IN PLONG Count,
IN BOOLEAN Increment);
NTSTATUS
STDCALL
IoGetDeviceInterfaceAlias(
IN PUNICODE_STRING SymbolicLinkName,
IN CONST GUID *AliasInterfaceClassGuid,
OUT PUNICODE_STRING AliasSymbolicLinkName);
NTSTATUS
STDCALL
IoGetDeviceInterfaces(
IN CONST GUID *InterfaceClassGuid,
IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
IN ULONG Flags,
OUT PWSTR *SymbolicLinkList);
NTSTATUS
STDCALL
IoGetDeviceProperty(
IN PDEVICE_OBJECT DeviceObject,
IN DEVICE_REGISTRY_PROPERTY DeviceProperty,
IN ULONG BufferLength,
OUT PVOID PropertyBuffer,
OUT PULONG ResultLength);
VOID
STDCALL
IoInvalidateDeviceRelations(
IN PDEVICE_OBJECT DeviceObject,
IN DEVICE_RELATION_TYPE Type);
VOID
STDCALL
IoInvalidateDeviceState(
IN PDEVICE_OBJECT PhysicalDeviceObject);
NTSTATUS
STDCALL
IoOpenDeviceInterfaceRegistryKey(
IN PUNICODE_STRING SymbolicLinkName,
IN ACCESS_MASK DesiredAccess,
OUT PHANDLE DeviceInterfaceKey);
NTSTATUS
STDCALL
IoOpenDeviceRegistryKey(
IN PDEVICE_OBJECT DeviceObject,
IN ULONG DevInstKeyType,
IN ACCESS_MASK DesiredAccess,
OUT PHANDLE DevInstRegKey);
NTSTATUS
STDCALL
IoRegisterDeviceInterface(
IN PDEVICE_OBJECT PhysicalDeviceObject,
IN CONST GUID *InterfaceClassGuid,
IN PUNICODE_STRING ReferenceString OPTIONAL,
OUT PUNICODE_STRING SymbolicLinkName);
NTSTATUS
STDCALL
IoRegisterPlugPlayNotification(
IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory,
IN ULONG EventCategoryFlags,
IN PVOID EventCategoryData OPTIONAL,
IN PDRIVER_OBJECT DriverObject,
IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine,
IN PVOID Context,
OUT PVOID *NotificationEntry);
NTSTATUS
STDCALL
IoReportDetectedDevice(
IN PDRIVER_OBJECT DriverObject,
IN INTERFACE_TYPE LegacyBusType,
IN ULONG BusNumber,
IN ULONG SlotNumber,
IN PCM_RESOURCE_LIST ResourceList,
IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL,
IN BOOLEAN ResourceAssigned,
IN OUT PDEVICE_OBJECT *DeviceObject);
NTSTATUS
STDCALL
IoReportResourceForDetection(
IN PDRIVER_OBJECT DriverObject,
IN PCM_RESOURCE_LIST DriverList OPTIONAL,
IN ULONG DriverListSize OPTIONAL,
IN PDEVICE_OBJECT DeviceObject OPTIONAL,
IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
IN ULONG DeviceListSize OPTIONAL,
OUT PBOOLEAN ConflictDetected);
NTSTATUS
STDCALL
IoReportTargetDeviceChange(
IN PDEVICE_OBJECT PhysicalDeviceObject,
IN PVOID NotificationStructure);
NTSTATUS
STDCALL
IoReportTargetDeviceChangeAsynchronous(
IN PDEVICE_OBJECT PhysicalDeviceObject,
IN PVOID NotificationStructure,
IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL,
IN PVOID Context OPTIONAL);
VOID
STDCALL
IoRequestDeviceEject(
IN PDEVICE_OBJECT PhysicalDeviceObject);
NTSTATUS
STDCALL
IoSetDeviceInterfaceState(
IN PUNICODE_STRING SymbolicLinkName,
IN BOOLEAN Enable);
NTSTATUS
STDCALL
IoUnregisterPlugPlayNotification(
IN PVOID NotificationEntry);
#endif /* __INCLUDE_DDK_PNPFUNCS_H */

View file

@ -0,0 +1,180 @@
#ifndef __INCLUDE_DDK_PNPTYPES_H
#define __INCLUDE_DDK_PNPTYPES_H
// windows.h may be included before
#ifndef GUID_DEFINED
#define GUID_DEFINED
typedef struct _GUID {
ULONG Data1;
USHORT Data2;
USHORT Data3;
UCHAR Data4[8];
} GUID, *LPGUID;
#endif
typedef struct _DEVICE_CAPABILITIES {
USHORT Size;
USHORT Version;
ULONG DeviceD1:1;
ULONG DeviceD2:1;
ULONG LockSupported:1;
ULONG EjectSupported:1;
ULONG Removable:1;
ULONG DockDevice:1;
ULONG UniqueID:1;
ULONG SilentInstall:1;
ULONG RawDeviceOK:1;
ULONG SurpriseRemovalOK:1;
ULONG WakeFromD0:1;
ULONG WakeFromD1:1;
ULONG WakeFromD2:1;
ULONG WakeFromD3:1;
ULONG HardwareDisabled:1;
ULONG NonDynamic:1;
ULONG WarmEjectSupported:1;
ULONG Reserved:15;
ULONG Address;
ULONG UINumber;
DEVICE_POWER_STATE DeviceState[PowerSystemMaximum];
SYSTEM_POWER_STATE SystemWake;
DEVICE_POWER_STATE DeviceWake;
ULONG D1Latency;
ULONG D2Latency;
ULONG D3Latency;
} DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES;
typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION {
USHORT Version;
USHORT Size;
GUID Event;
//
// Event-specific data
//
GUID InterfaceClassGuid;
PUNICODE_STRING SymbolicLinkName;
} DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION;
typedef struct _HWPROFILE_CHANGE_NOTIFICATION {
USHORT Version;
USHORT Size;
GUID Event;
//
// (No event-specific data)
//
} HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION;
typedef struct _PLUGPLAY_NOTIFICATION_HEADER {
USHORT Version;
USHORT Size;
GUID Event;
} PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER;
typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE;
typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION {
USHORT Version;
USHORT Size;
GUID Event;
//
// Event-specific data
//
PFILE_OBJECT FileObject;
LONG NameBufferOffset;
UCHAR CustomDataBuffer[1];
} TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION;
typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION {
USHORT Version;
USHORT Size;
GUID Event;
//
// Event-specific data
//
PFILE_OBJECT FileObject;
} TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION;
// PnP Device Property for IoGetDeviceProperty
typedef enum {
DevicePropertyDeviceDescription,
DevicePropertyHardwareID,
DevicePropertyCompatibleIDs,
DevicePropertyBootConfiguration,
DevicePropertyBootConfigurationTranslated,
DevicePropertyClassName,
DevicePropertyClassGuid,
DevicePropertyDriverKeyName,
DevicePropertyManufacturer,
DevicePropertyFriendlyName,
DevicePropertyLocationInformation,
DevicePropertyPhysicalDeviceObjectName,
DevicePropertyBusTypeGuid,
DevicePropertyLegacyBusType,
DevicePropertyBusNumber,
DevicePropertyEnumeratorName,
DevicePropertyAddress,
DevicePropertyUINumber
} DEVICE_REGISTRY_PROPERTY;
// DevInstKeyType values for IoOpenDeviceRegistryKey
#define PLUGPLAY_REGKEY_DEVICE 1
#define PLUGPLAY_REGKEY_DRIVER 2
#define PLUGPLAY_REGKEY_CURRENT_HWPROFILE 4
// EventCategory for IoRegisterPlugPlayNotification
typedef enum _IO_NOTIFICATION_EVENT_CATEGORY {
EventCategoryReserved,
EventCategoryHardwareProfileChange,
EventCategoryDeviceInterfaceChange,
EventCategoryTargetDeviceChange
} IO_NOTIFICATION_EVENT_CATEGORY;
// CallbackRoutine for IoRegisterPlugPlayNotification
typedef
NTSTATUS
(*PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)(
IN PVOID NotificationStructure,
IN PVOID Context);
// Callback for IoReportTargetDeviceChangeAsynchronous
typedef
VOID
(*PDEVICE_CHANGE_COMPLETE_CALLBACK)(
IN PVOID Context);
// PNP/POWER values for IRP_MJ_PNP/IRP_MJ_POWER
typedef enum _DEVICE_RELATION_TYPE {
BusRelations,
EjectionRelations,
PowerRelations,
RemovalRelations,
TargetDeviceRelation
} DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE;
typedef struct _DEVICE_RELATIONS {
ULONG Count;
PDEVICE_OBJECT Objects[1]; // variable length
} DEVICE_RELATIONS, *PDEVICE_RELATIONS;
typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {
DeviceUsageTypeUndefined,
DeviceUsageTypePaging,
DeviceUsageTypeHibernation,
DeviceUsageTypeDumpFile
} DEVICE_USAGE_NOTIFICATION_TYPE;
typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
BOOLEAN Removed;
BOOLEAN Reserved[3];
LONG IoCount;
KEVENT RemoveEvent;
} IO_REMOVE_LOCK_COMMON_BLOCK;
typedef struct _IO_REMOVE_LOCK {
IO_REMOVE_LOCK_COMMON_BLOCK Common;
} IO_REMOVE_LOCK, *PIO_REMOVE_LOCK;
#endif /* __INCLUDE_DDK_PNPTYPES_H */

View file

@ -0,0 +1,61 @@
#ifndef __INCLUDE_DDK_POFUNCS_H
#define __INCLUDE_DDK_POFUNCS_H
NTSTATUS
STDCALL
PoCallDriver(
IN PDEVICE_OBJECT DeviceObject,
IN OUT PIRP Irp);
PULONG
STDCALL
PoRegisterDeviceForIdleDetection(
IN PDEVICE_OBJECT DeviceObject,
IN ULONG ConservationIdleTime,
IN ULONG PerformanceIdleTime,
IN DEVICE_POWER_STATE State);
PVOID
STDCALL
PoRegisterSystemState(
IN PVOID StateHandle,
IN EXECUTION_STATE Flags);
NTSTATUS
STDCALL
PoRequestPowerIrp(
IN PDEVICE_OBJECT DeviceObject,
IN UCHAR MinorFunction,
IN POWER_STATE PowerState,
IN PREQUEST_POWER_COMPLETE CompletionFunction,
IN PVOID Context,
OUT PIRP *Irp OPTIONAL);
VOID
STDCALL
PoSetDeviceBusy(
PULONG IdlePointer);
POWER_STATE
STDCALL
PoSetPowerState(
IN PDEVICE_OBJECT DeviceObject,
IN POWER_STATE_TYPE Type,
IN POWER_STATE State);
VOID
STDCALL
PoSetSystemState(
IN EXECUTION_STATE Flags);
VOID
STDCALL
PoStartNextPowerIrp(
IN PIRP Irp);
VOID
STDCALL
PoUnregisterSystemState(
IN PVOID StateHandle);
#endif /* __INCLUDE_DDK_POFUNCS_H */

View file

@ -0,0 +1,68 @@
#ifndef __INCLUDE_DDK_POTYPES_H
#define __INCLUDE_DDK_POTYPES_H
// Flags for PoSetSystemState
typedef ULONG EXECUTION_STATE;
#define ES_SYSTEM_REQUIRED ((EXECUTION_STATE)0x00000001)
#define ES_DISPLAY_REQUIRED ((EXECUTION_STATE)0x00000002)
#define ES_USER_PRESENT ((EXECUTION_STATE)0x00000004)
#define ES_CONTINUOUS ((EXECUTION_STATE)0x80000000)
// PowerState for PoRequestPowerIrp
typedef enum _SYSTEM_POWER_STATE {
PowerSystemUnspecified = 0,
PowerSystemWorking,
PowerSystemSleeping1,
PowerSystemSleeping2,
PowerSystemSleeping3,
PowerSystemHibernate,
PowerSystemShutdown,
PowerSystemMaximum
} SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE;
// Values for IRP_MN_QUERY_POWER/IRP_MN_SET_POWER
typedef enum {
PowerActionNone = 0,
PowerActionReserved,
PowerActionSleep,
PowerActionHibernate,
PowerActionShutdown,
PowerActionShutdownReset,
PowerActionShutdownOff,
PowerActionWarmEject
} POWER_ACTION, *PPOWER_ACTION;
// State for PoRegisterDeviceForIdleDetection
typedef enum _DEVICE_POWER_STATE {
PowerDeviceUnspecified = 0,
PowerDeviceD0,
PowerDeviceD1,
PowerDeviceD2,
PowerDeviceD3,
PowerDeviceMaximum
} DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
// State for PoSetPowerState
typedef union _POWER_STATE {
SYSTEM_POWER_STATE SystemState;
DEVICE_POWER_STATE DeviceState;
} POWER_STATE, *PPOWER_STATE;
// Type for PoSetPowerState
typedef enum _POWER_STATE_TYPE {
SystemPowerState = 0,
DevicePowerState
} POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
// CompletionFunction for PoRequestPowerIrp
typedef
VOID
(*PREQUEST_POWER_COMPLETE) (
IN PDEVICE_OBJECT DeviceObject,
IN UCHAR MinorFunction,
IN POWER_STATE PowerState,
IN PVOID Context,
IN PIO_STATUS_BLOCK IoStatus);
#endif /* __INCLUDE_DDK_POTYPES_H */