ReactOS  0.4.15-dev-3294-ge98684e
inport.h File Reference
#include <wdm.h>
#include <wmilib.h>
#include <wmistr.h>
#include <kbdmou.h>
#include <section_attribs.h>
Include dependency graph for inport.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _INPORT_RAW_DATA
 
struct  _INPORT_DEVICE_EXTENSION
 

Macros

#define INPORT_TAG   'tPnI'
 

Typedefs

typedef struct _INPORT_RAW_DATA INPORT_RAW_DATA
 
typedef struct _INPORT_RAW_DATAPINPORT_RAW_DATA
 
typedef struct _INPORT_DEVICE_EXTENSION INPORT_DEVICE_EXTENSION
 
typedef struct _INPORT_DEVICE_EXTENSIONPINPORT_DEVICE_EXTENSION
 

Enumerations

enum  INPORT_DEVICE_STATE { dsStopped, dsStarted, dsRemoved }
 
enum  INPORT_MOUSE_TYPE { NecBusMouse, MsInPortMouse, LogitechBusMouse }
 

Functions

 _Dispatch_type_ (IRP_MJ_CREATE) _Dispatch_type_(IRP_MJ_CLOSE) DRIVER_DISPATCH_PAGED InPortCreateClose
 
 _Dispatch_type_ (IRP_MJ_INTERNAL_DEVICE_CONTROL) DRIVER_DISPATCH_RAISED InPortInternalDeviceControl
 
 _Dispatch_type_ (IRP_MJ_POWER) DRIVER_DISPATCH_RAISED InPortPower
 
 _Dispatch_type_ (IRP_MJ_SYSTEM_CONTROL) DRIVER_DISPATCH_PAGED InPortWmi
 
 _Dispatch_type_ (IRP_MJ_PNP) DRIVER_DISPATCH_PAGED InPortPnp
 
