1 | /* $Id: strategy.cpp,v 1.2 2000/04/24 19:45:18 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /* SCCSID = %W% %E% */
|
---|
4 | /****************************************************************************
|
---|
5 | * *
|
---|
6 | * Copyright (c) IBM Corporation 1994 - 1997. *
|
---|
7 | * *
|
---|
8 | * The following IBM OS/2 source code is provided to you solely for the *
|
---|
9 | * the purpose of assisting you in your development of OS/2 device drivers. *
|
---|
10 | * You may use this code in accordance with the IBM License Agreement *
|
---|
11 | * provided in the IBM Device Driver Source Kit for OS/2. *
|
---|
12 | * *
|
---|
13 | ****************************************************************************/
|
---|
14 | /**@internal %W%
|
---|
15 | * @notes
|
---|
16 | * The Strategy entry point lives here !!
|
---|
17 | * @version %I%
|
---|
18 | * @context Unless otherwise noted, all interfaces are Ring-0, 16-bit,
|
---|
19 | * kernel stack.
|
---|
20 | * @history
|
---|
21 | *
|
---|
22 | */
|
---|
23 | extern "C" { // 16-bit header files are not C++ aware
|
---|
24 | #define INCL_NOPMAPI
|
---|
25 | #define INCL_DOSINFOSEG
|
---|
26 | #include <os2.h>
|
---|
27 | #include <audio.h>
|
---|
28 | #include <os2medef.h>
|
---|
29 | }
|
---|
30 |
|
---|
31 | #include <include.h>
|
---|
32 | #include <devhelp.h>
|
---|
33 | #include "strategy.h"
|
---|
34 | #include "rtmidi.hpp" // Object definition
|
---|
35 | #include "end.h"
|
---|
36 |
|
---|
37 | // #include "ioctl.h"
|
---|
38 | #include "stream.hpp"
|
---|
39 | #include "idc_vdd.h"
|
---|
40 | #include <ossidc.h>
|
---|
41 | #include <dbgos2.h>
|
---|
42 | #include "ioctl.h"
|
---|
43 |
|
---|
44 | #include "apmcalls.h"
|
---|
45 |
|
---|
46 | extern USHORT FAR OSS16_APMEvent(struct _APMIDC_NOTIFY_PKT FAR *pNotifyPkt);
|
---|
47 | extern void StrategyInit(PREQPACKET prp);
|
---|
48 | extern void StrategyIoctl(PREQPACKET prp, USHORT LDev);
|
---|
49 |
|
---|
50 |
|
---|
51 | /*@external StrategyInitComplete
|
---|
52 | * Perform initialization tasks that require Ring 0 context or IDC with other
|
---|
53 | * drivers (InitComplete is called after all drivers are loaded). We perform
|
---|
54 | * RTMIDI registration here.
|
---|
55 | */
|
---|
56 |
|
---|
57 | void StrategyInitComplete(PREQPACKET prp)
|
---|
58 | {
|
---|
59 | if(OSS16_AttachToPdd() == FALSE) {
|
---|
60 | prp->usStatus = RPDONE | RPERR | RPGENFAIL;
|
---|
61 | return;
|
---|
62 | }
|
---|
63 |
|
---|
64 | // Rudi:
|
---|
65 | if( APMAttach() ) {
|
---|
66 | APMRegister(OSS16_APMEvent, APM_EVMASK_SUSPENDRESUME, 1);
|
---|
67 | }
|
---|
68 |
|
---|
69 | MixerInit();
|
---|
70 |
|
---|
71 | RTMIDI::vConnect();
|
---|
72 | }
|
---|
73 |
|
---|
74 | /* TROPEZ_StrategyOpen
|
---|
75 | *
|
---|
76 | * Purpose: Worker rountine for the Strategy Open function.
|
---|
77 | *
|
---|
78 | * Notes: The Strategy Open doesn't require allocation of any resources,
|
---|
79 | * and the function is treated as a NOP. The first allocation of
|
---|
80 | * resources happens at Strategy IOCtl time, in the handler for
|
---|
81 | * the AudioInit IOCtl.
|
---|
82 | * Check to see if the VDD has claimed the hardware and return with
|
---|
83 | * the busy bit on the the request packett.
|
---|
84 | * Increment the InUseCount so we know that an OS/2 app has an
|
---|
85 | * instance open and we don't let the VDD take the hardware..
|
---|
86 | *
|
---|
87 | *
|
---|
88 | *
|
---|
89 | */
|
---|
90 | void StrategyOpen(PREQPACKET prp)
|
---|
91 | {
|
---|
92 | if (usVDDHasHardware) {
|
---|
93 | prp->usStatus = RPDONE | RPERR | RPBUSY;
|
---|
94 | }
|
---|
95 | else {
|
---|
96 | ++usInUseCount;
|
---|
97 | }
|
---|
98 | }
|
---|
99 |
|
---|
100 | void StrategyClose(PREQPACKET prp)
|
---|
101 | {
|
---|
102 | --usInUseCount;
|
---|
103 |
|
---|
104 | PSTREAM pstream = FindStream_fromFile( prp->s.open_close.usSysFileNum );
|
---|
105 |
|
---|
106 | if (pstream)
|
---|
107 | delete pstream;
|
---|
108 | else
|
---|
109 | ; //### Log unexpected condition.
|
---|
110 |
|
---|
111 | MixerChangeCleanup(prp->s.open_close.usSysFileNum);
|
---|
112 | }
|
---|
113 |
|
---|
114 | void StrategyDeinstall(PREQPACKET /*prp*/)
|
---|
115 | {
|
---|
116 | while (pAudioHWList->IsElements())
|
---|
117 | pAudioHWList->DestroyElement(pAudioHWList->PopHead());
|
---|
118 | }
|
---|
119 |
|
---|
120 |
|
---|
121 |
|
---|
122 | extern "C" void __far StrategyHandler(PREQPACKET prp);
|
---|
123 | #pragma aux StrategyHandler parm [es bx];
|
---|
124 |
|
---|
125 | extern "C" void __far StrategyHandler(PREQPACKET prp)
|
---|
126 | {
|
---|
127 |
|
---|
128 | prp->usStatus = RPDONE;
|
---|
129 |
|
---|
130 | switch (prp->bCommand) {
|
---|
131 | case STRATEGY_INIT:
|
---|
132 | StrategyInit(prp);
|
---|
133 | break;
|
---|
134 | case STRATEGY_OPEN:
|
---|
135 | StrategyOpen(prp);
|
---|
136 | break;
|
---|
137 | case STRATEGY_CLOSE:
|
---|
138 | StrategyClose(prp);
|
---|
139 | break;
|
---|
140 | case STRATEGY_GENIOCTL:
|
---|
141 | StrategyIoctl(prp, 0);
|
---|
142 | break;
|
---|
143 | case STRATEGY_DEINSTALL:
|
---|
144 | StrategyDeinstall(prp);
|
---|
145 | break;
|
---|
146 | case STRATEGY_INITCOMPLETE:
|
---|
147 | StrategyInitComplete(prp);
|
---|
148 | break;
|
---|
149 | default:
|
---|
150 | prp->usStatus = RPDONE | RPERR | RPGENFAIL;
|
---|
151 | }
|
---|
152 | }
|
---|
153 |
|
---|
154 |
|
---|
155 | extern "C" void __far StrategyHandler2(PREQPACKET prp);
|
---|
156 | #pragma aux StrategyHandler2 parm [es bx];
|
---|
157 |
|
---|
158 | extern "C" void __far StrategyHandler2(PREQPACKET prp)
|
---|
159 | {
|
---|
160 |
|
---|
161 | prp->usStatus = RPDONE;
|
---|
162 |
|
---|
163 | switch (prp->bCommand) {
|
---|
164 | case STRATEGY_INIT:
|
---|
165 | prp->s.init_out.usCodeEnd = (USHORT) &end_of_text;
|
---|
166 | prp->s.init_out.usDataEnd = (USHORT) &end_of_heap;
|
---|
167 | break;
|
---|
168 | case STRATEGY_OPEN:
|
---|
169 | StrategyOpen(prp);
|
---|
170 | break;
|
---|
171 | case STRATEGY_CLOSE:
|
---|
172 | StrategyClose(prp);
|
---|
173 | break;
|
---|
174 | case STRATEGY_GENIOCTL:
|
---|
175 | StrategyIoctl(prp, 1);
|
---|
176 | break;
|
---|
177 | case STRATEGY_DEINSTALL:
|
---|
178 | // StrategyDeinstall(prp);
|
---|
179 | break;
|
---|
180 | case STRATEGY_INITCOMPLETE:
|
---|
181 | // prp->usStatus = RPDONE;
|
---|
182 | break;
|
---|
183 | default:
|
---|
184 | prp->usStatus = RPDONE | RPERR | RPGENFAIL;
|
---|
185 | }
|
---|
186 | }
|
---|
187 |
|
---|
188 |
|
---|