Пример #1
0
void user_ports_polling ()
{
    __po_hi_port_t portno;
    __po_hi_node_t mynode;
    __po_hi_node_t tmpnode;
    __po_hi_request_t request;
    __po_hi_port_kind_t pkind;
    int ret;

    mynode = __po_hi_transport_get_mynode ();

    for (portno = 0 ; portno < __PO_HI_NB_PORTS ; portno++)
    {
        pkind = __po_hi_transport_get_port_kind (portno);
        tmpnode = __po_hi_transport_get_node_from_entity (__po_hi_get_entity_from_global_port (portno));

        ret = -1;

        if (tmpnode == mynode)
        {

            if (pkind ==  __PO_HI_IN_DATA_INTER_PROCESS)
            {
                ret = XM_read_sampling_message (__po_hi_transport_xtratum_get_port (portno),
                                                &request,
                                                sizeof (__po_hi_request_t), 0);

            }

            if (pkind ==  __PO_HI_IN_EVENT_DATA_INTER_PROCESS)
            {
                ret = XM_receive_queuing_message (__po_hi_transport_xtratum_get_port (portno),
                                                  &request,
                                                  sizeof (__po_hi_request_t));
            }

            __DEBUGMSG ("[XTRATUM POLLER] Poll port %d, corresponding xtratum port = %d, return=%d\n", portno, __po_hi_transport_xtratum_get_port (portno), ret);

            if (ret > 0)
            {
                __po_hi_main_deliver (&request);
            }
        }
    }
}
Пример #2
0
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;
   __po_hi_uint8_t       ndest;
   __po_hi_uint8_t       i;
   __po_hi_local_port_t  local_port;
   __po_hi_port_t        destination_port;
   __po_hi_entity_t      destination_entity;

   local_port  = __po_hi_get_local_port_from_global_port (port);
   request     = __po_hi_gqueue_get_most_recent_value (id, local_port);

   if (request->port == -1)
   {
      __PO_HI_DEBUG_DEBUG ("Send output task %d, port %d : no value to send\n", id, port);
      return __PO_HI_SUCCESS;
   }

   ndest          = __po_hi_gqueue_get_destinations_number (id, local_port);

   __PO_HI_DEBUG_DEBUG ("Send value, emitter task %d, emitter port %d, emitter entity %d, destination ports :\n", id,  port, __po_hi_port_global_to_entity[port]);

#if __PO_HI_DEBUG_LEVEL >= __PO_HI_DEBUG_LEVEL_INFO
   __DEBUGMSG ("SENT Value: |");
   {
         int s;
         int i;
         unsigned int* tmp;
         tmp = (unsigned int*) &request->vars;
         s = sizeof (request->vars);
         for (i = 0 ; i < s ; i+=4)
         {
            __DEBUGMSG("%x", *tmp);
            tmp++;
            fflush (stdout);
         }
   }
   __DEBUGMSG ("|\n");
#endif

   for (i=0 ; i < __po_hi_gqueue_get_destinations_number (id, local_port) ; i++)
   {
      destination_port     = __po_hi_gqueue_get_destination (id, local_port, i);
      destination_entity   = __po_hi_get_entity_from_global_port (destination_port);
      __PO_HI_DEBUG_DEBUG ("\t%d (entity=%d)", destination_port, destination_entity);
      __po_hi_msg_reallocate (&msg);

      request->port = destination_port;

      if (__po_hi_transport_get_node_from_entity (__po_hi_get_entity_from_global_port (port)) ==
          __po_hi_transport_get_node_from_entity (__po_hi_get_entity_from_global_port (destination_port)))
      {
            __PO_HI_DEBUG_DEBUG (" [deliver locally]\n");
            __po_hi_main_deliver (request);
      }
#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);
         int ret;
         ret = -1;
         if (pkind == __PO_HI_OUT_DATA_INTER_PROCESS)
         {
            ret = XM_write_sampling_message (__po_hi_xtratum_port[port], request, sizeof (__po_hi_request_t));
         }

         if (pkind == __PO_HI_OUT_EVENT_DATA_INTER_PROCESS)
         {
            ret = XM_send_queuing_message (__po_hi_xtratum_port[port], request, sizeof (__po_hi_request_t));
         }

         if (ret < 0)
         {
            __PO_HI_DEBUG_CRITICAL ("[GQUEUE] Cannot deliver the data using inter-partitions ports, return=%d\n", ret);
         }
         else
         {
            __PO_HI_DEBUG_DEBUG ("[GQUEUE] Data delivered using inter-partitions ports, return=%d\n", ret);
         }
      }
