ReactOS 0.4.15-dev-8135-g1bc6c90
pdo.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Storport Driver
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Storport PDO code
5 * COPYRIGHT: Copyright 2017 Eric Kohl (eric.kohl@reactos.org)
6 */
7
8/* INCLUDES *******************************************************************/
9
10#include "precomp.h"
11
12#define NDEBUG
13#include <debug.h>
14
15
16/* FUNCTIONS ******************************************************************/
17
20 _In_ PFDO_DEVICE_EXTENSION FdoDeviceExtension,
21 _In_ ULONG Bus,
24 _Out_ PPDO_DEVICE_EXTENSION *PdoDeviceExtension)
25{
26 PPDO_DEVICE_EXTENSION DeviceExtension = NULL;
30
31 DPRINT("PortCreatePdo(%p %p)\n",
32 FdoDeviceExtension, PdoDeviceExtension);
33
34 /* Create the port device */
35 Status = IoCreateDevice(FdoDeviceExtension->Device->DriverObject,
37 NULL,
40 FALSE,
41 &Pdo);
42 if (!NT_SUCCESS(Status))
43 {
44 DPRINT1("IoCreateDevice() failed (Status 0x%lX)\n", Status);
45 return Status;
46 }
47
48 /* Initialize the device */
49 Pdo->Flags |= DO_DIRECT_IO;
50 Pdo->Flags |= DO_POWER_PAGABLE;
51
52 DeviceExtension = (PPDO_DEVICE_EXTENSION)Pdo->DeviceExtension;
53 RtlZeroMemory(DeviceExtension, sizeof(PDO_DEVICE_EXTENSION));
54
55 DeviceExtension->ExtensionType = PdoExtension;
56
57 DeviceExtension->Device = Pdo;
58 DeviceExtension->FdoExtension = FdoDeviceExtension;
59 DeviceExtension->PnpState = dsStopped;
60
61 /* Add the PDO to the PDO list*/
62 KeAcquireInStackQueuedSpinLock(&FdoDeviceExtension->PdoListLock,
63 &LockHandle);
64 InsertHeadList(&FdoDeviceExtension->PdoListHead,
65 &DeviceExtension->PdoListEntry);
66 FdoDeviceExtension->PdoCount++;
68
69 DeviceExtension->Bus = Bus;
70 DeviceExtension->Target = Target;
71 DeviceExtension->Lun = Lun;
72
73
74 // FIXME: More initialization
75
76
77 /* The device has been initialized */
78 Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
79
80 *PdoDeviceExtension = DeviceExtension;
81
82 return STATUS_SUCCESS;
83}
84
85
89{
91
92 DPRINT("PortDeletePdo(%p)\n", PdoExtension);
93
94 /* Remove the PDO from the PDO list*/
95 KeAcquireInStackQueuedSpinLock(&PdoExtension->FdoExtension->PdoListLock,
96 &LockHandle);
97 RemoveEntryList(&PdoExtension->PdoListEntry);
98 PdoExtension->FdoExtension->PdoCount--;
100
101 if (PdoExtension->InquiryBuffer)
102 {
104 PdoExtension->InquiryBuffer = NULL;
105 }
106
107
108 // FIXME: More uninitialization
109
110
111 /* Delete the PDO */
113
114 return STATUS_SUCCESS;
115}
116
117
119NTAPI
122 _In_ PIRP Irp)
123{
124 DPRINT1("PortPdoScsi(%p %p)\n", DeviceObject, Irp);
125
126 Irp->IoStatus.Information = 0;
127 Irp->IoStatus.Status = STATUS_SUCCESS;
129 return STATUS_SUCCESS;
130}
131
132
134NTAPI
137 _In_ PIRP Irp)
138{
139 DPRINT1("PortPdoPnp(%p %p)\n", DeviceObject, Irp);
140
141 Irp->IoStatus.Information = 0;
142 Irp->IoStatus.Status = STATUS_SUCCESS;
144 return STATUS_SUCCESS;
145}
146
147/* EOF */
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR _In_ UCHAR Lun
Definition: classpnp.h:1315
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
#define TAG_INQUIRY_DATA
Definition: precomp.h:32
@ PdoExtension
Definition: precomp.h:49
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertHeadList(ListHead, Entry)
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
Status
Definition: gdiplustypes.h:25
VOID FASTCALL KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:130
VOID FASTCALL KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:166
@ dsStopped
Definition: isapnp.h:34
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define FILE_DEVICE_MASS_STORAGE
Definition: imports.h:62
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define FILE_AUTOGENERATED_DEVICE_NAME
Definition: iotypes.h:138
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
NTSTATUS NTAPI PortPdoScsi(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: pdo.c:120
NTSTATUS PortDeletePdo(_In_ PPDO_DEVICE_EXTENSION PdoExtension)
Definition: pdo.c:87
NTSTATUS NTAPI PortPdoPnp(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: pdo.c:135
NTSTATUS PortCreatePdo(_In_ PFDO_DEVICE_EXTENSION FdoDeviceExtension, _In_ ULONG Bus, _In_ ULONG Target, _In_ ULONG Lun, _Out_ PPDO_DEVICE_EXTENSION *PdoDeviceExtension)
Definition: pdo.c:19
PFDO_DEVICE_EXTENSION FdoExtension
Definition: precomp.h:126
LIST_ENTRY PdoListEntry
Definition: precomp.h:128
PDEVICE_OBJECT Device
Definition: precomp.h:125
DEVICE_STATE PnpState
Definition: precomp.h:127
EXTENSION_TYPE ExtensionType
Definition: precomp.h:123
#define NTAPI
Definition: typedefs.h:36
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
_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:72
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define DO_POWER_PAGABLE
*LockHandle LockHandle _Out_ PKLOCK_QUEUE_HANDLE LockHandle
Definition: kefuncs.h:717