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

#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 */

/* 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];
} 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


#endif  /* _SIM_IPC_H_ */