simipc.h
2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*************************************************************************
*
* 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_ */