/* vim: set filetype=c:
 *
 * ioctl.h86  -  DOS IOCTL interface
 *
 * Copyright (C) 2003-2007 Gero Kuhlmann <gero@gkminix.han.de>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * $Id: ioctl.h86,v 1.5 2007/01/06 18:30:53 gkminix Exp $
 */

#ifndef DOS_IOCTL_H86
#define DOS_IOCTL_H86


/*
 * This file can only get included into target C or assembler source files.
 */
#define GCC_INCLUDE
#include <compiler.h>



/*
 ***************************************************************************
 *
 * Subfunction codes for IOCTL call:
 */
#define DOS_IOCTL_GETINFO	0	/* get device information */
#define DOS_IOCTL_SETINFO	1	/* set device information */
#define DOS_IOCTL_RDCHAR	2	/* read from char device control ch. */
#define DOS_IOCTL_WRCHAR	3	/* write to char device control ch. */
#define DOS_IOCTL_RDBLOCK	4	/* read from block device control ch. */
#define DOS_IOCTL_WRBLOCK	5	/* write to block device control ch. */
#define DOS_IOCTL_INSTS		6	/* get device input status */
#define DOS_IOCTL_OUTSTS	7	/* get device output status */
#define DOS_IOCTL_REMOVE	8	/* check if block device is removable */
#define DOS_IOCTL_DEVREM	9	/* check if block device is remote */
#define DOS_IOCTL_HDLREM	10	/* check if handle is remote */
#define DOS_IOCTL_RTRYCNT	11	/* set sharing retry count */
#define DOS_IOCTL_CHARREQ	12	/* generic char device request */
#define DOS_IOCTL_BLOCKREQ	13	/* generic block device request */
#define DOS_IOCTL_GETDRVMAP	14	/* get logical drive map */
#define DOS_IOCTL_SETDRVMAP	15	/* set logical drive map */
#define DOS_IOCTL_QRYHANDLE	16	/* query IOCTL capability (handle) */
#define DOS_IOCTL_QRYDRV	17	/* query IOCTL capability (drive) */



/*
 ***************************************************************************
 *
 * DOS generic IOCTL device category codes:
 */
#define DOS_CAT_COM		0x01	/* serial port */
#define DOS_CAT_CON		0x03	/* console */
#define DOS_CAT_LPT		0x05	/* printer */
#define DOS_CAT_DISK		0x08	/* disk drive */
#define DOS_CAT_FAT32		0x48	/* FAT32 disk drive */



/*
 ***************************************************************************
 *
 * Function codes for generic block device request:
 */
#define DOS_GEN_SETPARAMS	0x40	/* set device parameters */
#define DOS_GEN_WRITETRACK	0x41	/* write physical track */
#define DOS_GEN_FORMATTRACK	0x42	/* format physical track */
#define DOS_GEN_SETSERIAL	0x46	/* set volume serial number */
#define DOS_GEN_SETACCESS	0x47	/* set access flag */
#define DOS_GEN_SETLOCK		0x48	/* set media lock state */
#define DOS_GEN_EJECTMEDIA	0x49	/* eject media */
#define DOS_GEN_LOCKLOGICAL	0x4A	/* lock logical volume */
#define DOS_GEN_LOCKPHYSICAL	0x4B	/* lock physical volume */
#define DOS_GEN_GETPARAMS	0x60	/* get device parameters */
#define DOS_GEN_READTRACK	0x61	/* read physical track */
#define DOS_GEN_VERIFYTRACK	0x62	/* verify physical track */
#define DOS_GEN_GETSERIAL	0x66	/* get volume serial number */
#define DOS_GEN_GETACCESS	0x67	/* get access flag */
#define DOS_GEN_GETMEDIAID	0x68	/* get media type */
#define DOS_GEN_UNLOCKLOGICAL	0x6A	/* unlock logical volume */
#define DOS_GEN_UNLOCKPHYSICAL	0x6B	/* unlock physical volume */
#define DOS_GEN_GETLOCK		0x6C	/* get lock flag */
#define DOS_GEN_DRIVEMAP	0x6F	/* get drive map */



/*
 ***************************************************************************
 *
 * Parameter blocks for generic IOCTL device requests:
 */

/*
 * Functions 0x40 and 0x60: Set / get device parameters
 */
#define DOS_GEN_BPBSIZE	31

#ifndef _ASSEMBLY_

struct dos_gen_func40 {
	__u8    special;		/* special function bit flags */
	__u8    type;			/* device type */
	__u16   attrib;			/* device attributes */
	__u16   cylinders;		/* number of cylinders */
	__u8    media;			/* media type */
	__u8    bpb[DOS_GEN_BPBSIZE];	/* BPB */
};

#else

			.struct	0
dos_gen40_special:	.struct	.+1	/* special function bit flags */
dos_gen40_type:		.struct	.+1	/* device type */
dos_gen40_attrib:	.struct	.+2	/* device attributes */
dos_gen40_cylinders:	.struct	.+2	/* number of cylinders */
dos_gen40_media:	.struct	.+1	/* media type */
dos_gen40_bpb:		.struct	.+DOS_GEN_BPBSIZE

#endif


/*
 * Functions 0x41 and 0x61: Write / read physical track
 */
#ifndef _ASSEMBLY_

struct dos_gen_func41 {
	__u8    special;		/* special function bit flags */
	__u16   head;			/* disk head number */
	__u16   cylinder;		/* disk cylinder number */
	__u16   sector;			/* first sector number */
	__u16   sectnum;		/* number of sectors */
	__fptr  transfer;		/* transfer address */
};

#else

			.struct	0
dos_gen41_special:	.struct	.+1	/* special function bit flags */
dos_gen41_head:		.struct	.+2	/* disk head number */
dos_gen41_cylinder:	.struct	.+2	/* disk cylinder number */
dos_gen41_sector:	.struct	.+2	/* first sector number */
dos_gen41_sectnum:	.struct	.+2	/* number of sectors */
dos_gen41_transfer:	.struct	.+4	/* transfer address */

#endif


/*
 * Functions 0x42 and 0x62: Format / verify track
 */
#ifndef _ASSEMBLY_

struct dos_gen_func42 {
	__u8    special;		/* special function bit flags */
	__u16   head;			/* disk head number */
	__u16   cylinder;		/* disk cylinder number */
	__u16   tracknum;		/* number of tracks to process */
};

#else

			.struct	0
dos_gen42_special:	.struct	.+1	/* special function bit flags */
dos_gen42_head:		.struct	.+2	/* disk head number */
dos_gen42_cylinder:	.struct	.+2	/* disk cylinder number */
dos_gen42_tracknum:	.struct	.+2	/* number of tracks to process */

#endif


/*
 * Functions 0x46 and 0x66: Set / get volume name and serial number
 */
#ifndef _ASSEMBLY_

struct dos_gen_func46 {
	__u16   info;			/* info level */
	__u32   serial;			/* disk serial number */
	__u8    buf[19];		/* buffer for names */
};

#else

			.struct	0
dos_gen46_info:		.struct	.+2	/* info level */
dos_gen46_serial:	.struct	.+4	/* disk serial number */
dos_gen46_buf:		.struct	.+19	/* buffer for names */

#endif


/*
 * Functions 0x47 and 0x67: Set / get access flag
 */
#ifndef _ASSEMBLY_

struct dos_gen_func47 {
	__u8    special;		/* special function bit flags */
	__u8    flag;			/* access flag */
};

#else

			.struct	0
dos_gen47_special:	.struct	.+1	/* special function bit flags */
dos_gen47_flag:		.struct	.+1	/* access flag */

#endif


/*
 * Function 0x68: Get media ID
 */
#ifndef _ASSEMBLY_

struct dos_gen_func68 {
	__u8    special;		/* special function bit flags */
	__u8    mediaid;		/* media ID */
};

#else

			.struct	0
dos_gen68_special:	.struct	.+1	/* special function bit flags */
dos_gen68_mediaid:	.struct	.+1	/* media ID */

#endif


/*
 * Function 0x6F: Get drive map
 */
#ifndef _ASSEMBLY_

struct dos_gen_func6F {
	__u8    size;			/* size of this structure */
	__u8    len;			/* buffer size actually used */
	__u8    flags;			/* drive flags */
	__u8    drvnum;			/* physical drive number */
	__u32   drvmap;			/* drive map */
	__u32   partition[2];		/* block address of partition start */
};

#else

			.struct	0
dos_gen6F_size:		.struct	.+1	/* size of this structure */
dos_gen6F_len:		.struct	.+1	/* buffer size actually used */
dos_gen6F_flags:	.struct	.+1	/* drive flags */
dos_gen6F_drvnum:	.struct	.+1	/* physical drive number */
dos_gen6F_drvmap:	.struct	.+4	/* drive map */
dos_gen6F_partition:	.struct	.+8	/* block address of partition start */


#define DOS_GEN6F_LENGTH	16	/* size of structure */

#endif


#endif

