[NTOSKRNL] Add a first implementation of !handle command in KDBG
[reactos.git] / drivers / bus / isapnp / pdo.c
1 /*
2 * PROJECT: ReactOS ISA PnP Bus driver
3 * FILE: pdo.c
4 * PURPOSE: PDO-specific code
5 * PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org)
6 */
7
8 #include <isapnp.h>
9
10 #define NDEBUG
11 #include <debug.h>
12
13 NTSTATUS
14 NTAPI
15 IsaPdoQueryDeviceRelations(
16 IN PISAPNP_LOGICAL_DEVICE LogDev,
17 IN PIRP Irp,
18 IN PIO_STACK_LOCATION IrpSp)
19 {
20 PDEVICE_RELATIONS DeviceRelations;
21
22 if (IrpSp->Parameters.QueryDeviceRelations.Type != TargetDeviceRelation)
23 return Irp->IoStatus.Status;
24
25 DeviceRelations = ExAllocatePool(PagedPool, sizeof(*DeviceRelations));
26 if (!DeviceRelations)
27 return STATUS_INSUFFICIENT_RESOURCES;
28
29 DeviceRelations->Count = 1;
30 DeviceRelations->Objects[0] = LogDev->Common.Self;
31 ObReferenceObject(LogDev->Common.Self);
32
33 Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
34
35 return STATUS_SUCCESS;
36 }
37
38 NTSTATUS
39 NTAPI
40 IsaPdoPnp(
41 IN PISAPNP_LOGICAL_DEVICE LogDev,
42 IN PIRP Irp,
43 IN PIO_STACK_LOCATION IrpSp)
44 {
45 NTSTATUS Status = Irp->IoStatus.Status;
46
47 switch (IrpSp->MinorFunction)
48 {
49 case IRP_MN_START_DEVICE:
50 Status = IsaHwActivateDevice(LogDev);
51
52 if (NT_SUCCESS(Status))
53 LogDev->Common.State = dsStarted;
54 break;
55
56 case IRP_MN_STOP_DEVICE:
57 Status = IsaHwDeactivateDevice(LogDev);
58
59 if (NT_SUCCESS(Status))
60 LogDev->Common.State = dsStopped;
61 break;
62
63 case IRP_MN_QUERY_DEVICE_RELATIONS:
64 Status = IsaPdoQueryDeviceRelations(LogDev, Irp, IrpSp);
65 break;
66
67 case IRP_MN_QUERY_RESOURCES:
68 DPRINT1("IRP_MN_QUERY_RESOURCES is UNIMPLEMENTED!\n");
69 break;
70
71 case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
72 DPRINT1("IRP_MN_QUERY_RESOURCE_REQUIREMENTS is UNIMPLEMENTED!\n");
73 break;
74
75 default:
76 DPRINT1("Unknown PnP code: %x\n", IrpSp->MinorFunction);
77 break;
78 }
79
80 Irp->IoStatus.Status = Status;
81 IoCompleteRequest(Irp, IO_NO_INCREMENT);
82
83 return Status;
84 }