home *** CD-ROM | disk | FTP | other *** search
- page 58,132
- ;
- ; ioctl.asm
- ; contains: GetIOCTLDevInfo() getiodevi()
- ;
- ;
- include model.h
- include prologue.h
- include equ.h
-
- name ioctl
-
- ifndef AZTEC
- ReferVar _gferror,<cWord>
- endif
-
- dseg DIoCtrl
- ifdef AZTEC
- ReferVar _gferror,<cWord>
- endif
- endds
-
- pseg ioctl
-
- ifdef DSNOTHING
- assume ds:nothing
- endif
-
-
- DOSCALL equ 021h ; interrupt to DOS
- IOCTL equ 044h ; generic IOCTL for AH
-
- ;==>-- int getiodev( handle )
- ;
- ;
- ;; ARGUMENTS:
- ; int handle; - device or file handle from DOS
- ;
- ;; DESCRIPTION:
- ; Obtains IOCTL information from a device or file via handle.
- ;
- ;
- ;; SIDE EFFECTS:
- ; None.
- ;
- ;; RETURNS:
- ; 16-bit device word from DOS
- ;
- ;; AUTHOR:
- ; DK 05-Feb-1989 12:18:47
- ; Copyright (C)1990 Greenleaf Software Inc. All Rights Reserved.
- ;
- ;
- ;; MODIFICATIONS:
- ;
- ;
- ;;;
- cproc getiodev
- mov bx,parm1_ ; get incoming handle
- xor al,al
- mov ah,IOCTL
- int DOSCALL
- mov ax,dx ; return value
- cproce
-
-
- ;==>-- unsigned SetIOCTLDevInfo( int handle, unsigned char info )
- ; setiodev()
- ;
- ;; ARGUMENTS:
- ; int handle; - device or file handle from DOS
- ; unsigned char info; - device information
- ;
- ; Can contain any of the following bits or combination thereof:
- ;
- ; DEVISCIN
- ; DEVISCOT
- ; DEVISNUL
- ; DEVISCLK
- ; DEVBINARY
- ; DEVEOF
- ; DEVISDEV
- ;
- ;
- ;; DESCRIPTION:
- ; Sets bits in the device driver.
- ;
- ;; SIDE EFFECTS:
- ;
- ;
- ;; RETURNS:
- ; 16-bit device word from DOS
- ;
- ;; AUTHOR:
- ; DK 05-Feb-1989 12:25:37
- ; Copyright (C)1990 Greenleaf Software Inc. All Rights Reserved.
- ;
- ;
- ;; MODIFICATIONS:
- ;
- ;
- ;;;
- cproc setiodev
- mov bx,parm1_ ; get incoming handle
- mov dx,parm2_ ; get incoming control word to DL
- xor dh,dh ; clear DH
- mov al,01h ; command
- mov ah,IOCTL
- int DOSCALL
- mov ax,dx ; return value
- cproce
-
-
- ;==>-- unsigned ReadIOCTLCharDev( handle,bfr,n)
- ; readiocd
- ;
- ;; ARGUMENTS:
- ; int handle; - device or file handle from DOS
- ; char *bfr; - pointer to data buffer
- ; unsigned n; - Number of bytes to read
- ;
- ;; DESCRIPTION:
- ; Reads n characters from a character-oriented device handle.
- ;
- ;
- ;
- ;; SIDE EFFECTS:
- ;
- ;
- ;; RETURNS:
- ; Number of bytes read, or (if Cy flag set) 0 with error code in
- ; _gferror
- ;
- ;; AUTHOR:
- ; DK 05-Feb-1989 12:34:47
- ; Copyright (C)1989-90 Greenleaf Software Inc. All Rights Reserved.
- ;
- ;
- ;; MODIFICATIONS:
- ;
- ;
- ;;;
- cproc readiocd
- mov AH,IOCTL
- mov al,02h ; function to read
- mov bx,parm1_
- if _LDATA
- push ds
- lds dx,parm2_ ; pointer to buffer
- mov cx,parm4_
- else
- mov dx,parm2_
- mov cx,parm3_
- endif
- int DOSCALL
- jnc rdiocdxit ; if no error, # bytes is in AX
- ifdef DSNOTHING
- mov bx,seg _gferror
- mov ds,bx
- endif
- mov _gferror,ax ; error, so store error code
- xor ax,ax ; and indicate it to user
- rdiocdxit:
- if _LDATA
- pop ds
- endif
- cproce
-
-
- ;==>-- unsigned WriteIOCTLCharDev( handle,bfr,n)
- ; writiocd
- ;
- ;; ARGUMENTS:
- ; int handle; - device or file handle from DOS
- ; char *bfr; - pointer to data buffer
- ; unsigned n; - Number of bytes to write
- ;
- ;; DESCRIPTION:
- ; Writes n characters from buffer to
- ; a character-oriented device handle.
- ;
- ;; SIDE EFFECTS:
- ;
- ;
- ;; RETURNS:
- ; Number of bytes written, or (if Cy flag set) 0 with error code in
- ; _gferror
- ;
- ;; AUTHOR:
- ; DK 05-Feb-1989 12:34:47
- ; Copyright (C)1989-90 Greenleaf Software Inc. All Rights Reserved.
- ;
- ;
- ;; MODIFICATIONS:
- ;
- ;
- ;;;
- cproc writiocd
- mov AH,IOCTL
- mov al,03h ; function to write
- mov bx,parm1_
- if _LDATA
- push ds
- lds dx,parm2_ ; pointer to buffer
- mov cx,parm4_
- else
- mov dx,parm2_
- mov cx,parm3_
- endif
- int DOSCALL
- jnc writiocdxit ; if no error, # bytes is in AX
- ifdef DSNOTHING
- mov bx,seg _gferror
- mov ds,bx
- endif
- mov _gferror,ax ; error, so store error code
- xor ax,ax ; and indicate it to user
- writiocdxit:
- if _LDATA
- pop ds
- endif
- cproce
-
-
-
- ;==>-- unsigned SendIOCTLString( handle, buf, n )
- ; sendiost
- ;
- ;; ARGUMENTS:
- ; int drive; - drive number 0=default, 1=A, etc.
- ; char *bfr; - pointer to data buffer
- ; unsigned n; - Number of bytes to write
- ;
- ;; DESCRIPTION:
- ; Writes n character control string from buffer to
- ; a block-oriented device.
- ;
- ;; SIDE EFFECTS:
- ;
- ;
- ;; RETURNS:
- ; Number of bytes written, or (if Cy flag set) 0 with error code in
- ; _gferror
- ;
- ;; AUTHOR:
- ; DK 05-Feb-1989 12:34:47
- ; Copyright (C)1990 Greenleaf Software Inc. All Rights Reserved.
- ;
- ;
- ;; MODIFICATIONS:
- ;
- ;
- ;;;
- cproc sendiost
- mov AH,IOCTL
- mov al,05h ; function to write
- mov bx,parm1_
- if _LDATA
- push ds
- lds dx,parm2_ ; pointer to buffer
- mov cx,parm4_
- else
- mov dx,parm2_
- mov cx,parm3_
- endif
- int DOSCALL
- jnc sendiostxit ; if no error, # bytes is in AX
- ifdef DSNOTHING
- mov bx,seg _gferror
- mov ds,bx
- endif
- mov _gferror,ax ; error, so store error code
- xor ax,ax ; and indicate it to user
- sendiostxit:
- if _LDATA
- pop ds
- endif
- cproce
-
-
- ;==>-- unsigned ReadIOCTLString( handle, buf, n )
- ; readiost
- ;
- ;; ARGUMENTS:
- ; int drive; - drive number 0=default, 1=A, etc.
- ; char *bfr; - pointer to data buffer
- ; unsigned n; - Number of bytes to write
- ;
- ;; DESCRIPTION:
- ; Reads n character control string from
- ; a block-oriented device to buffer.
- ;
- ;; SIDE EFFECTS:
- ;
- ;
- ;; RETURNS:
- ; Number of bytes read, or (if Cy flag set) 0 with error code in
- ; _gferror
- ;
- ;; AUTHOR:
- ; DK 05-Feb-1989 12:34:47
- ; Copyright (C)1989-90 Greenleaf Software Inc. All Rights Reserved.
- ;
- ;
- ;; MODIFICATIONS:
- ;
- ;
- ;;;
- cproc readiost
- mov AH,IOCTL
- mov al,04h ; function to read
- mov bx,parm1_
- if _LDATA
- push ds
- lds dx,parm2_ ; pointer to buffer
- mov cx,parm4_
- else
- mov dx,parm2_
- mov cx,parm3_
- endif
- int DOSCALL
- jnc readiostxit ; if no error, # bytes is in AX
- ifdef DSNOTHING
- mov bx,seg _gferror
- mov ds,bx
- endif
- mov _gferror,ax ; error, so store error code
- xor ax,ax ; and indicate it to user
- readiostxit:
- if _LDATA
- pop ds
- endif
- cproce
-
-
-
- ;==>-- int ChkIOCTLInputRdy( handle )
- ; chkinrdy
- ;
- ;
- ;; ARGUMENTS:
- ; int handle; - device handle
- ;
- ;; DESCRIPTION:
- ; Checks to see if the handle is ready for input.
- ;
- ;
- ;
- ;; SIDE EFFECTS:
- ;
- ;
- ;; RETURNS:
- ; 0 if OK, ready for input, else -1. For file, this means after EOF.
- ;
- ;
- ;; AUTHOR:
- ; DK 05-Feb-1989 12:59:56
- ; Copyright (C)1989-90 Greenleaf Software Inc. All Rights Reserved.
- ;
- ;
- ;; MODIFICATIONS:
- ;
- ;
- ;;;
- cproc chkinrdy
- mov bx,parm1_
- mov AH,IOCTL
- mov al,06h ; function to check input status
- int DOSCALL
- xor ah,ah
- cmp al,0
- jz chkinrdyxit
- mov ax,-1 ; not ready so return -1
- chkinrdyxit:
- cproce
-
-
-
-
- ;==>-- int ChkIOCTLOutputRdy( handle )
- ; chkoprdy
- ;
- ;
- ;; ARGUMENTS:
- ; int handle; - device handle
- ;
- ;; DESCRIPTION:
- ; Checks to see if the handle is ready for output
- ;
- ;
- ;
- ;; SIDE EFFECTS:
- ;
- ;
- ;; RETURNS:
- ; 0 if OK, ready for output, else -1. For file, this means after EOF.
- ;
- ;
- ;; AUTHOR:
- ; DK 05-Feb-1989 12:59:56
- ; Copyright (C)1989-90 Greenleaf Software Inc. All Rights Reserved.
- ;
- ;
- ;; MODIFICATIONS:
- ;
- ;
- ;;;
- cproc chkoprdy
- mov bx,parm1_
- mov AH,IOCTL
- mov al,07h ; function to check output status
- int DOSCALL
- xor ah,ah
- cmp al,0
- jz chkoprdyxit
- mov ax,-1 ; not ready so return -1
- chkoprdyxit:
- cproce
-
-
- ;==>-- int IsIOCTLDevRemovable( drv )
- ; isremov
- ;
- ;; ARGUMENTS:
- ; int drv; - Drive 0=default, 1=A, etc.
- ;
- ;; DESCRIPTION:
- ; Checks if device supports removable media
- ;
- ;; SIDE EFFECTS:
- ;
- ;
- ;; RETURNS:
- ; 0 if removable, 1 if fixed, 0x000f if invalid drive specified.
- ;
- ;; AUTHOR:
- ; DK 05-Feb-1989 13:18:04
- ; Copyright (C)1989-90 Greenleaf Software Inc. All Rights Reserved.
- ;
- ;
- ;; MODIFICATIONS:
- ;
- ;
- ;;;
- cproc isremov
- mov bx,parm1_
- mov ah,IOCTL
- mov al,08h ; function to determine if removeable
- int DOSCALL ; return is ready-made in AX
- cproce
-
-
-
- ;==>-- int IsIOCTLNetwork( drv )
- ; isnetwk
- ;
- ;
- ;; ARGUMENTS:
- ; int drv; - Drive 0=default, 1=A, etc.
- ;
- ;; DESCRIPTION:
- ; Checks if logical drive is local or remote (associated with a
- ; network directory).
- ;
- ;; SIDE EFFECTS:
- ;
- ;
- ;; RETURNS:
- ; 0 if local, nonzero if network associated.
- ;
- ;; AUTHOR:
- ; 05-Feb-1989 13:23:54
- ; Copyright (C)1989-90 Greenleaf Software Inc. All Rights Reserved.
- ;
- ;
- ;; MODIFICATIONS:
- ;
- ;
- ;;;
- cproc isnetwk
- mov bx,parm1_
- mov ah,IOCTL
- mov al,09h ; function to check network vs. local
- int DOSCALL
- and dx,01000h ; mask off all but bit 12
- mov ax,dx ; return in AX
- cproce
-
-
-
- ;==>-- int IsIOCTLRemote( handle )
- ; isremote
- ;
- ;; ARGUMENTS:
- ; int handle; - Device (file) handle
- ;
- ;; DESCRIPTION:
- ; Checks if device handle is for a local device or a remote device
- ; accross the network.
- ;
- ;; SIDE EFFECTS:
- ;
- ;
- ;; RETURNS:
- ; 0 if local, nonzero if remote.
- ;
- ;; AUTHOR:
- ; 05-Feb-1989 13:28:49
- ; Copyright (C)1989-90 Greenleaf Software Inc. All Rights Reserved.
- ;
- ;
- ;; MODIFICATIONS:
- ;
- ;
- ;;;
- cproc isremote
- mov bx,parm1_
- mov ah,IOCTL
- mov al,0ah ; function to check network vs. local
- int DOSCALL
- and dx,08000h ; mask off all but bit 12
- mov ax,dx ; return in AX
- cproce
-
-
-
- ;==>-- int IOCTLShareControl( loop, n )
- ; ioctlshr
- ;
- ;
- ;; ARGUMENTS:
- ; unsigned loop; - number of times to execute a delay loop
- ; unsigned n; - number of retries
- ;
- ;; DESCRIPTION:
- ; All sharing and lock conflicts are automatically retried a number
- ; of times before they are returned as a DOS error or critical error.
- ;
- ; This function selects the number of retries and the delay between
- ; retries. The delay loop consists of the following sequence:
- ;
- ; XOR CX,CX
- ; LOOP $ ; spin 64 times
- ;
- ; The default that DOS will use is delay=1 and retries-3 if you never
- ; call this function. Increasing these values can reduce the amount
- ; of threshing due to having to check DOS error codes when applications
- ; use a lot of conflicts about file locks or sharing of files.
- ;
- ;; SIDE EFFECTS:
- ;
- ;
- ;; RETURNS:
- ; 0 if successful, else a DOS error code (if Cy flag set) (will also
- ; be in _gferror)
- ;
- ;; AUTHOR:
- ; DK 05-Feb-1989 13:33:12
- ; Copyright (C)1989-90 Greenleaf Software Inc. All Rights Reserved.
- ;
- ;
- ;; MODIFICATIONS:
- ;
- ;
- ;;;
- cproc ioctlshr
- mov cx,parm1_ ; loop count
- mov dx,parm2_ ; retries
- mov ah,IOCTL
- mov al,0bh ; function to set retries/loop
- int DOSCALL
- jc ioctlshrxit ; hop if AX contains error code
- xor ax,ax ; no error, assure clear AX
- ioctlshrxit:
- ifdef DSNOTHING
- mov bx,seg _gferror
- push ds
- mov ds,bx
- endif
- mov _gferror,ax
- ifdef DSNOTHING
- pop ds
- endif
- cproce
-
- endps
- end
-