Remove some debug output for USB drivers
[reactos.git] / reactos / drivers / fs / fs_rec / blockdev.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2002 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /*
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS kernel
22 * FILE: services/fs/fs_rec/blockdev.c
23 * PURPOSE: Filesystem recognizer driver
24 * PROGRAMMER: Eric Kohl
25 */
26
27 /* INCLUDES *****************************************************************/
28
29 #define NDEBUG
30 #include <debug.h>
31
32 #include "fs_rec.h"
33
34
35 /* FUNCTIONS ****************************************************************/
36
37 NTSTATUS
38 FsRecReadSectors(IN PDEVICE_OBJECT DeviceObject,
39 IN ULONG DiskSector,
40 IN ULONG SectorCount,
41 IN ULONG SectorSize,
42 IN OUT PUCHAR Buffer)
43 {
44 IO_STATUS_BLOCK IoStatus;
45 LARGE_INTEGER Offset;
46 ULONG BlockSize;
47 PKEVENT Event;
48 PIRP Irp;
49 NTSTATUS Status;
50
51 Event = ExAllocatePool(NonPagedPool, sizeof(KEVENT));
52 if (Event == NULL)
53 {
54 return(STATUS_INSUFFICIENT_RESOURCES);
55 }
56
57 KeInitializeEvent(Event,
58 NotificationEvent,
59 FALSE);
60
61 Offset.QuadPart = (LONGLONG)DiskSector * (LONGLONG)SectorSize;
62 BlockSize = SectorCount * SectorSize;
63
64 DPRINT("FsrecReadSectors(DeviceObject %x, DiskSector %d, Buffer %x)\n",
65 DeviceObject, DiskSector, Buffer);
66 DPRINT("Offset %I64x BlockSize %ld\n",
67 Offset.QuadPart,
68 BlockSize);
69
70 DPRINT("Building synchronous FSD Request...\n");
71 Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
72 DeviceObject,
73 Buffer,
74 BlockSize,
75 &Offset,
76 Event,
77 &IoStatus);
78 if (Irp == NULL)
79 {
80 DPRINT("IoBuildSynchronousFsdRequest failed\n");
81 ExFreePool(Event);
82 return(STATUS_INSUFFICIENT_RESOURCES);
83 }
84
85 DPRINT("Calling IO Driver... with irp %x\n", Irp);
86 Status = IoCallDriver(DeviceObject, Irp);
87 if (Status == STATUS_PENDING)
88 {
89 DPRINT("Operation pending\n");
90 KeWaitForSingleObject(Event, Suspended, KernelMode, FALSE, NULL);
91 Status = IoStatus.Status;
92 }
93
94 ExFreePool(Event);
95
96 return(STATUS_SUCCESS);
97 }
98
99
100 NTSTATUS
101 FsRecDeviceIoControl(IN PDEVICE_OBJECT DeviceObject,
102 IN ULONG ControlCode,
103 IN PVOID InputBuffer,
104 IN ULONG InputBufferSize,
105 IN OUT PVOID OutputBuffer,
106 IN OUT PULONG OutputBufferSize)
107 {
108 ULONG BufferSize = 0;
109 PKEVENT Event;
110 PIRP Irp;
111 IO_STATUS_BLOCK IoStatus;
112 NTSTATUS Status;
113
114 if (OutputBufferSize != NULL)
115 {
116 BufferSize = *OutputBufferSize;
117 }
118
119 Event = ExAllocatePool(NonPagedPool, sizeof(KEVENT));
120 if (Event == NULL)
121 {
122 return(STATUS_INSUFFICIENT_RESOURCES);
123 }
124
125 KeInitializeEvent(Event, NotificationEvent, FALSE);
126
127 DPRINT("Building device I/O control request ...\n");
128 Irp = IoBuildDeviceIoControlRequest(ControlCode,
129 DeviceObject,
130 InputBuffer,
131 InputBufferSize,
132 OutputBuffer,
133 BufferSize,
134 FALSE,
135 Event,
136 &IoStatus);
137 if (Irp == NULL)
138 {
139 DPRINT("IoBuildDeviceIoControlRequest() failed\n");
140 ExFreePool(Event);
141 return(STATUS_INSUFFICIENT_RESOURCES);
142 }
143
144 DPRINT("Calling IO Driver... with irp %x\n", Irp);
145 Status = IoCallDriver(DeviceObject, Irp);
146 if (Status == STATUS_PENDING)
147 {
148 KeWaitForSingleObject(Event, Suspended, KernelMode, FALSE, NULL);
149 Status = IoStatus.Status;
150 }
151
152 if (OutputBufferSize != NULL)
153 {
154 *OutputBufferSize = IoStatus.Information;
155 }
156
157 ExFreePool(Event);
158
159 return(Status);
160 }
161
162 /* EOF */