


/****************************************************************************
;
; NAME: osioctl.h
;
;
; DESCRIPTION:
;
;       Linux driver ioctl definitions
;
;
; REVISION HISTORY:
;
;       $Log: /ESASHBA2/Linux/driver/osioctl.h $
; 
; 8     10/07/08 4:48p Jseba
; ESAS2HBA support
; 
; 7     4/24/08 11:36a Jseba
; SmpIoctl stuff
; 
; 6     4/16/08 10:12a Jseba
; Add I2C stuff
; 
; 5     8/28/06 11:19a Jseba
; Support for ESASRAID driver
; 
; 4     12/28/04 9:49a Jseba
; Added EXPRESS_TSDK_DUMP (for internal use only - not enabled in release
; builds)
; 
; 3     11/19/04 11:21a Jseba
; MEMADDR/MEMRW support
; 
; 2     6/09/04 4:50p Jseba
; Update IOCTL_* definitions
; 
; 1     10/24/03 2:42p Jseba
; Initial entry
; 
; 
; 
;
;
; THIS PROGRAM AND THE INFORMATION CONTAINED HEREIN IS THE PROPERTY OF
; ATTO TECHNOLOGY, INC. AND SHALL NOT BE REPRODUCED, COPIED, OR USED IN
; WHOLE OR IN PART OTHER THAN AS PROVIDED FOR IN THE LICENSE AGREEMENT
; PURSUANT TO WHICH IT WAS FURNISHED.
;
; COPYRIGHT (c) ATTO TECHNOLOGY, INC. 2003
; ALL RIGHTS RESERVED.
;
;***************************************************************************/

#ifndef _OSIOCTL_H_
#define _OSIOCTL_H_

#include "hwtypes.h"
#ifdef CELERITYFC
#include "hwattotg.h"
#endif
#if defined (ESASHBA) || defined (ESAS2HBA) 
#include "hwismp.h"
#endif
#ifdef ESAS2HBA
#include "hwisastm.h"
#endif

#define EXPRESS_IOCTL_SIGNATURE        "Express"
#define EXPRESS_IOCTL_SIGNATURE_SIZE   8

/* Structure definitions for IOCTLs */

typedef struct _express_ioctl_header {
    BYTE            Signature [EXPRESS_IOCTL_SIGNATURE_SIZE];
    BYTE            ReturnCode;
/* PLEASE NOTE!  These definitions have been changed */
/*               starting with CelerityFC v1.30      */

#define IOCTL_SUCCESS               0   /* All good                     */

/* Note: error codes 1-5 (IOCTL_TARGET_ERR_...) */
/*       are now defined in HWATTOTGT.H         */

#define IOCTL_ERR_INVCMD          101   /* Unrecognized IOCTL code      */
#define IOCTL_INIT_FAILED         102   /* Adapter init failed          */
#define IOCTL_NOT_IMPLEMENTED     103   /* Unimplemented IOCTL          */
#define IOCTL_BAD_CHANNEL         104   /* Invalid Channel number       */
#define IOCTL_TARGET_OVERRUN      105   /* Data overrun (GET_INIT_INFO) */
#define IOCTL_TARGET_NOT_ENABLED  106   /* Target Mode not enabled      */
#define IOCTL_BAD_FLASH_IMGTYPE   107   /* Invalid FIRMWARERW.ImgType   */
#define IOCTL_OUT_OF_RESOURCES    108   /* Temporarily out of resources */
#define IOCTL_GENERAL_ERROR       109   /* Unspecified error occurred   */

    BYTE            Channel;
    BYTE            Retries;
    BYTE            Pad [5];
} EXPRESS_IOCTL_HEADER,
*PEXPRESS_IOCTL_HEADER;

/* NOTE - if Channel == 0xFF, the request is */
/* handled on the adapter it came in on.     */

#define MAX_NODE_NAMES  256

#ifdef CELERITYFC
typedef struct _express_target_init_inf {
    DWORD           Count;      /*  1c  Number of valid entries returned*/
    WWN             NodeName [MAX_NODE_NAMES];
                                /*  20  Array of logged in node names   */
} EXPRESS_TARGET_GET_INIT_INFO, /* 820  Size of structure               */
*PEXPRESS_TARGET_GET_INIT_INFO;

