- Remove a hack from KiGetMachineBootPointers and set the TSS selector properly in...
[reactos.git] / reactos / drivers / wdm / audio / backpln / portcls / port_factory.cpp
1 /*
2 ReactOS Operating System
3 Port Class API / Port Factory
4
5 by Andrew Greenwood
6 */
7
8 #define INITGUID
9
10 #include "private.h"
11 #include <portcls.h>
12 #include <ks.h>
13 #include <kcom.h>
14 #include "port.h"
15
16 /*
17 * @unimplemented
18 */
19 PORTCLASSAPI NTSTATUS NTAPI
20 PcNewPort(
21 OUT PPORT* OutPort,
22 IN REFCLSID ClassId)
23 {
24 /*
25 ClassId can be one of the following:
26 CLSID_PortDMus -> IPortDMus (dmusicks.h) -- TODO
27 CLSID_PortMidi -> IPortMidi
28 CLSID_PortTopology -> IPortTopology
29 CLSID_PortWaveCyclic -> IPortWaveCyclic
30 CLSID_PortWavePci -> IPortWavePci
31
32 TODO: What about PortWavePciStream?
33 */
34
35 PPORT new_port = NULL;
36 NTSTATUS status = STATUS_UNSUCCESSFUL;
37
38 if ( ! OutPort )
39 {
40 DPRINT("PcNewPort was supplied a NULL OutPort parameter\n");
41 return STATUS_INVALID_PARAMETER;
42 }
43
44 if ( ( IsEqualGUIDAligned(ClassId, &CLSID_PortMidi) ) ||
45 ( IsEqualGUIDAligned(ClassId, &CLSID_PortTopology) ) ||
46 ( IsEqualGUIDAligned(ClassId, &CLSID_PortWaveCyclic) ) ||
47 ( IsEqualGUIDAligned(ClassId, &CLSID_PortWavePci) ) )
48 {
49 DPRINT("Calling KoCreateInstance\n");
50 /* Call KS.SYS's Kernel-mode COM function */
51 status = KoCreateInstance(ClassId, NULL, CLSCTX_KERNEL_SERVER, &IID_IPort, (PVOID*)&new_port);
52 }
53 else
54 {
55
56 DPRINT("PcNewPort received a CLSID it does not deal with\n");
57 status = STATUS_NOT_SUPPORTED;
58 }
59
60 /* If an unsupported CLSID was handed to us, or the creation failed, we fail */
61 if ( status != STATUS_SUCCESS )
62 {
63 return status;
64 }
65
66 /* Fill the caller's PPORT* to point to the new port */
67 *OutPort = new_port;
68
69 DPRINT("PcNewPort succeeded\n");
70
71 return STATUS_SUCCESS;
72 }