home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 4 Drivers
/
04-Drivers.zip
/
cs0929a.zip
/
ioctl.lst
< prev
next >
Wrap
File List
|
1999-09-29
|
24KB
|
633 lines
Module: D:\dev\csrc\os2dd\scd\ioctl.c
Group: 'DGROUP' CONST,CONST2,_DATA,_BSS
Segment: _TEXT PARA 000002bd bytes
//
// ioctl.c
// 2-Feb-99
//
// VOID ioctlStrat(REQPACK __far *rpPtr, USHORT lDev);
#include "cs40.h"
#define VSD_RCID 99 // as in VSD RCID
// mixer/line stuff not yet done
// -------------------------
// in: rpPtr -> request pack
// lDev = logical device
//out: n/a
//nts: this checks that the SFN is not already a registered stream, and
// then
static VOID ioctlAudioInit(REQPACK __far *rpPtr, USHORT lDev) {
WAVESTREAM *wsPtr;
STREAM *streamPtr;
USHORT devType;
USHORT rc;
0000 51 ioctlAudioInit_ push cx
0001 56 push si
0002 57 push di
0003 55 push bp
0004 89 e5 mov bp,sp
0006 83 ec 0a sub sp,000aH
0009 89 46 f8 mov [bp-8H],ax
000c 89 56 fc mov [bp-4H],dx
000f 89 da mov dx,bx
MCI_AUDIO_INIT __far *mciInitPtr = rpPtr->ioctl.dataPtr;
0011 8e 46 fc mov es,[bp-4H]
0014 89 c3 mov bx,ax
0016 89 c6 mov si,ax
0018 26 8b 47 15 mov ax,es:[bx+15H]
001c 26 8b 74 13 mov si,es:[si+13H]
0020 89 46 fe mov [bp-2H],ax
USHORT SFN = rpPtr->ioctl.SFN;
// !!!
//ddprintf("@ioctlAudioInit...\n");
// if idle or deinit request, get the stream object based on SFN and set state to idle...
0023 26 8b 47 17 mov ax,es:[bx+17H]
if (mciInitPtr->sMode == IDLE) {
0027 8e 46 fe mov es,[bp-2H]
002a 26 8b 5c 0c mov bx,es:[si+0cH]
002e 89 46 fa mov [bp-6H],ax
0031 81 fb e7 03 cmp bx,03e7H
0035 75 12 jne L1
streamPtr = streamFindStreamSFN(SFN);
0037 e8 00 00 call streamFindStreamSFN_
003a 89 c3 mov bx,ax
if (streamPtr) streamPtr->streamState = streamPtr->streamState | STREAM_IDLE;
//mciInitPtr->pvReserved = (VOID __far *)((ULONG)SFN); // have to... done at good exit
rc = 0;
003c 85 c0 test ax,ax
003e 0f 84 f5 00 je L13
0042 80 4f 1e 04 or byte ptr [bx+1eH],04H
goto ExitNow;
}
else {
// check for stream with same SFN already -- if so and is idle, reset idle bit
// this has to be done because mmpm passes the idle state down if the stream is
// losing the hardware to another app (usually to another app) -- if not now idle,
// then the stream is either not registered or is being re-initialized (o) in another
// mode or with different file attributes (quote) ... this reinit is "a total hack on
// the part of mmpm since it should instead deregister the stream, then init a new
// stream, but mmpm doesn't do it that way" (at least, the VSD doesn't, supposedly)
// anyway, if this is the case, delete the current stream and make a new one based on
// this req pack
0046 e9 ee 00 jmp L13
streamPtr = streamFindStreamSFN(SFN);
0049 e8 00 00 L1 call streamFindStreamSFN_
004c 89 c3 mov bx,ax
if (streamPtr) {
004e 85 c0 test ax,ax
0050 74 18 je L3
if (streamPtr->streamState & STREAM_IDLE) {
0052 8a 47 1e mov al,[bx+1eH]
0055 24 04 and al,04H
0057 30 e4 xor ah,ah
0059 85 c0 test ax,ax
005b 74 07 je L2
streamPtr->streamState = streamPtr->streamState & STREAM_NOT_IDLE;
//mciInitPtr->pvReserved = (VOID __far *)((ULONG)SFN); // have to... done at good exit
rc = 0;
005d 80 67 1e fb and byte ptr [bx+1eH],0fbH
goto ExitNow;
}
else {
//streamDeinit(streamPtr); // was "delete pstream" (use wavestreamDeinit() instead)
0061 e9 d3 00 jmp L13
wavestreamDeinit(streamPtr->wsParentPtr);
}
}
}
0064 8b 47 24 L2 mov ax,[bx+24H]
0067 e8 00 00 call wavestreamDeinit_
devType = hwGetType(mciInitPtr->sMode, (USHORT)mciInitPtr->ulOperation, lDev); // AUDIOHW_WAVE_PLAY/CAPTURE
006a 8e 46 fe L3 mov es,[bp-2H]
006d 89 d3 mov bx,dx
006f 26 8b 8c 1c 01 mov cx,es:[si+11cH]
0074 26 8b 44 0c mov ax,es:[si+0cH]
0078 89 ca mov dx,cx
007a e8 00 00 call hwGetType_
007d 89 46 f6 mov [bp-0aH],ax
if (devType == AUDIOHW_INVALID_DEVICE) {
0080 3d ff ff cmp ax,0ffffH
0083 75 06 jne L4
rc = INVALID_REQUEST;
0085 b8 04 00 mov ax,0004H
goto ExitNow;
}
0088 e9 ae 00 jmp L14
mciInitPtr->ulFlags = 0;
008b 8e 46 fe L4 mov es,[bp-2H]
008e 26 c7 84 18 01 00
00 mov word ptr es:[si+118H],0000H
0095 26 c7 84 1a 01 00
00 mov word ptr es:[si+11aH],0000H
if (devType == AUDIOHW_WAVE_PLAY || devType == AUDIOHW_WAVE_CAPTURE) {
009c 3d 11 00 cmp ax,0011H
009f 74 05 je L5
00a1 3d 10 00 cmp ax,0010H
00a4 75 6e jne L11
wsPtr = malloc(sizeof(WAVESTREAM)); // wsPtr will be stored/tracked in streamPtr->wsParentPtr
00a6 b8 20 00 L5 mov ax,0020H
00a9 e8 00 00 call malloc_
00ac 89 c2 mov dx,ax
if (wsPtr) {
00ae 85 c0 test ax,ax
00b0 74 62 je L11
MEMSET(wsPtr,0,sizeof(WAVESTREAM));
00b2 b9 20 00 mov cx,0020H
00b5 89 d7 mov di,dx
00b7 1e push ds
00b8 07 pop es
00b9 31 c0 xor ax,ax
00bb fc cld
00bc 85 c9 test cx,cx
00be 74 43 je L10
00c0 83 f9 20 cmp cx,0020H
00c3 72 37 jb L9
00c5 f7 c1 01 00 test cx,0001H
00c9 74 02 je L6
00cb 88 c4 mov ah,al
00cd 89 c3 L6 mov bx,ax
00cf 66 c1 e0 10 shl eax,10H
00d3 89 d8 mov ax,bx
00d5 f7 c7 03 00 test di,0003H
00d9 74 12 je L8
00db f7 c7 01 00 test di,0001H
00df 74 08 je L7
00e1 aa stosb
00e2 49 dec cx
00e3 f7 c7 02 00 test di,0002H
00e7 74 04 je L8
00e9 ab L7 stosw
00ea 83 e9 02 sub cx,0002H
00ed 88 cb L8 mov bl,cl
00ef c1 e9 02 shr cx,02H
00f2 f3 66 ab repe stosd
00f5 80 e3 03 and bl,03H
00f8 74 09 je L10
00fa 88 d9 mov cl,bl
00fc d1 e9 L9 shr cx,1
00fe f3 ab repe stosw
0100 73 01 jae L10
0102 aa stosb
0103 8b 4e fe L10 mov cx,[bp-2H]
0106 8b 46 f6 mov ax,[bp-0aH]
streamPtr = wavestreamInit(devType, mciInitPtr, wsPtr); // wavestreamInit() allocates streamPtr
0109 89 f3 mov bx,si
010b e8 00 00 call wavestreamInit_
010e 89 c3 mov bx,ax
if (streamPtr == 0) {
0110 85 c0 test ax,ax
0112 75 05 jne L12
rc = INVALID_REQUEST;
0114 b8 04 00 L11 mov ax,0004H
goto ExitNow;
}
}
else {
rc = INVALID_REQUEST; // rc = 8; probably not a valid rc, but could use it in rp.status...
goto ExitNow; // see audio.h for valid return codes...
}
}
else {
rc = INVALID_REQUEST;
goto ExitNow;
}
0117 eb 20 jmp L14
mciInitPtr->ulFlags = mciInitPtr->ulFlags | VOLUME | INPUT | OUTPUT | MONITOR; // have to modify
0119 8e 46 fe L12 mov es,[bp-2H]
011c 26 8b 8c 1a 01 mov cx,es:[si+11aH]
mciInitPtr->sDeviceID = VSD_RCID; // reported in VSD DLL (I'll have to come up with my own, say 40)
0121 26 c7 84 24 01 63
00 mov word ptr es:[si+124H],0063H
0128 81 c9 e0 01 or cx,01e0H
streamPtr->SFN = SFN;
012c 8b 46 fa mov ax,[bp-6H]
012f 26 89 8c 1a 01 mov es:[si+11aH],cx
0134 89 47 0c mov [bx+0cH],ax
rc = 0;
ExitNow:
// !!!
//ddprintf("...mciInit.flags=%lx\n",mciInitPtr->ulFlags);
0137 31 c0 L13 xor ax,ax
if (rc == 0) {
0139 85 c0 L14 test ax,ax
013b 75 10 jne L15
013d 8e 46 fe mov es,[bp-2H]
mciInitPtr->pvReserved = (VOID __far *)((ULONG)SFN); // since common in all rc==0
// think this is for sending in, as in driver version needed?
// mciInitPtr->ulVersionLevel = DRIVER_VERSION;
}
0140 8b 56 fa mov dx,[bp-6H]
0143 26 89 94 26 01 mov es:[si+126H],dx
0148 26 89 84 28 01 mov es:[si+128H],ax
mciInitPtr->sReturnCode = rc;
014d 8e 46 fe L15 mov es,[bp-2H]
0150 26 89 84 20 01 mov es:[si+120H],ax
if (rc) rpPtr->status = rpPtr->status | RPERR;
return;
0155 74 0b je L16
0157 8e 46 fc mov es,[bp-4H]
015a 8b 5e f8 mov bx,[bp-8H]
015d 26 80 4f 04 80 or byte ptr es:[bx+4H],80H
}
// -------------------------
// in: rpPtr -> request pack
// lDev = logical device
//out: n/a
//nts:
0162 89 ec L16 mov sp,bp
0164 5d pop bp
0165 5f pop di
0166 5e pop si
0167 59 pop cx
0168 c3 ret
0169 89 c0 mov ax,ax
016b fc cld
static VOID ioctlAudioCaps(REQPACK __far *rpPtr, USHORT lDev) {
USHORT devType;
USHORT rc = 0;
016c 51 ioctlAudioCaps_ push cx
016d 56 push si
016e 57 push di
016f 55 push bp
0170 89 e5 mov bp,sp
0172 83 ec 02 sub sp,0002H
0175 89 c7 mov di,ax
0177 89 56 fe mov [bp-2H],dx
MCI_AUDIO_CAPS __far *devCapsPtr = rpPtr->ioctl.dataPtr;
017a 8e c2 mov es,dx
017c 26 8b 4d 15 mov cx,es:[di+15H]
0180 26 8b 75 13 mov si,es:[di+13H]
devType = hwGetType((USHORT)devCapsPtr->ulDataType, (USHORT)devCapsPtr->ulOperation, lDev);
0184 8e c1 mov es,cx
0186 26 8b 54 14 mov dx,es:[si+14H]
018a 26 8b 44 10 mov ax,es:[si+10H]
018e e8 00 00 call hwGetType_
if (devType == AUDIOHW_INVALID_DEVICE) {
0191 3d ff ff cmp ax,0ffffH
0194 75 05 jne L17
rc = UNSUPPORTED_DATATYPE;
0196 b8 08 00 mov ax,0008H
goto ExitNow;
}
0199 eb 0d jmp L18
waDevCaps(devCapsPtr);
019b 89 f0 L17 mov ax,si
019d 89 ca mov dx,cx
019f e8 00 00 call waDevCaps_
rc = devCapsPtr->ulSupport;
ExitNow:
01a2 8e c1 mov es,cx
01a4 26 8b 44 18 mov ax,es:[si+18H]
devCapsPtr->ulSupport = rc;
01a8 8e c1 L18 mov es,cx
01aa 26 c7 44 1a 00 00 mov word ptr es:[si+1aH],0000H
01b0 26 89 44 18 mov es:[si+18H],ax
if (rc) rpPtr->status = rpPtr->status | RPERR;
return;
01b4 85 c0 test ax,ax
01b6 74 08 je L19
01b8 8e 46 fe mov es,[bp-2H]
01bb 26 80 4d 04 80 or byte ptr es:[di+4H],80H
}
// -------------------------
// in: rpPtr -> request pack
//out: n/a
//nts:
// * if it's AUDIO_CHANGE, just report success, otherwise report failure
// * this is because we don't support volume, balance, multiple in/out devices,
// * etc. Also, START, STOP, RESUME, and PAUSE are redundant, so we don't
// * support those either.
01c0 89 ec L19 mov sp,bp
01c2 5d pop bp
01c3 5f pop di
01c4 5e pop si
01c5 59 pop cx
01c6 c3 ret
01c7 fc cld
static VOID ioctlAudioControl(REQPACK __far *rpPtr) {
01c8 ioctlAudioControl_:
01c8 53 push bx
01c9 56 push si
01ca 89 c3 mov bx,ax
01cc 8e c2 mov es,dx
MCI_AUDIO_CONTROL __far *controlPtr = rpPtr->ioctl.dataPtr;
01ce 26 c4 77 13 les si,dword ptr es:[bx+13H]
if (controlPtr->usIOCtlRequest == AUDIO_CHANGE) {
01d2 26 8b 14 mov dx,es:[si]
01d5 85 d2 test dx,dx
01d7 75 07 jne L20
controlPtr->sReturnCode = 0;
}
01d9 26 89 54 0a mov es:[si+0aH],dx
else {
01dd 5e pop si
01de 5b pop bx
01df c3 ret
controlPtr->sReturnCode = INVALID_REQUEST;
}
return;
01e0 26 c7 44 0a 04 00 L20 mov word ptr es:[si+0aH],0004H
}
// -------------------------
// in: rpPtr -> request pack (.status RPDONE bit already set)
// lDev = logical device (first header device is 0, second (if any) is 1, and so on)
//out: n/a
//nts: generic ioctl strategy entry
// cat80 is all that's supported...
01e6 5e pop si
01e7 5b pop bx
01e8 c3 ret
01e9 89 c0 mov ax,ax
01eb fc cld
VOID ioctlStrat(REQPACK __far *rpPtr, USHORT lDev) {
// !!!
#ifdef TRACE_STRAT_GENIOCTL
01ec 51 ioctlStrat_ push cx
01ed 56 push si
01ee 57 push di
01ef 55 push bp
01f0 89 e5 mov bp,sp
01f2 83 ec 02 sub sp,0002H
01f5 89 c6 mov si,ax
01f7 89 56 fe mov [bp-2H],dx
01fa 89 df mov di,bx
tracePerf(rpPtr->ioctl.category | TRACE_IN, rpPtr->ioctl.function);
#endif
01fc 8e c2 mov es,dx
01fe 31 c9 xor cx,cx
0200 26 8a 5c 0e mov bl,es:[si+0eH]
0204 26 8a 44 0d mov al,es:[si+0dH]
0208 30 ff xor bh,bh
020a 30 e4 xor ah,ah
020c e8 00 00 call tracePerf_
if (rpPtr->ioctl.category == AUDIO_IOCTL_CAT) {
020f 8e 46 fe mov es,[bp-2H]
0212 26 8a 44 0d mov al,es:[si+0dH]
0216 30 e4 xor ah,ah
0218 3d 80 00 cmp ax,0080H
021b 0f 85 79 00 jne L27
switch(rpPtr->ioctl.function) {
case AUDIO_INIT:
021f 26 8a 44 0e mov al,es:[si+0eH]
0223 3c 42 cmp al,42H
0225 72 12 jb L21
0227 76 1f jbe L22
0229 3c 48 cmp al,48H
022b 72 5b jb L26
022d 76 38 jbe L24
022f 3c 60 cmp al,60H
0231 72 55 jb L26
0233 3c 64 cmp al,64H
0235 76 3b jbe L25
0237 eb 4f jmp L26
0239 3c 40 L21 cmp al,40H
023b 75 4b jne L26
ioctlAudioInit(rpPtr,lDev);
023d 89 fb mov bx,di
023f 89 f0 mov ax,si
0241 8c c2 mov dx,es
0243 e8 00 00 call ioctlAudioInit_
break;
0246 eb 6e jmp L28
case AUDIO_CONTROL:
0248 26 8b 44 15 L22 mov ax,es:[si+15H]
ioctlAudioControl(rpPtr);
break;
case AUDIO_CAPABILITY:
024c 26 8b 5c 13 mov bx,es:[si+13H]
0250 8e c0 mov es,ax
0252 26 8b 0f mov cx,es:[bx]
0255 85 c9 test cx,cx
0257 75 06 jne L23
0259 26 89 4f 0a mov es:[bx+0aH],cx
025d eb 57 jmp L28
025f 26 c7 47 0a 04 00 L23 mov word ptr es:[bx+0aH],0004H
0265 eb 4f jmp L28
ioctlAudioCaps(rpPtr,lDev);
0267 89 fb L24 mov bx,di
0269 89 f0 mov ax,si
026b 8c c2 mov dx,es
026d e8 00 00 call ioctlAudioCaps_
break;
case MIX_GETCONNECTIONS:
case MIX_SETCONNECTIONS:
case MIX_GETLINEINFO:
case MIX_GETCONTROL:
case MIX_SETCONTROL:
// !!!
0270 eb 44 jmp L28
if (gCLflags & FLAGS_CL_DDPRINT) ddprintf("ioctl mixer calls, %u\n",rpPtr->ioctl.function);
break;
default:
0272 f6 06 01 00 40 L25 test byte ptr _gCLflags+1H,40H
0277 74 3d je L28
0279 30 e4 xor ah,ah
027b 50 push ax
027c 1e push ds
027d 68 00 00 push offset L29
0280 e8 00 00 call _ddprintf
0283 83 c4 06 add sp,0006H
0286 eb 2e jmp L28
rpPtr->status = rpPtr->status | RPERR | RPBADCMD;
break;
}
}
else {
0288 8e 46 fe L26 mov es,[bp-2H]
028b 26 81 4c 03 03 80 or word ptr es:[si+3H],8003H
0291 89 ec mov sp,bp
0293 5d pop bp
0294 5f pop di
0295 5e pop si
0296 59 pop cx
0297 c3 ret
rpPtr->status = rpPtr->status | RPERR | RPBADCMD;
// !!!
#ifdef TRACE_STRAT_GENIOCTL
0298 26 8b 54 03 L27 mov dx,es:[si+3H]
tracePerf(rpPtr->ioctl.category | TRACE_OUT, rpPtr->ioctl.function);
#endif
}
return;
029c 26 8a 5c 0e mov bl,es:[si+0eH]
02a0 26 8a 44 0d mov al,es:[si+0dH]
02a4 31 c9 xor cx,cx
02a6 81 ca 03 80 or dx,8003H
02aa 80 cc 80 or ah,80H
02ad 30 ff xor bh,bh
02af 26 89 54 03 mov es:[si+3H],dx
02b3 e8 00 00 call tracePerf_
}
02b6 89 ec L28 mov sp,bp
02b8 5d pop bp
02b9 5f pop di
02ba 5e pop si
02bb 59 pop cx
02bc c3 ret
No disassembly errors
List of external symbols
Symbol
----------------
streamFindStreamSFN_
0000004a 00000038
wavestreamDeinit_
00000068
hwGetType_ 0000018f 0000007b
malloc_ 000000aa
wavestreamInit_ 0000010c
waDevCaps_ 000001a0
tracePerf_ 000002b4 0000020d
ioctlAudioInit_ 00000244
ioctlAudioCaps_ 0000026e
_gCLflags 00000274
_ddprintf 00000281
------------------------------------------------------------
Segment: CONST WORD 00000017 bytes
0000 69 6f 63 74 6c 20 6d 69 L29 - ioctl mi
0008 78 65 72 20 63 61 6c 6c - xer call
0010 73 2c 20 25 75 0a 00 - s, %u..
No disassembly errors
------------------------------------------------------------
List of public symbols
SYMBOL GROUP SEGMENT ADDRESS
---------------------------------------------------------
ioctlAudioCaps_ _TEXT 0000016c
ioctlAudioControl_
_TEXT 000001c8
ioctlAudioInit_ _TEXT 00000000
ioctlStrat_ _TEXT 000001ec
------------------------------------------------------------