typedef union _express_target_initialize {
    IOCTL_TARGET_INITIALIZE_INPUT    Input;
    IOCTL_TARGET_INITIALIZE_INPUT_V2 InputV2;
    IOCTL_TARGET_INITIALIZE_OUTPUT   Output;
    FCTMD_INFO                       Info;
} EXPRESS_TARGET_INITIALIZE,
*PEXPRESS_TARGET_INITIALIZE;
#endif

typedef struct FirmwareRwRequest {  /* EXPRESS_IOCTL_RW_FIRMWARE        */
    BYTE        Function;           /*  00 Read or write firmware       */
        #define FUNC_FW_DOWNLOAD        0x09
        #define FUNC_FW_UPLOAD          0x12

    BYTE        ImgType;            /*  01 Image Type                   */
        #define FW_IMG_FM_API           0x05 /* Flash Memory API image  */

    BYTE        Pad[2];             /*  02 Pad                          */
    DWORD       ImgOffset;          /*  04 Image offset                 */
    DWORD       ImgSize;            /*  08 Image Size                   */
    BYTE        Image [0x80000];    /*  0c Image Data                   */
} FIRMWARERW, *PFIRMWARERW;         /* 8000c Size of Structure          */

typedef struct ParamRwRequest { /* EXPRESS_IOCTL_(READ/WRITE)_PARAMS    */
    WORD        Code;               /*  00  Returned result code        */
                                    /*      1 == Success                */
    char        DataBuffer [512];   /*  02  NVRAM header & data, see    */
                                    /*      flash.h                     */
} PARAMRW, *PPARAMRW;               /* 102  Size of structure           */

#define MAX_CHANNEL 256

typedef struct ChannelList { /* EXPRESS_IOCTL_GET_CHANNELS              */
    DWORD       NumChannels;           /*  00  Num of channels in list  */
    BYTE        Channel [MAX_CHANNEL]; /*  04  List of channels         */
} CHANNELLIST, *PCHANNELLIST;          /* 104  Size of structure        */

typedef struct ChannelInfo { /* EXPRESS_IOCTL_CHAN_INFO                 */
    BYTE        MajorRev;       /*  00  Driver major revision number    */
    BYTE        MinorRev;       /*  01  Driver minor revision number    */
    BYTE        IRQ;            /*  02  Interrupt request level         */
    BYTE        RevisionId;     /*  03  PCI Revision ID                 */
    BYTE        PciBus;         /*  04  PCI Bus Number                  */
    BYTE        PciDevFunc;     /*  05  PCI Device/Function             */
    BYTE        CoreRev;        /*  06  Core driver revision            */
    BYTE        HostNo;         /*  07  host->host_no from SCSI driver  */
    WORD        DeviceId;       /*  08  PCI Device ID                   */
    WORD        VendorId;       /*  0a  PCI Vendor ID                   */
    WORD        VenDevId;       /*  0c  Subsystem ID                    */
    BYTE        Pad [3];        /*  0d  Reserved                        */
    DWORD       HBAAPIRev;      /*  10  HBA API rev (ATTO_API_VERSION)  */
} CHANNELINFO, *PCHANNELINFO;   /*  14  Size of structure               */

typedef struct MemoryAddrRequest {  /* EXPRESS_ADDR_MEMORY              */
    PVOID       Data;               /*  00  Driver data area            */
    PVOID       Code;               /*  04  Code area                   */
    PVOID       Adapter;            /*  08  The Adapter structure       */
    PVOID       Globals;            /*  0c  Allocated Globals           */
    PVOID       Regs;               /*  10  Registers                   */
    PVOID       Reserved [11];      /*  14  Reserved for future use     */
} MEMADDR, *PMEMADDR;               /*  40  Size of structure           */

typedef struct MemoryRwRequest   {  /* EXPRESS_RW_MEMORY                */
    BYTE        Function;           /*  00 Read or write firmware       */
        #define FUNC_MEM_READ           0x00
        #define FUNC_MEM_WRITE          0x01
        #define FUNC_HUB_READ           0x02
        #define FUNC_HUB_WRITE          0x03
        #define FUNC_VDA_READ           0x04 /* Not implemented */
        #define FUNC_VDA_WRITE          0x05 /* Not implemented */
        #define FUNC_I2C_READ           0x06
        #define FUNC_I2C_WRITE          0x07

    BYTE        I2CDev;             /*  01 I2C Device address           */
    BYTE        I2CStat;            /*  02 I2C Status                   */
    BYTE        Pad [1];            /*  03 Pad                          */
    PBYTE       Address;            /*  04 Address to read/write        */
    DWORD       Length;             /*  08 Length to read/write         */
    BYTE        Image [0x80000];    /*  0c Image Data                   */
} MEMRW, *PMEMRW;                   /* 8000c Size of Structure          */

typedef struct TsdkDump          {  /* EXPRESS_TSDK_DUMP                */
    DWORD       CurrentTraceIndex;  /* 00 Current trace index           */
    DWORD       TraceBufferLength;  /* 04 Trace buffer length           */
    BYTE        Trace [0x80000];    /* 08 The trace                     */
} TSDKDUMP, *PTSDKDUMP;



typedef struct _express_ioctl
{
    EXPRESS_IOCTL_HEADER Header;

    union {
#ifdef CELERITYFC
        EXPRESS_TARGET_INITIALIZE    TargetInit;
        EXPRESS_TARGET_GET_INIT_INFO TargetGetInitInfo;
#endif
        FIRMWARERW                   fwrw;
        PARAMRW                      prw;
        CHANNELLIST                  chanlist;
        CHANNELINFO                  chaninfo;
        MEMADDR                      ma;
        MEMRW                        memrw;
        TSDKDUMP                     tsdkdump;
#ifdef ESASHBA
        HWIOCTL_SMP                  smpioctl;
#endif
#ifdef ESAS2HBA
        HWIOCTL_SASTM                sastm;
#endif
    } data;
} EXPRESS_IOCTL,
*PEXPRESS_IOCTL;

/* IOCTL cmd definitions */
/* Note that we don't use the size paramter in the IOCTL definitions, */
/* because EXPRESS_IOCTL is too large to be contained in this param.  */
/* The struct associated with the code is listed after the definition */

#define EXPRESS_IOCTL_MIN             0x4500

                                                /* IOCTL structure */
#define EXPRESS_IOCTL_RW_FIRMWARE     0x4500      /* FIRMWARERW    */
#define EXPRESS_IOCTL_READ_PARAMS     0x4501      /* PARAMRW       */
#define EXPRESS_IOCTL_WRITE_PARAMS    0x4502      /* PARAMRW       */
#define EXPRESS_IOCTL_FC_API          0x4503      /* internal      */
#define EXPRESS_IOCTL_GET_CHANNELS    0x4504      /* CHANNELLIST   */
#define EXPRESS_IOCTL_CHAN_INFO       0x4505      /* CHANNELINFO   */
#define EXPRESS_IOCTL_DEFAULT_PARAMS  0x4506      /* PARAMRW       */
#define EXPRESS_ADDR_MEMORY           0x4507      /* MEMADDR       */
#define EXPRESS_RW_MEMORY             0x4508      /* MEMRW         */
#define EXPRESS_TSDK_DUMP             0x4509      /* TSDKDUMP      */
#define EXPRESS_HWIOCTL_SMP           0x450A      /* HWIOCTL_SMP   */

#define EXPRESS_IOCTL_MAX             0x450A

/* The following are target mode ioctls.  These should *not* be used */
/* with the ioctl () call, rather they should be referenced through  */
/* the target_connect function - see the scsitmd sample driver.      */

#define EXPRESS_TARGET_INIT           0x4520      /* EXPRESS_TARGET_INITIALIZE    */
#define EXPRESS_TARGET_INIT_V2        0x4521      /* EXPRESS_TARGET_INITIALIZE    */
#define EXPRESS_TARGET_SHUTDOWN       0x4522      /* none                         */
#define EXPRESS_TARGET_GET_INFO       0x4523      /* EXPRESS_TARGET_GET_INFO      */
#define EXPRESS_TARGET_GET_INIT_INFO  0x4524      /* EXPRESS_TARGET_GET_INIT_INFO */

#ifdef ESAS2HBA
/* The following are only for the ESAS2HBA target mode interface */

#define ESAS2HBA_TARGET_CONTROL       0x4540
#define ESAS2HBA_TARGET_QUERY         0x4541
#endif

#endif /* _OSIOCTL_H_ */
