ReactOS 0.4.15-dev-8393-g61b7fb9
main.cpp File Reference
#include <sb16.h>
Include dependency graph for main.cpp:

Go to the source code of this file.

Classes

struct  Resources
 

Macros

#define MAX_MINIPORTS   1
 

Functions

DWORD DetectPlatform (PPORTTOPOLOGY Port)
 
NTSTATUS DetectFeatures (IN PRESOURCELIST ResourceList, OUT PBOOLEAN HasUart, OUT PBOOLEAN HasFmSynth, OUT PBOOLEAN HasWaveTable)
 
NTSTATUS AssignResources (IN PRESOURCELIST ResourceList, OUT Resources *Resources)
 
NTSTATUS StartDevice (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PRESOURCELIST ResourceList)
 
NTSTATUS AddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
 
NTSTATUS DriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPathName)
 

Macro Definition Documentation

◆ MAX_MINIPORTS

#define MAX_MINIPORTS   1

Definition at line 15 of file main.cpp.

Function Documentation

◆ AddDevice()

NTSTATUS AddDevice ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  PhysicalDeviceObject 
)

Definition at line 335 of file main.cpp.

338{
343 0);
344}
NTSTATUS NTAPI PcAddAdapterDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject, IN PCPFNSTARTDEVICE StartDevice, IN ULONG MaxObjects, IN ULONG DeviceExtensionSize)
Definition: adapter.cpp:73
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
#define MAX_MINIPORTS
Definition: main.cpp:15
NTSTATUS StartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PRESOURCELIST ResourceList)
Definition: main.cpp:307
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213

◆ AssignResources()

NTSTATUS AssignResources ( IN PRESOURCELIST  ResourceList,
OUT Resources Resources 
)

Definition at line 184 of file main.cpp.

187{
189 BOOLEAN HasUart, HasFmSynth, HasWaveTable;
190
196
197 status = DetectFeatures(ResourceList, &HasUart, &HasFmSynth, &HasWaveTable);
198
199 if ( ! NT_SUCCESS(status) )
200 {
201 return status;
202 }
203
204 /* Wave I/O resources */
205
207 NULL,
208 PagedPool,
210 ResourceList->NumberOfDmas() +
211 ResourceList->NumberOfInterrupts() + 1);
212
213 if ( NT_SUCCESS(status) )
214 {
215 ULONG i;
216
217 /* Base port address */
219
220 /* DMA channels */
221 if ( NT_SUCCESS(status) )
222 {
223 for ( i = 0; i < ResourceList->NumberOfDmas(); i ++ )
224 {
226
227 if ( ! NT_SUCCESS(status) )
228 break;
229 }
230 }
231
232 /* IRQs */
233 if ( NT_SUCCESS(status) )
234 {
235 for ( i = 0; i < ResourceList->NumberOfInterrupts(); i ++ )
236 {
238
239 if ( ! NT_SUCCESS(status) )
240 break;
241 }
242 }
243 }
244
245 /* UART resources */
246
247 if ( NT_SUCCESS(status) && HasUart )
248 {
249 /* TODO */
250 }
251
252 /* FM Synth resources */
253
254 if ( NT_SUCCESS(status) && HasFmSynth )
255 {
256 /* TODO */
257 }
258
259 /* Adapter resources */
260
261 if ( NT_SUCCESS(status) )
262 {
264 NULL,
265 PagedPool,
267 3);
268
269 if ( NT_SUCCESS(status) )
270 {
272 }
273
274 if ( NT_SUCCESS(status) )
275 {
277 }
278
279 if ( NT_SUCCESS(status) && HasUart )
280 {
281 /* TODO */
282 }
283 }
284
285 /* Cleanup - TODO: Make this cleanup UART, FM etc. */
286
287 if ( ! NT_SUCCESS(status) )
288 {
289 if ( (*Resources).Wave != NULL )
290 {
291 (*Resources->Wave).Release();
292 (*Resources).Wave = NULL;
293 }
294
295 if ( (*Resources).Adapter != NULL )
296 {
298 (*Resources).Adapter = NULL;
299 }
300 }
301
302 return status;
303}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
_In_ BOOLEAN Release
Definition: cdrom.h:920
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
NTSTATUS DetectFeatures(IN PRESOURCELIST ResourceList, OUT PBOOLEAN HasUart, OUT PBOOLEAN HasFmSynth, OUT PBOOLEAN HasWaveTable)
Definition: main.cpp:81
#define PagedPool
Definition: env_spec_w32.h:308
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define AddInterruptFromParent(p, n)
Definition: portcls.h:465
#define AddPortFromParent(p, n)
Definition: portcls.h:453
#define AddDmaFromParent(p, n)
Definition: portcls.h:489
PORTCLASSAPI NTSTATUS NTAPI PcNewResourceSublist(OUT PRESOURCELIST *OutResourceList, IN PUNKNOWN OuterUnknown OPTIONAL, IN POOL_TYPE PoolType, IN PRESOURCELIST ParentList, IN ULONG MaximumEntries)
Definition: resource.cpp:395
PRESOURCELIST Adapter
Definition: main.cpp:24
PRESOURCELIST Wave
Definition: main.cpp:20
PRESOURCELIST FmSynth
Definition: main.cpp:22
PRESOURCELIST Uart
Definition: main.cpp:23
PRESOURCELIST WaveTable
Definition: main.cpp:21
Definition: ps.c:97
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309

