/*++

Copyright (c) 1990-2011 Microsoft Corporation, All Rights Reserved
 
Module Name:

    gpioctl.h  

Version:
    V1.5

Abstract:   Include file for Generic Port I/O Example Driver


Author:    Robert R. Howell  January 8, 1993


Revision History:

 Robert B. Nelson (Microsoft)     March 1, 1993
 Epson Chiang (MOXA)		  September 3, 2010		First Release 	
 Epson Chiang (MOXA)		  Add Super IO definition	Feb 13, 2011
Epson Chiang (MOXA)		  Add Super IO definition	Feb 13, 2011
 				  

--*/

#if     !defined(__GPIOCTL_H__)
#define __GPIOCTL_H__

//
// Define the IOCTL codes we will use.  The IOCTL code contains a command
// identifier, plus other information about the device, the type of access
// with which the file must have been opened, and the type of buffering.
//
typedef struct _DIO {
	int	port;
	int	data;
} DIO, *PDIO;

typedef struct _GPIO {
	int	port;
	int	data;
} GPIO, *PGPIO;

typedef struct _SUPERIO {
	int		logic_device;
	int	 	index_port;
	int		data_port;
	UCHAR	reg_offset;
	UCHAR	reg_data;
} SUPERIO, *PSUPERIO;

//
// Device type           -- in the "User Defined" range."
// The IOCTL function codes from 0x800 to 0xFFF are for customer use.

#define GPD_TYPE 40000

// The IOCTL function codes from 0x800 to 0xFFF are for customer use.
#define MOXA_IOCTL              0x800
#define IOCTL_SET_MODE   CTL_CODE(FILE_DEVICE_SERIAL_PORT, MOXA_IOCTL+23,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_GET_MODE   CTL_CODE(FILE_DEVICE_SERIAL_PORT, MOXA_IOCTL+24,METHOD_BUFFERED,FILE_ANY_ACCESS)


#define MOXA_DIO_IOCTL 0x900 

#define IOCTL_SET_DOUT_ALL \
    CTL_CODE( GPD_TYPE, MOXA_DIO_IOCTL, METHOD_BUFFERED, FILE_ANY_ACCESS ) //0x900
    
#define IOCTL_GET_DOUT_ALL \
    CTL_CODE(GPD_TYPE,  MOXA_DIO_IOCTL+1, METHOD_BUFFERED, FILE_ANY_ACCESS)//0x901

#define IOCTL_SET_DOUT \
    CTL_CODE( GPD_TYPE, MOXA_DIO_IOCTL+2, METHOD_BUFFERED, FILE_ANY_ACCESS )//0x902

#define IOCTL_GET_DOUT \
    CTL_CODE( GPD_TYPE, MOXA_DIO_IOCTL+3, METHOD_BUFFERED, FILE_ANY_ACCESS )//0x903

#define IOCTL_GET_DIN_ALL \
    CTL_CODE(GPD_TYPE,  MOXA_DIO_IOCTL+4, METHOD_BUFFERED, FILE_ANY_ACCESS) //0x904

#define IOCTL_GET_DIN \
    CTL_CODE( GPD_TYPE, MOXA_DIO_IOCTL+5, METHOD_BUFFERED, FILE_ANY_ACCESS ) //0x905
    
#define IOCTL_SET_COUNTER_PCI \
    CTL_CODE(GPD_TYPE,  MOXA_DIO_IOCTL+6, METHOD_BUFFERED, FILE_ANY_ACCESS ) //0x906
    
#define IOCTL_GET_COUNTER_PCI \
    CTL_CODE(GPD_TYPE,  MOXA_DIO_IOCTL+7, METHOD_BUFFERED, FILE_ANY_ACCESS ) //0x907

#define IOCTL_CLEAR_COUNTER_PCI \
    CTL_CODE(GPD_TYPE,  MOXA_DIO_IOCTL+8, METHOD_BUFFERED, FILE_ANY_ACCESS ) //0x908


#define MOXA_GPIO_IOCTL 0x910 

#define IOCTL_GPIO_SET \
    CTL_CODE(GPD_TYPE,  MOXA_GPIO_IOCTL, METHOD_BUFFERED, FILE_ANY_ACCESS ) //0x910

#define IOCTL_GPIO_GET \
    CTL_CODE(GPD_TYPE,  MOXA_GPIO_IOCTL+1, METHOD_BUFFERED, FILE_ANY_ACCESS ) //0x911
    
#define IOCTL_GPIO_SET_MODE \
    CTL_CODE(GPD_TYPE,  MOXA_GPIO_IOCTL+2, METHOD_BUFFERED, FILE_ANY_ACCESS )//0x912

#define IOCTL_GPIO_GET_MODE \
    CTL_CODE(GPD_TYPE,  MOXA_GPIO_IOCTL+3, METHOD_BUFFERED, FILE_ANY_ACCESS )//0x913

#define IOCTL_SET_LED \
    CTL_CODE(GPD_TYPE,  MOXA_GPIO_IOCTL+4, METHOD_BUFFERED, FILE_ANY_ACCESS )//0x914

#define IOCTL_GET_LED \
    CTL_CODE(GPD_TYPE,  MOXA_GPIO_IOCTL+5, METHOD_BUFFERED, FILE_ANY_ACCESS ) //0x915
    
#define IOCTL_SUPERIO_SET \
    CTL_CODE(GPD_TYPE,  MOXA_GPIO_IOCTL+4, METHOD_BUFFERED, FILE_ANY_ACCESS )//0x914

#define IOCTL_SUPERIO_GET \
    CTL_CODE(GPD_TYPE,  MOXA_GPIO_IOCTL+5, METHOD_BUFFERED, FILE_ANY_ACCESS ) //0x915
    
    
    
#define MOXA_BIOS_IOCTL 0x920 

#define IOCTL_SET_BIOSINFO \
    CTL_CODE( GPD_TYPE, MOXA_BIOS_IOCTL, METHOD_BUFFERED, FILE_WRITE_ACCESS ) //0x920

#define IOCTL_GET_BIOSINFO \
    CTL_CODE( GPD_TYPE, MOXA_BIOS_IOCTL+1, METHOD_BUFFERED, FILE_WRITE_ACCESS )//0x921

#define IOCTL_SET_LVDS_SETTING \
    CTL_CODE( GPD_TYPE, MOXA_BIOS_IOCTL+2, METHOD_BUFFERED, FILE_WRITE_ACCESS )//0x922
    
#define IOCTL_GET_LVDS_SETTING \
    CTL_CODE( GPD_TYPE, MOXA_BIOS_IOCTL+3, METHOD_BUFFERED, FILE_WRITE_ACCESS )//0x923
    
    
#define MOXA_MEMORY_IOCTL 0x930
#define IOCTL_MEMORY_SET \
    CTL_CODE(GPD_TYPE,  MOXA_MEMORY_IOCTL, METHOD_BUFFERED, FILE_ANY_ACCESS) //0x930

#define IOCTL_MEMORY_GET \
    CTL_CODE(GPD_TYPE,  MOXA_MEMORY_IOCTL+1, METHOD_BUFFERED, FILE_ANY_ACCESS) //0x931
    

#define MOXA_IEEE1588_IOCTL 0x940
	
#define GET_RX_TIMESTAMP_SYNC \
    CTL_CODE(GPD_TYPE,  MOXA_IEEE1588_IOCTL, METHOD_BUFFERED, FILE_ANY_ACCESS) //0x940
	
#define GET_RX_TIMESTAMP_DEL_REQ \
    CTL_CODE(GPD_TYPE,  MOXA_IEEE1588_IOCTL+1, METHOD_BUFFERED, FILE_ANY_ACCESS) //0x941 
    
#define GET_RX_TIMESTAMP_PDEL_REQ \
    CTL_CODE(GPD_TYPE,  MOXA_IEEE1588_IOCTL+2, METHOD_BUFFERED, FILE_ANY_ACCESS) //0x942   

#define GET_RX_TIMESTAMP_PDEL_RESP \
    CTL_CODE(GPD_TYPE,  MOXA_IEEE1588_IOCTL+3, METHOD_BUFFERED, FILE_ANY_ACCESS) //0x943    
        
#define GET_TX_TIMESTAMP \
    CTL_CODE(GPD_TYPE,  MOXA_IEEE1588_IOCTL+4, METHOD_BUFFERED, FILE_ANY_ACCESS) //0x944    
    
#define GET_SYS_TIMESTAMP \
    CTL_CODE(GPD_TYPE,  MOXA_IEEE1588_IOCTL+5, METHOD_BUFFERED, FILE_ANY_ACCESS) //0x945      

#define SET_SYS_TIMESTAMP \
    CTL_CODE(GPD_TYPE,  MOXA_IEEE1588_IOCTL+6, METHOD_BUFFERED, FILE_ANY_ACCESS) //0x946  
    
#define ADJ_ADDEND \
    CTL_CODE(GPD_TYPE,  MOXA_IEEE1588_IOCTL+7, METHOD_BUFFERED, FILE_ANY_ACCESS) //0x947      

#define ADJ_FREQ \
    CTL_CODE(GPD_TYPE,  MOXA_IEEE1588_IOCTL+8, METHOD_BUFFERED, FILE_ANY_ACCESS) //0x948     
    
#define CLEAN_RX_TIME \
    CTL_CODE(GPD_TYPE,  MOXA_IEEE1588_IOCTL+9, METHOD_BUFFERED, FILE_ANY_ACCESS) //0x949      

#define CLEAN_TX_TIME \
    CTL_CODE(GPD_TYPE,  MOXA_IEEE1588_IOCTL+0xA, METHOD_BUFFERED, FILE_ANY_ACCESS) //0x94A 
    
#define MOXA_HTSP_IOCTL 0x950                   

#define IOCTL_GET_DISK_STATUS\
    CTL_CODE(GPD_TYPE,  MOXA_HTSP_IOCTL, METHOD_BUFFERED, FILE_ANY_ACCESS) //0x950 

#define IOCTL_SET_DISK_LED\
    CTL_CODE(GPD_TYPE,  MOXA_HTSP_IOCTL+1, METHOD_BUFFERED, FILE_ANY_ACCESS) //0x951 

#define IOCTL_GET_DISK_BTN\
    CTL_CODE(GPD_TYPE,  MOXA_HTSP_IOCTL+2, METHOD_BUFFERED, FILE_ANY_ACCESS) //0x952 

#define IOCTL_CHECK_DISK_PLUGGED\
    CTL_CODE(GPD_TYPE,  MOXA_HTSP_IOCTL+3, METHOD_BUFFERED, FILE_ANY_ACCESS) //0x953 


#endif

