ReactOS 0.4.16-dev-319-g6cf4263
adapter.cpp
Go to the documentation of this file.
1/*
2 ReactOS Operating System
3 MPU401 Example KS Driver
4
5 AUTHORS:
6 Andrew Greenwood
7
8 NOTES:
9 This is an example MPU401 driver. You can use DirectMusic instead with
10 this, by changing the CLSIDs accordingly.
11*/
12
13#define MAX_MINIPORTS 1
14#define PUT_GUIDS_HERE
15#define INITGUID
16
17#include <ntddk.h>
18#include <portcls.h>
19#include <debug.h>
20
21WCHAR DeviceName[] = L"Uart";
22
27 IN PIRP pIrp,
29{
30 PPORT port;
31 PMINIPORT miniport;
33
34 DPRINT1("MPU401_KS StartDevice called\n");
35
36 if (!ResourceList)
38
39 if (ResourceList->NumberOfEntries() == 0 )
40 {
42 }
43
44
45 DPRINT1("Calling PcNewPort with CLSID_PortMidi\n");
46 Status = PcNewPort(&port, CLSID_PortMidi);
47
48 if (!NT_SUCCESS(Status))
49 {
50 DPRINT("PcNewPort FAILED with status 0x%08x\n", Status);
51 return Status;
52 }
53
54 DPRINT1("Calling PcNewMiniport with CLSID_MiniportDriverUart\n");
55 Status = PcNewMiniport(&miniport, CLSID_MiniportDriverUart);
56
57 if (!NT_SUCCESS(Status))
58 {
59 DPRINT1("PcNewMiniport FAILED with status 0x%08x\n", Status);
60 return Status;
61 }
62
63 DPRINT1("Calling Init of port object\n");
64 Status = port->Init(pDeviceObject, pIrp, miniport, NULL, ResourceList);
65
66 if (!NT_SUCCESS(Status))
67 {
68 DPRINT1("Init FAILED with status 0x%08x\n", Status);
69 return Status;
70 }
71
72 DPRINT1("Registering subdevice via PcRegisterSubdevice\n");
74
75 if (!NT_SUCCESS(Status))
76 {
77 /* just print an error here */
78 DPRINT1("PcRegisterSubdevice FAILED with status 0x%08x\n", Status);
79 }
80
81 miniport->Release();
82 port->Release();
83
84 DPRINT1("Device started\n");
85
86 return Status;
87}
88
89
95{
96 DPRINT1("MPU401_KS AddDevice called\n");
101 0);
102}
103extern "C"
104{
106NTAPI
110{
112 DPRINT1("MPU401_KS DriverEntry\n");
113
116 AddDevice);
117
118 DPRINT1("PcInitializeAdapterDriver result 0x%08x\n", Status);
119
120 return Status;
121};
122}
123
NTSTATUS NTAPI PcAddAdapterDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject, IN PCPFNSTARTDEVICE StartDevice, IN ULONG MaxObjects, IN ULONG DeviceExtensionSize)
Definition: adapter.cpp:73
NTSTATUS NTAPI PcInitializeAdapterDriver(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPathName, IN PDRIVER_ADD_DEVICE AddDevice)
Definition: adapter.cpp:29
NTSTATUS NTAPI PcRegisterSubdevice(IN PDEVICE_OBJECT DeviceObject, IN PWCHAR Name, IN PUNKNOWN Unknown)
Definition: adapter.cpp:206
NTSTATUS NTAPI PcNewMiniport(OUT PMINIPORT *OutMiniport, IN REFCLSID ClassId)
Definition: miniport.cpp:45
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
USHORT port
Definition: uri.c:228
DRIVER_INITIALIZE DriverEntry
Definition: adapter.cpp:560
#define MAX_MINIPORTS
Definition: adapter.cpp:13
FxIrp * pIrp
Status
Definition: gdiplustypes.h:25
_In_ PNDIS_STRING _In_ PNDIS_STRING _Out_ PDEVICE_OBJECT * pDeviceObject
Definition: ndis.h:4679
static BOOL StartDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DevInfoData OPTIONAL, IN BOOL bEnable, IN DWORD HardwareProfile OPTIONAL, OUT BOOL *bNeedReboot OPTIONAL)
Definition: wizard.c:173
#define STATUS_INVALID_PARAMETER_3
Definition: ntstatus.h:477
#define L(x)
Definition: ntvdm.h:50
DRIVER_ADD_DEVICE AddDevice
Definition: parport.h:72
NTSTATUS NTAPI PcNewPort(OUT PPORT *OutPort, IN REFCLSID ClassId)
Definition: port.cpp:17
IResourceList * PRESOURCELIST
Definition: portcls.h:442
NTSTATUS(NTAPI * PCPFNSTARTDEVICE)(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PRESOURCELIST ResourceList)
Definition: portcls.h:2304
IPort * PPORT
Definition: portcls.h:1105
#define DPRINT
Definition: sndvol32.h:73
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309
__wchar_t WCHAR
Definition: xmlstorage.h:180