ReactOS  0.4.15-dev-976-g0f66c66
miniport.c File Reference
#include "pciidex.h"
#include <debug.h>
Include dependency graph for miniport.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static NTSTATUS NTAPI PciIdeXForwardOrIgnore (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
 _Dispatch_type_ (IRP_MJ_POWER)
 
 _Dispatch_type_ (IRP_MJ_PNP)
 
VOID PciIdeXDebugPrint (_In_ ULONG DebugPrintLevel, _In_z_ _Printf_format_string_ PCCHAR DebugMessage,...)
 Prints the given string with printf-like formatting to the kernel debugger. More...
 
NTSTATUS NTAPI PciIdeXInitialize (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath, IN PCONTROLLER_PROPERTIES HwGetControllerProperties, IN ULONG ExtensionSize)
 
NTSTATUS NTAPI PciIdeXGetBusData (IN PVOID DeviceExtension, IN PVOID Buffer, IN ULONG ConfigDataOffset, IN ULONG BufferLength)
 
NTSTATUS NTAPI PciIdeXSetBusData (IN PVOID DeviceExtension, IN PVOID Buffer, IN PVOID DataMask, IN ULONG ConfigDataOffset, IN ULONG BufferLength)
 

Variables

ULONG PciIdeDebug = 0
 Global debugging level. Valid values are between 0 (Error) and 3 (Trace). More...
 
static DRIVER_DISPATCH PciIdeXForwardOrIgnore
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file miniport.c.

Function Documentation

◆ _Dispatch_type_() [1/2]

_Dispatch_type_ ( IRP_MJ_POWER  )

Definition at line 48 of file miniport.c.

54 {
56  PIO_STACK_LOCATION IoStack;
57  PDEVICE_OBJECT LowerDevice;
58 
61  {
62  LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
65  return PoCallDriver(LowerDevice, Irp);
66  }
67  else
68  {
69  switch (IoStack->MinorFunction)
70  {
71  case IRP_MN_SET_POWER:
72  case IRP_MN_QUERY_POWER:
73  Irp->IoStatus.Status = STATUS_SUCCESS;
74  break;
75  }
76  Status = Irp->IoStatus.Status;
79  return Status;
80  }
81 }
#define IRP_MN_QUERY_POWER
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
#define IRP_MN_SET_POWER
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:737
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IO_NO_INCREMENT
Definition: iotypes.h:570
return STATUS_SUCCESS
Definition: btrfs.c:3014

◆ _Dispatch_type_() [2/2]

_Dispatch_type_ ( IRP_MJ_PNP  )

Definition at line 83 of file miniport.c.

89 {
92  else
94 }
_In_ PIRP Irp
Definition: csq.h:116
PVOID DeviceExtension
Definition: env_spec_w32.h:418
NTSTATUS NTAPI PciIdeXFdoPnpDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:402
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
NTSTATUS NTAPI PciIdeXPdoPnpDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pdo.c:359

◆ PciIdeXDebugPrint()

VOID PciIdeXDebugPrint ( _In_ ULONG  DebugPrintLevel,
_In_z_ _Printf_format_string_ PCCHAR  DebugMessage,
  ... 
)

Prints the given string with printf-like formatting to the kernel debugger.

Parameters
[in]DebugPrintLevelLevel of the debug message. Valid values are between 0 (Error) and 3 (Trace).
[in]DebugMessageFormat of the string/arguments.
[in]...Variable number of arguments matching the format specified in DebugMessage.
See also
PciIdeDebug

Definition at line 106 of file miniport.c.

110 {
111  va_list ap;
112 
113  /* Check if we can print anything */
114  if (DebugPrintLevel <= PciIdeDebug)
115  DebugPrintLevel = 0;
116 
117  va_start(ap, DebugMessage);
118  vDbgPrintEx(DPFLTR_PCIIDE_ID, DebugPrintLevel, DebugMessage, ap);
119  va_end(ap);
120 }
ULONG PciIdeDebug
Global debugging level. Valid values are between 0 (Error) and 3 (Trace).
Definition: miniport.c:15
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
NTSYSAPI ULONG NTAPI vDbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ PCCH Format, _In_ va_list ap)
#define va_start(ap, A)
Definition: acmsvcex.h:91
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32

