2 * PROJECT: ReactOS kernel
3 * FILE: regtests/kmregtests/driver.c
4 * PURPOSE: Kernel-mode regression testing driver
5 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 * 06-07-2003 CSH Created
9 #define NTOS_MODE_KERNEL
12 #include "kmregtests.h"
18 AllocateMemory(ULONG Size
)
20 return ExAllocatePool(NonPagedPool
, Size
);
25 FreeMemory(PVOID Base
)
27 ExFreePool(NonPagedPool
);
33 /* Shutdown bochs programmatically */
34 WRITE_PORT_BUFFER_UCHAR((PUCHAR
) 0x8900,
43 PIO_STACK_LOCATION IrpSp
)
50 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
51 Irp
->IoStatus
.Information
= 0;
52 return STATUS_SUCCESS
;
58 PDEVICE_OBJECT DeviceObject
,
61 * FUNCTION: IOCTL dispatch routine
63 * DeviceObject = Pointer to a device object for this driver
64 * Irp = Pointer to a I/O request packet
66 * Status of the operation
70 PIO_STACK_LOCATION IrpSp
;
72 IrpSp
= IoGetCurrentIrpStackLocation(Irp
);
74 DPRINT("Called. DeviceObject is at (0x%X), IRP is at (0x%X), IrpSp->FileObject (0x%X).\n",
75 DeviceObject
, Irp
, IrpSp
->FileObject
);
77 Irp
->IoStatus
.Information
= 0;
79 switch (IrpSp
->Parameters
.DeviceIoControl
.IoControlCode
) {
80 case IOCTL_KMREGTESTS_RUN
:
81 Status
= KMRegTestsRun(Irp
, IrpSp
);
85 DPRINT("Unknown IOCTL (0x%X).\n",
86 IrpSp
->Parameters
.DeviceIoControl
.IoControlCode
);
87 Status
= STATUS_NOT_IMPLEMENTED
;
91 if (Status
!= STATUS_PENDING
) {
92 Irp
->IoStatus
.Status
= Status
;
93 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
96 DPRINT("Leaving. Status (0x%X).\n", Status
);
102 KMRegTestsOpenClose(IN PDEVICE_OBJECT DeviceObject
, IN PIRP Irp
)
104 PIO_STACK_LOCATION piosStack
= IoGetCurrentIrpStackLocation(Irp
);
107 nErrCode
= STATUS_SUCCESS
;
109 switch(piosStack
->MajorFunction
)
111 /* Opening and closing handles to the device */
119 Irp
->IoStatus
.Information
= 0;
125 Irp
->IoStatus
.Information
= 0;
126 nErrCode
= STATUS_END_OF_FILE
;
129 /* Unsupported operations */
131 nErrCode
= STATUS_NOT_IMPLEMENTED
;
134 Irp
->IoStatus
.Status
= nErrCode
;
135 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
141 KMRegTestsUnload(PDRIVER_OBJECT DriverObject
)
143 return STATUS_SUCCESS
;
147 DriverEntry(PDRIVER_OBJECT DriverObject
,
148 PUNICODE_STRING RegistryPath
)
150 PDEVICE_OBJECT DeviceObject
;
151 UNICODE_STRING DeviceName
;
152 UNICODE_STRING DosName
;
155 /* Register driver routines */
156 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = (PDRIVER_DISPATCH
) KMRegTestsOpenClose
;
157 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = (PDRIVER_DISPATCH
) KMRegTestsOpenClose
;
158 DriverObject
->MajorFunction
[IRP_MJ_WRITE
] = (PDRIVER_DISPATCH
) KMRegTestsOpenClose
;
159 DriverObject
->MajorFunction
[IRP_MJ_READ
] = (PDRIVER_DISPATCH
) KMRegTestsOpenClose
;
160 DriverObject
->MajorFunction
[IRP_MJ_DEVICE_CONTROL
] = (PDRIVER_DISPATCH
) KMRegTestsDispatch
;
161 DriverObject
->DriverUnload
= (PDRIVER_UNLOAD
) KMRegTestsUnload
;
164 RtlInitUnicodeString(&DeviceName
,
165 L
"\\Device\\KMRegTests");
167 Status
= IoCreateDevice(DriverObject
,
174 if (!NT_SUCCESS(Status
))
179 DeviceObject
->Flags
|= DO_BUFFERED_IO
;