From 9f1be875f3b37802c2014454fb01b44185cbca14 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sat, 12 Feb 2005 23:31:15 +0000 Subject: [PATCH] Some basics of driver wrapper - establish dispatch functions, a very basic AddDevice handler. Still stubs, but they will be filled with something very soon! svn path=/trunk/; revision=13521 --- reactos/drivers/usb/cromwell/host/ohci_main.c | 61 ++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/reactos/drivers/usb/cromwell/host/ohci_main.c b/reactos/drivers/usb/cromwell/host/ohci_main.c index ffb37c81999..dd52a066739 100644 --- a/reactos/drivers/usb/cromwell/host/ohci_main.c +++ b/reactos/drivers/usb/cromwell/host/ohci_main.c @@ -4,13 +4,72 @@ */ #include +#include +NTSTATUS AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT pdo) +{ + PDEVICE_OBJECT fdo; + NTSTATUS Status; + WCHAR DeviceBuffer[20]; + UNICODE_STRING DeviceName; + + DbgPrint("ohci: AddDevice called\n"); + + /* Create a unicode device name. */ + swprintf(DeviceBuffer, L"\\Device\\usbohci"); + RtlInitUnicodeString(&DeviceName, DeviceBuffer); + + + Status = IoCreateDevice(DriverObject, 0, &DeviceName, FILE_DEVICE_VIDEO, 0, FALSE,&fdo); + + if (!NT_SUCCESS(Status)) + { + DPRINT("IoCreateDevice call failed with status 0x%08x\n", Status); + return Status; + } + + return STATUS_SUCCESS; +} + +VOID DriverUnload(PDRIVER_OBJECT DriverObject) +{ + // nothing to do here yet +} + +// Dispatch PNP +NTSTATUS DispatchPnp(PDEVICE_OBJECT fdo, PIRP Irp) +{ + ULONG fcn; + PIO_STACK_LOCATION stack; + + stack = IoGetCurrentIrpStackLocation(Irp); + fcn = stack->MinorFunction; + DbgPrint("IRP_MJ_PNP, fcn=%d\n", fcn); + + if (fcn == IRP_MN_REMOVE_DEVICE) + { + IoDeleteDevice(fdo); + } + + return STATUS_SUCCESS; +} + +NTSTATUS DispatchPower(PDEVICE_OBJECT fido, PIRP Irp) +{ + DbgPrint("IRP_MJ_POWER dispatch\n"); + return STATUS_SUCCESS; +} /* * Standard DriverEntry method. */ NTSTATUS STDCALL -DriverEntry(IN PVOID Context1, IN PVOID Context2) +DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegPath) { + DriverObject->DriverUnload = DriverUnload; + DriverObject->DriverExtension->AddDevice = AddDevice; + DriverObject->MajorFunction[IRP_MJ_PNP] = DispatchPnp; + DriverObject->MajorFunction[IRP_MJ_POWER] = DispatchPower; + return STATUS_SUCCESS; }