ReactOS 0.4.15-dev-8348-gc1b9bb5
fdo.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS ISA PnP Bus driver
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: FDO-specific code
5 * COPYRIGHT: Copyright 2010 Cameron Gutman <cameron.gutman@reactos.org>
6 * Copyright 2020 Hervé Poussineau <hpoussin@reactos.org>
7 * Copyright 2021 Dmitry Borisov <di.sean@protonmail.com>
8 */
9
10#include "isapnp.h"
11
12#define NDEBUG
13#include <debug.h>
14
15static
16CODE_SEG("PAGE")
21{
23
24 PAGED_CODE();
25
26 if (!IoForwardIrpSynchronously(FdoExt->Ldo, Irp))
27 {
29 }
30 Status = Irp->IoStatus.Status;
31 if (!NT_SUCCESS(Status))
32 {
33 return Status;
34 }
35
36 FdoExt->Common.State = dsStarted;
37
38 return STATUS_SUCCESS;
39}
40
41static
42CODE_SEG("PAGE")
47{
48 PAGED_CODE();
49
50 return IsaPnpFillDeviceRelations(FdoExt, Irp, TRUE);
51}
52
53static
54CODE_SEG("PAGE")
59{
62
63 PAGED_CODE();
64
65 IsaPnpAcquireDeviceDataLock(FdoExt);
66
67 /* Remove our logical devices */
68 while (!IsListEmpty(&FdoExt->DeviceListHead))
69 {
73 DeviceLink);
74
75 --FdoExt->DeviceCount;
76
77 if (LogDevice->Pdo)
78 {
80 }
81 }
82
83 IsaPnpReleaseDeviceDataLock(FdoExt);
84
85 IsaPnpAcquireBusDataLock();
86
87 /* Remove the Read Port */
88 if (FdoExt->ReadPortPdo)
89 {
90 IsaPnpRemoveReadPortDO(FdoExt->ReadPortPdo);
91 ReadPortCreated = FALSE;
92 }
93
94 /* Find the next ISA bus, if any */
95 Entry = BusListHead.Flink;
96 if (Entry != &BusListHead)
97 {
100 BusLink);
101
102 /* Create a new Read Port for it */
103 if (!ReadPortCreated)
105 }
106
107 RemoveEntryList(&FdoExt->BusLink);
108
109 IsaPnpReleaseBusDataLock();
110
111 Irp->IoStatus.Status = STATUS_SUCCESS;
113 Status = IoCallDriver(FdoExt->Ldo, Irp);
114
115 IoDetachDevice(FdoExt->Ldo);
116 IoDeleteDevice(FdoExt->Common.Self);
117
118 return Status;
119}
120
121CODE_SEG("PAGE")
127{
129
130 PAGED_CODE();
131
132 DPRINT("%s(%p, %p) FDO %lu, Minor - %X\n",
134 FdoExt,
135 Irp,
136 FdoExt->BusNumber,
138
139 switch (IrpSp->MinorFunction)
140 {
142 Status = IsaFdoStartDevice(FdoExt, Irp);
143
144 Irp->IoStatus.Status = Status;
146 return Status;
147
149 {
151 break;
152
154 if (!NT_SUCCESS(Status))
155 {
156 Irp->IoStatus.Status = Status;
158
159 return Status;
160 }
161
162 Irp->IoStatus.Status = Status;
163 break;
164 }
165
167 return IsaFdoRemoveDevice(FdoExt, Irp);
168
170 Irp->IoStatus.Information |= PNP_DEVICE_NOT_DISABLEABLE;
171 Irp->IoStatus.Status = STATUS_SUCCESS;
172 break;
173
175 {
178 {
179 break;
180 }
181 else if (!NT_SUCCESS(Status))
182 {
183 Irp->IoStatus.Status = Status;
185
186 return Status;
187 }
188
189 Irp->IoStatus.Status = Status;
190 break;
191 }
192
199 Irp->IoStatus.Status = STATUS_SUCCESS;
200 break;
201
202 default:
203 DPRINT("Unknown PnP code: %X\n", IrpSp->MinorFunction);
204 break;
205 }
206
208
209 return IoCallDriver(FdoExt->Ldo, Irp);
210}
#define PAGED_CODE()
#define CODE_SEG(...)
LONG NTSTATUS
Definition: precomp.h:26
static LIST_ENTRY DeviceListHead
Definition: fs.c:52
static NTSTATUS IsaFdoStartDevice(_In_ PISAPNP_FDO_EXTENSION FdoExt, _Inout_ PIRP Irp)
Definition: fdo.c:18
NTSTATUS IsaFdoPnp(_In_ PISAPNP_FDO_EXTENSION FdoExt, _Inout_ PIRP Irp, _In_ PIO_STACK_LOCATION IrpSp)
Definition: fdo.c:123
static NTSTATUS IsaFdoQueryBusRelations(_In_ PISAPNP_FDO_EXTENSION FdoExt, _Inout_ PIRP Irp)
Definition: fdo.c:44
static NTSTATUS IsaFdoRemoveDevice(_In_ PISAPNP_FDO_EXTENSION FdoExt, _Inout_ PIRP Irp)
Definition: fdo.c:56
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
NTSTATUS IsaFdoQueryInterface(_In_ PISAPNP_FDO_EXTENSION FdoExt, _In_ PIO_STACK_LOCATION IrpSp)
Definition: interface.c:19
#define __FUNCTION__
Definition: types.h:116
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
Status
Definition: gdiplustypes.h:25
NTSTATUS IsaPnpFillDeviceRelations(_In_ PISAPNP_FDO_EXTENSION FdoExt, _Inout_ PIRP Irp, _In_ BOOLEAN IncludeDataPort)
Definition: isapnp.c:1304
VOID IsaPnpRemoveReadPortDO(_In_ PDEVICE_OBJECT Pdo)
Definition: isapnp.c:1284
VOID IsaPnpRemoveLogicalDeviceDO(_In_ PDEVICE_OBJECT Pdo)
Definition: pdo.c:820
@ dsStarted
Definition: isapnp.h:35
#define _Inout_
Definition: ms_sal.h:378
#define _In_
Definition: ms_sal.h:308
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define IoCompleteRequest
Definition: irp.c:1240
BOOLEAN NTAPI IoForwardIrpSynchronously(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1625
#define IoCallDriver
Definition: irp.c:1225
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
VOID NTAPI IoInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
Definition: pnpmgr.c:1772
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
base of all file and directory entries
Definition: entries.h:83
union _IO_STACK_LOCATION::@1565 Parameters
struct _IO_STACK_LOCATION::@3974::@3999 QueryDeviceRelations
PDEVICE_OBJECT Pdo
Definition: isapnp.h:159
PDEVICE_OBJECT Pdo
Definition: isapnp.h:103
Definition: typedefs.h:120
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define IRP_MN_CANCEL_STOP_DEVICE
@ BusRelations
Definition: iotypes.h:2152
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define PNP_DEVICE_NOT_DISABLEABLE
Definition: iotypes.h:1006
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_MN_QUERY_INTERFACE
#define IRP_MN_START_DEVICE
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_STOP_DEVICE
#define IRP_MN_QUERY_REMOVE_DEVICE