#endif
   }
Пример #3
0
/*
 * The __po_hi_initialize function is only called
 * by the main thread (the one that executes the traditional
 * main() function.
 */
int __po_hi_initialize ()
{
#if (defined (XM3_RTEMS_MODE) && (__PO_HI_NB_PORTS > 0))
   #include <deployment.h>
   #include <po_hi_types.h>
   #include <po_hi_transport.h>
   #include <xm.h>

   __po_hi_port_kind_t        pkind;
   __po_hi_port_t             tmp;
   __po_hi_node_t             tmpnode;
   __po_hi_node_t             mynode;
   int                        portno;

   mynode = __po_hi_transport_get_mynode ();

   for (tmp = 0 ; tmp < __PO_HI_NB_PORTS ; tmp++)
   {
      pkind = __po_hi_transport_get_port_kind (tmp);
      tmpnode = __po_hi_transport_get_node_from_entity (__po_hi_get_entity_from_global_port (tmp));
      if ((tmpnode == mynode) &&
          ( (pkind ==  __PO_HI_IN_DATA_INTER_PROCESS)          ||
            (pkind ==  __PO_HI_OUT_DATA_INTER_PROCESS)         ||
            (pkind ==  __PO_HI_IN_EVENT_DATA_INTER_PROCESS)    ||
            (pkind ==  __PO_HI_OUT_EVENT_DATA_INTER_PROCESS)
          ))
      {
         __DEBUGMSG ("[MAIN] Should init port %d\n", tmp);
         portno = -1;
         switch (pkind)
         {
            case __PO_HI_IN_DATA_INTER_PROCESS:
               portno = XM_create_sampling_port (__po_hi_transport_get_model_name (tmp), __po_hi_transport_get_queue_size (tmp), XM_DESTINATION_PORT);
               break;

            case __PO_HI_OUT_DATA_INTER_PROCESS:
               portno = XM_create_sampling_port (__po_hi_transport_get_model_name (tmp), __po_hi_transport_get_queue_size (tmp), XM_SOURCE_PORT);
               break;

            case __PO_HI_IN_EVENT_DATA_INTER_PROCESS:
               portno = XM_create_queuing_port (__po_hi_transport_get_model_name (tmp), __po_hi_transport_get_queue_size (tmp), __po_hi_transport_get_data_size (tmp), XM_DESTINATION_PORT);
               break;

            case __PO_HI_OUT_EVENT_DATA_INTER_PROCESS:
               portno = XM_create_queuing_port (__po_hi_transport_get_model_name (tmp), __po_hi_transport_get_queue_size (tmp), __po_hi_transport_get_data_size (tmp), XM_SOURCE_PORT);
               break;

            default:
               __DEBUGMSG ("[MAIN] Port kind not handled at this time for port %d\n", tmp);
               break;
         }

         if (portno < 0)
         {
               __DEBUGMSG ("[MAIN] Cannot open port %d, name=%s, return=%d\n", tmp, __po_hi_transport_get_model_name (tmp), portno);
         }
         else
         {
               __po_hi_transport_xtratum_port_init (tmp, portno);
               __DEBUGMSG ("[MAIN] Port %d (name=%s) created, identifier = %d\n", tmp, __po_hi_transport_get_model_name (tmp), portno);
         }

      }
   }
#endif


/*!
 * Initialize the monitoring trace if needed
 */
#if defined (MONITORING)
  trace_initialize ();
#endif

  return (__PO_HI_SUCCESS);
}