Referenced by StartDevice().

◆ DetectFeatures()

NTSTATUS DetectFeatures ( IN PRESOURCELIST  ResourceList,
OUT PBOOLEAN  HasUart,
OUT PBOOLEAN  HasFmSynth,
OUT PBOOLEAN  HasWaveTable 
)

Definition at line 81 of file main.cpp.

86{
88
89 BOOLEAN DetectedWaveTable = FALSE;
90 BOOLEAN DetectedUart = FALSE;
91 BOOLEAN DetectedFmSynth = FALSE;
92
93 ULONG IoCount = ResourceList->NumberOfPorts();
94 ULONG IrqCount = ResourceList->NumberOfInterrupts();
95 ULONG DmaCount = ResourceList->NumberOfDmas();
96
97 switch ( IoCount )
98 {
99 case 1 : /* No FM / UART */
100 {
101 if ( ( ResourceList->FindTranslatedPort(0)->u.Port.Length < 16 ) ||
102 ( IrqCount < 1 ) ||
103 ( DmaCount < 1 ) )
104 {
106 }
107
108 break;
109 }
110
111 case 2 :
112 {
113 if ( ( ResourceList->FindTranslatedPort(0)->u.Port.Length < 16 ) ||
114 ( IrqCount < 1 ) ||
115 ( DmaCount < 1 ) )
116 {
118 }
119
120 else
121 {
122 /* The length of the port indicates the function provided */
123
124 switch ( ResourceList->FindTranslatedPort(1)->u.Port.Length )
125 {
126 case 2 :
127 {
128 DetectedUart = TRUE;
129 break;
130 }
131 case 4:
132 {
133 DetectedFmSynth = TRUE;
134 break;
135 }
136 default :
137 {
139 }
140 }
141 }
142
143 break;
144 }
145
146 case 3 :
147 {
148 if ( ( ResourceList->FindTranslatedPort(0)->u.Port.Length < 16 ) ||
149 ( ResourceList->FindTranslatedPort(1)->u.Port.Length != 2 ) ||
150 ( ResourceList->FindTranslatedPort(2)->u.Port.Length != 4 ) ||
151 ( IrqCount < 1 ) ||
152 ( DmaCount < 1 ) )
153 {
155 }
156 else
157 {
158 DetectedUart = TRUE;
159 DetectedFmSynth = TRUE;
160 }
161
162 break;
163 }
164
165 default :
166 {
168 break;
169 }
170 }
171
172 if ( HasUart )
173 *HasUart = DetectedUart;
174 if ( HasFmSynth )
175 *HasFmSynth = DetectedFmSynth;
176 if ( HasWaveTable )
177 *HasWaveTable = DetectedWaveTable;
178
179 return status;
180}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_Must_inspect_result_ _Out_ PULONG IoCount
Definition: ndis.h:6126
#define STATUS_DEVICE_CONFIGURATION_ERROR
Definition: ntstatus.h:619
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by AssignResources().

