po_hi_transport.h 10.1 KB
Newer Older
1 2 3 4 5
/*
 * This is a part of PolyORB-HI-C distribution, a minimal
 * middleware written for generated code from AADL models.
 * You should use it with the Ocarina toolsuite.
 *
jhugues's avatar
jhugues committed
6
 * For more informations, please visit http://assert-project.net/taste
7
 *
jhugues's avatar
jhugues committed
8
 * Copyright (C) 2007-2009 Telecom ParisTech, 2010-2012 ESA & ISAE.
9 10 11 12 13 14 15 16 17
 */

#ifndef __PO_HI_TRANSPORT__
#define __PO_HI_TRANSPORT__

#include <po_hi_messages.h>
#include <deployment.h>
#include <request.h>

18 19
#define __PO_HI_BIGENDIAN     0
#define __PO_HI_LITTLEENDIAN  1
20

21 22 23 24
#ifndef __PO_HI_NB_PROTOCOLS
#define __PO_HI_NB_PROTOCOLS 0
#endif

25 26
typedef struct
{
jdelange's avatar
jdelange committed
27 28
      void (*marshaller)   (void*, void*, int*);
      void (*unmarshaller) (void*, void*, int);
29 30
}__po_hi_protocol_conf_t;

jdelange's avatar
jdelange committed
31

32 33
#if __PO_HI_NB_PORTS > 0

jdelange's avatar
jdelange committed
34 35
typedef int (*__po_hi_transport_sending_func)(__po_hi_task_id, __po_hi_port_t);

julien.delange's avatar
julien.delange committed
36
typedef uint8_t __po_hi_queue_id;
37

jdelange's avatar
jdelange committed
38 39 40 41 42 43 44
/**
 * \fn __po_hi_transport_get_n_accessed_buses
 *
 * \brief Return the number of buses associated with a device.
 * If no bus is connected to the device or if the device
 * is invalid, the function returns 0. Otherwise, a positive value is
 * returned.
45
 */
jdelange's avatar
jdelange committed
46 47 48 49 50 51 52 53 54 55 56 57 58
uint32_t __po_hi_transport_get_n_accessed_buses (const __po_hi_device_id device);

/**
 * \fn __po_hi_transport_get_accessed_buses
 *
 * \brief Return a pointer to an array that contains all buses identifiers
 * accessed by the device passed as argument. If the argument is an invalid
 * device-id or if the device does not access any bus, NULL is returned.
 * The size of the array can be retrieved by the __po_hi_get_n_accessed_buses
 * function.
 */
__po_hi_bus_id* __po_hi_transport_get_accessed_buses (const __po_hi_device_id device);

jdelange's avatar
jdelange committed
59 60 61 62 63 64 65 66

/**
 * \fn __po_hi_transport_share_bus
 *
 * \brief Returns 1 if two devices share a common bus, 0 otherwise.
 */
int __po_hi_transport_share_bus (const __po_hi_device_id, const __po_hi_device_id);

jdelange's avatar
jdelange committed
67 68 69 70 71 72
/**
 * \fn __po_hi_get_node_from_entity
 *
 * \brief Returns the node identifier that corresponds to an entity.
 */
__po_hi_node_t    __po_hi_transport_get_node_from_entity (const __po_hi_entity_t entity);
73

74
/*
jdelange's avatar
jdelange committed
75 76 77
 * \fn __po_hi_get_entity_from_global_port
 *
 * \brief Return the entity identifier that own the port in parameters.
78
 */
jdelange's avatar
jdelange committed
79
__po_hi_entity_t  __po_hi_get_entity_from_global_port (const __po_hi_port_t port);
80

81
/*
jdelange's avatar
jdelange committed
82 83
 * \fn            __po_hi_transport_send_default
 * \brief         Default transport layer function.
84
 */
jdelange's avatar
jdelange committed
85 86 87 88
int               __po_hi_transport_send (__po_hi_task_id id, __po_hi_port_t port);

#define __po_hi_transport_send_default __po_hi_transport_send
#define __po_hi_send_output            __po_hi_transport_send
89

jdelange's avatar
jdelange committed
90 91 92 93 94

/*
 * \fn      __po_hi_get_port_name
 * \brief   Return the name of the port similar to the name within the AADL model.
 */
95
char* __po_hi_get_port_model_name (const __po_hi_port_t port);
96

jdelange's avatar
jdelange committed
97 98 99 100
/*
 * \fn      __po_hi_get_port_name
 * \brief   Return the name of the port according to mapping rules.
 */
