mirror of
https://github.com/reactos/reactos.git
synced 2024-08-01 17:11:35 +00:00
- Cleanup code a bit
svn path=/trunk/; revision=39816
This commit is contained in:
parent
09ce3c6e91
commit
69f81beb13
|
@ -11,73 +11,69 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MAX_MINIPORTS 1
|
#define MAX_MINIPORTS 1
|
||||||
|
|
||||||
#define PUT_GUIDS_HERE
|
#define PUT_GUIDS_HERE
|
||||||
|
|
||||||
#define INITGUID
|
#define INITGUID
|
||||||
|
|
||||||
#include <ntddk.h>
|
#include <ntddk.h>
|
||||||
|
#include <portcls.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <portcls.h>
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
StartDevice(
|
StartDevice(
|
||||||
IN PDEVICE_OBJECT pDeviceObject,
|
IN PDEVICE_OBJECT pDeviceObject,
|
||||||
IN PIRP pIrp,
|
IN PIRP pIrp,
|
||||||
IN PRESOURCELIST ResourceList)
|
IN PRESOURCELIST ResourceList)
|
||||||
{
|
{
|
||||||
DPRINT1("MPU401_KS StartDevice called\n");
|
|
||||||
|
|
||||||
if ( ! ResourceList )
|
|
||||||
return STATUS_INVALID_PARAMETER;
|
|
||||||
|
|
||||||
if ( ResourceList->NumberOfEntries() == 0 )
|
|
||||||
{
|
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT1("Sufficient resources available :)\n");
|
|
||||||
|
|
||||||
PPORT port;
|
PPORT port;
|
||||||
PMINIPORT miniport;
|
PMINIPORT miniport;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT1("MPU401_KS StartDevice called\n");
|
||||||
|
|
||||||
|
if (!ResourceList)
|
||||||
|
return STATUS_INVALID_PARAMETER_3;
|
||||||
|
|
||||||
|
if (ResourceList->NumberOfEntries() == 0 )
|
||||||
|
{
|
||||||
|
return STATUS_INVALID_PARAMETER_3;
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS status;
|
|
||||||
|
|
||||||
DPRINT1("Calling PcNewPort with CLSID_PortMidi\n");
|
DPRINT1("Calling PcNewPort with CLSID_PortMidi\n");
|
||||||
status = PcNewPort(&port, CLSID_PortMidi);
|
Status = PcNewPort(&port, CLSID_PortMidi);
|
||||||
|
|
||||||
if ( ! NT_SUCCESS(status) )
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("PcNewPort FAILED with status 0x%08x\n", status);
|
DPRINT("PcNewPort FAILED with status 0x%08x\n", Status);
|
||||||
return status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT1("Calling PcNewMiniport with CLSID_MiniportDriverUart\n");
|
DPRINT1("Calling PcNewMiniport with CLSID_MiniportDriverUart\n");
|
||||||
status = PcNewMiniport(&miniport, CLSID_MiniportDriverUart);
|
Status = PcNewMiniport(&miniport, CLSID_MiniportDriverUart);
|
||||||
|
|
||||||
if ( ! NT_SUCCESS(status) )
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("PcNewMiniport FAILED with status 0x%08x\n", status);
|
DPRINT1("PcNewMiniport FAILED with status 0x%08x\n", Status);
|
||||||
return status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT1("Calling Init of port object\n");
|
DPRINT1("Calling Init of port object\n");
|
||||||
status = port->Init(pDeviceObject, pIrp, miniport, NULL, ResourceList);
|
Status = port->Init(pDeviceObject, pIrp, miniport, NULL, ResourceList);
|
||||||
|
|
||||||
if ( ! NT_SUCCESS(status) )
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("Init FAILED with status 0x%08x\n", status);
|
DPRINT1("Init FAILED with status 0x%08x\n", Status);
|
||||||
return status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT1("Registering subdevice via PcRegisterSubdevice\n");
|
DPRINT1("Registering subdevice via PcRegisterSubdevice\n");
|
||||||
status = PcRegisterSubdevice(pDeviceObject, L"Uart", port);
|
Status = PcRegisterSubdevice(pDeviceObject, L"Uart", port);
|
||||||
|
|
||||||
if ( ! NT_SUCCESS(status) )
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* just print an error here */
|
/* just print an error here */
|
||||||
DPRINT1("PcRegisterSubdevice FAILED with status 0x%08x\n", status);
|
DPRINT1("PcRegisterSubdevice FAILED with status 0x%08x\n", Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
miniport->Release();
|
miniport->Release();
|
||||||
|
@ -85,59 +81,41 @@ StartDevice(
|
||||||
|
|
||||||
DPRINT1("Device started\n");
|
DPRINT1("Device started\n");
|
||||||
|
|
||||||
return status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
AddDevice(
|
AddDevice(
|
||||||
IN PVOID Context1,
|
IN PDRIVER_OBJECT DriverObject,
|
||||||
IN PVOID Context2)
|
IN PDEVICE_OBJECT PhysicalDeviceObject)
|
||||||
{
|
{
|
||||||
DPRINT1("MPU401_KS AddDevice called, redirecting to PcAddAdapterDevice\n");
|
DPRINT1("MPU401_KS AddDevice called\n");
|
||||||
return PcAddAdapterDevice((PDRIVER_OBJECT) Context1,
|
return PcAddAdapterDevice(DriverObject,
|
||||||
(PDEVICE_OBJECT) Context2,
|
PhysicalDeviceObject,
|
||||||
StartDevice,
|
(PCPFNSTARTDEVICE)StartDevice,
|
||||||
MAX_MINIPORTS,
|
MAX_MINIPORTS,
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
NTSTATUS
|
||||||
NTSTATUS NTAPI
|
NTAPI
|
||||||
DriverEntry(
|
DriverEntry(
|
||||||
IN PDRIVER_OBJECT Context1,
|
IN PDRIVER_OBJECT DriverObject,
|
||||||
IN PUNICODE_STRING Context2)
|
IN PUNICODE_STRING RegistryPath)
|
||||||
{
|
{
|
||||||
//PDEVICE_OBJECT DeviceObject;
|
NTSTATUS Status;
|
||||||
//UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\MPU401Static");
|
DPRINT1("MPU401_KS DriverEntry\n");
|
||||||
|
|
||||||
// KeBugCheck(0x0000007F);
|
Status = PcInitializeAdapterDriver(DriverObject,
|
||||||
DPRINT1("MPU401_KS DriverEntry called, redirecting to PcInitializeAdapterDriver\n");
|
RegistryPath,
|
||||||
|
AddDevice);
|
||||||
|
|
||||||
NTSTATUS status = PcInitializeAdapterDriver((PDRIVER_OBJECT) Context1,
|
DPRINT1("PcInitializeAdapterDriver result 0x%08x\n", Status);
|
||||||
(PUNICODE_STRING) Context2,
|
|
||||||
(PDRIVER_ADD_DEVICE) AddDevice);
|
|
||||||
DPRINT1("Result was 0x%08x\n", status);
|
|
||||||
|
|
||||||
/* Create a device (this will be handled by PnP manager really but we fake for now */
|
return Status;
|
||||||
|
|
||||||
/*
|
|
||||||
DPRINT1("Creating device\n");
|
|
||||||
status = IoCreateDevice(Context1,
|
|
||||||
0,
|
|
||||||
&DeviceName,
|
|
||||||
FILE_DEVICE_SOUND,
|
|
||||||
0,
|
|
||||||
FALSE,
|
|
||||||
&DeviceObject);
|
|
||||||
|
|
||||||
DPRINT1("Result was 0x%08x\n", status);
|
|
||||||
*/
|
|
||||||
|
|
||||||
return status;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue