ReactOS  0.4.14-dev-55-g2da92ac
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 
21 WCHAR DeviceName[] = L"Uart";
22 
24 NTAPI
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 
91 NTAPI
95 {
96  DPRINT1("MPU401_KS AddDevice called\n");
101  0);
102 }
103 extern "C"
104 {
105 NTSTATUS
106 NTAPI
110 {
112  DPRINT1("MPU401_KS DriverEntry\n");
113 
115  RegistryPath,
116  AddDevice);
117 
118  DPRINT1("PcInitializeAdapterDriver result 0x%08x\n", Status);
119 
120  return Status;
121 };
122 }
123 
#define IN
Definition: typedefs.h:38
_In_ PNDIS_STRING _In_ PNDIS_STRING _Out_ PDEVICE_OBJECT * pDeviceObject
Definition: ndis.h:4679
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1114
WCHAR DeviceName[]
Definition: adapter.cpp:21
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
NTSTATUS NTAPI PcNewMiniport(OUT PMINIPORT *OutMiniport, IN REFCLSID ClassId)
Definition: miniport.cpp:48
#define STATUS_INVALID_PARAMETER_3
Definition: ntstatus.h:463
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
IPort * PPORT
Definition: portcls.h:1093
NTSTATUS NTAPI PcAddAdapterDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject, IN PCPFNSTARTDEVICE StartDevice, IN ULONG MaxObjects, IN ULONG DeviceExtensionSize)
Definition: adapter.cpp:76
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS(NTAPI * PCPFNSTARTDEVICE)(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PRESOURCELIST ResourceList)
Definition: portcls.h:2231
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPathName)
Definition: adapter.cpp:403
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS NTAPI PcInitializeAdapterDriver(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPathName, IN PDRIVER_ADD_DEVICE AddDevice)
Definition: adapter.cpp:32
Status
Definition: gdiplustypes.h:24
IResourceList * PRESOURCELIST
Definition: portcls.h:442
#define DPRINT1
Definition: precomp.h:8
NTSTATUS NTAPI PcNewPort(OUT PPORT *OutPort, IN REFCLSID ClassId)
Definition: port.cpp:20
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
#define MAX_MINIPORTS
Definition: adapter.cpp:13
USHORT port
Definition: uri.c:227
NTSTATUS NTAPI StartDevice(PDEVICE_OBJECT DeviceObject, PIRP Irp, PRESOURCELIST ResourceList)
Definition: adapter.cpp:115
NTSTATUS NTAPI AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT PhysicalDeviceObject)
Definition: adapter.cpp:259
NTSTATUS NTAPI PcRegisterSubdevice(IN PDEVICE_OBJECT DeviceObject, IN PWCHAR Name, IN PUNKNOWN Unknown)
Definition: adapter.cpp:210