/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* bos72Q src/bos/kernel/sys/scdisk.h 1.38.4.3                            */
/*                                                                        */
/* Licensed Materials - Property of IBM                                   */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 1988,2018              */
/* All Rights Reserved                                                    */
/*                                                                        */
/* US Government Users Restricted Rights - Use, duplication or            */
/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.      */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
/* @(#)16       1.38.4.3  src/bos/kernel/sys/scdisk.h, sysxdisk, bos72Q, q2018_46B4 8/9/18 00:25:51 */
#ifndef _H_SCDISK
#define _H_SCDISK
/*
 * COMPONENT_NAME: (SYSXDISK) SCSI Disk Device Driver Include File
 *
 * FUNCTIONS:  NONE
 *
 * ORIGINS: 27
 *
 * (C) COPYRIGHT International Business Machines Corp. 1988, 2008
 *
 * All Rights Reserved
 * Licensed Materials - Property of IBM
 *
 * US Government Users Restricted Rights - Use, duplication or
 * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
 */

/************************************************************************/
/* scdisk.h header dependencies                                         */
/************************************************************************/

#include <sys/types.h>
#include <sys/scsi.h>

/************************************************************************/
/* SCSI CD-ROM, Disk, Read/Write Optical Drive Ioctls                   */
/************************************************************************/

#define DKIORDSE             0x01     /* Read and return sense data on*/
                                      /* error.                       */
#define DKIOWRSE             0x02     /* Write and return sense data  */
                                      /* on error.                    */
#define DKIOCMD              0x03     /* Issue a user-defined SCSI    */
                                      /* command                      */
#define DKEJECT              0x04     /* Eject Media from drive       */
#define DKPMR                0x05     /* Prevent media removal        */
#define DKAMR                0x06     /* Allow media removal          */
#define DKFORMAT             0x07     /* Format media                 */
#define DKAUDIO              0x08     /* CD-ROM Play Audio Operations */
#define DK_CD_MODE           0x09     /* Get or Change CD-ROM data    */
                                      /* modes                        */
#define DKIOLRDSE            0x10     /* Read and return sense data on*/
                                      /* error for SCSI-3 driver.     */
#define DKIOLWRSE            0x11     /* Write and return sense data  */
                                      /*on error for SCSI-3 driver.   */
#define DKIOLCMD             0x12     /* Issue a user-defined SCSI    */
                                      /* command for SCSI-3 driver.   */
#define DKIOCMD16            0x13     /* Issue a user-defined 16-byte */
                                      /* SCSI command                 */
#define DKUCFG_STOPU         0x14     /* Spindown disk on unconfigure */
#define DK_PASSTHRU          0x17     /* Issue user-defined SCSI      */
                                      /* command with argument of     */
                                      /* struct sc_passthru defined   */
                                      /* scsi.h                       */
#define DK_RWBUFFER          0x18     /* Issue SCSI Read Buffer or    */
                                      /* Write Buffer command         */
#define DKPRES_READKEYS      0x19     /* Persistent Reserve In command*/ 
                                      /* read keys service action     */ 
#define DKPRES_READRES       0x1a     /* Persistent Reserve In command*/
                                      /* read reservations ser action */
#define DKPRES_CLEAR         0x1b     /* Persistent ReserveOut command*/
                                      /* with clear service action    */
#define DKPRES_PREEMPT       0x1c     /* Persistent ReserveOut command*/
                                      /* with preempt service action  */
#define DKPRES_PREEMPT_ABORT 0x1d     /* Persistent ReserveOut command*/ 
                                      /* with preempt and abort       */
                                      /* service action               */
#define DKPRES_REGISTER      0x1e     /* Persistent ReserveOut command*/
                                      /* with Register & Ignore exist */
                                      /* ing key service action.      */
#define DKIORDSE16           0x1f     /* Read with up to 16-byte CDB  */
                                      /* and return sense data on     */
                                      /* error.                       */
#define DKIOWRSE16           0x20     /* Write with up to 16-byte CDB */
                                      /* and return sense data on     */
                                      /* error.                       */
#define DKPATHFORCE          0x30     /* Specify a single MPIO path   */
                                      /* for subsequent I/O           */
