ReactOS  0.4.14-dev-1007-g90d795b
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 {
341  StartDevice,
343  0);
344 }
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1122
NTSTATUS NTAPI PcAddAdapterDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject, IN PCPFNSTARTDEVICE StartDevice, IN ULONG MaxObjects, IN ULONG DeviceExtensionSize)
Definition: adapter.cpp:76
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
NTSTATUS StartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PRESOURCELIST ResourceList)
Definition: main.cpp:307
#define MAX_MINIPORTS
Definition: main.cpp:15

Referenced by DriverEntry().

◆ AssignResources()

NTSTATUS AssignResources ( IN PRESOURCELIST  ResourceList,
OUT Resources Resources 
)

Definition at line 184 of file main.cpp.

187 {
189  BOOLEAN HasUart, HasFmSynth, HasWaveTable;
190 
192  Resources->Wave = NULL;
193  Resources->Uart = NULL;
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,
209  ResourceList,
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,
266  ResourceList,
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  {
297  (*Resources->Adapter).Release();
298  (*Resources).Adapter = NULL;
299  }
300  }
301 
302  return status;
303 }
PRESOURCELIST Adapter
Definition: main.cpp:24
_In_ BOOLEAN Release
Definition: classpnp.h:929
LONG NTSTATUS
Definition: precomp.h:26
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
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
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
PRESOURCELIST Wave
Definition: main.cpp:20
NTSTATUS DetectFeatures(IN PRESOURCELIST ResourceList, OUT PBOOLEAN HasUart, OUT PBOOLEAN HasFmSynth, OUT PBOOLEAN HasWaveTable)
Definition: main.cpp:81
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PRESOURCELIST WaveTable
Definition: main.cpp:21
PRESOURCELIST Uart
Definition: main.cpp:23
PRESOURCELIST FmSynth
Definition: main.cpp:22
#define AddPortFromParent(p, n)
Definition: portcls.h:453
unsigned int ULONG
Definition: retypes.h:1
#define AddDmaFromParent(p, n)
Definition: portcls.h:489
static SERVICE_STATUS status
Definition: service.c:31
PORTCLASSAPI NTSTATUS NTAPI PcNewResourceSublist(OUT PRESOURCELIST *OutResourceList, IN PUNKNOWN OuterUnknown OPTIONAL, IN POOL_TYPE PoolType, IN PRESOURCELIST ParentList, IN ULONG MaximumEntries)
Definition: resource.cpp:410
Definition: ps.c:97

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
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _Out_ PULONG IoCount
Definition: ndis.h:6126
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
unsigned char BOOLEAN
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_DEVICE_CONFIGURATION_ERROR
Definition: ntstatus.h:605
return STATUS_SUCCESS
Definition: btrfs.c:2938
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

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;
38  DWORD version;
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 }
IPortEvents * PPORTEVENTS
Definition: portcls.h:2065
static const WCHAR version[]
Definition: asmname.c:66
IDrmPort * PDRMPORT
Definition: portcls.h:2120
unsigned long DWORD
Definition: ntddk_ex.h:95
IPortClsVersion * PPORTCLSVERSION
Definition: portcls.h:2209

◆ 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 }
LONG NTSTATUS
Definition: precomp.h:26
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
NTSTATUS NTAPI PcInitializeAdapterDriver(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPathName, IN PDRIVER_ADD_DEVICE AddDevice)
Definition: adapter.cpp:32
DRIVER_ADD_DEVICE * PDRIVER_ADD_DEVICE
Definition: iotypes.h:2108
NTSTATUS AddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
Definition: main.cpp:335
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ 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 }
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS AssignResources(IN PRESOURCELIST ResourceList, OUT Resources *Resources)
Definition: main.cpp:184
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
return STATUS_SUCCESS
Definition: btrfs.c:2938
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by AddDevice().