Commit 9e09f330 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Sync with subversion

parent 8b7df180
Pipeline #20 skipped
This diff is collapsed.
......@@ -815,43 +815,51 @@ void Set_Interface_Queue_Size (const unsigned long long s)
}
/* New interface: set the name and distant FV to which it is connected */
void New_Interface(char *name, size_t length, char *dist_fv,
size_t distant_length,
void New_Interface(char *name, size_t length,
char *dist_fv, size_t distant_length,
char *distant_name, size_t dist_name_length,
IF_type direction)
{
interface = NULL;
Create_Interface(&interface);
if (NULL != interface) {
build_string(&(interface->name), name, length);
/* RI can have a local identifier which may be different from
* the corresponding PI it is connected to. In that case we set
* the "distant_name" field of the interface to make sure that
* the connection will be properly handled
*/
if (NULL != distant_name) {
build_string (&(interface->distant_name),
distant_name, dist_name_length);
}
assert (NULL != interface);
build_string(&(interface->name), name, length);
/* Set the port name as the interface name, so that if later
* the interface name is changed, we still know to which port we
* have to connect it (in case of distributed systems */
build_string (&(interface->port_name), name, length);
if (distant_length > 0)
build_string (&(interface->distant_fv), dist_fv,
distant_length);
else
interface->distant_fv = NULL;
interface->direction = direction;
interface->wcet_low = 0;
interface->wcet_high = 0;
interface->wcet_low_unit = NULL;
interface->wcet_high_unit = NULL;
interface->queue_size = 1;
/* RI can have a local identifier which may be different from
* the corresponding PI it is connected to. In that case we set
* the "distant_name" field of the interface to make sure that
* the connection will be properly handled
*/
if (NULL != distant_name) {
build_string (&(interface->distant_name),
distant_name, dist_name_length);
}
/* Set the port name as the interface name, so that if later
* the interface name is changed, we still know to which port we
* have to connect it (in case of distributed systems */
build_string (&(interface->port_name), name, length);
if (distant_length > 0) {
build_string (&(interface->distant_fv), dist_fv, distant_length);
}
else {
interface->distant_fv = NULL;
}
interface->direction = direction;
interface->wcet_low = 0;
interface->wcet_high = 0;
interface->wcet_low_unit = NULL;
interface->wcet_high_unit = NULL;
interface->queue_size = 1;
/* ignore params will be kept to true if all callers of a given PI
* are located in the same node (binary) - in that case the parameters
* will not be copied from the sender to the receiver through the orb
* but made available directly through global pointers.
*/
interface->ignore_params = true;
}
/* New Provided interface */
......@@ -872,21 +880,21 @@ void Add_RI(char *ri, size_t length,
char *dist_fv, size_t distant_length,
char *dist_name, size_t dist_name_length)
{
size_t tmp = 0;
char *local_name = ri;
size_t tmp = 0;
char *local_name = ri;
assert (NULL != ri);
assert (NULL != dist_fv);
assert (NULL != dist_name);
tmp = remove_objXXX_suffix (ri, length);
tmp = remove_objXXX_suffix (ri, length);
dist_name_length = remove_objXXX_suffix (dist_name, dist_name_length);
/* If the first 3 characters of the local RI name are "obj" we suppose
* it is a name generated randomly by TASTE-IV. In that case we replace
* the local RI name with the name of the remote PI.
* Whenever TASTE-IV is fixed (after version 1.1.2)
* this should become obsolete */
* This is kept only for backward compatibility
*/
if (tmp >= 4 && !strncmp (ri, "obj", 3)) {
local_name = dist_name;
length = dist_name_length;
......@@ -900,9 +908,9 @@ void Add_RI(char *ri, size_t length,
}
/* add an IN parameter to the list */
void Add_In_Param(char *name, size_t l1,
char *type, size_t l2,
char *module, size_t l3,
void Add_In_Param(char *name, size_t l1,
char *type, size_t l2,
char *module, size_t l3,
char *filename, size_t l4)
{
type = asn2underscore(type, l2);
......@@ -1038,13 +1046,15 @@ void CompareFVname(FV * fv_local, FV ** result)
}
}
/* main function to be called */
FV *FindFV(char *fv_name)
{ /* main function to be called */
{
FV *result_fv = NULL;
SetSearchName(fv_name);
FOREACH(f, FV, system_ast->functions, {
CompareFVname(f, &result_fv);})
SetSearchName(NULL);
CompareFVname(f, &result_fv);
});
SetSearchName(NULL);
return result_fv;
}
......@@ -1074,9 +1084,24 @@ Interface *FindInterface(FV * function, char *interface_name)
return result;
}
/* Given a PI (from any function) and a known caller, find the corresponding
* RI in the remote function
*/
Interface *FindCorrespondingRI(FV *remote, Interface *pi)
{
FOREACH (i, Interface, remote->interfaces, {
if (RI == i->direction &&
!strcmp (i->distant_name, pi->name) &&
!strcmp (i->distant_fv, pi->parent_fv->name)) {
return i;
}
});
return NULL;
}
/* End Find Interface functions */
/* Return the list of FV calling a given PI
/* Return the list of FV calling a given PI
the conditions are, for each RI of each FV that :
- RI's distant name = PI's name
- RI's distant FV = PI's parent FV
......@@ -1133,18 +1158,17 @@ void Delete_System_AST()
Clear_System(system_ast);
}
/* Get dataview file name based (same as dataview.aadl
* passed with -d but replace with .asn extension */
/* Get dataview file name based (same as dataview.aadl
* passed with -d but replace with .asn extension
*/
char *getASN1DataView()
{
char *p = strrchr (get_context()->dataview,'/');
if (NULL == p) p = get_context()->dataview - 1;
return make_string
("%.*s.asn",
strlen (p + 1) - strlen (".aadl"),
p + 1);
return make_string ("%.*s.asn", strlen (p + 1) - strlen (".aadl"), p + 1);
}
/* Get dataView path */
char *getDataViewPath()
{
......@@ -1190,11 +1214,12 @@ void Print_Interface(Interface * i)
printf("\tperiod/miat = %lld\n", i->period);
printf("\tdistant_fv = %s\n", i->distant_fv);
printf("\tdistant_name = %s\n", i->distant_name);
printf("\twcet = %llu %s .. %llu %s\n\n",
printf("\twcet = %llu %s .. %llu %s\n",
(unsigned long long) i->wcet_low,
i->wcet_low_unit,
(unsigned long long) i->wcet_high,
i->wcet_high_unit);
printf("\tignore params = %s\n\n", i->ignore_params ? "true": "false");
}
void Dump_Interfaces(Interface_list * l)
......
/* Buildsupport is (c) 2008-2015 European Space Agency
/* Buildsupport is (c) 2008-2016 European Space Agency
* contact: maxime.perrotin@esa.int
* License is LGPL, check LICENSE file */
/*
......@@ -46,8 +46,8 @@ void C_End()
Semantic_Checks();
/*
* Temporary support for OpenGEODE - Will be removed when TASTE-IV supports it
* Replace SDL language with Ada for building glue code
* Temporary support for OpenGEODE
* Replace SDL language with Ada for building glue code
*/
if (get_context()->glue) {
FOREACH(fv, FV, get_system_ast()->functions, {
......@@ -57,21 +57,22 @@ void C_End()
/* Mark the callers of QGen functions */
FOREACH(fv, FV, get_system_ast()->functions, {
FOREACH(i, Interface, fv->interfaces, {
if (RI == i->direction) {
FV *connected_fv = NULL;
Interface *connected_pi = NULL;
connected_fv = FindFV (i->distant_fv);
if ((connected_fv != NULL) && ((qgenada == connected_fv->language) || (qgenc == connected_fv->language))) {
i->distant_qgen->language = connected_fv->language;
i->distant_qgen->fv_name = connected_fv->name;
connected_pi = FindInterface (connected_fv, i->distant_name);
if (connected_pi != NULL) {
connected_pi->distant_qgen->language = connected_fv->language;
connected_pi->distant_qgen->fv_name = fv->name;
}
FOREACH(i, Interface, fv->interfaces, {
if (RI == i->direction) {
FV *connected_fv = NULL;
Interface *connected_pi = NULL;
connected_fv = FindFV (i->distant_fv);
if ((connected_fv != NULL) &&
((qgenada == connected_fv->language) || (qgenc == connected_fv->language))) {
i->distant_qgen->language = connected_fv->language;
i->distant_qgen->fv_name = connected_fv->name;
connected_pi = FindInterface (connected_fv, i->distant_name);
if (connected_pi != NULL) {
connected_pi->distant_qgen->language = connected_fv->language;
connected_pi->distant_qgen->fv_name = fv->name;
}
}
}
});
});
......@@ -95,9 +96,9 @@ void C_End()
});
});
/*
/*
* If Semantic errors have been found (erros in the user AADL models),
* then the application is exited with an error message.
* then the application is exited with an error message.
*/
if (error_count > 0) {
fprintf(stderr, "\nFound %d errors.. Aborting...\n", error_count);
......@@ -143,7 +144,7 @@ void C_End()
})
/*
/*
* Perform the first part of the Vertical transformation (-glue flag):
* Tranform the interface view to allow a one-to-one mapping Function-Thread
*/
......@@ -155,35 +156,33 @@ void C_End()
* Debug mode (userflag -test) : dump the result of the transformation
* TODO: generate an AADL model (equivalent to the Concurrency View)
*/
if (get_system_ast()->context->test)
if (get_system_ast()->context->test) {
Dump_model(get_system_ast());
}
/*
/*
* Execute various backends applicable to each FV
*/
FOREACH(fv, FV, get_system_ast()->functions, {
/*
* Call 'asn2dataModel' if glue code is not required
* (to avoid slowing down the orchestrator, which is
* the only place where the glue code is requested
*/
if (get_context()->gw &&
!get_context()->glue &&
NULL == fv->zipfile) {
FOREACH(fv, FV, get_system_ast()->functions, {
/*
* Call 'asn2dataModel' if glue code is not required
* (to avoid slowing down the orchestrator, which is
* the only place where the glue code is requested
*/
if (get_context()->gw && !get_context()->glue && NULL == fv->zipfile) {
Call_asn2dataModel(fv);
}
}
/* Process all functional states declared in the interface view */
if (get_context()->gw &&
(NULL == fv->zipfile || get_context()->glue)) {
Process_Context_Parameters(fv);
}
/* Process all functional states declared in the interface view */
if (get_context()->gw && (NULL == fv->zipfile || get_context()->glue)) {
Process_Context_Parameters(fv);
}
/* Process function directives */
if (get_context()->glue || get_context()->test) {
Process_Directives (fv);
}
if (get_context()->glue) {
GLUE_OG_Backend(fv);
GLUE_RTDS_Backend(fv);
......@@ -197,7 +196,7 @@ void C_End()
})
/*
* Perform the second part of the Vertical transformation:
* Perform the second part of the Vertical transformation:
* Generate driver configuration
* Generate the full concurrency view (process.aadl et al.)
* Additionnally create an AADL file of the concurrency view
......@@ -212,15 +211,9 @@ void C_End()
(get_system_ast()->name));
AADL_CV_Unparser ();
}
/* Generation of system configuration used by C_ASN1_Types.h */
System_Config(get_system_ast());
}
/*
* Free the memory used by the system AST
* Removed, this is useless at the end of the application
*/
// Delete_System_AST();
}
......@@ -92,15 +92,19 @@ void Process_Context_Parameters(FV *fv)
* In the future this namespace shall comme automatically from Asn1Scc
*/
fprintf(asn, "\nContext-%s ::= SEQUENCE {", fv_no_underscore);
bool first = true;
FOREACH (cp, Context_Parameter, fv->context_parameters, {
if (strcmp (cp->type.name, "Taste-directive") &&
strcmp (cp->type.name, "Simulink-Tunable-Parameter") &&
strcmp(cp->type.name, "Timer")) {
cp_no_underscore = underscore_to_dash
(cp->name, strlen(cp->name));
fprintf(asn, "%s\t%s %s",
cp != fv->context_parameters->value? ",\n": "\n",
cp_no_underscore,
if (false == first) {
fprintf(asn, ",");
}
first = false;
fprintf(asn, "\n\t%s %s",
cp_no_underscore,
cp->type.name);
free (cp_no_underscore);
}
......@@ -113,16 +117,19 @@ void Process_Context_Parameters(FV *fv)
fprintf(asn, "\n%s-ctxt Context-%s ::= {",
fv_no_underscore,
fv_no_underscore);
first = true;
FOREACH (cp, Context_Parameter, fv->context_parameters, {
if (strcmp (cp->type.name, "Taste-directive") &&
strcmp (cp->type.name, "Simulink-Tunable-Parameter") &&
strcmp(cp->type.name, "Timer")) {
cp_no_underscore = underscore_to_dash
(cp->name, strlen(cp->name));
fprintf(asn, "%s\t%s %s",
cp != fv->context_parameters->value? ",\n": "\n",
cp_no_underscore,
if (false == first) {
fprintf(asn, ",");
}
first = false;
fprintf(asn, "\n\t%s %s",
cp_no_underscore,
cp->value);
free (cp_no_underscore);
}
......
/* Buildsupport is (c) 2008-2015 European Space Agency
/* Buildsupport is (c) 2008-2016 European Space Agency
* contact: maxime.perrotin@esa.int
* License is LGPL, check LICENSE file */
/* preprocessing_backend.c
......@@ -13,7 +13,8 @@
3) For each PRO/UNPRO RI of each FV,
attach the RI to the calling thread (SPO/Cyclic FV)
4) If some nodes use timers, generate the code for a timer
manager (one per partition).
manager (one per partition).
5) Set the "ignore_params" flag on interfaces that run on the same node
*/
......@@ -199,61 +200,68 @@ void Add_timers_to_function (FV *fv, FV *timer_manager)
timer,
fv->name,
timer);
/* Add sporadic PI - corresponding to the timer expiration */
expire = NULL;
Create_Interface (&expire);
expire->name = make_string (timer);
expire->distant_name = make_string ("%s_%s", fv->name, timer);
expire->distant_fv = make_string (timer_manager->name);
expire->direction = PI;
expire->synchronism = asynch;
expire->rcm = sporadic;
expire->period = 100;
expire->parent_fv = fv;
expire->wcet_high = 10;
expire->wcet_low = 10;
expire->wcet_low_unit = make_string ("ms");
expire->name = make_string (timer);
expire->distant_name = make_string ("%s_%s", fv->name, timer);
expire->distant_fv = make_string (timer_manager->name);
expire->direction = PI;
expire->synchronism = asynch;
expire->rcm = sporadic;
expire->period = 100;
expire->parent_fv = fv;
expire->wcet_high = 10;
expire->wcet_low = 10;
expire->wcet_low_unit = make_string ("ms");
expire->wcet_high_unit = make_string ("ms");
APPEND_TO_LIST (Interface, fv->interfaces, expire);
/* Add corresponding RI in the timer manager */
expire = Duplicate_Interface (RI, expire, timer_manager);
expire->name = expire->distant_name;
expire->distant_name = make_string (timer);
expire->name = expire->distant_name;
expire->distant_name = make_string (timer);
free (expire->distant_fv);
expire->distant_fv = make_string (fv->name);
expire->distant_fv = make_string (fv->name);
APPEND_TO_LIST (Interface, timer_manager->interfaces, expire);
/* Add Unpro PI "RESET_timer" to timer manager (no param) */
reset_timer = Duplicate_Interface (PI, expire, timer_manager);
free (reset_timer->name);
reset_timer->name = make_string ("RESET_%s", timer);
reset_timer->name = make_string ("RESET_%s", timer);
free (reset_timer->distant_name);
reset_timer->distant_name = make_string (reset_timer->name);
reset_timer->rcm = unprotected;
reset_timer->synchronism = synch;
reset_timer->rcm = unprotected;
reset_timer->synchronism = synch;
APPEND_TO_LIST (Interface, timer_manager->interfaces, reset_timer);
/* Add corresponding RI in the user FV */
reset_timer = Duplicate_Interface (RI, reset_timer, fv);
free (reset_timer->distant_fv);
reset_timer->distant_fv = make_string (timer_manager->name);
APPEND_TO_LIST (Interface, fv->interfaces, reset_timer);
/* Add Unpro PI "SET_timer(value)" in timer manager */
set_timer = Duplicate_Interface (PI, reset_timer, timer_manager);
free (set_timer->name);
set_timer->name = make_string ("SET_%s", timer);
set_timer->name = make_string ("SET_%s", timer);
free (set_timer->distant_name);
set_timer->distant_name = make_string (set_timer->name);
/* Add IN param holding the timer duration */
Create_Parameter (&param);
param->name = make_string ("duration");
param->type = make_string ("T_UInt32");
param->encoding = native;
param->asn1_module = make_string ("taste_basictypes");
param->basic_type = integer;
param->asn1_filename = make_string ("taste-types.asn");
param->interface = set_timer;
param->name = make_string ("duration");
param->type = make_string ("T_UInt32");
param->encoding = native;
param->asn1_module = make_string ("taste_basictypes");
param->basic_type = integer;
param->asn1_filename = make_string ("taste-types.asn");
param->interface = set_timer;
param->param_direction = param_in;
APPEND_TO_LIST (Parameter, set_timer->in, param);
APPEND_TO_LIST (Interface, timer_manager->interfaces, set_timer);
/* Add corresponding RI in the user FV */
set_timer = Duplicate_Interface (RI, set_timer, fv);
free (set_timer->distant_fv);
......@@ -305,9 +313,9 @@ void Add_Artificial_Function (Interface *duplicate_pi,
*/
duplicate_pi->parent_fv = new_fv;
duplicate_pi->rcm=pi_rcm;
duplicate_pi->rcm = pi_rcm;
duplicate_ri =(Interface *) Duplicate_Interface (RI, duplicate_pi, new_fv);
duplicate_ri = (Interface *) Duplicate_Interface (RI, duplicate_pi, new_fv);
duplicate_ri->rcm = ri_rcm;
free(duplicate_ri->distant_fv);
duplicate_ri->distant_fv = NULL;
......@@ -338,7 +346,7 @@ void Add_Artificial_Function (Interface *duplicate_pi,
/* 3) Create a file called "_hook" to add this function
* to the orchestrator work */
path = make_string ("%s/%s", OUTPUT_PATH, new_fv->name);
new_fv->artificial = true;
new_fv->artificial = true;
new_fv->original_name = original_name;
create_file (path, "_hook", &hook);
......@@ -410,15 +418,16 @@ void ProcessArtificial_FV_Creation (Interface *i, RCM rcm)
distant_RI = NULL;
/* Find the corresponding interface in the caller */
FOREACH (interface, Interface, caller->interfaces, {
if (RI == interface->direction &&
!strcmp (interface->distant_name, i->name) &&
!strcmp (interface->distant_fv, i->parent_fv->name)) {
distant_RI = interface;
}
});
if (NULL !=distant_RI
distant_RI = FindCorrespondingRI(caller, i);
// FOREACH (interface, Interface, caller->interfaces, {
// if (RI == interface->direction &&
// !strcmp (interface->distant_name, i->name) &&
// !strcmp (interface->distant_fv, i->parent_fv->name)) {
// distant_RI = interface;
// }
// });
if (NULL != distant_RI
&& strcmp(artificial_fv_name, distant_RI->parent_fv->name)) {
if (NULL != distant_RI->distant_fv) {
free(distant_RI->distant_fv);
......@@ -452,7 +461,7 @@ void ProcessArtificial_FV_Creation (Interface *i, RCM rcm)
i->synchronism = synch;
free (interface_name);
}
/*
/*
* 4th pre-processing:
* check if a RI is not already present in a FV and if not, add it.
* MP 27/07/2010 :
......@@ -461,7 +470,7 @@ void ProcessArtificial_FV_Creation (Interface *i, RCM rcm)
* same synchronism) is not present.
* We can have the same RI name but one being asynchronous,
* the other synchronous.
*/
*/
void Add_RI_To_Thread (Interface *i, FV *fv)
{
bool check = false;
......@@ -473,7 +482,7 @@ void Add_RI_To_Thread (Interface *i, FV *fv)
build_string(&new_name, i->name, strlen(i->name));
build_string(&new_name, "_vt", strlen("_vt"));
/*
/*
* Check if this RI was not already there
* Fixed (MP 27/07/2010) : now allows twice the same RI name
* but with different synchronism
......@@ -594,12 +603,12 @@ void Propagate_Calling_Thread(Interface *i, FV **fv)
}
/*
/*
Set of preprocessing done for each FV independently
*/
void Preprocess_FV (FV *fv)
{
int count_thread = 0,
int count_thread = 0,
count_pro = 0,
count_unpro = 0;
......@@ -636,6 +645,7 @@ void Preprocess_FV (FV *fv)
}
}
}
/*
preprocessing: FV containing more than one
'active' PI (cyclic/sporadic, protected)
......@@ -749,6 +759,30 @@ void Preprocess_timers (Process *node)
Close_Timer_Files();
}
/* Look at all provided interfaces of a function and if some do
* not reside on the same node as any of their callers set the ignore_params
* flag to false. This enables some runtime optimisations wrt buffer copies.
*/
void Set_Ignore_Params(FV *fv)
{
Interface *distant_RI = NULL;
FOREACH(i, Interface, fv->interfaces, {
if (PI == i->direction) {
FOREACH (remote, FV, Find_All_Calling_FV(i), {