Commit f967c6bf authored by jdelange's avatar jdelange

* include/po_hi_transport.h

   src/po_hi_transport.c
   - Update transport functions, use
     a dynamic function table to store
     the function to be call for each device to send data.
   - Introduce a static __po_hi_send_output, remove the old
     generated one.
   - Introduce the following functions to help the handling
     of device driver sending functions:

     * __po_hi_transport_get_sending_func
     * __po_hi_transport_set_sending_func
     * __po_hi_transport_call_sending_func_by_port
     * __po_hi_transport_call_sending_func_by_device

   - Remove the __po_hi_transport_send_default, replace
     with a single function __po_hi_transport_send for
     both local and distributed communications.
   
   - __po_hi_transport_send is synonym for __po_hi_send_output
     and __po_hi_transport_default (backward compatibility)


 * include/po_hi_types.h
   - Update copyright header for types

 * src/drivers/po_hi_driver_sockets.c
   - Update driver, register sending function
     when starting




git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-c@4903 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 3422844a
......@@ -6,7 +6,7 @@
* For more informations, please visit http://ocarina.enst.fr
*
* Copyright (C) 2007-2008, GET-Telecom Paris.
* Copyright (C) 2010, European Space Agency.
* Copyright (C) 2010-2012, European Space Agency.
*/
#ifndef __PO_HI_TRANSPORT__
......@@ -29,8 +29,11 @@ typedef struct
void (*unmarshaller) (void*, void*, int);
}__po_hi_protocol_conf_t;
#if __PO_HI_NB_PORTS > 0
typedef int (*__po_hi_transport_sending_func)(__po_hi_task_id, __po_hi_port_t);
typedef uint8_t __po_hi_queue_id;
/**
......@@ -80,7 +83,10 @@ __po_hi_entity_t __po_hi_get_entity_from_global_port (const __po_hi_port_t port
* \fn __po_hi_transport_send_default
* \brief Default transport layer function.
*/
int __po_hi_transport_send_default (__po_hi_task_id id, __po_hi_port_t port);
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
/*
......@@ -120,6 +126,7 @@ __po_hi_uint8_t __po_hi_get_endianness (const __po_hi_node_t node);
*/
__po_hi_device_id __po_hi_get_device_from_port (const __po_hi_port_t port);
char* __po_hi_get_device_naming (const __po_hi_device_id dev);
/*
......@@ -230,11 +237,73 @@ __po_hi_protocol_t __po_hi_transport_get_protocol (const __po_hi_port_t
__po_hi_protocol_conf_t* __po_hi_transport_get_protocol_configuration (const __po_hi_protocol_t p);
/*
* \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);
#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
#endif /* __PO_HI_NB_PORTS > 0 */
......
......@@ -6,6 +6,7 @@
* For more informations, please visit http://ocarina.enst.fr
*
* Copyright (C) 2007-2009, GET-Telecom Paris.
* Copyright (C) 2010-2012, European Space Agency.
*/
#ifndef __PO_HI_TYPES_H_
......
......@@ -470,6 +470,9 @@ void __po_hi_driver_sockets_init (__po_hi_device_id dev_id)
__po_hi_c_sockets_array_init_done = 1;
}
__po_hi_transport_set_sending_func (dev_id, __po_hi_driver_sockets_send);
ipconf = (__po_hi_c_ip_conf_t*)__po_hi_get_device_configuration (dev_id);
ip_port = ipconf->port;
......
......@@ -6,7 +6,7 @@
* For more informations, please visit http://ocarina.enst.fr
*
* Copyright (C) 2007-2008, GET-Telecom Paris.
* Copyright (C) 2010, European Space Agency.
* Copyright (C) 2010-2012, European Space Agency.
*/
#include <po_hi_config.h>
......@@ -39,12 +39,14 @@ extern __po_hi_uint8_t __po_hi_deployment_endiannesses[__PO_HI_NB_NODE
extern __po_hi_protocol_conf_t __po_hi_protocols_configuration[__PO_HI_NB_PROTOCOLS];
#if __PO_HI_NB_DEVICES > 0
extern __po_hi_port_t __po_hi_devices_to_nodes[__PO_HI_NB_DEVICES];
extern __po_hi_device_id __po_hi_port_to_device[__PO_HI_NB_PORTS];
extern char* __po_hi_devices_naming[__PO_HI_NB_DEVICES];
extern __po_hi_uint32_t* __po_hi_devices_configuration_values[__PO_HI_NB_DEVICES];
extern __po_hi_uint32_t __po_hi_devices_nb_accessed_buses[__PO_HI_NB_DEVICES];
extern __po_hi_bus_id* __po_hi_devices_accessed_buses[__PO_HI_NB_DEVICES];
__po_hi_transport_sending_func __po_hi_transport_devices_sending_funcs[__PO_HI_NB_DEVICES];
extern __po_hi_port_t __po_hi_devices_to_nodes[__PO_HI_NB_DEVICES];
extern __po_hi_port_t __po_hi_devices_to_nodes[__PO_HI_NB_DEVICES];
extern __po_hi_device_id __po_hi_port_to_device[__PO_HI_NB_PORTS];
extern char* __po_hi_devices_naming[__PO_HI_NB_DEVICES];
extern __po_hi_uint32_t* __po_hi_devices_configuration_values[__PO_HI_NB_DEVICES];
extern __po_hi_uint32_t __po_hi_devices_nb_accessed_buses[__PO_HI_NB_DEVICES];
extern __po_hi_bus_id* __po_hi_devices_accessed_buses[__PO_HI_NB_DEVICES];
#endif
#if __PO_HI_NB_PROTOCOLS > 0
......@@ -61,7 +63,7 @@ int __po_hi_xtratum_port[__PO_HI_NB_PORTS];
#endif
int __po_hi_transport_send_default (__po_hi_task_id id, __po_hi_port_t port)
int __po_hi_transport_send (__po_hi_task_id id, __po_hi_port_t port)
{
__po_hi_msg_t msg;
__po_hi_request_t* request;
......@@ -117,7 +119,13 @@ int __po_hi_transport_send_default (__po_hi_task_id id, __po_hi_port_t port)
__PO_HI_DEBUG_DEBUG (" [deliver locally]\n");
__po_hi_main_deliver (request);
}
#ifdef XM3_RTEMS_MODE
#ifndef XM3_RTEMS_MODE
else
{
__PO_HI_DEBUG_DEBUG (" [deliver remotely]\n");
__po_hi_transport_call_sending_func_by_port (id, port);
}
#else /* for XTratuM */
else
{
__po_hi_port_kind_t pkind = __po_hi_transport_get_port_kind (port);
......@@ -192,6 +200,52 @@ __po_hi_uint8_t __po_hi_get_endianness (const __po_hi_node_t node)
}
#if __PO_HI_NB_DEVICES > 0
int __po_hi_transport_call_sending_func_by_port (__po_hi_task_id task_id, __po_hi_port_t port)
{
__po_hi_device_id device =__po_hi_get_device_from_port (port);
__PO_HI_DEBUG_DEBUG ("[TRANSPORT] Calling function for device %d\n", device);
if (device != invalid_device_id)
{
return __po_hi_transport_call_sending_func_by_device (device, task_id, port);
}
return __PO_HI_UNAVAILABLE;
}
int __po_hi_transport_call_sending_func_by_device (const __po_hi_device_id device, __po_hi_task_id task_id, __po_hi_port_t port)
{
__po_hi_transport_sending_func send_func;
send_func = __po_hi_transport_get_sending_func (device);
if (send_func == NULL)
{
return __PO_HI_UNAVAILABLE;
}
return send_func (task_id, port);
}
__po_hi_transport_sending_func __po_hi_transport_get_sending_func (const __po_hi_device_id device)
{
if (device > __PO_HI_NB_DEVICES)
{
return NULL;
}
return __po_hi_transport_devices_sending_funcs[device];
}
int __po_hi_transport_set_sending_func (const __po_hi_device_id device, const __po_hi_transport_sending_func func)
{
if (device > __PO_HI_NB_DEVICES)
{
return __PO_HI_UNAVAILABLE;
}
__po_hi_transport_devices_sending_funcs[device] = func;
}
int __po_hi_transport_associate_port_bus (const __po_hi_port_t port, const __po_hi_bus_id bus)
{
__po_hi_device_id current_device;
......
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