/* mscdex.h */
/* Copyright (C) 1994 Yggdrasil Computing, Incorporated
   4880 Stevens Creek Blvd. Suite 205
   San Jose, CA 95129-1034
   USA
   Tel (408) 261-6630
   Fax (408) 261-6631

   This file is part of the Linux Kernel

   Linux 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, or (at your option)
   any later version.

   Linux 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 Linux; see the file COPYING.  If not, write to
   the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
/* Written by Ross Biro July 1994 */
#ifndef __MSCDEX_H__
#define __MSCDEX_H__

#if 0
#undef __attribute__
#define __attribute__(x)
#endif

#include <linux/types.h>

#ifdef __GNUC__
#include "system.h"
#endif

struct ioctlhdr {
  unsigned char len;
  unsigned char subunit;
  unsigned char command;
  unsigned short status __attribute__ ((packed));
  char reserved[8] __attribute__ ((packed));
};

struct ioctlplay {
  struct ioctlhdr hdr;
  unsigned char descr __attribute__ ((packed));
  unsigned short toff __attribute__ ((packed));
  unsigned short tseg __attribute__ ((packed));
  unsigned short tlen __attribute__ ((packed));
  unsigned short num __attribute__ ((packed));
};

struct ioctlread {
  struct ioctlhdr hdr;
  unsigned char descr;
  unsigned short toff __attribute__ ((packed));
  unsigned short tseg __attribute__ ((packed));
  unsigned short tlen __attribute__ ((packed));
  unsigned short num __attribute__ ((packed));
  unsigned short sector __attribute__ ((packed));
  unsigned short voloff __attribute__ ((packed));
  unsigned short volseg __attribute__ ((packed));
};

struct ioreadlong {
  struct ioctlhdr hdr;
  u_char descr;
  u_short toff;   /* offset of buffer to put reads in */
  u_short tseg;   /* segment of buffer to put reads in */
  u_short num;    /* number of sectors */
  u_short startl; /* lower byte of starting sector */
  u_short starth; /* upper byte of starting sector */
  u_char read_mode;
  u_char isize;  /* interleave size */
  u_char ifact;  /* interleave skip factor */
};

struct ioctlstop {
  struct ioctlhdr hdr;
};

struct ioctlresume {
  struct ioctlhdr hdr;
};

struct sector_size {
  char command;
  char read_mode;
  uint16 size;
};

#ifndef __KERNEL__
extern int ismscdex (void);
extern int numdrvs (void);
extern int firstdrv (void);
extern double mscdex_ver (void);
extern void senddevreq (int arg1, int arg2);
extern void cdstop (int drive);
#endif /* __KERNEL__ */

/* MSCDEX COMMANDS */
#define MSCDEX_INT	0x2f
#define MSCDEX_BASE	0x1500

#define MSCDEX_GETNUM	(MSCDEX_BASE | 0x00)
#define MSCDEX_READ	(MSCDEX_BASE | 0x08)
#define MSCDEX_GETDRVS	(MSCDEX_BASE | 0x0d)
#define MSCDEX_DEVREQ	(MSCDEX_BASE | 0x10)
#define MSCDEX_VER      (MSCDEX_BASE | 0x0C)

/* defines for DOS COMMANDS */
#define CD_IOCTLI	  3
#define CD_IOCTLO	 12
#define CD_SEEK	        131
#define CD_PLAY_AUDIO	132
#define CD_STOP_AUDIO	133
#define CD_RESUME_AUDIO	136
#define CD_READ_LONG    128

/* Defines for the DOS IOCTL IN's */
#define DIO_DEVICE_HEADER	 0
#define DIO_HEAD_LOCATION	 1
#define DIO_AUDIO_CINFO		 4
#define DIO_READ_DRIVE		 5
#define DIO_DEV_STATUS		 6
#define DIO_SEC_SIZE		 7
#define DIO_VOL_SIZE	 	 8
#define DIO_MED_CHANGE		 9
#define DIO_AUDIO_DINFO		10
#define DIO_AUDIO_TINFO		11
#define DIO_AUDIO_QINFO		12
#define DIO_AUDIO_SINFO		13
#define DIO_UPC_CODE		14
#define DIO_AUDIO_STATUS	15

#define DIO_DEVICE_HEADER_LEN 		  5
#define DIO_HEAD_LOCATION_LEN		  6
#define DIO_AUDIO_CINFO_LEN 		  9
#define DIO_READ_DRIVE_LEN 		130
#define DIO_DEV_STATUS_LEN		  5
#define DIO_SEC_SIZE_LEN		  4
#define DIO_VOL_SIZE_LEN		  5
#define DIO_MED_CHANGE_LEN		  2
#define DIO_AUDIO_DINFO_LEN		  7
#define DIO_AUDIO_TINFO_LEN		  7
#define DIO_AUDIO_QINFO_LEN		 11
#define DIO_AUDIO_SINFO_LEN		 13
#define DIO_UPC_CODE_LEN		 11
#define DIO_AUDIO_STATUS_LEN	 11

/* Defines for DOS IOCTL OUT's */
#define DIO_RESET	2
#define DIO_RESET_LEN	1


#define SECTOR_SIZE 2048 /* we should really figure out what this is. */
#define MAJOR_NR MSCDEX_MAJOR

#endif
