ReactOS 0.4.15-dev-5667-ged97270
miniport.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: PCI IDE bus driver extension
4 * FILE: drivers/storage/pciidex/miniport.c
5 * PURPOSE: Miniport functions
6 * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
7 */
8
9#include "pciidex.h"
10
11#define NDEBUG
12#include <debug.h>
13
16
18static NTSTATUS NTAPI
21 IN PIRP Irp)
22{
23 if (((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
25 else
26 {
29
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}
47
49static DRIVER_DISPATCH PciIdeXPowerDispatch;
50static NTSTATUS NTAPI
51PciIdeXPowerDispatch(
53 IN PIRP Irp)
54{
56 PIO_STACK_LOCATION IoStack;
57 PDEVICE_OBJECT LowerDevice;
58
60 if (((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
61 {
62 LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
65 return PoCallDriver(LowerDevice, Irp);
66 }
67 else
68 {
69 switch (IoStack->MinorFunction)
70 {
73 Irp->IoStatus.Status = STATUS_SUCCESS;
74 break;
75 }
76 Status = Irp->IoStatus.Status;
79 return Status;
80 }
81}
82
84static DRIVER_DISPATCH PciIdeXPnpDispatch;
85static NTSTATUS NTAPI
86PciIdeXPnpDispatch(
88 IN PIRP Irp)
89{
90 if (((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
92 else
94}
95
105VOID
107 _In_ ULONG DebugPrintLevel,
108 _In_z_ _Printf_format_string_ PCCHAR DebugMessage,
109 ...)
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}
121
126 IN PCONTROLLER_PROPERTIES HwGetControllerProperties,
127 IN ULONG ExtensionSize)
128{
129 ULONG i;
132
133 DPRINT("PciIdeXInitialize(%p '%wZ' %p 0x%lx)\n",
134 DriverObject, RegistryPath, HwGetControllerProperties, ExtensionSize);
135
141 if (!NT_SUCCESS(Status))
142 return Status;
144 DriverExtension->MiniControllerExtensionSize = ExtensionSize;
145 DriverExtension->HwGetControllerProperties = HwGetControllerProperties;
146
147 DriverObject->DriverExtension->AddDevice = PciIdeXAddDevice;
148
149 for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
150 DriverObject->MajorFunction[i] = PciIdeXForwardOrIgnore;
151 DriverObject->MajorFunction[IRP_MJ_POWER] = PciIdeXPowerDispatch;
152 DriverObject->MajorFunction[IRP_MJ_PNP] = PciIdeXPnpDispatch;
153
154 return STATUS_SUCCESS;
155}
156
157/* May be called at IRQL <= DISPATCH_LEVEL */
160 IN PVOID DeviceExtension,
162 IN ULONG ConfigDataOffset,
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,
181 if (BytesRead == BufferLength)
183 }
184
185 return Status;
186}
187
188/* May be called at IRQL <= DISPATCH_LEVEL */
191 IN PVOID DeviceExtension,
193 IN PVOID DataMask,
194 IN ULONG ConfigDataOffset,
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,
234 else
236
237cleanup:
239 return Status;
240}
static ACPI_BUFFER CurrentBuffer
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
NTSYSAPI ULONG NTAPI vDbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ PCCH Format, _In_ va_list ap)
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define _Dispatch_type_(a)
Definition: btrfs_drv.h:204
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
Definition: bufpool.h:45
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static void cleanup(void)
Definition: main.c:1335
@ DPFLTR_PCIIDE_ID
Definition: dpfilter.h:86
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define NonPagedPool
Definition: env_spec_w32.h:307
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
Status
Definition: gdiplustypes.h:25
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
DRIVER_DISPATCH ForwardIrpAndForget
Definition: i8042prt.h:341
NTSTATUS(NTAPI * PCONTROLLER_PROPERTIES)(IN PVOID DeviceExtension, IN PIDE_CONTROLLER_PROPERTIES ControllerProperties)
Definition: ide.h:245
#define _In_z_
Definition: ms_sal.h:313
#define _In_
Definition: ms_sal.h:308
#define _Printf_format_string_
Definition: ms_sal.h:561
DRIVER_DISPATCH(nfs41_FsdDispatch)
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
NTSTATUS NTAPI IoAllocateDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress, IN ULONG DriverObjectExtensionSize, OUT PVOID *DriverObjectExtension)
Definition: driver.c:1811
#define IoCompleteRequest
Definition: irp.c:1240
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:746
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
DRIVER_ADD_DEVICE PciIdeXAddDevice
Definition: pciidex.h:43
NTSTATUS NTAPI PciIdeXPdoPnpDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pdo.c:359
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
NTSTATUS NTAPI PciIdeXFdoPnpDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:402
VOID PciIdeXDebugPrint(_In_ ULONG DebugPrintLevel, _In_z_ _Printf_format_string_ PCCHAR DebugMessage,...)
Prints the given string with printf-like formatting to the kernel debugger.
Definition: miniport.c:106
NTSTATUS NTAPI PciIdeXInitialize(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath, IN PCONTROLLER_PROPERTIES HwGetControllerProperties, IN ULONG ExtensionSize)
Definition: miniport.c:123
NTSTATUS NTAPI PciIdeXSetBusData(IN PVOID DeviceExtension, IN PVOID Buffer, IN PVOID DataMask, IN ULONG ConfigDataOffset, IN ULONG BufferLength)
Definition: miniport.c:190
ULONG PciIdeDebug
Global debugging level. Valid values are between 0 (Error) and 3 (Trace).
Definition: miniport.c:15
static DRIVER_DISPATCH PciIdeXForwardOrIgnore
Definition: miniport.c:17
NTSTATUS NTAPI PciIdeXGetBusData(IN PVOID DeviceExtension, IN PVOID Buffer, IN ULONG ConfigDataOffset, IN ULONG BufferLength)
Definition: miniport.c:159
PGET_SET_DEVICE_DATA SetBusData
Definition: iotypes.h:915
PGET_SET_DEVICE_DATA GetBusData
Definition: iotypes.h:916
PBUS_INTERFACE_STANDARD BusInterface
Definition: pciidex.h:23
#define NTAPI
Definition: typedefs.h:36
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ UCHAR MajorFunction
Definition: wdfdevice.h:1697
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:960
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define PCI_WHICHSPACE_CONFIG
Definition: iotypes.h:3644
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_MN_SET_POWER
#define IRP_MJ_POWER
#define IRP_MN_QUERY_POWER
#define IRP_MJ_CLEANUP
#define IRP_MJ_MAXIMUM_FUNCTION