simipc.h 3.94 KB
/*************************************************************************
 *
 *  File: simipc.h 
 *        This file contains definitions for the IPC structure and
 *	  debugging information
 *
 *  $Revision: 1.2 $
 *
 */

#ifndef _SIM_IPC_H_
#define _SIM_IPC_H_


/* General typedefs and definitions */

#define DEFAULT_NAME_PATH	"/tmp/.iosimipc.%s"

#define IPC_CLIENT	1
#define IPC_SERVER	2

/* SysCmd(1:0) single read request size */
#define	SYS_CMD_SRDSZ_1BYTE	0
#define SYS_CMD_SRDSZ_2BYTE	1	/* Half Word */
#define SYS_CMD_SRDSZ_3BYTE	2	/* Tri-Byte */
#define SYS_CMD_SRDSZ_4BYTE	3	/* Single Word */

/* SysCmd(1:0) block read request size */
#define	SYS_CMD_BRDSZ_2WORD	0
#define SYS_CMD_BRDSZ_4WORD	1
#define SYS_CMD_BRDSZ_8WORD	2

/* SysCmd(1:0) single write request size */
#define	SYS_CMD_SWRSZ_1BYTE	0
#define SYS_CMD_SWRSZ_2BYTE	1	/* Half Word */
#define SYS_CMD_SWRSZ_3BYTE	2	/* Tri-Byte */
#define SYS_CMD_SWRSZ_4BYTE	3	/* Single Word */

/* SysCmd(1:0) block write request size */
#define SYS_CMD_BWRSZ_2WORD	0
#define SYS_CMD_BWRSZ_4WORD	1
#define SYS_CMD_BWRSZ_8WORD	2

/* Request codes */
#define	REQ_SINGLE_READ		1
#define	REQ_SINGLE_WRITE	2
#define	REQ_BLOCK_READ		3
#define	REQ_BLOCK_WRITE		4
#define	REQ_STALL    		5
#define	REQ_CONFIG_RDRAM	6
#define	REQ_RUN_TEST		7
#define	REQ_QUIT	    	100

#define	REQ_LOAD		REQ_SINGLE_READ
#define	REQ_STORE		REQ_SINGLE_WRITE

#define DIR_SINGLE_LOAD		REQ_SINGLE_READ
#define DIR_SINGLE_STORE	REQ_SINGLE_WRITE
#define DIR_BLOCK_LOAD		REQ_BLOCK_READ
#define DIR_BLOCK_STORE		REQ_BLOCK_WRITE

#define	SIZE_1BYTE		SYS_CMD_SRDSZ_1BYTE
#define	SIZE_2BYTE		SYS_CMD_SRDSZ_2BYTE
#define	SIZE_3BYTE		SYS_CMD_SRDSZ_3BYTE
#define	SIZE_4BYTE		SYS_CMD_SRDSZ_4BYTE

#define	SIZE_2WORD		SYS_CMD_BRDSZ_2WORD
#define	SIZE_4WORD		SYS_CMD_BRDSZ_4WORD
#define	SIZE_8WORD		SYS_CMD_BRDSZ_8WORD

/* Request size codes */
#define	REQ_SZ_BYTE	1
#define	REQ_SZ_HALF	2
#define	REQ_SZ_3BYTE	3
#define	REQ_SZ_WORD	4
#define	REQ_SZ_DWORD	8

/* Response codes */
#define	RSP_OK		1
#define	RSP_DATA	2
#define	RSP_LOAD	3
#define	RSP_STORE	4
#define	RSP_ERROR	100

/* IPC types */
#define IPC_CLIENT	1
#define IPC_SERVER	2


/* Offset to packet structure */
#define	PKT_LEN_OFS	0
#define	PKT_CODE_OFS	1
#define	PKT_SIZE_OFS	2
#define	PKT_ADDR_OFS	3
#define	PKT_DATA_OFS	4

/* Request size codes */
#define	PKT_DATA_WORD	8			/* 8 words */
#define	PKT_DATA_BYTES	(PKT_DATA_WORD*4)	/* 4 bytes * 8 */

/* To let xz value passed through iosim, we double the
   size of data and the first PKT_DATA_WORD is data itself,
   and the second half is its xz value. */
/* IPC packet structure for both request/response */
typedef struct _IpcPktStruct {
        unsigned int    length;
        unsigned int	code;
        unsigned int	size;
        unsigned int    address;
        unsigned int    data[(PKT_DATA_WORD<<1)];
} IpcPkt;


/*
#define	LFP(a)		((a)?(a):stderr)
*/

#ifndef PLI

extern	int	IpcInit(char *);
extern	int	IpcOpen(int);
extern	int	IpcAccept(int);
extern	int	IpcConnect(int);
extern	int	IpcClose(int);
extern	int	IpcSend(int, char *, int);
extern	int	IpcReceive(int, char *, int);

#endif

/* * * * * * Broadon Extension * * * * * * * * * */

// backdoor request codes

   // Bits 31 specify zero time(verilog) operation
#define ZERO_BCP_TIME			   0x80000000

   // All backdoor access are zero operations
#define BD_REQ_SINGLE_READ         0x80001001
#define BD_REQ_SINGLE_WRITE        0x80001002
#define BD_REQ_SINGLE_SEARCH       0x80001086
#define BD_REQ_DISPLAY_MSG         0x80001087

   // Need to do data xz combination(bit 29)/split(bit 28)
   // bits [27:24] --- How many words need to be combined 
   //      [23:20] --- How many words need to be split
   // 
#define BCP_COMBINE_XZ             0x20000000
#define BCP_SPLIT_XZ			   0x10000000
#define BCP_COMBINE_WORD(x)        ( ((x) >> 24) & 0xf)
#define BCP_SPLIT_WORD(x)		   ( ((x) >> 20) & 0xf)
#define BCP_DEL_SPLIT(x)		   ( (x) & 0xEF0FFFFF )	
   	
/* * * * * * End of Broadon Extension * * * * * * */

#endif  /* _SIM_IPC_H_ */