101 102
char* __po_hi_get_port_name (const __po_hi_port_t port);

jdelange's avatar
jdelange committed
103 104 105 106 107
/*
 * \fn      __po_hi_get_local_port_from_local_port
 * \brief   Return the local port identifier of the given global port to handle data on the node.
 */

108
__po_hi_local_port_t __po_hi_get_local_port_from_global_port (const __po_hi_port_t global_port);
109

jdelange's avatar
jdelange committed
110 111 112 113 114 115
/*
 * \fn      __po_hi_get_endianness
 * \brief   Return the endianness of the node given in parameter.
 *
 * The resulting value is either __PO_HI_BIGENDIAN  or __PO_HI_LITTLEENDIAN.
 */
116
__po_hi_uint8_t  __po_hi_get_endianness (const __po_hi_node_t node);
jdelange's avatar
jdelange committed
117 118 119 120 121 122 123 124 125

/*
 * \fn      __po_hi_get_device_from_port
 * \brief   Return the device associated with a given port.
 *
 * The resulting value is a device identifier generated in deployment.h.
 * If no device is associated with the port, it returns the constant
 * value invalid_device_id.
 */
126 127
__po_hi_device_id __po_hi_get_device_from_port (const __po_hi_port_t port);

jdelange's avatar
jdelange committed
128

129
char* __po_hi_get_device_naming (const __po_hi_device_id dev);
130

jdelange's avatar
jdelange committed
131 132 133 134 135 136 137
/*
 * \fn      __po_hi_get_device_configuration
 * \brief   Returns a pointer to the configuration data of the device.
 *
 * The configuration data can be either a string of a more complex
 * data structure, such as an instance of an ASN1 type.
 */
138
__po_hi_uint32_t* __po_hi_get_device_configuration (const __po_hi_device_id);
139

140

jdelange's avatar
jdelange committed
141 142 143 144
/*
 * \fn      __po_hi_transport_get_data_size
 * \brief   Returns the size of the data stored in the port given as parameter.
 */
145 146
__po_hi_uint32_t __po_hi_transport_get_data_size (const __po_hi_port_t portno);

jdelange's avatar
jdelange committed
147 148 149 150 151 152 153 154

/*
 * \fn      __po_hi_transport_get_queue_size
 * \brief   Return the size of the queue associated with the port.
 *
 * The size if specified as the number of request the port can store,
 * this is NOT the number of bytes that can be stored.
 */
155 156
__po_hi_uint32_t __po_hi_transport_get_queue_size (const __po_hi_port_t portno);

jdelange's avatar
jdelange committed
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
/*
 * \fn      __po_hi_transport_get_port_kind
 * \brief   Indicate the kind of the port given in parameter or __PO_HI_INVALID_PORT_KIND when not appropriate.
 *
 * The values that are returned indicate if the port is a pure event
 * port, if it has a data associated and if it is an inter-process
 * port or not.
 *
 * Potential return values are:
 *
 *  __PO_HI_IN_DATA_INTER_PROCESS
 *  __PO_HI_OUT_DATA_INTER_PROCESS
 *  __PO_HI_IN_DATA_INTRA_PROCESS
 *  __PO_HI_OUT_DATA_INTRA_PROCESS
 *  __PO_HI_IN_EVENT_DATA_INTER_PROCESS
 *  __PO_HI_OUT_EVENT_DATA_INTER_PROCESS
 *  __PO_HI_IN_EVENT_DATA_INTRA_PROCESS
 *  __PO_HI_OUT_EVENT_DATA_INTRA_PROCESS
 *  __PO_HI_IN_EVENT_INTER_PROCESS
 *  __PO_HI_OUT_EVENT_INTER_PROCESS
 *  __PO_HI_IN_EVENT_INTRA_PROCESS
 *  __PO_HI_OUT_EVENT_INTRA_PROCESS
 *  __PO_HI_INVALID_PORT_KIND
 */
181 182 183
__po_hi_port_kind_t __po_hi_transport_get_port_kind (const __po_hi_port_t portno);


jdelange's avatar
jdelange committed
184 185 186 187 188 189 190 191 192 193 194 195 196
/*
 * \fn      __po_hi_transport_get_model_name
 * \brief   Return the name of the port given in parameter.
 */

char*             __po_hi_transport_get_model_name (const __po_hi_port_t portno);


/* \fn      __po_hi_transport_get_mynode
 * \brief   Return the node identifier of the node that executes the current system.
 */
__po_hi_node_t    __po_hi_transport_get_mynode (void);