#define DKPATHIOCMD          0x31     /* Issue a user-defined SCSI    */
                                      /* command (like DKIOCMD16) to  */
                                      /* a specific MPIO path         */
#define DKPATHIOLCMD         0x32     /* Issue a user-defined SCSI    */
                                      /* command (like DKIOLCMD) to   */
                                      /* a specific MPIO path         */
#define DKPATHPASSTHRU       0x33     /* Issue user-defined SCSI      */
                                      /* command with argument of     */
                                      /* struct sc_passthru defined   */
                                      /* scsi.h to a speicific MPIO   */
                                      /* path                         */
#define DKPATHRWBUFFER       0x34     /* Issue SCSI Read Buffer or    */
                                      /* Write Buffer command to a    */
                                      /* specific MPIO path           */
#define DKPCMPASSTHRU        0x35     /* Issue a user-defined MPIO    */
                                      /* pass thru command            */
#define DKLOGSENSE           0x36     /* Issue LOG SENSE SCSI         */
                                      /* command with argument of     */
                                      /* struct sc_log_sense defined  */
                                      /* in scsi.h                    */
#define DKLOGSELECT          0x37     /* Issue LOG SELECT SCSI        */
                                      /* command with argument of     */
                                      /* struct sc_log_select defined */
                                      /* in scsi.h                    */
#define DKIOLRESLOCK         0x38     /* Get reserve_lock field of    */
                                      /* scsidisk_diskinfo structure  */

/************************************************************************/
/* Structure for the output of reserve_lock information in DKIOLRESLOCK */
/* ioctl.                                                               */
/************************************************************************/
struct reserve_lock {
        ushort          version;          /* Currently not taken as input */
                                          /* Will take effect if any      */
                                          /* change in this structure.    */
        uchar           cfg_reserve_lck;  /* reserve lock configurable    */
                                          /* attribute's value.           */
        uchar           reserve_lock;     /* Flag to lock target from     */
                                          /* other initiators.            */
};

/************************************************************************/
/* Structure for Play Audio Operations on CD-ROM drives                 */
/************************************************************************/

struct cd_audio_cmd {
       char   audio_cmds;      /* CD_ROM audio commands or*/
                               /* operations.*/

#define CD_PLAY_AUDIO      0x1  /* Plays Audio on CD-ROM drive  */
#define CD_PAUSE_AUDIO     0x2  /* Pause the current Play Audio */
                                /* operation.                   */
#define CD_RESUME_AUDIO    0x3  /* Resume the paused Play Audio */
                                /* operation.                   */
#define CD_STOP_AUDIO      0x4  /* Stop the current Play Audio  */
                                /* operation.                   */
#define CD_INFO_AUDIO      0x5  /* Get information on current   */
                                /* status of Play Audio         */
                                /* operation (i.e. track,       */
                                /* volume, and whether it is    */
                                /* paused or not).              */
#define CD_TRK_INFO_AUDIO  0x6  /* Get number of tracks or MSF  */
                                /* (minutes, seconds,frames) of */
                                /* last track/index on media.   */
#define CD_GET_TRK_MSF     0x7  /* Get MSF information on the   */
                                /* specified track.             */
#define CD_SET_VOLUME      0x8  /* Set the the audio volume of  */
                                /* the output ports of CD-ROM   */
                                /* drive. This value  can be    */
                                /* logically or'ed with:        */
                                /* CD_PLAY_AUDIO                */
                                /* CD_PAUSE_AUDIO               */
                                /* CD_RESUME_AUDIO              */
                                /* CD_STOP_AUDIO                */
                                /* CD_INFO_AUDIO                */
                                /* to create a one combined     */
                                /* command, which will set the  */
                                /* volume as well.              */


