| 1 | /* $Id: idc.c,v 1.3 2000/07/17 18:34:54 sandervl Exp $ */
|
|---|
| 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 |
|
|---|
| 40 | //******************************************************************************
|
|---|
| 41 | //******************************************************************************
|
|---|
| 42 |
|
|---|
| 43 | WORD32 OSS32IDC(ULONG cmd, PIDC32_PACKET pPacket)
|
|---|
| 44 | {
|
|---|
| 45 | switch(cmd)
|
|---|
| 46 | {
|
|---|
| 47 | case IDC32_INIT:
|
|---|
| 48 | idc16_PddHandler = (IDC16_HANDLER)__Make48Pointer(pPacket->init.handler16);
|
|---|
| 49 | return OSS32_InitDriver();
|
|---|
| 50 |
|
|---|
| 51 | case IDC32_EXIT:
|
|---|
| 52 | idc16_PddHandler = 0;
|
|---|
| 53 | return TRUE;
|
|---|
| 54 | /*
|
|---|
| 55 | Rudi: see SBLive32IDC
|
|---|
| 56 | case IDC32_IRQ:
|
|---|
| 57 | return oss_process_interrupt(pPacket->irq.irqnr);
|
|---|
| 58 | */
|
|---|
| 59 | case IDC32_STREAM_OPEN:
|
|---|
| 60 | return OSS32_StreamOpen(pPacket->open.streamtype);
|
|---|
| 61 |
|
|---|
| 62 | case IDC32_STREAM_CLOSE:
|
|---|
| 63 | return OSS32_StreamClose(pPacket->close.streamtype, pPacket->close.streamid);
|
|---|
| 64 |
|
|---|
| 65 | case IDC32_STREAM_ADDBUFFER:
|
|---|
| 66 | return OSS32_StreamAddBuffer(pPacket->buffer.streamtype,
|
|---|
| 67 | pPacket->buffer.streamid,
|
|---|
| 68 | pPacket->buffer.buffer, pPacket->buffer.size);
|
|---|
| 69 | /*
|
|---|
| 70 | case IDC32_STREAM_PAUSE:
|
|---|
| 71 | break;
|
|---|
| 72 | */
|
|---|
| 73 | case IDC32_STREAM_START:
|
|---|
| 74 | case IDC32_STREAM_STOP:
|
|---|
| 75 | {
|
|---|
| 76 | ULONG fStart = (cmd == IDC32_STREAM_START);
|
|---|
| 77 |
|
|---|
| 78 | #ifdef KEE
|
|---|
| 79 | return OSS32_StreamTrigger(pPacket->startstop.streamtype,
|
|---|
| 80 | pPacket->startstop.streamid, &fStart);
|
|---|
| 81 | #else
|
|---|
| 82 | return OSS32_StreamTrigger(pPacket->startstop.streamtype,
|
|---|
| 83 | pPacket->startstop.streamid,
|
|---|
| 84 | (ULONG NEAR *)__StackToFlat((ULONG)&fStart));
|
|---|
| 85 | #endif
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | case IDC32_MIDI_WRITE:
|
|---|
| 89 | return OSS32_StreamMidiWrite(pPacket->midiwrite.streamid,
|
|---|
| 90 | pPacket->midiwrite.midiByte);
|
|---|
| 91 |
|
|---|
| 92 | case IDC32_MIDI_READ:
|
|---|
| 93 | return OSS32_StreamMidiRead(pPacket->midiread.streamid,
|
|---|
| 94 | (char NEAR *)__StackToFlat((ULONG)pPacket->midiread.buffer),
|
|---|
| 95 | pPacket->midiread.bufsize);
|
|---|
| 96 |
|
|---|
| 97 | case IDC32_STREAM_RESET:
|
|---|
| 98 | return OSS32_StreamReset(pPacket->startstop.streamtype, pPacket->startstop.streamid);
|
|---|
| 99 |
|
|---|
| 100 | case IDC32_STREAM_GETSPACE:
|
|---|
| 101 | return OSS32_StreamGetSpace(pPacket->getspace.streamtype, pPacket->getspace.streamid);
|
|---|
| 102 |
|
|---|
| 103 | case IDC32_STREAM_IOCTL:
|
|---|
| 104 | if( pPacket->ioctl.cmd == IOCTL_SETFORMAT )
|
|---|
| 105 | return OSS32_StreamSetFormat(pPacket->ioctl.streamtype,
|
|---|
| 106 | pPacket->ioctl.streamid, pPacket->ioctl.cmd,
|
|---|
| 107 | (FORMAT_INFO NEAR *)__StackToFlat(pPacket->ioctl.ioctl_param));
|
|---|
| 108 | else
|
|---|
| 109 | return OSS32_StreamIOCtl(pPacket->ioctl.streamtype,
|
|---|
| 110 | pPacket->ioctl.streamid, pPacket->ioctl.cmd,
|
|---|
| 111 | (char NEAR *)__StackToFlat(pPacket->ioctl.ioctl_param));
|
|---|
| 112 |
|
|---|
| 113 | case IDC32_STREAM_MIXER:
|
|---|
| 114 | return OSS32_SetVolume(pPacket->mixer.streamtype,
|
|---|
| 115 | pPacket->mixer.streamid, pPacket->mixer.cmd,
|
|---|
| 116 | pPacket->mixer.volume);
|
|---|
| 117 |
|
|---|
| 118 | case IDC32_DEVESCAPE:
|
|---|
| 119 | return OSS32_DevEscape(pPacket->info.chipno, pPacket->info.command,
|
|---|
| 120 | pPacket->info.param1, pPacket->info.param2);
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | return 0;
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 | //******************************************************************************
|
|---|
| 128 | //******************************************************************************
|
|---|
| 129 |
|
|---|
| 130 | //packet pointer must reference a structure on the stack
|
|---|
| 131 |
|
|---|
| 132 | WORD32 SBLive32IDC(ULONG cmd, ULONG packet);
|
|---|
| 133 | #pragma aux SBLive32IDC "SBLIVE_IDC" parm reverse [ecx edx]
|
|---|
| 134 |
|
|---|
| 135 | WORD32 SBLive32IDC(ULONG cmd, ULONG packet)
|
|---|
| 136 | {
|
|---|
| 137 | PIDC32_PACKET pPacket = (PIDC32_PACKET)__StackToFlat(packet);
|
|---|
| 138 | ULONG oldfileid;
|
|---|
| 139 | WORD32 rc;
|
|---|
| 140 |
|
|---|
| 141 | // Rudi: faster interrupt handling...
|
|---|
| 142 | if( cmd == IDC32_IRQ )
|
|---|
| 143 | return oss_process_interrupt(pPacket->irq.irqnr, pPacket->irq.param);
|
|---|
| 144 |
|
|---|
| 145 | //Sets file id in current task structure
|
|---|
| 146 | oldfileid = OSS32_SetFileId(pPacket->fileid);
|
|---|
| 147 | rc = OSS32IDC(cmd, pPacket);
|
|---|
| 148 | OSS32_SetFileId(oldfileid);
|
|---|
| 149 | return rc;
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|