1/* BEGIN LICENSE BLOCK
2 * Version: CMPL 1.1
3 *
4 * The contents of this file are subject to the Cisco-style Mozilla Public
5 * License Version 1.1 (the "License"); you may not use this file except
6 * in compliance with the License.  You may obtain a copy of the License
7 * at www.eclipse-clp.org/license.
8 *
9 * Software distributed under the License is distributed on an "AS IS"
10 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See
11 * the License for the specific language governing rights and limitations
12 * under the License.
13 *
14 * The Original Code is  The ECLiPSe Constraint Logic Programming System.
15 * The Initial Developer of the Original Code is  Cisco Systems, Inc.
16 * Portions created by the Initial Developer are
17 * Copyright (C) 1994-2006 Cisco Systems, Inc.  All Rights Reserved.
18 *
19 * Contributor(s): Kees Schuerman, ECRC
20 *
21 * END LICENSE BLOCK */
22/**********************************************************************
23**      System: Parallel Distributed System
24**        File: amsg.msg.h
25**      Author: Kees Schuerman
26**      SccsId: "@(#)amsg.msg.h	1.1 8/31/95"
27** Description: Message Passing System: Application Layer Interface
28***********************************************************************/
29
30#ifndef _AMSG_MSG_H_
31#define _AMSG_MSG_H_
32
33
34/*
35** Return Codes
36*/
37
38#define AMSG_OK              PDS_OK            /* success               */
39#define AMSG_NYI	     PDS_NYI	       /* not yet implemented   */
40#define AMSG_WARN            PDS_WARN          /* general warning       */
41#define AMSG_ERROR           PDS_ERROR         /* general error         */
42#define AMSG_IMPLIM          PDS_IMPLIM        /* implementation limit  */
43#define AMSG_INVAL           PDS_INVAL         /* invalid argument      */
44#define AMSG_NORESOURCES     PDS_NORESOURCES   /* no resources	        */
45#define AMSG_NOMEMORY        PDS_NOMEMORY      /* no memory             */
46#define AMSG_NOT_READY       PDS_NOT_READY     /* not ready             */
47
48#define AMSG_NOPORT          (PDS_RET_MAX + 1)  /* no such port         */
49#define AMSG_NOMESSAGE       (PDS_RET_MAX + 2)  /* no message           */
50#define AMSG_NOOWNER 	     (PDS_RET_MAX + 3)  /* no owner		*/
51#define AMSG_NOSENDRIGHTS    (PDS_RET_MAX + 4)  /* no send rights	*/
52#define AMSG_NORCVRIGHTS     (PDS_RET_MAX + 5)  /* no receive rights	*/
53#define AMSG_NORIGHTS 	     (PDS_RET_MAX + 6)  /* no rights		*/
54#define AMSG_PBLOCKED        (PDS_RET_MAX + 7)  /* port blocked         */
55#define AMSG_PDYING          (PDS_RET_MAX + 8)  /* port dying           */
56#define AMSG_PNOTAVAILABLE   (PDS_RET_MAX + 9)  /* port not available   */
57#define AMSG_PUNREACH  	     (PDS_RET_MAX + 10) /* port unreachable 	*/
58
59
60/*
61** Warnings, Errors, Panics
62*/
63
64#define AMSG_WEP_OK	     AMSG_OK           /* success               */
65#define AMSG_WEP_NYI	     AMSG_NYI	       /* not yet implemented   */
66#define AMSG_WEP_WARN        AMSG_WARN         /* general warning       */
67#define AMSG_WEP_ERROR       AMSG_ERROR        /* general error         */
68#define AMSG_WEP_IMPLIM      AMSG_IMPLIM       /* implementation limit  */
69#define AMSG_WEP_INVAL       AMSG_INVAL        /* invalid argument      */
70#define AMSG_WEP_NORESOURCES AMSG_NORESOURCES  /* no resources	        */
71#define AMSG_WEP_NOMEMORY    AMSG_NOMEMORY     /* no memory             */
72
73#define AMSG_WEP_NOPORT	     AMSG_NOPORT       /* no such port		*/
74
75
76/*
77** Version
78*/
79
80typedef struct {
81    pds_uint32 v_minor;
82    pds_uint32 v_major;
83} amsg_version_t;
84
85extern msg_type_t MDT_AMSGVERSION;
86
87
88/*
89** Message Passing System Options
90*/
91
92#define AMSG_ALOG_ON            0x10
93#define AMSG_ALOG_OPEN          0x20
94#define AMSG_ALOG_CLOSE         0x40
95#define AMSG_ALOG_MASTER        0x80
96
97
98/*
99** Generic Option Values
100*/
101
102#define AMSG_OFF        	0x00
103#define AMSG_ON         	0x01
104
105
106/*
107** Port Option Names
108*/
109
110#define APORT_NOTIFY      	0x01	/* on,off      		  */
111#define APORT_NOTIFY_LEVEL	0x02	/* notify level		  */
112#define APORT_NOTIFY_DEFER     	0x03	/* off,local,global  	  */
113#define APORT_DATA_PTR         	0x04
114
115
116/*
117** Port Option Values
118*/
119
120#define APORT_NOTIFY_LEVEL_MAX		15
121#define APORT_NOTIFY_DEFER_OFF		((aport_optval_t) 0x00)
122#define APORT_NOTIFY_DEFER_LOCAL	((aport_optval_t) 0x01)
123#define APORT_NOTIFY_DEFER_GLOBAL 	((aport_optval_t) 0xFF)
124
125
126
127/*
128** Message Classes
129*/
130
131#define AMSG_SHORT      64      /* message data size:     <=   64 bytes */
132#define AMSG_MEDIUM     512     /*                  :  65 ..  512 bytes */
133#define AMSG_LONG               /*                  :      >  512 bytes */
134
135
136/*
137** Type Definitions and Associated Message Data Types
138*/
139
140#define AMSG_INTFC	2
141
142typedef pds_byte_t amsg_descriptor_t;
143#define msg_descriptor_t amsg_descriptor_t
144
145typedef pds_word_t aport_id_t;
146typedef pds_size_t amsg_size_t;
147typedef void_ptr amsg_t;
148typedef msg_data_t amsg_data_t;
149typedef void_ptr aport_optval_t;
150typedef msg_option_t amsg_option_t;
151typedef pds_word_t aport_optname_t;
152typedef msg_type_t amsg_type_t;
153typedef msg_typedef_t amsg_typedef_t;
154typedef msg_type_no_t amsg_type_no_t;
155typedef msg_intfc_no_t amsg_intfc_no_t;
156typedef msg_count_t amsg_count_t;
157typedef pds_ret_t amsg_ret_t;
158
159#define MDT_APORTID		MDT_WORD
160#define MDT_AMSGSIZE		MDT_SIZE
161#define MDT_AMSGOPTION		MDT_MSGOPTION
162#define MDT_APORTOPTNAME	MDT_WORD
163#define MDT_AMSGTYPE		MDT_MSGTYPE
164#define MDT_AMSGTYPEDEF		MDT_MSGTYPEDEF
165#define MDT_AMSGTYPENO		MDT_MSGTYPENO
166#define MDT_AMSGINTFCNO		MDT_MSGINTFCNO
167#define MDT_AMSGCOUNT		MDT_MSGCOUNT
168#define MDT_AMSGRET		MDT_RET
169
170
171typedef struct {
172    aport_id_t aport_id;	/* aport identifier   */
173    bport_id_t bport_id;	/* bport identifier   */
174    bdomain_id_t bdomain_id;	/* bdomain identifier */
175} aport_t;
176
177extern msg_type_t MDT_APORT;
178
179typedef pds_dp_float amsg_counter_t;
180
181#define MDT_AMSGCOUNTER		MDT_DP_FLOAT
182
183typedef struct {
184    amsg_counter_t sent_short;	/* # short sized messages sent	    */
185    amsg_counter_t sent_medium;	/* # medium sized messages sent     */
186    amsg_counter_t sent_long;	/* # long sized messages sent	    */
187    amsg_counter_t rcvd_short;	/* # short sized messages received  */
188    amsg_counter_t rcvd_medium; /* # medium sized messages received */
189    amsg_counter_t rcvd_long;	/* # long sized messages received   */
190} amsg_info_t;
191
192extern msg_type_t MDT_AMSGINFO;
193
194typedef struct {
195    amsg_counter_t sends;	/* # messages sent      */
196    amsg_counter_t receives;	/* # messages received  */
197} aport_info_t;
198
199extern msg_type_t MDT_APORTINFO;
200
201typedef pds_word_t amsg_wep_t;
202typedef amsg_wep_t amsg_warn_t;
203typedef amsg_wep_t amsg_error_t;
204typedef amsg_wep_t amsg_panic_t;
205
206#define MDT_AMSGWEP	MDT_WORD
207#define MDT_AMSGWARN	MDT_AMSGWEP
208#define MDT_AMSGERROR	MDT_AMSGWEP
209#define MDT_AMSGPANIC	MDT_AMSGWEP
210
211
212
213/*
214** Type System
215*/
216
217#define amsg_type_define(IntfcNo,TypeNo,TypeDef,MsgType)        \
218        pds_type_define(IntfcNo,TypeNo,TypeDef,MsgType)
219
220#define amsg_type_size(MsgType,Size,Option)                     \
221        pds_type_size(MsgType,Size,Option)
222
223#define amsg_type_xdr(Xdrs,MsgType,MsgData)                     \
224        pds_type_xdr(Xdrs,MsgType,MsgData)
225
226
227
228/*
229** Port Primitives
230*/
231
232#if defined(__STDC__)
233extern amsg_ret_t aport_allocate(aport_id_t * port_id,
234				 void (* notify_procedure)
235				      (aport_id_t aport_id));
236extern amsg_ret_t aport_deallocate(aport_id_t port_id);
237extern amsg_ret_t aport_port(aport_id_t port_id,
238                             aport_t * port);
239extern aport_id_t aport_id(bport_id_t bport_id,
240			   unsigned index);
241extern bport_id_t aport_bport_id(aport_id_t port_id);
242extern amsg_ret_t aport_flush(aport_id_t port_id);
243extern amsg_ret_t aport_set_option(aport_id_t port_id,
244				   aport_optname_t optname,
245				   aport_optval_t optval);
246extern amsg_ret_t aport_get_option(aport_id_t port_id,
247				   aport_optname_t optname,
248				   aport_optval_t * optval);
249#else /* __STDC__ */
250extern amsg_ret_t aport_allocate();
251extern amsg_ret_t aport_deallocate();
252extern amsg_ret_t aport_port();
253extern aport_id_t aport_id();
254extern bport_id_t aport_bport_id();
255extern amsg_ret_t aport_flush();
256extern amsg_ret_t aport_set_option();
257extern amsg_ret_t aport_get_option();
258#endif /* __STDC__ */
259
260
261/*
262** Message Primitives
263*/
264
265#if defined(__STDC__)
266extern amsg_ret_t amsg_alloc(amsg_size_t size,
267			     amsg_data_t * * msg_data,
268			     amsg_t * msg);
269extern amsg_ret_t amsg_free(amsg_t msg);
270extern amsg_size_t amsg_size(amsg_t msg);
271extern amsg_data_t * amsg_data(amsg_t msg);
272extern amsg_ret_t amsg_send(aport_id_t port_id,
273			    amsg_t msg,
274			    amsg_type_t msg_type,
275			    amsg_count_t msg_count,
276			    amsg_option_t option);
277extern amsg_ret_t amsg_receive(aport_id_t port_id,
278			       amsg_t * msg,
279			       amsg_data_t * * msg_data,
280                               amsg_type_t * msg_type,
281			       amsg_count_t * msg_count,
282			       amsg_option_t option);
283extern amsg_ret_t amsg_peek(aport_id_t port_id,
284			    amsg_t * msg,
285                            amsg_data_t * * msg_data,
286                            amsg_type_t * msg_type,
287                            amsg_count_t * msg_count);
288#else /* __STDC__ */
289extern amsg_ret_t amsg_alloc();
290extern amsg_ret_t amsg_free();
291extern amsg_size_t amsg_size();
292extern amsg_data_t * amsg_data();
293extern amsg_ret_t amsg_send();
294extern amsg_ret_t amsg_receive();
295extern amsg_ret_t amsg_peek();
296#endif /* __STDC__ */
297
298
299/*
300** Miscellaneous Primitives
301*/
302
303extern int amsg_initialised;
304extern int amsg_exited;
305extern int amsg_exiting;
306
307#define amsg_ready()	(amsg_initialised && !amsg_exited)
308
309
310#if defined(__STDC__)
311extern bmsg_ret_t amsg_version(amsg_version_t * version);
312extern amsg_ret_t amsg_init(unsigned size,
313			    void (* notify_procedure [])
314				 (aport_id_t port_id),
315			    aport_id_t port_id [],
316			    amsg_option_t option);
317extern void amsg_exit(void);
318extern void amsg_warn(amsg_warn_t msg_warn,			/* upcall */
319		      aport_id_t culprit);
320extern void amsg_error(amsg_error_t msg_error,			/* upcall */
321		       aport_id_t culprit);
322extern void amsg_panic(amsg_panic_t msg_panic,			/* upcall */
323		       aport_id_t culprit);
324extern char * amsg_error_string(amsg_ret_t aret);
325extern void amsg_perror(amsg_ret_t aret,
326                        char * s);
327extern amsg_ret_t amsg_info(amsg_info_t * msg_info);
328extern amsg_ret_t aport_info(aport_id_t port_id,
329			     aport_info_t * port_info);
330#else /* __STDC__ */
331extern amsg_ret_t amsg_version();
332extern amsg_ret_t amsg_init();
333extern void amsg_exit();
334extern void amsg_warn();					/* upcall */
335extern void amsg_error();					/* upcall */
336extern void amsg_panic();					/* upcall */
337extern char * amsg_error_string();
338extern void amsg_perror();
339extern amsg_ret_t amsg_info();
340extern amsg_ret_t aport_info();
341#endif /* __STDC__ */
342
343#endif /* _AMSG_MSG_H_ */
344
345