◆ PciIdeXForwardOrIgnore()

static NTSTATUS NTAPI PciIdeXForwardOrIgnore ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 19 of file miniport.c.

22 {
25  else
26  {
29 
30  if (MajorFunction == IRP_MJ_CREATE ||
31  MajorFunction == IRP_MJ_CLEANUP ||
32  MajorFunction == IRP_MJ_CLOSE)
33  {
35  }
36  else
37  {
38  DPRINT1("PDO stub for major function 0x%lx\n", MajorFunction);
40  }
41  Irp->IoStatus.Information = 0;
42  Irp->IoStatus.Status = Status;
44  return Status;
45  }
46 }
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
_In_ PIRP Irp
Definition: csq.h:116
DRIVER_DISPATCH ForwardIrpAndForget
Definition: i8042prt.h:341
LONG NTSTATUS
Definition: precomp.h:26
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define IoCompleteRequest
Definition: irp.c:1240
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define DPRINT1
Definition: precomp.h:8
#define IRP_MJ_CLEANUP
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:570
return STATUS_SUCCESS
Definition: btrfs.c:3014

◆ PciIdeXGetBusData()

NTSTATUS NTAPI PciIdeXGetBusData ( IN PVOID  DeviceExtension,
IN PVOID  Buffer,
IN ULONG  ConfigDataOffset,
IN ULONG  BufferLength 
)

Definition at line 159 of file miniport.c.

164 {
165  PFDO_DEVICE_EXTENSION FdoDeviceExtension;
168 
169  DPRINT("PciIdeXGetBusData(%p %p 0x%lx 0x%lx)\n",
170  DeviceExtension, Buffer, ConfigDataOffset, BufferLength);
171 
172  FdoDeviceExtension = CONTAINING_RECORD(DeviceExtension, FDO_DEVICE_EXTENSION, MiniControllerExtension);
173  if (FdoDeviceExtension->BusInterface)
174  {
175  BytesRead = (*FdoDeviceExtension->BusInterface->GetBusData)(
176  FdoDeviceExtension->BusInterface->Context,
178  Buffer,
179  ConfigDataOffset,
180  BufferLength);
181  if (BytesRead == BufferLength)
183  }
184 
185  return Status;
186 }
PBUS_INTERFACE_STANDARD BusInterface
Definition: pciidex.h:23
LONG NTSTATUS
Definition: precomp.h:26
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
_In_ UCHAR BufferLength
Definition: scsi.h:4066
PGET_SET_DEVICE_DATA GetBusData
Definition: iotypes.h:888
#define PCI_WHICHSPACE_CONFIG
Definition: iotypes.h:3295
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:3014
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255

Referenced by PciIdeChannelEnabled(), and PciIdeXSetBusData().

◆ PciIdeXInitialize()

NTSTATUS NTAPI PciIdeXInitialize ( IN PDRIVER_OBJECT  DriverObject,
IN PUNICODE_STRING  RegistryPath,
IN PCONTROLLER_PROPERTIES  HwGetControllerProperties,
IN ULONG  ExtensionSize 
)

Definition at line 123 of file miniport.c.