    char    msf_flag;           /* TRUE if Minutes, Seconds,    */
                                /* and Frames (MSF) is being    */
                                /* used.  FALSE if Track/Index  */
                                /* is being used.               */
                                /* This flag is ignored for the */
                                /* CD_INFO_AUDIO and            */
                                /* CD_GET_TRK_MSF operations,   */
                                /* since these operation use    */
                                /* both the current track       */
                                /* and current msf information. */
    union {
        struct {                /* If msf_flag is false use this*/
                                /* structure to specify location*/
            uchar first_track;
            uchar first_index;
            uchar last_track;
            uchar last_index;
            uchar resvd1;
            uchar resvd2;
        } track_index; 
        struct {                /* If msf_flag is true, use this*/
                                /* structure to specify location*/
            uchar first_mins;
            uchar first_secs;
            uchar first_frames;
            uchar last_mins;
            uchar last_secs;
            uchar last_frames;
        } msf;
        struct {                /* If the audio_cmds is         */
                                /* CD_INFO_AUDIO, then this     */
                                /* structure will be returned   */
                                /* with the current track/index */
                                /* and current msf location.    */
            uchar current_track;
            uchar current_index;
            uchar resvd1;
            uchar current_mins;
            uchar current_secs;
            uchar current_frames;			
        } info_audio;
        struct {                /* If the audio_cmds is         */
                                /* CD_GET_TRK_MSF, then this    */
                                /* structure is used. The       */
                                /* track field must be set by   */
                                /* the caller.  The mins,       */
                                /* seconds, and frames are      */
                                /* returned for the supplied    */
                                /* track.                       */
            uchar track;
            uchar resvd1;
            uchar resvd2;
            uchar mins;
            uchar secs;
            uchar frames;
        }track_msf;
      } indexing;
      uchar   volume_type;       /* Type of volume control to    */
                                 /* use.                         */

#define CD_VOLUME_ALL       0x1  /* Control the the volume of    */
                                 /* all output ports to one      */
                                 /* common volume level.         */
#define CD_VOLUME_CHNLS     0x2  /* Control the volume of        */
                                 /* individual output ports.     */
#define CD_ALL_AUDIO_MUTE   0x3  /* Mute all output ports.       */
				
#define CD_SET_AUDIO_CHNLS  0x4  /* Set up which audio channels  */
                                 /* map to which output ports of */
                                 /* the CD-ROM drive.            */

       uchar    all_channel_vol;  /* This specifies the common    */
                                  /* volume of all output ports   */
                                  /* when the CD_VOLUME_ALL       */
                                  /* volume type is used.         */
       uchar    status;           /* This field returns the status*/
                                  /* for the CD_INFO_AUDIO        */
                                  /* operation.                   */

#define CD_NO_AUDIO          0x9  /* No Play Audio in progress.   */
#define CD_COMPLETED         0xa  /* Play operation successfully  */
                                  /* completed.                   */
#define CD_STATUS_ERROR      0xb  /* Either invalid audio status  */
                                  /* or play operation stopped due*/
                                  /* to an error.                 */
#define CD_NOT_VALID         0xc  /* Audio status is not valid or */
                                  /* not supported.               */


       uchar     resvd1;          /* reserved for future expansion*/
       uchar     resvd2;          /* reserved for future expansion*/
       uchar     resvd3;          /* reserved for future expansion*/
       uchar     resvd4;          /* reserved for future expansion*/
       uint      resvd5;          /* reserved for future expansion*/
       uint      resvd6;          /* reserved for future expansion*/


       uchar     out_port_0_vol;  /* Controls the volume of output*/
                                  /* port 0 of the CD-ROM drive.  */
       uchar     out_port_1_vol;  /* Controls the volume of output*/
                                  /* port 1 of the CD-ROM drive.  */
       uchar     out_port_2_vol;  /* Controls the volume of output*/
                                  /* port 2 of the CD-ROM drive.  */
       uchar     out_port_3_vol;  /* Controls the volume of output*/
                                  /* port 3 of the CD-ROM drive.  */