NTSTATUS NTAPI InPortStartDevice (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
 
NTSTATUS NTAPI InPortRemoveDevice (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
 
VOID NTAPI InPortInitializeMouse (_In_ PINPORT_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI InPortWmiRegistration (_Inout_ PINPORT_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI InPortWmiDeRegistration (_Inout_ PINPORT_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI InPortQueryWmiRegInfo (_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PULONG RegFlags, _Inout_ PUNICODE_STRING InstanceName, _Out_opt_ PUNICODE_STRING *RegistryPath, _Inout_ PUNICODE_STRING MofResourceName, _Out_opt_ PDEVICE_OBJECT *Pdo)
 
NTSTATUS NTAPI InPortQueryWmiDataBlock (_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _In_ ULONG GuidIndex, _In_ ULONG InstanceIndex, _In_ ULONG InstanceCount, _Out_opt_ PULONG InstanceLengthArray, _In_ ULONG BufferAvail, _Out_opt_ PUCHAR Buffer)
 

Variables

DRIVER_INITIALIZE DriverEntry
 
DRIVER_UNLOAD InPortUnload
 
DRIVER_ADD_DEVICE InPortAddDevice
 
KSERVICE_ROUTINE InPortIsr
 
IO_DPC_ROUTINE InPortDpcForIsr
 
KSYNCHRONIZE_ROUTINE InPortStartMouse
 
KSYNCHRONIZE_ROUTINE InPortStopMouse
 
UNICODE_STRING DriverRegistryPath
 

Macro Definition Documentation

◆ INPORT_TAG

#define INPORT_TAG   'tPnI'

Definition at line 18 of file inport.h.

Typedef Documentation

◆ INPORT_DEVICE_EXTENSION

◆ INPORT_RAW_DATA

◆ PINPORT_DEVICE_EXTENSION

◆ PINPORT_RAW_DATA

Enumeration Type Documentation

◆ INPORT_DEVICE_STATE

Enumerator
dsStopped 
dsStarted 
dsRemoved 

Definition at line 20 of file inport.h.

21 {
22  dsStopped,
23  dsStarted,
24  dsRemoved
INPORT_DEVICE_STATE
Definition: inport.h:20

◆ INPORT_MOUSE_TYPE

Enumerator
NecBusMouse 
MsInPortMouse 
LogitechBusMouse 

Definition at line 27 of file inport.h.

Function Documentation

◆ _Dispatch_type_() [1/5]

_Dispatch_type_ ( IRP_MJ_CREATE  )

Definition at line 984 of file isapnp.c.

995 {
996  PAGED_CODE();
997 
998  Irp->IoStatus.Status = STATUS_SUCCESS;
999 
1000  DPRINT("%s(%p, %p)\n", __FUNCTION__, DeviceObject, Irp);
1001 
1003 
1004  return STATUS_SUCCESS;
1005 }
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define __FUNCTION__
Definition: types.h:112
#define PAGED_CODE()

◆ _Dispatch_type_() [2/5]

_Dispatch_type_ ( IRP_MJ_INTERNAL_DEVICE_CONTROL  )

◆ _Dispatch_type_() [3/5]

_Dispatch_type_ ( IRP_MJ_POWER  )

Definition at line 1543 of file isapnp.c.

1552 {
1553  PISAPNP_COMMON_EXTENSION DevExt = DeviceObject->DeviceExtension;
1554  NTSTATUS Status;
1555 
1556  if (DevExt->Signature != IsaPnpBus)
1557  {
1559  {
1560  case IRP_MN_SET_POWER:
1561  case IRP_MN_QUERY_POWER:
1563  Irp->IoStatus.Status = Status;
1564  break;
1565 
1566  default:
1567  Status = Irp->IoStatus.Status;
1568  break;
1569  }
1570 
1573  return Status;
1574  }
1575 
1578  return PoCallDriver(((PISAPNP_FDO_EXTENSION)DevExt)->Ldo, Irp);
1579 }
#define IRP_MN_QUERY_POWER
LONG NTSTATUS
Definition: precomp.h:26
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
_In_ UCHAR _In_ UCHAR MinorFunction
Definition: wdfdevice.h:1697
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
#define IRP_MN_SET_POWER
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:746
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
ISAPNP_SIGNATURE Signature
Definition: isapnp.h:150
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ _Dispatch_type_() [4/5]

_Dispatch_type_ ( IRP_MJ_SYSTEM_CONTROL  )

Definition at line 5676 of file btrfs.c.

5678  {
5679  NTSTATUS Status;
5680  device_extension* Vcb = DeviceObject->DeviceExtension;
5681  bool top_level;
5682 
5684 
5685  top_level = is_top_level(Irp);
5686 
5687  Irp->IoStatus.Information = 0;
5688 
5689  if (Vcb && Vcb->type == VCB_TYPE_VOLUME) {
5690  volume_device_extension* vde = DeviceObject->DeviceExtension;
5691 
5693 
5695 
5696  goto exit;
5697  } else if (Vcb && Vcb->type == VCB_TYPE_FS) {
5699 
5700  Status = IoCallDriver(Vcb->Vpb->RealDevice, Irp);
5701 
5702  goto exit;
5703  } else if (Vcb && Vcb->type == VCB_TYPE_BUS) {
5704  bus_device_extension* bde = DeviceObject->DeviceExtension;
5705 
5707 
5709 
5710  goto exit;
5711  }
5712 
5713  Status = Irp->IoStatus.Status;
5715 
5716 exit:
5717  if (top_level)
5719 
5721 
5722  return Status;
5723 }
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: btrfs.c:4232
#define VCB_TYPE_FS
Definition: btrfs_drv.h:695
bool is_top_level(_In_ PIRP Irp)
Definition: btrfs.c:279
#define VCB_TYPE_BUS
Definition: btrfs_drv.h:699
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
InsertTailList & Vcb
Definition: btrfs.c:2978
Status
Definition: gdiplustypes.h:24
#define VCB_TYPE_VOLUME
Definition: btrfs_drv.h:697
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
PDEVICE_OBJECT attached_device
Definition: btrfs_drv.h:888
PDEVICE_OBJECT attached_device
Definition: btrfs_drv.h:857
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IO_NO_INCREMENT
Definition: iotypes.h:598
void exit(int exitcode)
Definition: _exit.c:33

◆ _Dispatch_type_() [5/5]

_Dispatch_type_ ( IRP_MJ_PNP  )

Definition at line 1581 of file isapnp.c.

1591 {
1593  PISAPNP_COMMON_EXTENSION DevExt = DeviceObject->DeviceExtension;
1594 
1595  PAGED_CODE();
1596 
1597  if (DevExt->Signature == IsaPnpBus)
1598  return IsaFdoPnp((PISAPNP_FDO_EXTENSION)DevExt, Irp, IrpSp);
1599  else
1600  return IsaPdoPnp((PISAPNP_PDO_EXTENSION)DevExt, Irp, IrpSp);
1601 }
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
NTSTATUS IsaFdoPnp(_In_ PISAPNP_FDO_EXTENSION FdoExt, _Inout_ PIRP Irp, _In_ PIO_STACK_LOCATION IrpSp)
Definition: fdo.c:123
ISAPNP_SIGNATURE Signature
Definition: isapnp.h:150
NTSTATUS IsaPdoPnp(_In_ PISAPNP_PDO_EXTENSION PdoDeviceExtension, _Inout_ PIRP Irp, _In_ PIO_STACK_LOCATION IrpSp)
Definition: pdo.c:864
#define PAGED_CODE()

◆ InPortInitializeMouse()

VOID NTAPI InPortInitializeMouse ( _In_ PINPORT_DEVICE_EXTENSION  DeviceExtension)

Definition at line 340 of file hardware.c.

342 {
343  PAGED_CODE();
344 
345  /* Initialize mouse and disable interrupts */
346  switch (DeviceExtension->MouseType)
347  {
348  case NecBusMouse:
350 
351  /* Setup interrupt rate (unavailable on hireso machines) */
352  if (DeviceExtension->IoBase != NEC_BM_HIRESO_BASE)
353  WRITE_MOUSE(DeviceExtension, NEC_BM_INT_RATE, NEC_RATE_60_HZ);
354 
355  WRITE_MOUSE(DeviceExtension, NEC_BM_CONFIG, NEC_PPI_INT_DISABLE);
356  WRITE_MOUSE(DeviceExtension, NEC_BM_CONFIG, NEC_PPI_HC_NO_CLEAR);
357  WRITE_MOUSE(DeviceExtension, NEC_BM_CONFIG, NEC_PPI_HC_CLEAR);
358  break;
359 
360  case MsInPortMouse:
361  WRITE_MOUSE(DeviceExtension, MS_INPORT_CONTROL, INPORT_RESET);
362  WRITE_MOUSE(DeviceExtension, MS_INPORT_CONTROL, INPORT_REG_MODE);
363  WRITE_MOUSE(DeviceExtension, MS_INPORT_DATA, INPORT_MODE_BASE);
364  break;
365 
366  case LogitechBusMouse:
367  WRITE_MOUSE(DeviceExtension, LOG_BM_CONFIG, LOG_DEFAULT_MODE);
368  WRITE_MOUSE(DeviceExtension, LOG_BM_CONTROL, LOG_DISABLE_IRQ);
369  break;
370  }
371 }
#define NEC_RATE_60_HZ
Definition: hardware.c:51
#define LOG_BM_CONTROL
Definition: hardware.c:89
#define INPORT_MODE_BASE
Definition: hardware.c:72
#define NEC_PPI_HC_CLEAR
Definition: hardware.c:46
#define INPORT_REG_MODE
Definition: hardware.c:67
#define NEC_BM_INT_RATE
Definition: hardware.c:49
#define NEC_BM_HIRESO_BASE
Definition: hardware.c:55
#define NEC_PPI_INT_DISABLE
Definition: hardware.c:44
#define MS_INPORT_DATA
Definition: hardware.c:70
#define LOG_BM_CONFIG
Definition: hardware.c:98
#define NEC_PPI_DEFAULT_MODE
Definition: hardware.c:47
#define LOG_DEFAULT_MODE
Definition: hardware.c:99
#define INPORT_RESET
Definition: hardware.c:68
#define MS_INPORT_CONTROL
Definition: hardware.c:63
#define WRITE_MOUSE(DeviceExtension, Port, Data)
Definition: hardware.c:22
#define NEC_BM_CONFIG
Definition: hardware.c:42
#define LOG_DISABLE_IRQ
Definition: hardware.c:91
#define NEC_PPI_HC_NO_CLEAR
Definition: hardware.c:45
#define PAGED_CODE()

Referenced by InPortStartDevice().

◆ InPortQueryWmiDataBlock()

NTSTATUS NTAPI InPortQueryWmiDataBlock ( _Inout_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp,
_In_ ULONG  GuidIndex,
_In_ ULONG  InstanceIndex,
_In_ ULONG  InstanceCount,
_Out_opt_ PULONG  InstanceLengthArray,
_In_ ULONG  BufferAvail,
_Out_opt_ PUCHAR  Buffer 
)

Definition at line 55 of file wmi.c.

64 {
66  PPOINTER_PORT_WMI_STD_DATA InPortData;
67  PINPORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
68 
69  PAGED_CODE();
70 
71  DPRINT("%s()\n", __FUNCTION__);
72 
74  {
76  goto Complete;
77  }
78 
79  /* Only register 1 instance per GUID */
80  if (InstanceIndex != 0 || InstanceCount != 1)
81  {
83  goto Complete;
84  }
85 
86  if (!InstanceLengthArray || BufferAvail < sizeof(POINTER_PORT_WMI_STD_DATA))
87  {
89  goto Complete;
90  }
91 
92  InPortData = (PPOINTER_PORT_WMI_STD_DATA)Buffer;
93 
94  /* Bus mouse connector isn't defined in the DDK, so set type to something generic */
96  /* 1 packet */
97  InPortData->DataQueueSize = 1;
98  /* Not supported by device */
99  InPortData->ErrorCount = 0;
100 
101  InPortData->Buttons = DeviceExtension->MouseAttributes.NumberOfButtons;
103  *InstanceLengthArray = sizeof(POINTER_PORT_WMI_STD_DATA);
104 
106 
107 Complete:
109  Irp,
110  Status,
113 }
#define STATUS_WMI_GUID_NOT_FOUND
Definition: ntstatus.h:776
WMIGUIDREGINFO InPortWmiGuidList[]
Definition: wmi.c:19
LONG NTSTATUS
Definition: precomp.h:26
_In_ LPGUID _In_ ULONG InstanceIndex
Definition: classpnp.h:1250
NTSTATUS NTAPI WmiCompleteRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN NTSTATUS Status, IN ULONG BufferUsed, IN CCHAR PriorityBoost)
Definition: wmilib.c:24
#define STATUS_WMI_INSTANCE_NOT_FOUND
Definition: ntstatus.h:777
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
struct _POINTER_PORT_WMI_STD_DATA * PPOINTER_PORT_WMI_STD_DATA
_In_ PIRP Irp
Definition: csq.h:116
pRequest Complete(RequestStatus)
_In_ PIRP _In_ ULONG GuidIndex
Definition: classpnp.h:418
Definition: bufpool.h:45
struct _POINTER_PORT_WMI_STD_DATA POINTER_PORT_WMI_STD_DATA
Status
Definition: gdiplustypes.h:24
_In_ PIRP _In_ ULONG _In_ ULONG BufferAvail
Definition: classpnp.h:418
#define POINTER_PORT_WMI_STD_MOUSE
Definition: wmidata.h:3180
MOUSE_ATTRIBUTES MouseAttributes
Definition: inport.h:76
#define POINTER_PORT_WMI_STD_I8042
Definition: wmidata.h:3169
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define IO_NO_INCREMENT
Definition: iotypes.h:598
_In_ ULONG InstanceCount
Definition: iofuncs.h:1323
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define __FUNCTION__
Definition: types.h:112
USHORT NumberOfButtons
Definition: ntddmou.h:110
#define PAGED_CODE()

Referenced by InPortWmiRegistration().

◆ InPortQueryWmiRegInfo()

NTSTATUS NTAPI InPortQueryWmiRegInfo ( _Inout_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PULONG  RegFlags,
_Inout_ PUNICODE_STRING  InstanceName,
_Out_opt_ PUNICODE_STRING RegistryPath,
_Inout_ PUNICODE_STRING  MofResourceName,
_Out_opt_ PDEVICE_OBJECT Pdo 
)

Definition at line 28 of file wmi.c.

35 {
36  PINPORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
37 
40 
41  PAGED_CODE();
42 
43  DPRINT("%s()\n", __FUNCTION__);
44 
47  *Pdo = DeviceExtension->Pdo;
48 
49  return STATUS_SUCCESS;
50 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:213
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_ WDFDRIVER _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT Pdo
Definition: wdfminiport.h:64
_Out_ ULONG * RegFlags
Definition: classpnp.h:403
#define WMIREG_FLAG_INSTANCE_PDO
Definition: wmistr.h:69
PDEVICE_OBJECT Pdo
Definition: inport.h:45
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING MofResourceName
Definition: wdfdevice.h:2461
UNICODE_STRING DriverRegistryPath
Definition: inport.c:17
_Must_inspect_result_ _Inout_ PFLT_VOLUME _In_opt_ PCUNICODE_STRING InstanceName
Definition: fltkernel.h:1162
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define __FUNCTION__
Definition: types.h:112
#define PAGED_CODE()

Referenced by InPortWmiRegistration().

◆ InPortRemoveDevice()

NTSTATUS NTAPI InPortRemoveDevice ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp 
)

Definition at line 177 of file pnp.c.

180 {
182  BOOLEAN IsStarted;
183  PINPORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
184 
185  PAGED_CODE();
186 
187  InPortWmiDeRegistration(DeviceExtension);
188 
189  IsStarted = (DeviceExtension->State == dsStarted);
190 
191  DeviceExtension->State = dsRemoved;
192 
193  Irp->IoStatus.Status = STATUS_SUCCESS;
195  Status = IoCallDriver(DeviceExtension->Ldo, Irp);
196 
197  IoReleaseRemoveLockAndWait(&DeviceExtension->RemoveLock, Irp);
198 
199  /* Device is active */
200  if (IsStarted)
201  {
202  KeSynchronizeExecution(DeviceExtension->InterruptObject,
204  DeviceExtension);
205 
206  IoDisconnectInterrupt(DeviceExtension->InterruptObject);
207 
208  /* Flush DPC for ISR */
210  }
211 
212  IoDetachDevice(DeviceExtension->Ldo);
214 
215  return Status;
216 }
Definition: pci.h:35
PDEVICE_OBJECT Ldo
Definition: inport.h:46
INPORT_DEVICE_STATE State
Definition: inport.h:47
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
KSYNCHRONIZE_ROUTINE InPortStopMouse
Definition: inport.h:113
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
unsigned char BOOLEAN
VOID NTAPI IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
Definition: irq.c:140
PKINTERRUPT InterruptObject
Definition: inport.h:54
Status
Definition: gdiplustypes.h:24
IO_REMOVE_LOCK RemoveLock
Definition: inport.h:48
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
BOOLEAN NTAPI KeSynchronizeExecution(IN OUT PKINTERRUPT Interrupt, IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, IN PVOID SynchronizeContext OPTIONAL)
Definition: interrupt.c:165
#define IoReleaseRemoveLockAndWait(_RemoveLock, _Tag)
Definition: iofuncs.h:2774
#define STATUS_SUCCESS
Definition: shellext.h:65
VOID NTAPI KeFlushQueuedDpcs(VOID)
Definition: dpc.c:919
NTSTATUS NTAPI InPortWmiDeRegistration(_Inout_ PINPORT_DEVICE_EXTENSION DeviceExtension)
Definition: wmi.c:140
#define PAGED_CODE()

Referenced by InPortPnp().

◆ InPortStartDevice()

NTSTATUS NTAPI InPortStartDevice ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp 
)

Definition at line 20 of file pnp.c.

23 {
26  PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, DescriptorTranslated;
27  ULONG i;
28  ULONG RawVector;
29  BOOLEAN FoundBasePort = FALSE, FoundIrq = FALSE;
30  PINPORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
32 
33  PAGED_CODE();
34 
35  ASSERT(DeviceExtension->State == dsStopped);
36 
37  if (!IoForwardIrpSynchronously(DeviceExtension->Ldo, Irp))
38  {
40  goto Complete;
41  }
42  Status = Irp->IoStatus.Status;
43  if (!NT_SUCCESS(Status))
44  {
45  DPRINT1("LDO failed to start 0x%X\n", Status);
46  goto Complete;
47  }
48 
49  AllocatedResources = IrpSp->Parameters.StartDevice.AllocatedResources;
50  AllocatedResourcesTranslated = IrpSp->Parameters.StartDevice.AllocatedResourcesTranslated;
52  {
53  DPRINT1("No allocated resources\n");
55  goto Complete;
56  }
57 
58  if (AllocatedResources->Count != 1)
59  DPRINT1("Expected FullList count is 1, got %d\n", AllocatedResources->Count);
60 
61  for (i = 0; i < AllocatedResources->List[0].PartialResourceList.Count; i++)
62  {
63  Descriptor = &AllocatedResources->List[0].PartialResourceList.PartialDescriptors[i];
64  DescriptorTranslated = &AllocatedResourcesTranslated->List[0].PartialResourceList.PartialDescriptors[i];
65 
66  switch (Descriptor->Type)
67  {
68  case CmResourceTypePort:
69  {
70  DPRINT("[%p:%X:%X] I/O ports at [%p-%p]\n",
71  Descriptor,
72  Descriptor->ShareDisposition,
73  Descriptor->Flags,
74  Descriptor->u.Port.Start.LowPart,
75  Descriptor->u.Port.Start.LowPart + (Descriptor->u.Port.Length - 1));
76 
77  if (!FoundBasePort)
78  {
79  DeviceExtension->IoBase = ULongToPtr(Descriptor->u.Port.Start.u.LowPart);
80 
81  FoundBasePort = TRUE;
82  }
83 
84  break;
85  }
86 
88  {
89  DPRINT("[%p:%X:%X] INT Vec %d Lev %d Aff %IX\n",
90  Descriptor,
91  Descriptor->ShareDisposition,
92  Descriptor->Flags,
93  Descriptor->u.Interrupt.Vector,
94  Descriptor->u.Interrupt.Level,
95  Descriptor->u.Interrupt.Affinity);
96 
97  if (!FoundIrq)
98  {
99  DeviceExtension->InterruptVector = DescriptorTranslated->u.Interrupt.Vector;
100  DeviceExtension->InterruptLevel = (KIRQL)DescriptorTranslated->u.Interrupt.Level;
101  if (DescriptorTranslated->Flags & CM_RESOURCE_INTERRUPT_LATCHED)
102  DeviceExtension->InterruptMode = Latched;
103  else
104  DeviceExtension->InterruptMode = LevelSensitive;
105  DeviceExtension->InterruptShared = (DescriptorTranslated->ShareDisposition == CmResourceShareShared);
106  DeviceExtension->InterruptAffinity = DescriptorTranslated->u.Interrupt.Affinity;
107  RawVector = Descriptor->u.Interrupt.Vector;
108 
109  FoundIrq = TRUE;
110  }
111 
112  break;
113  }
114 
115  default:
116  DPRINT("[%p:%X:%X] Unrecognized resource type %X\n",
117  Descriptor,
118  Descriptor->ShareDisposition,
119  Descriptor->Flags,
120  Descriptor->Type);
121  break;
122  }
123  }
124 
125  if (!FoundBasePort || !FoundIrq)
126  {
127  DPRINT1("The device resources were not found\n");
129  goto Complete;
130  }
131 
132  DPRINT("I/O base at %p\n", DeviceExtension->IoBase);
133  DPRINT("IRQ %d\n", RawVector);
134 
135  Status = InPortWmiRegistration(DeviceExtension);
136  if (!NT_SUCCESS(Status))
137  {
138  DPRINT1("WMI registration failed 0x%X\n", Status);
139  goto Complete;
140  }
141 
142  InPortInitializeMouse(DeviceExtension);
143 
144  Status = IoConnectInterrupt(&DeviceExtension->InterruptObject,
145  InPortIsr,
146  DeviceExtension,
147  NULL,
148  DeviceExtension->InterruptVector,
149  DeviceExtension->InterruptLevel,
150  DeviceExtension->InterruptLevel,
151  DeviceExtension->InterruptMode,
152  DeviceExtension->InterruptShared,
153  DeviceExtension->InterruptAffinity,
154  FALSE);
155  if (!NT_SUCCESS(Status))
156  {
157  DPRINT1("Could not connect to interrupt %d\n", DeviceExtension->InterruptVector);
158  goto Complete;
159  }
160 
161  KeSynchronizeExecution(DeviceExtension->InterruptObject,
163  DeviceExtension);
164 
165  DeviceExtension->State = dsStarted;
166 
167 Complete:
168  Irp->IoStatus.Status = Status;
170 
171  return Status;
172 }
PDEVICE_OBJECT Ldo
Definition: inport.h:46
KSYNCHRONIZE_ROUTINE InPortStartMouse
Definition: inport.h:111
INPORT_DEVICE_STATE State
Definition: inport.h:47
#define ULongToPtr(ul)
Definition: basetsd.h:92
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:339
NTSTATUS NTAPI InPortWmiRegistration(_Inout_ PINPORT_DEVICE_EXTENSION DeviceExtension)
Definition: wmi.c:118
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResources
Definition: ndis.h:4640
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI IoForwardIrpSynchronously(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1625
LONG NTSTATUS
Definition: precomp.h:26
KSERVICE_ROUTINE InPortIsr
Definition: inport.h:107
KINTERRUPT_MODE InterruptMode
Definition: inport.h:57
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define CmResourceTypePort
Definition: hwresource.cpp:123
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@376 u
UCHAR KIRQL
Definition: env_spec_w32.h:591
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
pRequest Complete(RequestStatus)
NTSTATUS NTAPI IoConnectInterrupt(OUT PKINTERRUPT *InterruptObject, IN PKSERVICE_ROUTINE ServiceRoutine, IN PVOID ServiceContext, IN PKSPIN_LOCK SpinLock, IN ULONG Vector, IN KIRQL Irql, IN KIRQL SynchronizeIrql, IN KINTERRUPT_MODE InterruptMode, IN BOOLEAN ShareVector, IN KAFFINITY ProcessorEnableMask, IN BOOLEAN FloatingSave)
Definition: irq.c:22
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResourcesTranslated
Definition: ndis.h:4640
KAFFINITY InterruptAffinity
Definition: inport.h:59
unsigned char BOOLEAN
#define IoCompleteRequest
Definition: irp.c:1240
VOID NTAPI InPortInitializeMouse(_In_ PINPORT_DEVICE_EXTENSION DeviceExtension)
Definition: hardware.c:340
PKINTERRUPT InterruptObject
Definition: inport.h:54
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define NULL
Definition: types.h:112
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define DPRINT1
Definition: precomp.h:8
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:598
BOOLEAN NTAPI KeSynchronizeExecution(IN OUT PKINTERRUPT Interrupt, IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, IN PVOID SynchronizeContext OPTIONAL)
Definition: interrupt.c:165
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@376::@379 Interrupt
#define DPRINT
Definition: sndvol32.h:71
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
#define STATUS_DEVICE_CONFIGURATION_ERROR
Definition: ntstatus.h:619
BOOLEAN InterruptShared
Definition: inport.h:58
#define PAGED_CODE()

Referenced by InPortPnp().

◆ InPortWmiDeRegistration()

NTSTATUS NTAPI InPortWmiDeRegistration ( _Inout_ PINPORT_DEVICE_EXTENSION  DeviceExtension)

Definition at line 140 of file wmi.c.

142 {
143  PAGED_CODE();
144 
145  return IoWMIRegistrationControl(DeviceExtension->Self,
147 }
#define WMIREG_ACTION_DEREGISTER
NTSTATUS NTAPI IoWMIRegistrationControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG Action)
Definition: wmi.c:68
#define PAGED_CODE()

Referenced by InPortRemoveDevice().

◆ InPortWmiRegistration()

NTSTATUS NTAPI InPortWmiRegistration ( _Inout_ PINPORT_DEVICE_EXTENSION  DeviceExtension)

Definition at line 118 of file wmi.c.

120 {
121  PAGED_CODE();
122 
123  DeviceExtension->WmiLibInfo.GuidCount = RTL_NUMBER_OF(InPortWmiGuidList);
124  DeviceExtension->WmiLibInfo.GuidList = InPortWmiGuidList;
125 
126  DeviceExtension->WmiLibInfo.QueryWmiRegInfo = InPortQueryWmiRegInfo;
127  DeviceExtension->WmiLibInfo.QueryWmiDataBlock = InPortQueryWmiDataBlock;
128  DeviceExtension->WmiLibInfo.SetWmiDataBlock = NULL;
129  DeviceExtension->WmiLibInfo.SetWmiDataItem = NULL;
130  DeviceExtension->WmiLibInfo.ExecuteWmiMethod = NULL;
131  DeviceExtension->WmiLibInfo.WmiFunctionControl = NULL;
132 
133  return IoWMIRegistrationControl(DeviceExtension->Self,
135 }
WMIGUIDREGINFO InPortWmiGuidList[]
Definition: wmi.c:19
NTSTATUS NTAPI InPortQueryWmiDataBlock(_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _In_ ULONG GuidIndex, _In_ ULONG InstanceIndex, _In_ ULONG InstanceCount, _Out_opt_ PULONG InstanceLengthArray, _In_ ULONG BufferAvail, _Out_opt_ PUCHAR Buffer)
Definition: wmi.c:55
NTSTATUS NTAPI InPortQueryWmiRegInfo(_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PULONG RegFlags, _Inout_ PUNICODE_STRING InstanceName, _Out_opt_ PUNICODE_STRING *RegistryPath, _Inout_ PUNICODE_STRING MofResourceName, _Out_opt_ PDEVICE_OBJECT *Pdo)
Definition: wmi.c:28
NTSTATUS NTAPI IoWMIRegistrationControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG Action)
Definition: wmi.c:68
#define WMIREG_ACTION_REGISTER
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define NULL
Definition: types.h:112
#define PAGED_CODE()

Referenced by InPortStartDevice().

Variable Documentation

◆ DriverEntry

DRIVER_INITIALIZE DriverEntry

Definition at line 80 of file inport.h.

◆ DriverRegistryPath

◆ InPortAddDevice

DRIVER_ADD_DEVICE InPortAddDevice

Definition at line 86 of file inport.h.

◆ InPortDpcForIsr

IO_DPC_ROUTINE InPortDpcForIsr

Definition at line 109 of file inport.h.

Referenced by InPortAddDevice().

◆ InPortIsr

KSERVICE_ROUTINE InPortIsr

Definition at line 107 of file inport.h.

Referenced by InPortStartDevice().

◆ InPortStartMouse

KSYNCHRONIZE_ROUTINE InPortStartMouse

Definition at line 111 of file inport.h.

Referenced by InPortStartDevice().

◆ InPortStopMouse

KSYNCHRONIZE_ROUTINE InPortStopMouse

Definition at line 113 of file inport.h.

Referenced by InPortRemoveDevice().

◆ InPortUnload

DRIVER_UNLOAD InPortUnload

Definition at line 83 of file inport.h.