2 ReactOS Operating System
3 MPU401 Example KS Driver
9 This is an example MPU401 driver. You can use DirectMusic instead with
10 this, by changing the CLSIDs accordingly.
13 #define MAX_MINIPORTS 1
15 #define PUT_GUIDS_HERE
26 IN PDEVICE_OBJECT pDeviceObject
,
28 IN PRESOURCELIST ResourceList
)
30 DPRINT1("MPU401_KS StartDevice called\n");
33 return STATUS_INVALID_PARAMETER
;
35 if ( ResourceList
->NumberOfEntries() == 0 )
37 return STATUS_INSUFFICIENT_RESOURCES
;
40 DPRINT1("Sufficient resources available :)\n");
47 DPRINT1("Calling PcNewPort with CLSID_PortMidi\n");
48 status
= PcNewPort(&port
, CLSID_PortMidi
);
50 if ( ! NT_SUCCESS(status
) )
52 DPRINT("PcNewPort FAILED with status 0x%08x\n", status
);
56 DPRINT1("Calling PcNewMiniport with CLSID_MiniportDriverUart\n");
57 status
= PcNewMiniport(&miniport
, CLSID_MiniportDriverUart
);
59 if ( ! NT_SUCCESS(status
) )
61 DPRINT1("PcNewMiniport FAILED with status 0x%08x\n", status
);
65 DPRINT1("Calling Init of port object\n");
66 status
= port
->Init(pDeviceObject
, pIrp
, miniport
, NULL
, ResourceList
);
68 if ( ! NT_SUCCESS(status
) )
70 DPRINT1("Init FAILED with status 0x%08x\n", status
);
74 DPRINT1("Registering subdevice via PcRegisterSubdevice\n");
75 status
= PcRegisterSubdevice(pDeviceObject
, L
"Uart", port
);
77 if ( ! NT_SUCCESS(status
) )
79 /* just print an error here */
80 DPRINT1("PcRegisterSubdevice FAILED with status 0x%08x\n", status
);
86 DPRINT1("Device started\n");
98 DPRINT1("MPU401_KS AddDevice called, redirecting to PcAddAdapterDevice\n");
99 return PcAddAdapterDevice((PDRIVER_OBJECT
) Context1
,
100 (PDEVICE_OBJECT
) Context2
,
111 IN PDRIVER_OBJECT Context1
,
112 IN PUNICODE_STRING Context2
)
114 PDEVICE_OBJECT DeviceObject
;
115 UNICODE_STRING DeviceName
= RTL_CONSTANT_STRING(L
"\\Device\\MPU401Static");
117 // KeBugCheck(0x0000007F);
118 DPRINT1("MPU401_KS DriverEntry called, redirecting to PcInitializeAdapterDriver\n");
120 NTSTATUS status
= PcInitializeAdapterDriver((PDRIVER_OBJECT
) Context1
,
121 (PUNICODE_STRING
) Context2
,
122 (PDRIVER_ADD_DEVICE
) AddDevice
);
123 DPRINT1("Result was 0x%08x\n", status
);
125 /* Create a device (this will be handled by PnP manager really but we fake for now */
128 DPRINT1("Creating device\n");
129 status = IoCreateDevice(Context1,
137 DPRINT1("Result was 0x%08x\n", status);