delorie.com/djgpp/doc/libc/libc_493.html | search |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
ioctl
performs an
interrupt 0x21, function 0x44. It takes care of supplying transfer buffers in
low address regions, if they are needed. For an exhaustive description of the
various commands and subcommands, see Ralf Brown's interrupt list.
It is highly recommended to use only the DOS_* functions listed in `sys/ioctl.h'.
#include <sys/ioctl.h> int ioctl(int fd, int cmd, ... ); |
fd
must refer to a file descriptor for character device
functions, or the number of a block device (usually current=0, A:=1, ...).
The following constants can be used for the cmd
parameter:
DOS_GETDEVDATA
DX
.
The call to ioctl
should look like this:
int ret_val = ioctl (fd, DOS_GETDEVDATA); |
For another way of achieving the same effect, see _get_dev_info
(see section _get_dev_info).
DOS_SETDEVDATA
DX
or -1. The call to ioctl
should look like this:
int ret_val = ioctl (fd, DOS_SETDEVDATA, 0, dev_info); |
DOS_RCVDATA
cmd
must follow the
number of requested bytes to read and a pointer to a buffer. Returns the number
of bytes actually read or -1 on error. The call to ioctl
should
look like this:
unsigned char buf[bytes_to_read]; int ret_val = ioctl (fd, DOS_RCVDATA, bytes_to_read, &buf); |
DOS_SNDDATA
cmd
must follow the
number of bytes to write and a pointer to a buffer holding the data.
Returns the number of bytes actually written. An example of a call:
unsigned char buf[bytes_to_write]; int ret_val = ioctl (fd, DOS_SNDDATA, bytes_to_write, &buf); |
DOS_RCVCTLDATA
DOS_RCVDATA
.
DOS_SNDCTLDATA
DOS_SNDDATA
.
DOS_CHKINSTAT
0xff
if file is ready. Here's an example of how to call:
int ret_val = ioctl (fd, DOS_CHKINSTAT); |
A more portable way of doing this is by calling select
.
See section select.
DOS_CHKOUTSTAT
0xff
if file is ready. select
(see section select) is
another, more portable way of doing the same.
DOS_ISCHANGEABLE
int ret_val = ioctl (fd, DOS_ISCHANGEABLE); |
DOS_ISREDIRBLK
_is_remote_drive
(see section _is_remote_drive) is another way of
returning the same info.
DOS_ISREDIRHND
_is_remote_handle
(see section _is_remote_handle) for another way
of doing this.
DOS_SETRETRY
int ret_val = ioctl (fd, DOS_SETRETRY, pause_between_retries, max_retries); |
DOS_GENCHARREQ
int ret_val = ioctl (fd, DOS_GENCHARREQ, category_and_function, ¶m_block, si_value, di_value, param_block_size); |
Refer to Ralf Brown's Interrupt List for the details about each function and relevant parameter block layout.
DOS_GENBLKREQ
int ret_val = ioctl (drive_no, DOS_GENBLKREQ, category_and_function, ¶m_block, si_value, di_value, param_block_size); |
Note that instead of the handle, the first argument is the disk drive number (0 = default, 1 = A:, etc.).
DOS_GLDRVMAP
int ret_val = ioctl (drive_no, DOS_GLDRVMAP); |
will return 0 if the block device has only one logical drive assigned,
or a number in the range 1..26 which is the last drive numer used to
reference that drive (1 = A:, etc.). Thus, on a machine which has a
single floppy drive, calling ioctl (1, DOS_GLDRVMAP);
will return
2 if the floppy was last refered to as B:. This function and the next
one can be used together to prevent DOS from popping the ugly prompt
saying "Insert diskette for drive B: and press any key when ready".
DOS_SLDRVMAP
ioctl (1, DOS_SLDRVMAP); |
will cause drive A: to be mapped to drive B:.
DOS_QGIOCTLCAPH
int ret_val = ioctl (fd, DOS_QGIOCTLCAPH, category_and_function); |
This will return zero if the specified IOCTL function is supported, 1 if not.
DOS_QGIOCTLCAPD
If your specific device driver requires different commands, they must be or'ed
together with the flags listed in <sys/ioctl.h>
to tell the drive about
transfer buffers and what to return.
Disk file:
#include <sys/ioctl.h> int main(int argc, char **argv) { char buf[6]; short *s; open(fd,"EMMQXXX0",O_RDONLY); mybuf[0] = '\0'; s = mybuf; ioctl(fd,DOS_SNDDATA,6, (int) &mybuf); if(*s ==0x25 )printf("EMM386 >= 4.45\n"); mybuf[0]='\x02'; ioctl(fd,DOS_SNDDATA,2,(int )&mybuf); printf("EMM Version %d.%d\n",(int )mybuf[0],(int) mybuf[1]); close(fd); } |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
webmaster | delorie software privacy |
Copyright © 2004 | Updated Apr 2004 |