Commit 97e1393d authored by Maxime Perrotin's avatar Maxime Perrotin

Sync with subversion

parent 82de8cbd
Pipeline #350 skipped
......@@ -42,6 +42,7 @@ endif
# strip $(exec)
install:
$(MAKE)
cp buildsupport `ocarina-config --prefix`/bin/
cp misc/driveGnuPlotsStreams.pl `ocarina-config --prefix`/bin/
......
This diff is collapsed.
......@@ -34,7 +34,8 @@ package Imported_Routines is
Id : String;
LenId : Integer;
Node_Name : String;
Len_Node : Integer);
Len_Node : Integer;
Coverage : Integer);
procedure C_New_Processor (Name : String;
Name_Len : Integer;
......
This diff is collapsed.
......@@ -73,6 +73,15 @@ int ada_gw_preamble(FV * fv)
FOREACH(i, Interface, fv->interfaces, {
FOREACH(p, Parameter, i->in, ADD_TO_SET(ASN1_Module, modules, p->asn1_module));
FOREACH(p, Parameter, i->out, ADD_TO_SET(ASN1_Module, modules, p->asn1_module));
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")) {
ADD_TO_SET(ASN1_Module,
modules,
asn2underscore(cp->type.module, strlen(cp->type.module)));
}
});
});
FOREACH(m, ASN1_Module, modules, {
......@@ -99,7 +108,7 @@ int ada_gw_preamble(FV * fv)
"\t%s : asn1Scc%s := context_%s.%s_ctxt.%s;\n"
"\tpragma export(C, %s, \"%s_%s\");\n",
cp->name,
cp->type.name,
asn2underscore(cp->type.name, strlen(cp->type.name)),
fv->name,
fv->name,
cp->name,
......
/* 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 */
/* build_c_skeletons.c
......@@ -6,6 +6,7 @@
this program generates empty C functions respecting the interfaces defined
in the interface view. it provides functions to invoke RI.
updated 10/06/2016: properly align params and use FOREACH
updated 20/04/2009 to disable in case "-onlycv" flag is set
updated 8/10/2009 to rename the user_code.h/c to FV_name.h/c like in the Ada backend
*/
......@@ -58,7 +59,7 @@ void c_gw_preamble(FV * fv)
/* b. user_code.c preamble (if applicable) */
if (NULL != user_code_c) {
fprintf(user_code_c,
"/* Functions to be filled by the user (never overwritten by buildsupport tool) */\n\n");
"/* User code: This file will not be overwritten by TASTE. */\n\n");
fprintf(user_code_c, "#include \"%s.h\"\n\n", fv->name);
......@@ -92,12 +93,14 @@ int Init_C_GW_Backend(FV * fv, bool generateC)
strlen(fv->system_ast->context->output));
}
build_string(&path, fv->name, strlen(fv->name));
build_string(&filename, fv->name, strlen(fv->name));
build_string(&filename, ".h", strlen(".h"));
create_file(path, filename, &user_code_h);
create_file(path, filename, &user_code_h);
filename[strlen(filename) - 1] = 'c'; /* change from .h to .c */
if (cpp == fv->language) {
build_string(&filename, "c", 1); /* change from .c to .cc */
}
if (!file_exists(path, filename) && true == generateC)
create_file(path, filename, &user_code_c);
......@@ -131,79 +134,92 @@ void close_c_gw_files()
*/
void add_PI_to_C_gw(Interface * i)
{
Parameter_list *tmp;
if (NULL == user_code_h)
return;
fprintf(user_code_h, "void %s_PI_%s(", i->parent_fv->name, i->name);
if (NULL != user_code_c)
fprintf(user_code_c, "void %s_PI_%s(", i->parent_fv->name,
i->name);
char *signature = make_string("void %s_PI_%s(",
i->parent_fv->name,
i->name);
tmp = i->in;
size_t sig_len = strlen(signature);
char *sep = make_string(",\n%*s", sig_len, "");
bool comma = false;
while (NULL != tmp) {
fprintf(user_code_h, "%sconst asn1Scc%s *",
(tmp != i->in) ? ", " : "", tmp->value->type);
if (NULL != user_code_c)
fprintf(user_code_c, "%sconst asn1Scc%s *IN_%s",
(tmp != i->in) ? ", " : "",
tmp->value->type, tmp->value->name);
tmp = tmp->next;
}
fprintf(user_code_h, "%s", signature);
tmp = i->out;
while (NULL != tmp) {
fprintf(user_code_h, "%sasn1Scc%s *",
(tmp != i->out
|| (tmp == i->out
&& NULL != i->in)) ? ", " : "", tmp->value->type);
if (NULL != user_code_c)
fprintf(user_code_c, "%sasn1Scc%s *OUT_%s",
(tmp != i->out
|| (tmp == i->out
&& NULL != i->in)) ? ", " : "", tmp->value->type,
tmp->value->name);
tmp = tmp->next;
if (NULL != user_code_c) {
fprintf(user_code_c, "%s", signature);
}
FOREACH (p, Parameter, i->in, {
char *sort = make_string("%sconst asn1Scc%s *",
comma? sep: "",
p->type);
fprintf(user_code_h, "%s", sort);
if(NULL != user_code_c) {
fprintf(user_code_c, "%sIN_%s",
sort,
p->name);
}
free(sort);
comma = true;
});
FOREACH (p, Parameter, i->out, {
char *sort = make_string("%sasn1Scc%s *",
comma? sep: "",
p->type);
fprintf(user_code_h, "%s", sort);
if(NULL != user_code_c) {
fprintf(user_code_c, "%sOUT_%s",
sort,
p->name);
}
free(sort);
comma = true;
});
fprintf(user_code_h, ");\n\n");
if (NULL != user_code_c)
fprintf(user_code_c, ")\n{\n /* Write your code here! */\n}\n\n");
free(signature);
free(sep);
}
/* Declaration of the RI in user_code.h */
void add_RI_to_C_gw(Interface * i)
{
Parameter_list *tmp;
if (NULL == user_code_h)
return;
fprintf(user_code_h, "extern void %s_RI_%s(", i->parent_fv->name,
i->name);
char *signature = make_string("extern void %s_RI_%s(",
i->parent_fv->name,
i->name);
tmp = i->in;
size_t sig_len = strlen(signature);
char *sep = make_string(",\n%*s", sig_len, "");
bool comma = false;
while (NULL != tmp) {
fprintf(user_code_h, "%sconst asn1Scc%s *",
(tmp != i->in) ? ", " : "", tmp->value->type);
tmp = tmp->next;
}
fprintf(user_code_h, "%s", signature);
tmp = i->out;
FOREACH (p, Parameter, i->in, {
fprintf(user_code_h, "%sconst asn1Scc%s *",
comma? sep: "",
p->type);
comma = true;
});
while (NULL != tmp) {
fprintf(user_code_h, "%sasn1Scc%s *",
(tmp != i->out
|| (tmp == i->out
&& NULL != i->in)) ? ", " : "", tmp->value->type);
tmp = tmp->next;
}
FOREACH (p, Parameter, i->out, {
fprintf(user_code_h,"%sconst asn1Scc%s *",
comma? sep: "",
p->type);
comma = true;
});
fprintf(user_code_h, ");\n\n");
free(signature);
free(sep);
}
/* Add timer declarations to the C code skeletons */
......
/* 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 */
/* build_script.c
this backend generates parts of the build_sample.sh script that are project-specific.
this backend generates the build script that generates the binary files
1st version 20 may 2009
......@@ -105,20 +105,34 @@ void Create_script()
fprintf (script, "SKELS=\"%s\"\n\n", OUTPUT_PATH);
fprintf (script, "# Update the data view with local paths\n"
"taste-update-data-view\n\n");
/* OpenGEODE-specific: call code generator on the fly */
FOREACH (fv, FV, get_system_ast()->functions, {
if (sdl == fv->language) {
fprintf(script,
"# Generate code for OpenGEODE function %s\n"
"cd \"$SKELS\"/%s && "
"opengeode --toAda %s.pr system_structure.pr "
"&& cd $OLDPWD\n\n",
fv->name, fv->name, fv->name);
}
});
/* Remove old zip files and create fresh new ones from user code */
fprintf (script, "cd \"$SKELS\"\n");
FOREACH (fv, FV, get_system_ast()->functions, {
//if (sdl != fv->language PUT BACK WHEN OPENGEODE FULLY SUPPORTED
if (vhdl != fv->language
&& gui != fv->language
&& rtds != fv->language
&& NULL == fv->zipfile) {
fprintf (script, "rm -f %s.zip\n", fv->name);
fprintf (script, "zip %s %s/*\n", fv->name, fv->name);
fprintf (script,
"cd \"$SKELS\" && rm -f %s.zip && "
"zip %s %s/* && cd $OLDPWD\n\n",
fv->name, fv->name, fv->name);
}
})
fprintf (script, "cd \"$OLDPWD\"\n\n");
fprintf (script, "[ ! -z \"$CLEANUP\" ] && rm -rf binary\n\n");
......@@ -215,11 +229,21 @@ void Create_script()
}
})
/* If node is configured with code coverage flag, set the option */
FOREACH (process, Process, get_system_ast()->processes, {
if (true == process->coverage) {
fprintf(script,
" \\\n\t--nodeOptions %s@gcov=on",
process->name);
}
});
/* Let user add custom orchestrator flags */
fprintf (script, " \\\n\t$ORCHESTRATOR_OPTIONS\n");
close_file(&script);
if (chmod ("build-script.sh", S_IRWXG | S_IRWXO | S_IRWXU)) {
fprintf (stderr, "Warning: Unable to change mode of build-script.sh to make it executable\n");
fprintf (stderr, "Warning: Unable to change mode of build-script.sh to make it executable\n");
}
}
......
......@@ -8,8 +8,6 @@
*/
#define ID "$Id$"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -319,7 +317,7 @@ void Set_Context_Variable (char *name, size_t len1, char *type, size_t len2,
{
Context_Parameter *cp = NULL;
unsigned int i = 0;
cp = (Context_Parameter *) malloc (sizeof (Context_Parameter));
assert (NULL != cp);
......@@ -334,7 +332,7 @@ void Set_Context_Variable (char *name, size_t len1, char *type, size_t len2,
/* First check the validity of the ASN.1 module name */
if (!strncmp (mod, "nomodule", len4)) {
ERROR ("** Error: The dataview you are using was generated using an old version\n");
ERROR (" of the toolchain. You must update it by calling asn2aadlPlus.py <file.asn>.\n");
ERROR (" of the toolchain. You must update it by calling taste-update-data-view\n");
exit (-1);
}
/* Temporary for the SMP2 support until version of taste-IV withtout obj suffixes */
......@@ -503,7 +501,8 @@ void New_Process(char *procname,
char *procid,
size_t lenid,
char *node,
size_t lennode)
size_t lennode,
bool coverage)
{
Create_Process(&process);
......@@ -520,6 +519,7 @@ void New_Process(char *procname,
old_cpu_name);
//free(old_cpu_name);
}
process->coverage = coverage;
}
}
......@@ -907,7 +907,7 @@ void Add_RI(char *ri, size_t length,
RI);
}
/* add an IN parameter to the list */
/* add an IN parameter to the list (name respects the case) */
void Add_In_Param(char *name, size_t l1,
char *type, size_t l2,
char *module, size_t l3,
......@@ -917,8 +917,14 @@ void Add_In_Param(char *name, size_t l1,
Create_Parameter(&parameter);
assert (NULL != parameter && NULL != interface);
char *param_name = name;
build_string(&(parameter->name), name, l1);
if (0 == system_ast->context->keep_case) {
// user does not want to keep case of the parameters
param_name = string_to_lower(name);
}
build_string(&(parameter->name), param_name, l1);
build_string(&(parameter->type), type, l2);
build_string(&(parameter->asn1_module), module, l3);
build_string(&(parameter->asn1_filename), filename, l4);
......@@ -938,8 +944,14 @@ void Add_Out_Param(char *name, size_t l1,
Create_Parameter(&parameter);
assert (NULL != parameter && NULL != interface);
char *param_name = name;
if (0 == system_ast->context->keep_case) {
// user does not want to keep case of the parameters
param_name = string_to_lower(name);
}
build_string(&(parameter->name), name, l1);
build_string(&(parameter->name), param_name, l1);
build_string(&(parameter->type), type, l2);
build_string(&(parameter->asn1_module), module, l3);
build_string(&(parameter->asn1_filename), filename, l4);
......
......@@ -21,8 +21,6 @@
static FILE *h = NULL, *cfile = NULL;
extern void Check_If_A_Calling_Thread_Has_No_Async_RI(FV *, int *);
/* Adds header to files */
void c_wrappers_preamble(FV * fv)
{
......@@ -224,10 +222,10 @@ void add_sync_PI_to_c_wrappers(Interface * i)
fprintf(h, "----------------------------------------------------*/\n");
fprintf(h, "void sync_%s_%s(int", i->parent_fv->name, i->name);
FOREACH(p, Parameter, i->in, {
(void) p; fprintf(h, ", void *, int");});
(void) p; fprintf(h, ", void *, size_t");});
FOREACH(p, Parameter, i->out, {
(void) p; fprintf(h, ", void *, int *");});
(void) p; fprintf(h, ", void *, size_t *");});
fprintf(h, ");\n\n");
......@@ -241,11 +239,11 @@ void add_sync_PI_to_c_wrappers(Interface * i)
fprintf(cfile, "void sync_%s_%s(int calling_thread",
i->parent_fv->name, i->name);
FOREACH(p, Parameter, i->in, {
fprintf(cfile, ", void *%s, int %s_len", p->name, p->name);
fprintf(cfile, ", void *%s, size_t %s_len", p->name, p->name);
});
FOREACH(p, Parameter, i->out, {
fprintf(cfile, ", void *%s, int *%s_len", p->name, p->name);
fprintf(cfile, ", void *%s, size_t *%s_len", p->name, p->name);
});
fprintf(cfile, ")\n{\n");
......@@ -592,8 +590,8 @@ void Generate_C_CallingStack(FV * fv)
if (2 > count)
return;
fprintf(h, "static int %s_stack[%d] = {0};\n\n", fv->name, count);
/*
fprintf(cfile, "static int %s_stack[%d] = {0};\n\n", fv->name, count);
/*
In C we would need a semaphore to protect the stack.
TO BE INVESTIGATED (we could create a new function with protected interfaces at system level)
But when we are already in a protected function there is no risk to be preempted by a higher
......@@ -610,6 +608,7 @@ void Generate_C_CallingStack(FV * fv)
fprintf(cfile,
"#ifdef __unix__\n\tprintf(\"### STACK ERROR (GET TOP EMPTY STACK) in %s\\n\");\n#endif\n",
fv->name);
fprintf(cfile, "return -1;\n");
fprintf(cfile, "}\n\n");
/* push function */
......
/* 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 */
/* Practical functions used by the backends */
......@@ -14,6 +14,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
#include <stdbool.h>
#include "practical_functions.h"
......@@ -21,12 +22,16 @@
char *asn2underscore(char *s, size_t len)
{
unsigned int i = 0;
char *result = (char*) malloc(len + 1);
for (i = 0; i < (unsigned int)len; i++)
if ('-' == s[i])
s[i] = '_';
assert(NULL != result);
for (i = 0; i < (unsigned int)len; i++) {
result[i] = ('-' == s[i])? '_': s[i];
}
result[len] = '\0';
return s;
return result;
}
/* Convert a string to lowercase - create a new string */
......@@ -349,6 +354,7 @@ void Create_Process(Process ** p)
(*p)->bindings = NULL;
(*p)->drivers = NULL;
(*p)->connections = 0;
(*p)->coverage = false;
}
}
......@@ -930,7 +936,6 @@ void Clear_FV(FV * fv)
free(fv->name);
fv->name = NULL;
}
if (NULL != fv->nameWithCase) {
free(fv->nameWithCase);
fv->nameWithCase = NULL;
......@@ -986,8 +991,6 @@ void Clear_System(System * s)
Clear_FV_List(s->functions);
//Clear_Processes_List(s->processes);
Clear_Packages_List(s->packages);
Clear_Connections_List(s->connections);
......@@ -1157,23 +1160,6 @@ void Add_With_RI_Wrapper_to_Ada(Interface * i, FILE ** file)
}
/*
* Check if there is at least one cyclic PI in a function
*/
void IsThereAtLeastOneCyclicPI(Interface * i, int *res)
{
if (PI == i->direction && cyclic == i->rcm)
*res = 1;
}
/* Check if there is at least one ASYNC RI in the current FV */
void IsThereAtLeastOneAsyncRI(Interface * i, int *res)
{
if (RI == i->direction && asynch == i->synchronism)
*res = 1;
}
/*
* Write to file the list of parameters with their type, separated with commas:
* const asn1SccTYPE1 *IN_param1, ..., asn1SccTYPEi *OUT_parami
......
This diff is collapsed.
This diff is collapsed.
......@@ -220,7 +220,7 @@ void write_thread_implementation(FV *fv)
}
/* Default source stack size per thread */
fprintf(thread,"\tSource_Stack_Size => 250 KByte;\n");
fprintf(thread,"\tSource_Stack_Size => 50 KByte;\n");
/* Calculate the priority : temporary solution using the period */
FOREACH(i, Interface, fv->interfaces, {
......@@ -811,6 +811,9 @@ void GenerateProcessImplementation(Process *p)
else {
fprintf (nodes, " default");
}
if (p->coverage) {
fprintf(nodes, " coverage");
}
fprintf (nodes, "\n");
FOREACH(b, Aplc_binding, p->bindings, {
fprintf(nodes, "%s\n", b->fv->name);
......
......@@ -29,11 +29,11 @@ void Add_Binding(char *b, size_t length);
void Set_Current_Process(Process *p);
void End_Process();
void New_Drivers_Section();
void End_Drivers_Section();
void End_Drivers_Section();
void New_Processor (char *name, size_t name_length,
char *classifier, size_t classifier_length,
char* platform, size_t platform_length);
void New_Process(char *, size_t, char *,size_t, char *, size_t);
void New_Process(char *, size_t, char *,size_t, char *, size_t, bool);
void Set_OutDir(char *o,size_t len);
void Set_Interfaceview (char *name, size_t len);
void Set_Dataview (char *name, size_t len);
......
......@@ -148,7 +148,7 @@ typedef struct t_contextparam {
DECLARE_LIST (Context_Parameter)
/*
/*
Type used to define a parameter's attributes (name, type, encoding)
*/
typedef struct t_parameter {
......@@ -313,6 +313,7 @@ typedef struct t_process {
Aplc_binding_list *bindings;
Device_list *drivers;
unsigned int connections;
bool coverage;
} Process;
DECLARE_LIST(Process)
......
......@@ -19,7 +19,7 @@
/* Return a string representing the selected encoding rules for a Parameter */
#define BINARY_ENCODING(p) (native==p->encoding)?"NATIVE":(uper==p->encoding)?"UPER":(acn==p->encoding)?"ACN":"#ERROR#"
#define LANGUAGE(fv) ada==fv->language?"Ada": c==fv->language?"C": sdl==fv->language?"OG": rtds==fv->language?"RTDS": scade==fv->language?"SCADE6":simulink==fv->language?"SIMULINK": blackbox_device==fv->language? "C": rhapsody==fv->language? "C": vhdl==fv->language?"VHDL": system_c==fv->language?"SYSTEM_C":gui==fv->language?"GUI": qgenc==fv->language?"QGenC": qgenada==fv->language?"QGenAda":"UNSUPPORTED_LANGUAGE!"
#define LANGUAGE(fv) ada==fv->language?"Ada": c==fv->language?"C": sdl==fv->language?"OG": rtds==fv->language?"RTDS": scade==fv->language?"SCADE6":simulink==fv->language?"SIMULINK": blackbox_device==fv->language? "C": rhapsody==fv->language? "C": vhdl==fv->language?"VHDL": system_c==fv->language?"SYSTEM_C":gui==fv->language?"GUI": qgenc==fv->language?"QGenC": qgenada==fv->language?"QGenAda": cpp==fv->language?"CPP": "UNSUPPORTED_LANGUAGE!"
#define RCM_KIND(IF) (protected==IF->rcm?"protected":unprotected==IF->rcm?"unprotected":sporadic==IF->rcm?"sporadic":cyclic==IF->rcm?"cyclic":variator==IF->rcm?"variator":"unknown")
......@@ -181,13 +181,6 @@ void Create_QGenAda_Argument(char * name, char **result, bool deref);
*/
void Add_With_RI_Wrapper_to_Ada(Interface *i, FILE **file);
/* Check if there is at least one cyclic PI in a function
*/
void IsThereAtLeastOneCyclicPI (Interface *i, int *res);
/* Check if there is at least one ASYNC RI in the current FV */
void IsThereAtLeastOneAsyncRI (Interface *i, int *res);
/* Copy an interface */
Interface *Duplicate_Interface (IF_type direction, Interface *i, FV *fv);
......
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