jdelange's avatar
jdelange committed
197 198 199 200
/* \fn      __po_hi_transport_get_node_from_device
 * \brief   Return the node identifier associated with the device given in parameter.
 */
__po_hi_node_t    __po_hi_transport_get_node_from_device (const __po_hi_device_id device);
jdelange's avatar
jdelange committed
201

jdelange's avatar
jdelange committed
202 203 204 205 206 207 208 209 210 211 212 213 214

/* \fn      __po_hi_transport_associate_port_bus
 * \brief   Associate a port to a bus. Return 1 on success, 0 otherwise.
 *
 * When calling this function, you have to be very careful and make sure
 * that the bus you are passing by argument is connected to the node
 * that actually host this port.
 * Definition of port and bus values are enclosed in the deployment.h
 * file generated by Ocarina.
 */

int __po_hi_transport_associate_port_bus (const __po_hi_port_t port, const __po_hi_bus_id bus);

jdelange's avatar
jdelange committed
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
/*
 * \fn      __po_hi_transport_get_protocol
 * \brief   Return the protocol identifier that is used between port src and port dst.
 *
 * Get the protocol identifier used to communicate
 * between port src and port dst. It returns a protocol
 * identifier generated in deployment.h.
 * If no specific protocol is used, it returns the value
 * invalid_protocol.
 */
__po_hi_protocol_t         __po_hi_transport_get_protocol (const __po_hi_port_t src, const __po_hi_port_t dst);

/*
 * \fn      __po_hi_transport_get_protocol_configuration
 * \brief   Retrieve the configuration of the given protocol identifier. Returns a pointer on the conf or NULL.
 *      
 *
 * Protocol identifier can be retrieve in the generated deployment.h file
 * under the type __po_hi_protocol_t. Invalid protocol identifier
 * will result in returning NULL.
 */
__po_hi_protocol_conf_t*   __po_hi_transport_get_protocol_configuration (const __po_hi_protocol_t p);

238

jdelange's avatar
jdelange committed
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
/*
 * \fn      __po_hi_transport_set_sending_func
 * \brief   Set the sending function to be called to send data using a particular device.
 *
 *
 * The first argument is device that would be used to send the data while the
 * second is the function that would be called.
 *
 * The function returns __PO_HI_SUCCESS when the new calling function
 * is successfully set. Otherwise, returns __PO_HI_UNAVAILABLE.
 */
int __po_hi_transport_set_sending_func (const __po_hi_device_id device, const __po_hi_transport_sending_func func);

/*
 * \fn      __po_hi_transport_call_sending_func_by_device
 * \brief   Call the sending function to send data from a port associated to a
 *          task.
 *
 * First argument is the device that would be used to send the data. The second
 * argument is the task that is sending the data while th third argument
 * is the port identifier that contain the data to be sent.
 *
 * The function returns  __PO_HI_UNAVAILABLE is no sending function
 * has been set for this device or if the device identifier is invalid.
 * Otherwise, it returns the value returned by the sending function
 * associated to the device.
 */
int __po_hi_transport_call_sending_func_by_device (const __po_hi_device_id, __po_hi_task_id, __po_hi_port_t);

/*
 * \fn      __po_hi_transport_call_sending_func
 * \brief   Call the sending function to send data from a port associated to a
 *          task. The function to call is retrieved using the port.
 *
 * First argument is the task that is sending the data. The second
 * is the port associated with the task and the device. The device
 * to call is deduced from the port.
 * 
 * The function returns  __PO_HI_UNAVAILABLE is no sending function
 * has been set for this device or if the device identifier is invalid.
 * Otherwise, it returns the value returned by the sending function
 * associated to the device.
 */
int __po_hi_transport_call_sending_func_by_port (__po_hi_task_id, __po_hi_port_t);



/*
 * \fn      __po_hi_transport_get_sending_func
 * \brief   Get the sending function to be called to send data using a device
 *
 *
 * The first argument is device that would be used to send the data.
 * Returns NULL if the device identifier is incorrect or no function
 * has been set.
 */

__po_hi_transport_sending_func __po_hi_transport_get_sending_func (const __po_hi_device_id device);


299 300 301 302 303
#ifdef XM3_RTEMS_MODE
void __po_hi_transport_xtratum_port_init (const __po_hi_port_t portno, int val);
int __po_hi_transport_xtratum_get_port (const __po_hi_port_t portno);
#endif

jdelange's avatar
jdelange committed
304 305


306
#endif /* __PO_HI_NB_PORTS > 0 */
307

308 309


310
#endif /* __PO_HI_TRANSPORT__ */