[142] | 1 | /* $Id: ossidc.cpp 151 2000-05-28 16:50:46Z sandervl $ */
|
---|
| 2 |
|
---|
| 3 | //******************************************************************************
|
---|
| 4 | // OS/2 IDC services (callback to 16 bits MMPM2 driver)
|
---|
| 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 | #define INCL_NOPMAPI
|
---|
| 25 | #define INCL_DOSERRORS // for ERROR_INVALID_FUNCTION
|
---|
| 26 | #include <os2.h>
|
---|
| 27 | #include <ossdefos2.h>
|
---|
| 28 | #include <ossidc.h>
|
---|
| 29 | #include <devhelp.h>
|
---|
| 30 | #ifdef KEE
|
---|
| 31 | #include <kee.h>
|
---|
| 32 | #endif
|
---|
| 33 |
|
---|
| 34 | //******************************************************************************
|
---|
| 35 | //******************************************************************************
|
---|
| 36 | BOOL CallOSS16(ULONG cmd, ULONG param1, ULONG param2)
|
---|
| 37 | {
|
---|
| 38 | IDC16_PACKET idcpacket;
|
---|
| 39 | ULONG pPacket;
|
---|
| 40 | BOOL rc;
|
---|
| 41 |
|
---|
| 42 | if(idc16_PddHandler == 0) {
|
---|
| 43 | return FALSE;
|
---|
| 44 | }
|
---|
| 45 | idcpacket.param1 = param1;
|
---|
| 46 | idcpacket.param2 = param2;
|
---|
[148] | 47 | #ifdef KEE
|
---|
[142] | 48 | pPacket = (ULONG)__FlatToStack(&idcpacket);
|
---|
[148] | 49 | #else
|
---|
| 50 | pPacket = (ULONG)__Compress48Pointer((char FAR48 *)&idcpacket);
|
---|
| 51 | #endif
|
---|
[142] | 52 |
|
---|
| 53 | #ifdef KEE
|
---|
| 54 | //NOTE: This isn't safe if the compiler uses ebp (or esp) to hold
|
---|
| 55 | // idc16_PddHandler, cmd or pPacket!! (works now though)
|
---|
| 56 | KernThunkStackTo16();
|
---|
| 57 | //// KernSerialize16BitDD();
|
---|
| 58 | #endif
|
---|
| 59 | rc = idc16_PddHandler(cmd, pPacket);
|
---|
| 60 | #ifdef KEE
|
---|
| 61 | //// KernUnserialize16BitDD();
|
---|
| 62 | KernThunkStackTo32();
|
---|
| 63 | #endif
|
---|
| 64 |
|
---|
| 65 | return rc;
|
---|
| 66 | }
|
---|
| 67 | //******************************************************************************
|
---|
| 68 | //******************************************************************************
|
---|
| 69 | BOOL OSS32_SetIrq(int irq, ULONG handler)
|
---|
| 70 | {
|
---|
| 71 | return CallOSS16(IDC16_SETIRQ, irq, handler);
|
---|
| 72 | }
|
---|
| 73 | //******************************************************************************
|
---|
| 74 | //******************************************************************************
|
---|
| 75 | BOOL OSS32_FreeIrq(int irq)
|
---|
| 76 | {
|
---|
| 77 | return CallOSS16(IDC16_FREEIRQ, irq, 0);
|
---|
| 78 | }
|
---|
| 79 | //******************************************************************************
|
---|
| 80 | extern "C" int init_module();
|
---|
| 81 | extern "C" void cleanup_module();
|
---|
| 82 | //******************************************************************************
|
---|
| 83 | BOOL OSS32_InitDriver()
|
---|
| 84 | {
|
---|
| 85 | return init_module() == 0;
|
---|
| 86 | }
|
---|
| 87 | //******************************************************************************
|
---|
| 88 | //Called during OS/2 shutdown
|
---|
| 89 | //******************************************************************************
|
---|
| 90 | void OSS32_RemoveDriver()
|
---|
| 91 | {
|
---|
| 92 | cleanup_module();
|
---|
| 93 | }
|
---|
| 94 | //******************************************************************************
|
---|
| 95 | //******************************************************************************
|
---|
| 96 | extern "C" int OSS32_ProcessIRQ(int fWaveOut, unsigned long streamid)
|
---|
| 97 | {
|
---|
[151] | 98 | return CallOSS16(IDC16_PROCESS, (fWaveOut) ? IDC16_WAVEOUT_IRQ : IDC16_WAVEIN_IRQ, streamid);
|
---|
[142] | 99 | }
|
---|
| 100 | //******************************************************************************
|
---|
| 101 | //******************************************************************************
|
---|
[151] | 102 | extern "C" int OSS32_ProcessMidiIRQ(unsigned long streamid)
|
---|
| 103 | {
|
---|
| 104 | return CallOSS16(IDC16_PROCESS, IDC16_MIDI_IRQ, streamid);
|
---|
| 105 | }
|
---|
| 106 | //******************************************************************************
|
---|
| 107 | //******************************************************************************
|
---|