Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenadapter.cpp
Go to the documentation of this file.
00001 /* 00002 ReactOS Operating System 00003 MPU401 Example KS Driver 00004 00005 AUTHORS: 00006 Andrew Greenwood 00007 00008 NOTES: 00009 This is an example MPU401 driver. You can use DirectMusic instead with 00010 this, by changing the CLSIDs accordingly. 00011 */ 00012 00013 #define MAX_MINIPORTS 1 00014 #define PUT_GUIDS_HERE 00015 #define INITGUID 00016 00017 #include <ntddk.h> 00018 #include <portcls.h> 00019 #include <debug.h> 00020 00021 WCHAR DeviceName[] = L"Uart"; 00022 00023 NTSTATUS 00024 NTAPI 00025 StartDevice( 00026 IN PDEVICE_OBJECT pDeviceObject, 00027 IN PIRP pIrp, 00028 IN PRESOURCELIST ResourceList) 00029 { 00030 PPORT port; 00031 PMINIPORT miniport; 00032 NTSTATUS Status; 00033 00034 DPRINT1("MPU401_KS StartDevice called\n"); 00035 00036 if (!ResourceList) 00037 return STATUS_INVALID_PARAMETER_3; 00038 00039 if (ResourceList->NumberOfEntries() == 0 ) 00040 { 00041 return STATUS_INVALID_PARAMETER_3; 00042 } 00043 00044 00045 DPRINT1("Calling PcNewPort with CLSID_PortMidi\n"); 00046 Status = PcNewPort(&port, CLSID_PortMidi); 00047 00048 if (!NT_SUCCESS(Status)) 00049 { 00050 DPRINT("PcNewPort FAILED with status 0x%08x\n", Status); 00051 return Status; 00052 } 00053 00054 DPRINT1("Calling PcNewMiniport with CLSID_MiniportDriverUart\n"); 00055 Status = PcNewMiniport(&miniport, CLSID_MiniportDriverUart); 00056 00057 if (!NT_SUCCESS(Status)) 00058 { 00059 DPRINT1("PcNewMiniport FAILED with status 0x%08x\n", Status); 00060 return Status; 00061 } 00062 00063 DPRINT1("Calling Init of port object\n"); 00064 Status = port->Init(pDeviceObject, pIrp, miniport, NULL, ResourceList); 00065 00066 if (!NT_SUCCESS(Status)) 00067 { 00068 DPRINT1("Init FAILED with status 0x%08x\n", Status); 00069 return Status; 00070 } 00071 00072 DPRINT1("Registering subdevice via PcRegisterSubdevice\n"); 00073 Status = PcRegisterSubdevice(pDeviceObject, DeviceName, port); 00074 00075 if (!NT_SUCCESS(Status)) 00076 { 00077 /* just print an error here */ 00078 DPRINT1("PcRegisterSubdevice FAILED with status 0x%08x\n", Status); 00079 } 00080 00081 miniport->Release(); 00082 port->Release(); 00083 00084 DPRINT1("Device started\n"); 00085 00086 return Status; 00087 } 00088 00089 00090 NTSTATUS 00091 NTAPI 00092 AddDevice( 00093 IN PDRIVER_OBJECT DriverObject, 00094 IN PDEVICE_OBJECT PhysicalDeviceObject) 00095 { 00096 DPRINT1("MPU401_KS AddDevice called\n"); 00097 return PcAddAdapterDevice(DriverObject, 00098 PhysicalDeviceObject, 00099 (PCPFNSTARTDEVICE)StartDevice, 00100 MAX_MINIPORTS, 00101 0); 00102 } 00103 extern "C" 00104 { 00105 NTSTATUS 00106 NTAPI 00107 DriverEntry( 00108 IN PDRIVER_OBJECT DriverObject, 00109 IN PUNICODE_STRING RegistryPath) 00110 { 00111 NTSTATUS Status; 00112 DPRINT1("MPU401_KS DriverEntry\n"); 00113 00114 Status = PcInitializeAdapterDriver(DriverObject, 00115 RegistryPath, 00116 AddDevice); 00117 00118 DPRINT1("PcInitializeAdapterDriver result 0x%08x\n", Status); 00119 00120 return Status; 00121 }; 00122 } 00123 Generated on Thu May 24 2012 04:29:06 for ReactOS by
1.7.6.1
|