Commit 42cbee65 authored by julien.delange's avatar julien.delange
Browse files

delete protocols.c|h

update build system



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-c@546 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent a32dcac9
/*
* 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.
*
* For more informations, please visit http://ocarina.enst.fr
*
* Copyright (C) 2010, European Space Agency
* Copyright (C) 2007-2009, GET-Telecom Paris.
*/
#ifndef __PO_HI_PROTOCOLS__
#define __PO_HI_PROTOCOLS__
#include <po_hi_messages.h>
#include <po_hi_types.h>
#include <deployment.h>
#include <request.h>
typedef __po_hi_uint16_t __po_hi_inetport_t;
typedef char* __po_hi_inetaddr_t;
#define __PO_HI_NOPORT 1
#define __PO_HI_NOADDR ""
int __po_hi_protocols_send_default (__po_hi_task_id id,
__po_hi_port_t port);
int __po_hi_protocols_send (__po_hi_entity_t from,
__po_hi_entity_t to,
__po_hi_msg_t* msg);
/*
* Send a message to a specified entity. The "from" argument is the
* node which send the message. The argument "to" is used to designate
* the entity which receive the message. Finally, the last argument
* (msg) is the message
*/
int __po_hi_protocols_receive (__po_hi_entity_t from,
__po_hi_msg_t* msg);
/*
* Receive a message from a specified entity The entity which sent the
* message is specified by the first argument. The second argument
* will contains the received message.
*/
int __po_hi_protocols_nonblocking_receive (__po_hi_entity_t from,
__po_hi_msg_t* msg);
/*
* Receive a message from a specified entity The entity which sent the
* message is specified by the first argument. The second argument
* will contains the received message. Receive 1 if data was received
*/
#endif /* __PO_HI_PROTOCOLS__ */
......@@ -6,65 +6,34 @@
* For more informations, please visit http://ocarina.enst.fr
*
* Copyright (C) 2007-2008, GET-Telecom Paris.
* Copyright (C) 2010, European Space Agency.
*/
#ifndef __PO_HI_TRANSPORT__
#define __PO_HI_TRANSPORT__
#include <po_hi_messages.h>
#include <po_hi_protocols.h>
#include <deployment.h>
#include <request.h>
typedef uint8_t __po_hi_queue_id;
typedef __po_hi_uint16_t __po_hi_inetport_t;
typedef char* __po_hi_inetaddr_t;
int __po_hi_transport_receive (__po_hi_entity_t from,
__po_hi_msg_t* msg);
/*
* Receive data from a node. The argument designated the sender of the
* data. The second argument (msg) is the message which will receive
* the data. If no message has been received, the function will block
* the thread.
*/
#define __PO_HI_NOPORT 1
#define __PO_HI_NOADDR ""
int __po_hi_transport_nonblocking_receive (__po_hi_entity_t from,
__po_hi_msg_t* msg);
/* Try to receive data from the node designed by the first
argument. The data are stored in the second argument. Returns
__PO_HI_RECEIVE_SUCCESS if it receives data. Else, it returns
__PO_HI_RECEIVE_ERROR if no data are available
*/
void __po_hi_initialize_transport ();
/*
* Initialize the transport layer (create and initialize
* variables, ...)
*/
int __po_hi_transport_send (__po_hi_entity_t from,
__po_hi_entity_t to,
__po_hi_msg_t* msg);
/*
* Send a message to a specified entity. The "from" argument is the
* node which send the message. The argument "to" is used to designate
* the entity which receive the message. Finally, the last argument
* (msg) is the message
*/
typedef uint8_t __po_hi_queue_id;
void __po_hi_initialize_transport_low_level ();
__po_hi_node_t __po_hi_transport_get_node_from_entity (__po_hi_entity_t entity);
/*
* Initialize low-level transport driver. It creates all structures
* and variables required.
* Returns the node identifier that corresponds to an entity.
*/
int __po_hi_transport_low_level_send (__po_hi_entity_t from,
__po_hi_entity_t to,
__po_hi_msg_t* msg);
int __po_hi_transport_send_default (__po_hi_task_id id, __po_hi_port_t port);
/*
* Send the data through the low-level driver. The first argument is
* the node which will receive the data. Argument msg is the message
* which is sent.
* Default transport layer
*/
#endif /* __PO_HI_TRANSPORT__ */
......@@ -59,7 +59,6 @@ ifeq ($(NEED_TRANSPORT), yes)
po_hi_main.o \
po_hi_messages.o \
po_hi_marshallers.o \
po_hi_protocols.o \
po_hi_giop.o \
po_hi_utils.o \
po_hi_types.o \
......
......@@ -8,9 +8,7 @@ C_FILES = $(srcdir)/po_hi_task.c \
$(srcdir)/po_hi_gqueue.c \
$(srcdir)/po_hi_giop.c \
$(srcdir)/po_hi_protected.c \
$(srcdir)/po_hi_protocols.c \
$(srcdir)/po_hi_transport.c \
$(srcdir)/po_hi_transport_dummy.c \
$(srcdir)/po_hi_types.c \
$(srcdir)/po_hi_utils.c \
$(srcdir)/po_hi_simulink.c \
......
......@@ -17,7 +17,6 @@
#include <po_hi_task.h>
#include <po_hi_transport.h>
#include <drivers/po_hi_driver_sockets.h>
#include <po_hi_protocols.h>
#include <po_hi_debug.h>
#include <po_hi_types.h>
#include <po_hi_messages.h>
......@@ -248,9 +247,9 @@ void __po_hi_driver_sockets_init (void)
}
}
int __po_hi_sockets_send (__po_hi_entity_t from,
__po_hi_entity_t to,
__po_hi_msg_t* msg)
int __po_hi_driver_sockets_send (__po_hi_entity_t from,
__po_hi_entity_t to,
__po_hi_msg_t* msg)
{
__po_hi_node_t node;
int len;
......
......@@ -13,7 +13,6 @@
#include <po_hi_messages.h>
#include <po_hi_returns.h>
#include <po_hi_transport.h>
#include <po_hi_protocols.h>
#include <po_hi_debug.h>
#include <po_hi_gqueue.h>
/* Headers from PolyORB-HI-C */
......@@ -207,6 +206,7 @@ __po_hi_uint8_t __po_hi_gqueue_store_in (__po_hi_task_id id,
return __PO_HI_SUCCESS;
}
/*
int __po_hi_gqueue_send_output (__po_hi_task_id id, __po_hi_port_t port)
{
__po_hi_msg_t msg;
......@@ -262,6 +262,7 @@ int __po_hi_gqueue_send_output (__po_hi_task_id id, __po_hi_port_t port)
return __PO_HI_SUCCESS;
}
*/
void __po_hi_gqueue_wait_for_incoming_event( __po_hi_task_id id,
__po_hi_local_port_t* port)
......
......@@ -18,9 +18,7 @@
#include <po_hi_returns.h>
#include <po_hi_task.h>
#include <po_hi_protected.h>
/* included files from PolyORB-HI-C */
void __po_hi_initialize_transport ();
pthread_cond_t cond_init;
pthread_mutex_t mutex_init;
......@@ -60,12 +58,6 @@ int __po_hi_initialize ()
__po_hi_protected_init();
#endif
#if __PO_HI_NB_NODES > 1
/* We initialize the transport only if
* the node have servers*/
__po_hi_initialize_transport ();
#endif
return (__PO_HI_SUCCESS);
}
......
/*
* 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.
*
* For more informations, please visit http://ocarina.enst.fr
*
* Copyright (C) 2010, European Space Agency
* Copyright (C) 2007-2008, GET-Telecom Paris.
*/
#include <po_hi_config.h>
#include <po_hi_transport.h>
#include <po_hi_protocols.h>
#include <po_hi_types.h>
#include <po_hi_debug.h>
#include <po_hi_returns.h>
#include <po_hi_gqueue.h>
#include <deployment.h>
#include <marshallers.h>
#include <types.h>
int __po_hi_protocols_send (__po_hi_entity_t from,
__po_hi_entity_t to,
__po_hi_msg_t* msg)
{
return (__po_hi_transport_send (from, to, msg));
}
extern __po_hi_entity_t __po_hi_port_global_to_entity[__PO_HI_NB_PORTS];
extern __po_hi_local_port_t __po_hi_port_global_to_local[__PO_HI_NB_PORTS];
extern __po_hi_request_t* __po_hi_gqueues_most_recent_values[__PO_HI_NB_TASKS];
extern __po_hi_uint8_t* __po_hi_gqueues_n_destinations[__PO_HI_NB_TASKS];
extern __po_hi_port_t** __po_hi_gqueues_destinations[__PO_HI_NB_TASKS];
int __po_hi_protocols_send_default (__po_hi_task_id id, __po_hi_port_t port)
{
__po_hi_msg_t msg;
__po_hi_request_t* request;
__po_hi_port_t* destinations;
__po_hi_uint8_t ndest;
__po_hi_uint8_t i;
__po_hi_local_port_t local_port;
int error;
local_port = __po_hi_port_global_to_local[(int)port];
request = &(__po_hi_gqueues_most_recent_values[id][local_port]);
if (request->port == -1)
{
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("Send output task %d, port %d : no value to send\n",
id, port);
#endif
return __PO_HI_SUCCESS;
}
destinations = __po_hi_gqueues_destinations[id][local_port];
ndest = __po_hi_gqueues_n_destinations[id][local_port];
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("Send value, emitter task %d, emitter port %d, emitter entity %d, destination ports :\n", id, port, __po_hi_port_global_to_entity[port]);
#endif
for (i=0;i<ndest;i++)
{
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("\t%d (entity=%d)\n",
destinations[i],
__po_hi_port_global_to_entity[destinations[i]]);
#endif
__po_hi_msg_reallocate (&msg);
request->port = (__po_hi_port_t) destinations[i];
__po_hi_marshall_request (request, &msg);
error =__po_hi_protocols_send
(__po_hi_port_global_to_entity[port],
__po_hi_port_global_to_entity[destinations[i]],
&msg);
if (error != __PO_HI_SUCCESS)
{
return error;
}
}
request->port = __PO_HI_GQUEUE_INVALID_PORT;
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("\n");
#endif
return __PO_HI_SUCCESS;
}
......@@ -17,8 +17,11 @@
#include <po_hi_giop.h>
#include <po_hi_messages.h>
#include <po_hi_returns.h>
#include <po_hi_gqueue.h>
#include <deployment.h>
#include <marshallers.h>
#include <types.h>
#include <activity.h>
#include <request.h>
......@@ -27,34 +30,73 @@
* deployment.h.
*/
extern __po_hi_node_t
entity_table[__PO_HI_NB_ENTITIES];
extern __po_hi_node_t entity_table[__PO_HI_NB_ENTITIES];
void __po_hi_initialize_transport ()
{
}
extern __po_hi_entity_t __po_hi_port_global_to_entity[__PO_HI_NB_PORTS];
extern __po_hi_local_port_t __po_hi_port_global_to_local[__PO_HI_NB_PORTS];
extern __po_hi_request_t* __po_hi_gqueues_most_recent_values[__PO_HI_NB_TASKS];
extern __po_hi_uint8_t* __po_hi_gqueues_n_destinations[__PO_HI_NB_TASKS];
extern __po_hi_port_t** __po_hi_gqueues_destinations[__PO_HI_NB_TASKS];
int __po_hi_transport_send (__po_hi_entity_t from,
__po_hi_entity_t to,
__po_hi_msg_t* msg)
int __po_hi_transport_send_default (__po_hi_task_id id, __po_hi_port_t port)
{
if (entity_table[from] == entity_table[to])
__po_hi_msg_t msg;
__po_hi_request_t* request;
__po_hi_port_t* destinations;
__po_hi_uint8_t ndest;
__po_hi_uint8_t i;
__po_hi_local_port_t local_port;
int error;
local_port = __po_hi_port_global_to_local[(int)port];
request = &(__po_hi_gqueues_most_recent_values[id][local_port]);
if (request->port == -1)
{
#ifdef __PO_HI_DEBUG
__DEBUGMSG (" ... deliver locally ... \n");
__DEBUGMSG ("Send output task %d, port %d : no value to send\n",
id, port);
#endif
__po_hi_main_deliver(msg);
return __PO_HI_SUCCESS;
}
#if __PO_HI_NB_NODES > 1
else
{
#ifdef __PO_HI_USE_GIOP
return __po_hi_giop_send (from, to, msg);
#elif defined (__PO_HI_NEED_DRIVER_SOCKETS)
return __po_hi_sockets_send (from, to, msg);
destinations = __po_hi_gqueues_destinations[id][local_port];
ndest = __po_hi_gqueues_n_destinations[id][local_port];
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("Send value, emitter task %d, emitter port %d, emitter entity %d, destination ports :\n", id, port, __po_hi_port_global_to_entity[port]);
#endif
for (i=0;i<ndest;i++)
{
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("\t%d (entity=%d)\n",
destinations[i],
__po_hi_port_global_to_entity[destinations[i]]);
#endif
__po_hi_msg_reallocate (&msg);
request->port = (__po_hi_port_t) destinations[i];
__po_hi_marshall_request (request, &msg);
error =__po_hi_driver_sockets_send
(__po_hi_port_global_to_entity[port],
__po_hi_port_global_to_entity[destinations[i]],
&msg);
if (error != __PO_HI_SUCCESS)
{
return error;
}
}
request->port = __PO_HI_GQUEUE_INVALID_PORT;
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("\n");
#endif
return __PO_HI_UNAVAILABLE;
return __PO_HI_SUCCESS;
}
__po_hi_node_t __po_hi_transport_get_node_from_entity (__po_hi_entity_t entity)
{
return entity_table[entity];
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment