
/*M*                     
//                    INTEL CORPORATION PROPRIETARY INFORMATION
//      This software is supplied under the terms of a license agreement or
//      nondisclosure agreement with Intel Corporation and may not be copied
//      or disclosed except in accordance with the terms of that agreement.
//            Copyright (c) 1995-2000 Intel Corporation.  All Rights Reserved.
//
*M*/
/*
 * $Log:   \\cospublic004\shareddata\ISC\ISC2x\COMMON\SRC\imb\imb_if.h.v  $
 * 
 *    Rev 1.1   08 Dec 1998 10:55:44   jpaiasno
 * Added code to support async.
 * DPC events from the EMP console.
 * 
 *    Rev 1.8   03 Apr 1998 15:39:56   HMAHADEX
 * Added ifdef UNIX  around 
 * IOCTL_IMB_POLL_ASYNC
 * 
 *    Rev 1.7   24 Mar 1998 14:21:34   fkhanx
 * Added copyright Header
*/
#ifndef IMB_IF__

#define IMB_IF__

//
// This is the structure passed in to the IOCTL_IMB_SHUTDOWN_CODE request
//
typedef struct {
	int	code;		// values defined below
#define		SD_NO_ACTION				0
#define		SD_RESET					1
#define		SD_POWER_OFF				2

	int	delayTime;  // in units of 100 millisecond

} ShutdownCmdBuffer;

#pragma pack(1)
//
// This is the generic IMB packet format, the final checksum can't be
// represented in this structure and will show up as the last data byte
//
typedef struct {

	BYTE rsSa;
	BYTE nfLn;
	BYTE cSum1;
	BYTE rqSa;
	BYTE seqLn;
	BYTE cmd;
	BYTE data[1];

} ImbPacket;

#define MIN_IMB_PACKET_SIZE		7	// ImbPacket w/o data, but w/trailing checksum
#define MAX_IMB_PACKET_SIZE		33	// as per spec
//
// This is the standard IMB response format where the first byte of
// IMB packet data is interpreted as a command completion code.
//
typedef struct {

	BYTE rsSa;
	BYTE nfLn;
	BYTE cSum1;
	BYTE rqSa;
	BYTE seqLn;
	BYTE cmd;
	BYTE cCode;
	BYTE data[1];

} ImbRespPacket;

#define MIN_IMB_RESPONSE_SIZE	7	// min packet + completion code
#define MAX_IMB_RESPONSE_SIZE	MAX_IMB_PACKET_SIZE

/////////////////////////////////////////////////////////////////////////////////////////
//  ImbRequestBuffer
/////////////////////////////////////////////////////////////////////////////////////////

/*D*
//  Name:       ImbRequestBuffer
//  Purpose:    Structure definition for holding IMB message data
//  Context:    Used by SendTimedImbpMessage and SendTimedI2cMessge
//              functions in the library interface. In use, it is overlayed on a 
//				char buffer of size MIN_IMB_REQ_BUF_SIZE + 
//  Fields:     
//              respBufSize     size of the response buffer
//
//              timeout         timeout value in milli seconds   
//                     
//              req			    body of request to send
//              
*D*/			
typedef struct {
	BYTE rsSa;			// IMB address of responder
	BYTE cmd;			// IMB command
	BYTE netFn;			// netFn for command
	BYTE rsLun;			// logical unit on responder
	BYTE dataLength;	// length of following data
	BYTE data[1];		// request data
} ImbRequest;

typedef struct {

   DWORD		flags;			// request flags
#define				NO_RESPONSE_EXPECTED	0x01	// don't wait around for an IMB response

   DWORD		timeOut;		// in uSec units
   ImbRequest	req;			// message buffer

} ImbRequestBuffer;

#define MIN_IMB_REQ_BUF_SIZE	13	// a buffer without any request data

/////////////////////////////////////////////////////////////////////////////////////////
//  ImbResponseBuffer
/////////////////////////////////////////////////////////////////////////////////////////

/*D*
//  Name:       ImbResponseBuffer
//  Purpose:    Structure definition for response of a previous send 
//  Context:    Used by DeviceIoControl to pass the message to be sent to
//              MISSMIC port
//  Fields:     
//  			cCode		completion code returned by firmware
//              data		buffer for  response data from firmware
*D*/

typedef struct {
	BYTE       cCode;		// completion code		
	BYTE       data[1];		// response data buffer
} ImbResponseBuffer;

#define MIN_IMB_RESP_BUF_SIZE	1	// a buffer without any request data
#define MAX_IMB_RESP_SIZE		(MIN_IMB_RESP_BUF_SIZE + MAX_IMB_RESPONSE_SIZE)

#pragma pack()
//
// Async message access structures and types
//
typedef DWORD	ImbAsyncSeq;
//
// This is the structure passed in to IOCTL_IMB_GET_ASYNC_MSG
//
typedef struct {
	DWORD			timeOut;	// how long to wait for a message to come in
	ImbAsyncSeq		lastSeq;	// last message seen or ASYNC_SEQ_START
} ImbAsyncRequest;

#define ASYNC_SEQ_START		0	// starting sequence number

typedef struct {
	ImbAsyncSeq		thisSeq;	// tag for returned message
	BYTE data[1];
} ImbAsyncResponse;

#define MIN_ASYNC_RESP_SIZE		sizeof( ImbAsyncSeq )
#define MAX_ASYNC_RESP_SIZE		(MIN_ASYNC_RESP_SIZE + MAX_IMB_PACKET_SIZE)
//
// Driver Ioctls
//
#define FILE_DEVICE_IMB			0x00008010
#define IOCTL_IMB_BASE			0x00000880

#define IOCTL_IMB_SEND_MESSAGE		CTL_CODE(FILE_DEVICE_IMB, IOCTL_IMB_BASE + 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_IMB_GET_ASYNC_MSG		CTL_CODE(FILE_DEVICE_IMB, IOCTL_IMB_BASE + 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_IMB_MAP_MEMORY		CTL_CODE(FILE_DEVICE_IMB, IOCTL_IMB_BASE + 14,METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_IMB_UNMAP_MEMORY		CTL_CODE(FILE_DEVICE_IMB, IOCTL_IMB_BASE + 16,METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_IMB_SHUTDOWN_CODE		CTL_CODE(FILE_DEVICE_IMB, IOCTL_IMB_BASE + 18,METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_IMB_REGISTER_ASYNC_OBJ	CTL_CODE(FILE_DEVICE_IMB, IOCTL_IMB_BASE + 24,METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_IMB_DEREGISTER_ASYNC_OBJ	CTL_CODE(FILE_DEVICE_IMB, IOCTL_IMB_BASE + 26,METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_IMB_CHECK_EVENT		CTL_CODE(FILE_DEVICE_IMB, IOCTL_IMB_BASE + 28,METHOD_BUFFERED, FILE_ANY_ACCESS)

#if defined(UWSVR4) || defined (UNIX)
#define IOCTL_IMB_POLL_ASYNC		CTL_CODE(FILE_DEVICE_IMB, IOCTL_IMB_BASE + 20,METHOD_BUFFERED, FILE_ANY_ACCESS)
#endif

#endif // IMB_IF__
