1 #ifndef BAMBOO_MULTICORE_MSG_H
2 #define BAMBOO_MULTICORE_MSG_H
5 // data structures for msgs
6 #define BAMBOO_OUT_BUF_LENGTH 2048
7 #define BAMBOO_OUT_BUF_MASK (0x7FF)
8 #define BAMBOO_MSG_BUF_LENGTH 2048
9 #define BAMBOO_MSG_BUF_MASK (0x7FF)
10 int msgdata[BAMBOO_MSG_BUF_LENGTH];
11 volatile int msgdataindex;
12 volatile int msgdatalast;
14 volatile bool msgdatafull;
15 int outmsgdata[BAMBOO_OUT_BUF_LENGTH];
19 volatile bool isMsgHanging;
21 #define MSG_INDEXINC_I() \
22 msgdataindex = (msgdataindex + 1) & (BAMBOO_MSG_BUF_MASK)
24 #define MSG_LASTINDEXINC_I() \
25 msgdatalast = (msgdatalast + 1) & (BAMBOO_MSG_BUF_MASK)
27 #define MSG_CACHE_I(n) \
28 msgdata[msgdatalast] = (n); \
31 // NOTE: if msgdataindex == msgdatalast, it always means that the buffer if
32 // full. In the case that the buffer is empty, should never call this
34 #define MSG_REMAINSIZE_I(s) \
35 if(msgdataindex < msgdatalast) { \
36 (*(int*)s) = msgdatalast - msgdataindex; \
37 } else if((msgdataindex == msgdatalast) && (!msgdatafull)) { \
40 (*(int*)s) = (BAMBOO_MSG_BUF_LENGTH) - msgdataindex + msgdatalast; \
43 #define OUTMSG_INDEXINC() \
44 outmsgindex = (outmsgindex + 1) & (BAMBOO_OUT_BUF_MASK)
46 #define OUTMSG_LASTINDEXINC() \
47 outmsglast = (outmsglast + 1) & (BAMBOO_OUT_BUF_MASK); \
48 if(outmsglast == outmsgindex) { \
49 BAMBOO_EXIT(0xd101); \
52 #define OUTMSG_CACHE(n) \
53 outmsgdata[outmsglast] = (n); \
54 OUTMSG_LASTINDEXINC();
58 * type: 1 -- transfer object
59 * 2 -- transfer stall msg
64 * // add for profile info
65 * 7 -- transfer profile output msg
66 * 8 -- transfer profile output finish msg
67 * // add for alias lock strategy
68 * 9 -- redirect lock request
69 * a -- lock grant with redirect info
70 * b -- lock deny with redirect info
71 * c -- lock release with redirect info
72 * d -- status confirm request
73 * e -- status report msg
75 * 10 -- requiring for new memory
76 * 11 -- response for new memory request
77 * 12 -- GC init phase start
79 * 14 -- compact phase start
80 * 15 -- flush phase start
81 * 16 -- init phase finish
82 * 17 -- mark phase finish
83 * 18 -- compact phase finish
84 * 19 -- flush phase finish
86 * 1b -- marked phase finish confirm request
87 * 1c -- marked phase finish confirm response
89 * 1e -- start moving objs msg
90 * 1f -- ask for mapping info of a markedObj
91 * 20 -- mapping info of a markedObj
92 * 21 -- large objs info request
93 * 22 -- large objs info response
94 * 23 -- large objs mapping info
96 * ObjMsg: 1 + size of msg + obj's address + (task index + param index)+
97 * StallMsg: 2 + corenum + sendobjs + receiveobjs
98 * (size is always 4 * sizeof(int))
99 * LockMsg: 3 + lock type + obj pointer + lock + request core
100 * (size is always 5 * sizeof(int))
101 * 4/5/6 + lock type + obj pointer + lock
102 * (size is always 4 * sizeof(int))
103 * 9 + lock type + obj pointer + redirect lock + root request core
105 * (size is always 6 * sizeof(int))
106 * a/b + lock type + obj pointer + redirect lock
107 * (size is always 4 * sizeof(int))
108 * c + lock type + lock + redirect lock
109 * (size is always 4 * sizeof(int))
110 * lock type: 0 -- read; 1 -- write
111 * ProfileMsg: 7 + totalexetime
112 * (size is always 2 * sizeof(int))
114 * (size is always 2 * sizeof(int))
115 * StatusMsg: d (size is always 1 * sizeof(int))
116 * e + status + corenum + sendobjs + receiveobjs
117 * (size is always 5 * sizeof(int))
118 * status: 0 -- stall; 1 -- busy
119 * TerminateMsg: f (size is always 1 * sizeof(int)
120 * MemoryMsg: 10 + size + corenum
121 * (size is always 3 * sizeof(int))
122 * 11 + base_va + size
123 * (size is always 3 * sizeof(int))
124 * GCMsg: 12/13 (size is always 1 * sizeof(int))
125 * 14 + size of msg + (num of objs to move + (start address
126 * + end address + dst core + start dst)+)?
127 * + (num of incoming objs + (start dst + orig core)+)?
128 * + (num of large obj lists + (start address + lenght
130 * 15 (size is always 1 * sizeof(int))
132 * (size is always 2 * sizeof(int))
133 * 17 + corenum + gcsendobjs + gcreceiveobjs
134 * (size if always 4 * sizeof(int))
135 * 18 + corenum + fulfilled blocks num + (finish compact(1) + current
136 * heap top)/(need mem(0) + mem need)
137 * size is always 5 * sizeof(int))
139 * (size is always 2 * sizeof(int))
140 * 1a (size is always 1 * sizeof(int))
141 * 1b (size if always 1 * sizeof(int))
142 * 1c + size of msg + corenum + gcsendobjs + gcreceiveobjs
143 * (size is always 5 * sizeof(int))
144 * 1d + obj's address + request core
145 * (size is always 3 * sizeof(int))
146 * 1e + corenum + start addr + end addr
147 * (size if always 4 * sizeof(int))
148 * 1f + obj's address + corenum
149 * (size is always 3 * sizeof(int))
150 * 20 + obj's address + dst address
151 * (size if always 3 * sizeof(int))
152 * 21 (size is always 1 * sizeof(int))
153 * 22 + size of msg + corenum + current heap size
154 * + (num of large obj lists + (start address + length)+)?
155 * 23 + orig large obj ptr + new large obj ptr
156 * (size is always 3 * sizeof(int))
159 MSGSTART = 0xD0, // 0xD0
166 PROFILEOUTPUT, // 0xD7
167 PROFILEFINISH, // 0xD8
168 REDIRECTLOCK, // 0xD9
169 REDIRECTGROUNT, // 0xDa
170 REDIRECTDENY, // 0xDb
171 REDIRECTRELEASE, // 0xDc
172 STATUSCONFIRM, // 0xDd
173 STATUSREPORT, // 0xDe
181 GCSTARTCOMPACT, // 0xE5
182 GCSTARTFLUSH, // 0xE6
184 GCFINISHINIT, // 0xE8
185 GCFINISHMARK, // 0xE9
186 GCFINISHCOMPACT, // 0xEa
187 GCFINISHFLUSH, // 0xEb
189 GCMARKCONFIRM, // 0xEd
190 GCMARKREPORT, // 0xEe
193 GCLOBJREQUEST, // 0xF1
198 #ifdef GC_CACHE_ADAPT
199 GCSTARTPOSTINIT, // 0xF4
201 GCFINISHPOSTINIT, // 0xF6
202 GCFINISHPREF, // 0xF7
203 #endif // GC_CACHE_ADAPT
204 #endif // MULTICORE_GC
208 // msg related functions
209 INLINE void send_hanging_msg(bool isInterrupt);
210 INLINE void send_msg_1(int targetcore,
213 INLINE void send_msg_2(int targetcore,
217 INLINE void send_msg_3(int targetcore,
222 INLINE void send_msg_4(int targetcore,
228 INLINE void send_msg_5(int targetcore,
235 INLINE void send_msg_6(int targetcore,
243 INLINE void cache_msg_1(int targetcore,
245 INLINE void cache_msg_2(int targetcore,
248 INLINE void cache_msg_3(int targetcore,
252 INLINE void cache_msg_4(int targetcore,
257 INLINE void cache_msg_5(int targetcore,
263 INLINE void cache_msg_6(int targetcore,
270 INLINE int receiveMsg(unsigned int send_port_pending);
272 INLINE void transferObject(struct transObjInfo * transObj);
276 INLINE void transferMarkResults();
280 #endif // BAMBOO_MULTICORE_MSG_H