diff --git a/examples/aadlv2/ping/ping-xtratum.aadl b/examples/aadlv2/ping/ping-xtratum.aadl index 881d8adf76985e4415c1429859dc579120899c51..61d691b72085558e7d380d2d7b34882eed2aeb11 100644 --- a/examples/aadlv2/ping/ping-xtratum.aadl +++ b/examples/aadlv2/ping/ping-xtratum.aadl @@ -26,13 +26,38 @@ features Data_Sink : in event data port Software::Simple_Type; end B; +subprogram do_ports_polling +properties + source_language => C; + source_name => "user_ports_polling"; + source_text => ("xtratum_polling.c"); +end do_ports_polling; + +thread xtratum_poller +end xtratum_poller; + +thread implementation xtratum_poller.i +calls +Mycalls: { + P_Spg : subprogram do_ports_polling; +}; +properties + Dispatch_Protocol => Periodic; + Period => 100 Ms; + Compute_Execution_time => 0 ms .. 3 ms; + Deadline => 100 ms; +end xtratum_poller.i; + process implementation B.Impl subcomponents Ping_Me : thread Software::Q.Impl; + poll_port : thread xtratum_poller.i; connections port Data_Sink -> Ping_Me.Data_Sink; end B.Impl; + + memory myram end myram; diff --git a/examples/aadlv2/ping/software.aadl b/examples/aadlv2/ping/software.aadl index e04fe8934585c2d34be285e37c09ff1d1156b333..5ce6b08f97a3ef98f649f0b314ca5b2f9fbc084d 100644 --- a/examples/aadlv2/ping/software.aadl +++ b/examples/aadlv2/ping/software.aadl @@ -17,6 +17,7 @@ data Simple_Type properties Type_Source_Name => "custom_int"; Source_Text => ("ping"); + Source_Data_Size => 8 Bytes; end Simple_Type; ----------------- @@ -41,6 +42,7 @@ properties source_text => ("ping.c"); end Ping_Spg; + ------------- -- Threads -- ------------- diff --git a/examples/aadlv2/ping/xtratum_polling.c b/examples/aadlv2/ping/xtratum_polling.c new file mode 100644 index 0000000000000000000000000000000000000000..8bbd9aeb49604262d01fb9e334f5cb1e3fcc1796 --- /dev/null +++ b/examples/aadlv2/ping/xtratum_polling.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#include +#include +#include + +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)); + } + + printf ("[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); + } + } + } +} diff --git a/include/po_hi_gqueue.h b/include/po_hi_gqueue.h index b009d39133ef29724fae9ae750d68098c65b7734..8875c1ec5b5e7956e5dbc79308933177db0cffff 100644 --- a/include/po_hi_gqueue.h +++ b/include/po_hi_gqueue.h @@ -132,4 +132,6 @@ __po_hi_request_t* __po_hi_gqueue_get_most_recent_value __po_hi_port_t __po_hi_gqueue_get_destination (const __po_hi_task_id task_id, const __po_hi_local_port_t local_port, const uint8_t destination_number); uint8_t __po_hi_gqueue_get_destinations_number (const __po_hi_task_id task_id, const __po_hi_local_port_t local_port); + + #endif /* __PO_HI_GQUEUE_H__ */ diff --git a/include/po_hi_transport.h b/include/po_hi_transport.h index 65e777d88ad5d24d05df0b0d7996886f8ba0cfa8..ae4f7cb3de627cdec8f8b569777873fdf7598d4f 100644 --- a/include/po_hi_transport.h +++ b/include/po_hi_transport.h @@ -51,6 +51,25 @@ char* __po_hi_get_device_naming (const __po_hi_device_id dev); __po_hi_uint32_t* __po_hi_get_device_configuration (const __po_hi_device_id); + +__po_hi_uint32_t __po_hi_transport_get_data_size (const __po_hi_port_t portno); + +__po_hi_uint32_t __po_hi_transport_get_queue_size (const __po_hi_port_t portno); + +__po_hi_port_kind_t __po_hi_transport_get_port_kind (const __po_hi_port_t portno); + +char* __po_hi_transport_get_model_name (const __po_hi_port_t portno); + +__po_hi_node_t __po_hi_transport_get_mynode (void); + +#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 */ + + #endif /* __PO_HI_TRANSPORT__ */ diff --git a/include/po_hi_types.h b/include/po_hi_types.h index 1b6c4ecdf095cd09f83f1ec029d0f22b9668ae4b..172f2c96e3b642e557c1083befed37c43cdb3b26 100644 --- a/include/po_hi_types.h +++ b/include/po_hi_types.h @@ -96,7 +96,8 @@ typedef enum __PO_HI_IN_EVENT_INTER_PROCESS = 16, __PO_HI_OUT_EVENT_INTER_PROCESS = 18, __PO_HI_IN_EVENT_INTRA_PROCESS = 20, - __PO_HI_OUT_EVENT_INTRA_PROCESS = 22 + __PO_HI_OUT_EVENT_INTRA_PROCESS = 22, + __PO_HI_INVALID_PORT_KIND = 50 }__po_hi_port_kind_t; void __po_hi_copy_array (void* dst, void* src, __po_hi_uint16_t size); diff --git a/src/po_hi_gqueue.c b/src/po_hi_gqueue.c index 1d301c01663b3326c95560b83344b947cb273414..7299d75f71795948dbba5e70a43003556dd862ad 100644 --- a/src/po_hi_gqueue.c +++ b/src/po_hi_gqueue.c @@ -570,3 +570,5 @@ __po_hi_port_t __po_hi_gqueue_get_destination (const __po_hi_task_id task_id, co { return (__po_hi_gqueues_destinations[task_id][local_port][destination_number]); } + + diff --git a/src/po_hi_main.c b/src/po_hi_main.c index d0306c56a0ae1335a2f9eaaa71d985a63d18a568..7526bdb59b991cfd9bd68753245583a44598cf89 100644 --- a/src/po_hi_main.c +++ b/src/po_hi_main.c @@ -203,54 +203,46 @@ int __po_hi_initialize () #ifdef XM3_RTEMS_MODE #include #include + #include #include - extern __po_hi_node_t __po_hi_mynode; - extern __po_hi_entity_t __po_hi_port_global_to_entity[__PO_HI_NB_PORTS]; - extern __po_hi_node_t __po_hi_entity_table[__PO_HI_NB_ENTITIES]; - extern __po_hi_port_kind_t __po_hi_port_global_kind[__PO_HI_NB_PORTS]; - extern char* __po_hi_port_global_model_names[__PO_HI_NB_PORTS]; + __po_hi_port_kind_t pkind; + __po_hi_port_t tmp; + __po_hi_node_t tmpnode; + __po_hi_node_t mynode; + int portno; - __po_hi_port_t tmp; + mynode = __po_hi_transport_get_mynode (); for (tmp = 0 ; tmp < __PO_HI_NB_PORTS ; tmp++) { - if ((__po_hi_entity_table[__po_hi_port_global_to_entity[tmp]] == __po_hi_mynode) && - ( (__po_hi_port_global_kind[tmp] == __PO_HI_IN_DATA_INTER_PROCESS) || - (__po_hi_port_global_kind[tmp] == __PO_HI_OUT_DATA_INTER_PROCESS) || - (__po_hi_port_global_kind[tmp] == __PO_HI_IN_EVENT_DATA_INTER_PROCESS) || - (__po_hi_port_global_kind[tmp] == __PO_HI_OUT_EVENT_DATA_INTER_PROCESS) + 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); - switch (__po_hi_port_global_kind[tmp]) + portno = -1; + switch (pkind) { case __PO_HI_IN_DATA_INTER_PROCESS: - if (XM_create_sampling_port (__po_hi_port_global_model_names [tmp], 8, XM_DESTINATION_PORT) < 0) - { - __DEBUGMSG ("[MAIN] Sampling destination port %d cannot be created !\n", tmp); - } + 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: - if (XM_create_sampling_port (__po_hi_port_global_model_names [tmp], 8, XM_SOURCE_PORT) < 0) - { - __DEBUGMSG ("[MAIN] Sampling source port %d cannot be created !\n", tmp); - } + 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: - if (XM_create_queuing_port (__po_hi_port_global_model_names [tmp], 1, 8, XM_DESTINATION_PORT) < 0) - { - __DEBUGMSG ("[MAIN] Queuing destination port %d cannot be created !\n", tmp); - } + 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: - if (XM_create_queuing_port (__po_hi_port_global_model_names [tmp], 1, 8, XM_SOURCE_PORT) < 0) - { - __DEBUGMSG ("[MAIN] Queuing source port %d cannot be created !\n", tmp); - } + 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: @@ -258,6 +250,16 @@ int __po_hi_initialize () 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 diff --git a/src/po_hi_transport.c b/src/po_hi_transport.c index ff46b5430a131030ec0db9943977753207928346..5edad27f0e8e9f0f38beb51cbab0c3e3531e5a0c 100644 --- a/src/po_hi_transport.c +++ b/src/po_hi_transport.c @@ -44,6 +44,16 @@ extern char* __po_hi_devices_naming[__PO_HI_NB_DEVICES]; extern __po_hi_uint32_t* __po_hi_devices_configuration_values[__PO_HI_NB_DEVICES]; #endif +#ifdef XM3_RTEMS_MODE + +#include +#include +#include +#include +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) { __po_hi_msg_t msg; @@ -100,6 +110,32 @@ 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 + 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_DEBUG ("[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 } request->port = __PO_HI_GQUEUE_INVALID_PORT; @@ -115,6 +151,13 @@ __po_hi_node_t __po_hi_transport_get_node_from_entity (const __po_hi_entity_t en return __po_hi_entity_table[entity]; } +__po_hi_node_t __po_hi_transport_get_mynode (void) +{ + extern __po_hi_node_t __po_hi_mynode; + return (__po_hi_mynode); +} + + __po_hi_entity_t __po_hi_get_entity_from_global_port (const __po_hi_port_t port) { return __po_hi_port_global_to_entity[port]; @@ -163,3 +206,78 @@ __po_hi_uint32_t* __po_hi_get_device_configuration (const __po_hi_device_id dev) #endif + +char* __po_hi_transport_get_model_name (const __po_hi_port_t portno) +{ + extern char* __po_hi_port_global_model_names[__PO_HI_NB_PORTS]; + + if (portno >= __PO_HI_NB_PORTS) + { + __DEBUGMSG ("[TRANSPORT] Try to get the name of a non-existing port\n"); + return NULL; + } + else + { + return __po_hi_port_global_model_names[portno]; + } +} + + +__po_hi_uint32_t __po_hi_transport_get_queue_size (const __po_hi_port_t portno) +{ + extern __po_hi_uint32_t __po_hi_port_global_queue_size[__PO_HI_NB_PORTS]; + + if (portno >= __PO_HI_NB_PORTS) + { + __DEBUGMSG ("[TRANSPORT] Try to get the queue size of a non-existing port\n"); + return 1; + } + else + { + return __po_hi_port_global_queue_size[portno]; + } +} + +__po_hi_uint32_t __po_hi_transport_get_data_size (const __po_hi_port_t portno) +{ + extern __po_hi_uint32_t __po_hi_port_global_data_size[__PO_HI_NB_PORTS]; + + if (portno >= __PO_HI_NB_PORTS) + { + __DEBUGMSG ("[TRANSPORT] Try to get the data size of a non-existing port\n"); + return 1; + } + else + { + return __po_hi_port_global_data_size[portno]; + } +} + +__po_hi_port_kind_t __po_hi_transport_get_port_kind (const __po_hi_port_t portno) +{ + extern __po_hi_port_kind_t __po_hi_port_global_kind[__PO_HI_NB_PORTS]; + if (portno >= __PO_HI_NB_PORTS) + { + __DEBUGMSG ("[TRANSPORT] Try to get the type/kind of a non-existing port\n"); + return __PO_HI_INVALID_PORT_KIND; + } + else + { + return __po_hi_port_global_kind[portno]; + } + +} + +#ifdef XM3_RTEMS_MODE +void __po_hi_transport_xtratum_port_init (const __po_hi_port_t portno, int val) +{ + __po_hi_xtratum_port[portno] = val; +} + +int __po_hi_transport_xtratum_get_port (const __po_hi_port_t portno) +{ + return __po_hi_xtratum_port[portno]; +} +#endif + +