       uchar     out_port_0_sel;  /* Specifies which audio channel*/
                                  /* maps to output port 0.       */
       uchar     out_port_1_sel;  /* Specifies which audio channel*/
                                  /* maps to output port 1.       */
       uchar     out_port_2_sel;  /* Specifies which audio channel*/
                                  /* maps to output port 2.       */
       uchar     out_port_3_sel;  /* Specifies which audio channel*/
                                  /* maps to output port 3.       */

/* The following defines are used for the above out_port selections */

#define CD_MUTE_PORT      0x0     /* Mute output port.            */
#define CD_AUDIO_CHNL_0   0x1     /* Use audio channel 0 for this */
                                  /* output port.                 */
#define CD_AUDIO_CHNL_1   0x2     /* Use audio channel 1 for this */
                                  /* output port.                 */
#define CD_AUDIO_CHNL_2   0x4     /* Use audio channel 2 for this */
                                  /* output port.                 */
#define CD_AUDIO_CHNL_3   0x8     /* Use audio channel 3 for this */
                                  /* output port.                 */



};

/************************************************************************/
/* Structure for CD-ROM Data Modes                                      */
/************************************************************************/

struct mode_form_op {
    uchar   action;         /* Determines if this operation  */
                            /* is to get the current CD-ROM  */
                            /* data mode or to change it to  */
                            /* the values specified below.   */

#define CD_GET_MODE    0x1  /* Get current CD-ROM data mode. */
#define CD_CHG_MODE    0x2  /* Change CD-ROM data mode.      */

    uchar   cd_mode_form;   /* Specifies the CD-ROM data     */
                            /* mode.                         */

#define CD_MODE1       0x1  /* CD-ROM Data Mode 1.           */
#define CD_MODE2_FORM1 0x2  /* CD-ROM XA Data Mode 2 Form 1  */
                            /* The device block size used    */
                            /* for this mode is 2048 bytes   */
                            /* per block                     */
#define CD_MODE2_FORM2 0x3  /* CD-ROM XA Data Mode 2 Form 2  */
                            /* The device block size used    */
                            /* for this mode is 2336 bytes   */
                            /* per block.                    */
#define CD_DA          0x4  /* CD-DA. The device block size  */
                            /* used for this mode is 2352    */
                            /* bytes per block.              */
#define DVD_ROM        0x5  /* DVD-ROM. The device block     */
                            /* size used for this mode is    */
                            /* 2048 bytes per block.         */
#define DVD_RAM        0x6  /* DVD-RAM. The device block     */
                            /* size used for this mode is    */
                            /* 2048 bytes per block.         */
#define DVD_RW         0x7  /* DVD-RW. The device block      */
                            /* size used for this mode is    */
                            /* 2048 bytes per block.         */
#define BD_ROM         0x8  /* BD-ROM The device block       */
                            /* size used for this mode is    */
                            /* 2048 bytes per block.         */
#define BD_REC         0x9  /* BD-REC. The device block      */
                            /* size used for this mode is    */
                            /* 2048 bytes per block.         */
    uchar   resvd1;         /* reserved for future expansion */
    uchar   resvd2;         /* reserved for future expansion */
    uchar   resvd3;         /* reserved for future expansion */
    uchar   resvd4;         /* reserved for future expansion */
    uchar   resvd5;         /* reserved for future expansion */
    uchar   resvd6;         /* reserved for future expansion */

};

/*
 * Persistent Reserve In - IOCTL structure.  This structure
 * supports DKPRES_READKEYS & DKPRES_READRES flags.  
 */
struct dk_pres_in {
    ushort  version;           /* Version of Persistent Reserve */
                               /* implementation.               */
    ushort  allocation_length; /* Allocation space for the      */
                               /* return parameters pertain to  */
                               /* reservation_info              */
    uint    generation;        /* counter maintain by the LUN to*/
                               /* keep track of reservation key */
                               /* on when it's being changed.   */
    uint    returned_length;   /* number of bytes in the        */
                               /* reservation key list.         */
    uchar   scsi_status;       /* scsi command status           */
    uchar   sense_key;         /* check condition data          */
    uchar   scsi_asc;          /* check condition data          */
    uchar   scsi_ascq;         /* check condition data          */
    uchar   *reservation_info; /* reservation key(s) data return*/
};

#ifdef _KERNEL
/*
 * NOTE: This structure is not supported for use by applications. It is only 
 *       for internal device driver use.
 * 
 * dk_pres_in is size variant for 32/64 bit, thus require two separate
 * structure to handle the size differences.
 */