128 {
129  ULONG i;
132 
133  DPRINT("PciIdeXInitialize(%p '%wZ' %p 0x%lx)\n",
134  DriverObject, RegistryPath, HwGetControllerProperties, ExtensionSize);
135 
137  DriverObject,
138  DriverObject,
139  sizeof(PCIIDEX_DRIVER_EXTENSION),
141  if (!NT_SUCCESS(Status))
142  return Status;
144  DriverExtension->MiniControllerExtensionSize = ExtensionSize;
145  DriverExtension->HwGetControllerProperties = HwGetControllerProperties;
146 
148 
149  for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
151  DriverObject->MajorFunction[IRP_MJ_POWER] = PciIdeXPowerDispatch;
152  DriverObject->MajorFunction[IRP_MJ_PNP] = PciIdeXPnpDispatch;
153 
154  return STATUS_SUCCESS;
155 }
NTSTATUS NTAPI IoAllocateDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress, IN ULONG DriverObjectExtensionSize, OUT PVOID *DriverObjectExtension)
Definition: driver.c:1791
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define IRP_MJ_MAXIMUM_FUNCTION
LONG NTSTATUS
Definition: precomp.h:26
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
PDRIVER_EXTENSION DriverExtension
Definition: iotypes.h:2181
DRIVER_ADD_DEVICE PciIdeXAddDevice
Definition: pciidex.h:43
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
void DPRINT(...)
Definition: polytest.cpp:61
_In_z_ PWSTR RegistryPath
Definition: classp.h:1930
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IRP_MJ_POWER
Status
Definition: gdiplustypes.h:24
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
PDRIVER_ADD_DEVICE AddDevice
Definition: iotypes.h:2119
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: iotypes.h:2188
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
static DRIVER_DISPATCH PciIdeXForwardOrIgnore
Definition: miniport.c:17
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by DriverEntry().

◆ PciIdeXSetBusData()

NTSTATUS NTAPI PciIdeXSetBusData ( IN PVOID  DeviceExtension,
IN PVOID  Buffer,
IN PVOID  DataMask,
IN ULONG  ConfigDataOffset,
IN ULONG  BufferLength 
)

Definition at line 190 of file miniport.c.

196 {
197  PFDO_DEVICE_EXTENSION FdoDeviceExtension;
201 
202  DPRINT("PciIdeXSetBusData(%p %p %p 0x%lx 0x%lx)\n",
203  DeviceExtension, Buffer, DataMask, ConfigDataOffset, BufferLength);
204 
206  if (!CurrentBuffer)
207  {
209  return Status;
210  }
211 
212  Status = PciIdeXGetBusData(DeviceExtension, Buffer, ConfigDataOffset, BufferLength);
213  if (!NT_SUCCESS(Status))
214  goto cleanup;
215 
216  for (i = 0; i < BufferLength; i++)
217  CurrentBuffer[i] = (CurrentBuffer[i] & ~((PUCHAR)DataMask)[i]) | (((PUCHAR)DataMask)[i] & ((PUCHAR)Buffer)[i]);
218 
219  FdoDeviceExtension = CONTAINING_RECORD(DeviceExtension, FDO_DEVICE_EXTENSION, MiniControllerExtension);
220  if (!FdoDeviceExtension->BusInterface)
221  {
223  goto cleanup;
224  }
225 
226  BytesWritten = (*FdoDeviceExtension->BusInterface->SetBusData)(
227  FdoDeviceExtension->BusInterface->Context,
230  ConfigDataOffset,
231  BufferLength);
232  if (BytesWritten == BufferLength)
234  else
236 
237 cleanup:
239  return Status;
240 }
static ACPI_BUFFER CurrentBuffer
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesWritten
Definition: fltkernel.h:1293
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PBUS_INTERFACE_STANDARD BusInterface
Definition: pciidex.h:23
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
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
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
_In_ UCHAR BufferLength
Definition: scsi.h:4066
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define PCI_WHICHSPACE_CONFIG
Definition: iotypes.h:3295
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
PGET_SET_DEVICE_DATA SetBusData
Definition: iotypes.h:887
unsigned int ULONG
Definition: retypes.h:1
char * cleanup(char *str)
Definition: wpickclick.c:99
return STATUS_SUCCESS
Definition: btrfs.c:3014
NTSTATUS NTAPI PciIdeXGetBusData(IN PVOID DeviceExtension, IN PVOID Buffer, IN ULONG ConfigDataOffset, IN ULONG BufferLength)
Definition: miniport.c:159
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Variable Documentation

◆ PciIdeDebug

ULONG PciIdeDebug = 0

Global debugging level. Valid values are between 0 (Error) and 3 (Trace).

Definition at line 15 of file miniport.c.

Referenced by PciIdeXDebugPrint().

◆ PciIdeXForwardOrIgnore

DRIVER_DISPATCH PciIdeXForwardOrIgnore
static

Definition at line 17 of file miniport.c.

Referenced by PciIdeXInitialize().