xref: /reactos/drivers/bus/isapnp/fdo.c (revision 682f85ad)
1 /*
2  * PROJECT:         ReactOS ISA PnP Bus driver
3  * FILE:            fdo.c
4  * PURPOSE:         FDO-specific code
5  * PROGRAMMERS:     Cameron Gutman (cameron.gutman@reactos.org)
6  *                  Hervé Poussineau
7  */
8 
9 #include <isapnp.h>
10 
11 #define NDEBUG
12 #include <debug.h>
13 
14 NTSTATUS
15 NTAPI
16 IsaFdoStartDevice(
17     IN PISAPNP_FDO_EXTENSION FdoExt,
18     IN PIRP Irp,
19     IN PIO_STACK_LOCATION IrpSp)
20 {
21     UNREFERENCED_PARAMETER(Irp);
22     UNREFERENCED_PARAMETER(IrpSp);
23 
24     FdoExt->Common.State = dsStarted;
25 
26     return STATUS_SUCCESS;
27 }
28 
29 NTSTATUS
30 NTAPI
31 IsaFdoQueryDeviceRelations(
32     IN PISAPNP_FDO_EXTENSION FdoExt,
33     IN PIRP Irp,
34     IN PIO_STACK_LOCATION IrpSp)
35 {
36     if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
37         return Irp->IoStatus.Status;
38 
39     return IsaPnpFillDeviceRelations(FdoExt, Irp, TRUE);
40 }
41 
42 NTSTATUS
43 NTAPI
44 IsaFdoPnp(
45     IN PISAPNP_FDO_EXTENSION FdoExt,
46     IN PIRP Irp,
47     IN PIO_STACK_LOCATION IrpSp)
48 {
49     NTSTATUS Status = Irp->IoStatus.Status;
50 
51     switch (IrpSp->MinorFunction)
52     {
53         case IRP_MN_START_DEVICE:
54             Status = IsaForwardIrpSynchronous(FdoExt, Irp);
55 
56             if (NT_SUCCESS(Status))
57                 Status = IsaFdoStartDevice(FdoExt, Irp, IrpSp);
58 
59             Irp->IoStatus.Status = Status;
60 
61             IoCompleteRequest(Irp, IO_NO_INCREMENT);
62             return Status;
63 
64         case IRP_MN_STOP_DEVICE:
65             FdoExt->Common.State = dsStopped;
66 
67             Status = STATUS_SUCCESS;
68             break;
69 
70         case IRP_MN_QUERY_DEVICE_RELATIONS:
71             Status = IsaFdoQueryDeviceRelations(FdoExt, Irp, IrpSp);
72 
73             Irp->IoStatus.Status = Status;
74 
75             IoCompleteRequest(Irp, IO_NO_INCREMENT);
76             return Status;
77 
78         case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
79             DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
80             break;
81 
82         default:
83             DPRINT1("Unknown PnP code: %x\n", IrpSp->MinorFunction);
84             break;
85     }
86 
87     IoSkipCurrentIrpStackLocation(Irp);
88 
89     return IoCallDriver(FdoExt->Ldo, Irp);
90 }
91