struct dk_pres_in32 {
        ushort  version;                /* Version of Persistent Reserve */
                                        /* implementation.               */
        ushort  allocation_length;      /* Allocation space for the      */      
                                        /* return parameters pertain to  */
                                        /* reservation_info              */
        uint    generation;             /* counter maintain by the LUN to*/
                                        /* keep track of reservation key */
                                        /* on when it's being changed.   */
        uint    returned_length;        /* number of bytes in the        */
                                        /* reservation key list.         */
        uchar   scsi_status;            /* scsi command status           */
        uchar   sense_key;              /* check condition data          */
        uchar   scsi_asc;               /* check condition data          */
        uchar   scsi_ascq;              /* check condition data          */
        ptr32   reservation_info;       /* reservation key(s) data return*/
};

/*
 * NOTE: This structure is not supported for use by applications. It is only 
 *       for internal device driver use.
 *
 * dk_pres_in is size variant for 32/64 bit, thus require two separate
 * structure to handle the size differences.
 */
struct dk_pres_in64 {
        ushort  version;                /* Version of Persistent Reserve */
                                        /* implementation.               */
        ushort  allocation_length;      /* Allocation space for the      */      
                                        /* return parameters pertain to  */
                                        /* reservation_info              */
        uint    generation;             /* counter maintain by the LUN to*/
                                        /* keep track of reservation key */
                                        /* on when it's being changed.   */
        uint    returned_length;        /* number of bytes in the        */
                                        /* reservation key list.         */
        uchar   scsi_status;            /* scsi command status           */
        uchar   sense_key;              /* check condition data          */
        uchar   scsi_asc;               /* check condition data          */
        uchar   scsi_ascq;              /* check condition data          */
        ptr64   reservation_info;       /* reservation key(s) data return*/
};

#endif /* _KERNEL */

/*
 * Persistent Reserve Out - IOCTL structure.  This structure
 * supports DKPRES_CLEAR flag. 
 */
struct dk_pres_clear {
   ushort               version;        /* Version of Persistent Reserve */
                                        /* implementation.               */
   uchar              scsi_status;      /* scsi command status           */
   uchar              sense_key;        /* check condition data          */
   uchar              scsi_asc;         /* check condition data          */
   uchar              scsi_ascq;        /* check condition data          */

};

/*
 * Persistent Reserve Out - IOCTL structure.  This structure
 * supports DKPRES_PREEMPT & DKPRES_PREEMPT_ABORT flags.
 */
struct dk_pres_preempt {
   ushort               version;        /* Version of Persistent Reserve */
   unsigned long long preempt_key;      /* current key in the LUN being  */
                                        /* preempted.                    */
   uchar              scsi_status;      /* scsi command status           */
   uchar              sense_key;        /* check condition data          */
   uchar              scsi_asc;         /* check condition data          */
   uchar              scsi_ascq;        /* check condition data          */
};

/*
 * Persistent Reserve Out - IOCTL structure.  This structure
 * supports DKPRES_REGISTER flag.
 */
struct dk_pres_register {
   ushort             version;          /* Version of Persistent Reserve */
   uchar              scsi_status;      /* scsi command status           */
   uchar              sense_key;        /* check condition data          */
   uchar              scsi_asc;         /* check condition data          */
   uchar              scsi_ascq;        /* check condition data          */
};

/*
 * MPIO ioctl structure for DKPATHIOCMD DK_PATHPASSTHRU DK_PATHRWBUFFER
 */
typedef struct scdisk_pathiocmd {
   ushort                path_id;       /* path id to issue ioctl       */
   uint                  size; 
   void                  *path_iocmd;   /* cmd to issue                 */
}pathiocmd_t;

#ifdef _KERNEL

/*
 * NOTE: This structure is not supported for use by applications. It is only
 *       for internal device driver use.
 */
typedef struct scdisk_pathiocmd32 {     /* 32 bit version of path_iocmd */ 
   ushort                path_id;
   uint                  size;
   ptr32                 path_iocmd;
}pathiocmd32_t;

typedef struct scdisk_pathiocmd64 {     /* 64 bit version of path_iocmd */
   ushort                path_id;
   uint                  size;
   ptr64                 path_iocmd;
}pathiocmd64_t;

#endif


#endif /* _H_SCDISK */
