1 | /* $Id: idc.c 151 2000-05-28 16:50:46Z sandervl $ */
|
---|
2 |
|
---|
3 | //******************************************************************************
|
---|
4 | // IDC entrypoint (all calls from 16 bits MMPM2 driver end up here)
|
---|
5 | //
|
---|
6 | // Copyright 2000 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
7 | //
|
---|
8 | // This program is free software; you can redistribute it and/or
|
---|
9 | // modify it under the terms of the GNU General Public License as
|
---|
10 | // published by the Free Software Foundation; either version 2 of
|
---|
11 | // the License, or (at your option) any later version.
|
---|
12 | //
|
---|
13 | // This program is distributed in the hope that it will be useful,
|
---|
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
16 | // GNU General Public License for more details.
|
---|
17 | //
|
---|
18 | // You should have received a copy of the GNU General Public
|
---|
19 | // License along with this program; if not, write to the Free
|
---|
20 | // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
|
---|
21 | // USA.
|
---|
22 | //
|
---|
23 | //******************************************************************************
|
---|
24 | extern "C" { // 16-bit header files are not C++ aware
|
---|
25 | #define INCL_NOPMAPI
|
---|
26 | #define INCL_DOSINFOSEG
|
---|
27 | #include <os2.h>
|
---|
28 | }
|
---|
29 | #include <devtype.h>
|
---|
30 | #include <devhelp.h>
|
---|
31 | #include <strategy.h>
|
---|
32 | #include <ossidc.h>
|
---|
33 | #include <irqos2.h>
|
---|
34 | #include <stacktoflat.h>
|
---|
35 |
|
---|
36 | //16:32 address of 16 bits pdd idc handler
|
---|
37 | IDC16_HANDLER idc16_PddHandler = 0;
|
---|
38 |
|
---|
39 | WORD32 OSS32IDC(ULONG cmd, PIDC32_PACKET pPacket);
|
---|
40 |
|
---|
41 | //packet pointer must reference a structure on the stack
|
---|
42 |
|
---|
43 | WORD32 SBLive32IDC(ULONG cmd, ULONG packet);
|
---|
44 | #pragma aux SBLive32IDC "SBLIVE_IDC" parm reverse [ecx edx]
|
---|
45 | WORD32 SBLive32IDC(ULONG cmd, ULONG packet)
|
---|
46 | {
|
---|
47 | PIDC32_PACKET pPacket = (PIDC32_PACKET)__StackToFlat(packet);
|
---|
48 | ULONG oldfileid;
|
---|
49 | WORD32 rc;
|
---|
50 |
|
---|
51 | //Sets file id in current task structure
|
---|
52 | oldfileid = OSS32_SetFileId(pPacket->fileid);
|
---|
53 | rc = OSS32IDC(cmd & 0xFFFF, pPacket);
|
---|
54 | OSS32_SetFileId(oldfileid);
|
---|
55 | return rc;
|
---|
56 | }
|
---|
57 |
|
---|
58 | WORD32 OSS32IDC(ULONG cmd, PIDC32_PACKET pPacket)
|
---|
59 | {
|
---|
60 | switch(cmd)
|
---|
61 | {
|
---|
62 | case IDC32_INIT:
|
---|
63 | idc16_PddHandler = (IDC16_HANDLER)__Make48Pointer(pPacket->init.handler16);
|
---|
64 | return OSS32_InitDriver();
|
---|
65 |
|
---|
66 | case IDC32_EXIT:
|
---|
67 | idc16_PddHandler = 0;
|
---|
68 | return TRUE;
|
---|
69 |
|
---|
70 | case IDC32_IRQ:
|
---|
71 | return oss_process_interrupt(pPacket->irq.irqnr);
|
---|
72 |
|
---|
73 | case IDC32_STREAM_OPEN:
|
---|
74 | return OSS32_StreamOpen(pPacket->open.streamtype);
|
---|
75 |
|
---|
76 | case IDC32_STREAM_CLOSE:
|
---|
77 | return OSS32_StreamClose(pPacket->close.streamtype, pPacket->close.streamid);
|
---|
78 |
|
---|
79 | case IDC32_STREAM_ADDBUFFER:
|
---|
80 | return OSS32_StreamAddBuffer(pPacket->buffer.streamtype, pPacket->buffer.streamid, pPacket->buffer.buffer, pPacket->buffer.size);
|
---|
81 |
|
---|
82 | case IDC32_STREAM_PAUSE:
|
---|
83 | break;
|
---|
84 |
|
---|
85 | case IDC32_STREAM_START:
|
---|
86 | {
|
---|
87 | ULONG fStart = TRUE;
|
---|
88 |
|
---|
89 | #ifdef KEE
|
---|
90 | return OSS32_StreamTrigger(pPacket->startstop.streamtype, pPacket->startstop.streamid, (ULONG *)&fStart);
|
---|
91 | #else
|
---|
92 | return OSS32_StreamTrigger(pPacket->startstop.streamtype, pPacket->startstop.streamid, (ULONG NEAR *)__StackToFlat((ULONG)&fStart));
|
---|
93 | #endif
|
---|
94 | }
|
---|
95 |
|
---|
96 | case IDC32_STREAM_STOP:
|
---|
97 | {
|
---|
98 | ULONG fStart = FALSE;
|
---|
99 |
|
---|
100 | #ifdef KEE
|
---|
101 | return OSS32_StreamTrigger(pPacket->startstop.streamtype, pPacket->startstop.streamid, (ULONG *)&fStart);
|
---|
102 | #else
|
---|
103 | return OSS32_StreamTrigger(pPacket->startstop.streamtype, pPacket->startstop.streamid, (ULONG NEAR *)__StackToFlat((ULONG)&fStart));
|
---|
104 | #endif
|
---|
105 | }
|
---|
106 |
|
---|
107 | case IDC32_MIDI_WRITE:
|
---|
108 | return OSS32_StreamMidiWrite(pPacket->midiwrite.streamid, pPacket->midiwrite.midiByte);
|
---|
109 |
|
---|
110 | case IDC32_MIDI_READ:
|
---|
111 | return OSS32_StreamMidiRead(pPacket->midiread.streamid, (char NEAR *)__StackToFlat((ULONG)pPacket->midiread.buffer), pPacket->midiread.bufsize);
|
---|
112 |
|
---|
113 | case IDC32_STREAM_RESET:
|
---|
114 | return OSS32_StreamReset(pPacket->startstop.streamtype, pPacket->startstop.streamid);
|
---|
115 |
|
---|
116 | case IDC32_STREAM_IOCTL:
|
---|
117 | switch(pPacket->ioctl.cmd) {
|
---|
118 | case IOCTL_SETFORMAT:
|
---|
119 | {
|
---|
120 | FORMAT_INFO NEAR *pFormatInfo = (FORMAT_INFO NEAR *)__StackToFlat(pPacket->ioctl.ioctl_param);
|
---|
121 |
|
---|
122 | return OSS32_StreamSetFormat(pPacket->ioctl.streamtype, pPacket->ioctl.streamid, pPacket->ioctl.cmd, pFormatInfo);
|
---|
123 | }
|
---|
124 | default:
|
---|
125 | return OSS32_StreamIOCtl(pPacket->ioctl.streamtype, pPacket->ioctl.streamid, pPacket->ioctl.cmd, (char NEAR *)__StackToFlat(pPacket->ioctl.ioctl_param));
|
---|
126 | }
|
---|
127 | case IDC32_STREAM_MIXER:
|
---|
128 | return OSS32_SetVolume(pPacket->mixer.streamtype, pPacket->mixer.streamid, pPacket->mixer.cmd, pPacket->mixer.volume);
|
---|
129 | }
|
---|
130 | return 0;
|
---|
131 | }
|
---|