◆ DetectPlatform()

DWORD DetectPlatform ( PPORTTOPOLOGY  Port)

Definition at line 29 of file main.cpp.

31{
32 /* ASSERT(Port); */
33
34#if 0
35 PPORTCLSVERSION portcls_version;
36 PDRMPORT drm_port;
37 PPORTEVENTS port_events;
39
40/*
41 TODO: This stuff needs IID impls
42
43 Port->QueryInterface( IID_IPortClsVersion, (PVOID*) &portcls_version);
44 Port->QueryInterface( IID_IDrmPort, (PVOID*) &drm_port);
45 Port->QueryInterface( IID_IPortEvents, (PVOID*) &port_events);
46*/
47
48 if ( portcls_version )
49 {
50 version = portcls_version->GetVersion();
51 portcls_version->Release();
52 }
53
54 /* If we don't support portcls' GetVersion, we can try other methods */
55 else if ( drm_port )
56 {
58 // ASSERT(IoIsWdmVersionAvailable(0x01, 0x05));
59 }
60
61 /* If portcls GetVersion and DRMPort not supported, it'll be Win98 */
62 else if ( port_events )
63 {
65 }
66
67 /* IPortEvents was added in Win 98 SE so if not supported, it's not 98 SE */
68 else
69 {
71 }
72
73 return version;
74#else
75 return kVersionWin98;
76#endif
77}
static const WCHAR version[]
Definition: asmname.c:66
unsigned long DWORD
Definition: ntddk_ex.h:95
IPortEvents * PPORTEVENTS
Definition: portcls.h:2121
IPortClsVersion * PPORTCLSVERSION
Definition: portcls.h:2263
@ kVersionWin98SE
Definition: portcls.h:209
@ kVersionWin98
Definition: portcls.h:208
@ kVersionWinME
Definition: portcls.h:213
IDrmPort * PDRMPORT
Definition: portcls.h:2176

◆ DriverEntry()

NTSTATUS DriverEntry ( IN PDRIVER_OBJECT  DriverObject,
IN PUNICODE_STRING  RegistryPathName 
)

Definition at line 348 of file main.cpp.

351{
353
355 RegistryPathName,
357
358 /* TODO: Add our own IRP handlers here */
359
360 return status;
361}
NTSTATUS NTAPI PcInitializeAdapterDriver(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPathName, IN PDRIVER_ADD_DEVICE AddDevice)
Definition: adapter.cpp:29
DRIVER_ADD_DEVICE AddDevice
Definition: parport.h:72
DRIVER_ADD_DEVICE * PDRIVER_ADD_DEVICE
Definition: iotypes.h:2216

◆ StartDevice()

NTSTATUS StartDevice ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PRESOURCELIST  ResourceList 
)

Definition at line 307 of file main.cpp.

311{
313
314 Resources DeviceResources;
315
316 PUNKNOWN UnknownTopology = NULL;
317 PUNKNOWN UnknownWave = NULL;
318 PUNKNOWN UnknownWaveTable = NULL;
319 PUNKNOWN UnknownFmSynth = NULL;
320
321// PADAPTERCOMMON AdapterCommon = NULL;
322 PUNKNOWN UnknownCommon = NULL;
323
324 status = AssignResources(ResourceList, &DeviceResources);
325
326 if ( NT_SUCCESS(status) )
327 {
328 }
329
330 return status;
331}
NTSTATUS AssignResources(IN PRESOURCELIST ResourceList, OUT Resources *Resources)
Definition: main.cpp:184

Referenced by AddDevice().