Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
buildsupport
Commits
43ecb12e
Commit
43ecb12e
authored
Dec 15, 2016
by
Maxime Perrotin
Browse files
Make timer resolution user-defined
parent
63b0d5c3
Changes
9
Hide whitespace changes
Inline
Side-by-side
README
View file @
43ecb12e
...
...
@@ -2,7 +2,7 @@ buildsupport is a low-level TASTE command, responsible for the generation of ske
License: LGPL (see LICENSE file)
Copyright (c) 2008-201
5
European Space Agency
Copyright (c) 2008-201
6
European Space Agency
ada/buildsupport.adb
View file @
43ecb12e
...
...
@@ -66,6 +66,7 @@ procedure BuildSupport is
Success
:
Boolean
;
OutDir
:
Integer
:=
0
;
Stack_Val
:
Integer
:=
0
;
Timer_Resolution
:
Integer
:=
0
;
Subs
:
Node_id
;
Interface_view
:
Integer
:=
0
;
Concurrency_view
:
Integer
:=
0
;
...
...
@@ -168,6 +169,13 @@ procedure BuildSupport is
Ada
.
Command_Line
.
Argument
(
stack_val
)'
Length
);
end
if
;
-- Set the timer resolution value
if
Timer_Resolution
>
0
then
Imported_Routines
.
C_Set_Timer_Resolution
(
Ada
.
Command_Line
.
Argument
(
Timer_Resolution
),
Ada
.
Command_Line
.
Argument
(
Timer_Resolution
)'
Length
);
end
if
;
-- Current_function is read from the list of system subcomponents
Current_function
:=
First_Node
(
Subcomponents
(
My_System
));
...
...
@@ -1334,6 +1342,7 @@ procedure BuildSupport is
Previous_CView
:
Boolean
:=
False
;
Previous_DataView
:
Boolean
:=
False
;
Previous_Stack
:
Boolean
:=
False
;
Previous_TimerRes
:
Boolean
:=
False
;
begin
for
J
in
1
..
Ada
.
Command_Line
.
Argument_Count
loop
-- Parse the file corresponding to the Jth argument of the
...
...
@@ -1359,6 +1368,10 @@ procedure BuildSupport is
Stack_Val
:=
J
;
Previous_Stack
:=
false
;
elsif
Previous_TimerRes
then
Timer_Resolution
:=
J
;
Previous_TimerRes
:=
false
;
elsif
Ada
.
Command_Line
.
Argument
(
J
)
=
"--polyorb-hi-c"
or
else
Ada
.
Command_Line
.
Argument
(
J
)
=
"-p"
or
else
Ada
.
Command_Line
.
Argument
(
J
)
=
"-polyorb-hi-c"
...
...
@@ -1423,6 +1436,12 @@ procedure BuildSupport is
then
Previous_Stack
:=
True
;
elsif
Ada
.
Command_Line
.
Argument
(
J
)
=
"--timer"
or
else
Ada
.
Command_Line
.
Argument
(
J
)
=
"-timer"
or
else
Ada
.
Command_Line
.
Argument
(
J
)
=
"-x"
then
Previous_TimerRes
:=
True
;
elsif
Ada
.
Command_Line
.
Argument
(
J
)
=
"--deploymentview"
or
else
Ada
.
Command_Line
.
Argument
(
J
)
=
"-c"
then
...
...
ada/buildsupport_utils.adb
View file @
43ecb12e
...
...
@@ -69,7 +69,9 @@ package body Buildsupport_Utils is
Put
(
"-g, --debug"
&
HT
&
HT
&
HT
&
HT
);
Put_Line
(
"Generate runtime debug output"
);
Put
(
"-s, --stack <stack-value>"
&
HT
&
HT
);
Put_Line
(
"Set the size of the stack in kbytes (default 100)"
);
Put_Line
(
"Set the size of the stack per thread in kbytes (default 50)"
);
Put
(
"-x, --timer <timer-resolution in ms>"
&
HT
);
Put_Line
(
"Set the timer resolution (default 100 ms)"
);
Put
(
"-v, --version"
&
HT
&
HT
&
HT
&
HT
);
Put_Line
(
"Display buildsupport version number"
);
Put
(
"-p, --polyorb-hi-c"
&
HT
&
HT
&
HT
);
...
...
ada/imported_routines.ads
View file @
43ecb12e
...
...
@@ -8,6 +8,7 @@ package Imported_Routines is
procedure
C_Set_OutDir
(
Dir
:
String
;
Len
:
Integer
);
procedure
C_Set_Stack
(
Val
:
String
;
Len
:
Integer
);
procedure
C_Set_Timer_Resolution
(
Val
:
String
;
Len
:
Integer
);
procedure
C_New_APLC
(
Arg
:
String
;
Len
:
Integer
);
procedure
C_New_FV
(
Arg
:
String
;
Len
:
Integer
;
CS
:
String
);
...
...
@@ -211,6 +212,7 @@ private
pragma
Import
(
C
,
C_Set_Interfaceview
,
"Set_Interfaceview"
);
pragma
Import
(
C
,
C_Set_Dataview
,
"Set_Dataview"
);
pragma
Import
(
C
,
C_Set_Stack
,
"Set_Stack"
);
pragma
Import
(
C
,
C_Set_Timer_Resolution
,
"Set_Timer_Resolution"
);
pragma
Import
(
C
,
C_New_APLC
,
"New_APLC"
);
pragma
Import
(
C
,
C_New_FV
,
"New_FV"
);
pragma
Import
(
C
,
C_Add_PI
,
"Add_PI"
);
...
...
c/c_ast_construction.c
View file @
43ecb12e
...
...
@@ -445,6 +445,22 @@ void Set_Test()
}
}
void
Set_Timer_Resolution
(
char
*
val
,
size_t
len
)
{
errno
=
0
;
if
(
NULL
!=
(
system_ast
->
context
))
{
char
*
str
=
make_string
(
"%.*s"
,
len
,
val
);
int
time_res
=
(
int
)
strtol
(
str
,
(
char
**
)
NULL
,
10
);
if
(
0
!=
errno
)
{
ERROR
(
"** Error: Timer resolution must be a valid number
\n
"
);
}
else
{
printf
(
"[INFO] Set timer resolution to %d
\n
"
,
time_res
);
system_ast
->
context
->
timer_resolution
=
time_res
;
}
}
}
/* Set Future - Flag that can be used for temporary purposes,
* like when migrating from one TASTE version to another one when all
* tools are not ready.
...
...
c/practical_functions.c
View file @
43ecb12e
...
...
@@ -887,6 +887,7 @@ void Create_Context(Context ** context)
(
*
context
)
->
polyorb_hi_c
=
0
;
(
*
context
)
->
stacksize
=
NULL
;
(
*
context
)
->
needs_basictypes
=
false
;
(
*
context
)
->
timer_resolution
=
100
;
// milliseconds
}
// Free the memory of a Context data structure
...
...
c/preprocessing_backend.c
View file @
43ecb12e
...
...
@@ -46,6 +46,7 @@ FV *Add_timer_manager(Process *node, FV_list *fv_with_timer)
char
*
name
=
NULL
;
char
*
path
=
NULL
;
FILE
*
hook
=
NULL
;
int
timer_res
=
get_context
()
->
timer_resolution
;
name
=
make_string
(
"%s_timer_manager"
,
node
->
name
);
...
...
@@ -57,17 +58,17 @@ FV *Add_timer_manager(Process *node, FV_list *fv_with_timer)
assert
(
NULL
!=
fv
&&
NULL
!=
interface
);
interface
->
name
=
make_string
(
"tick_
100ms"
);
interface
->
name
=
make_string
(
"tick_
%dms"
,
timer_res
);
interface
->
distant_fv
=
NULL
;
interface
->
direction
=
PI
;
interface
->
synchronism
=
asynch
;
interface
->
rcm
=
cyclic
;
/* clock rate for timers is 100 ms */
interface
->
period
=
100
;
/* clock rate for timers is 100 ms
by default
*/
interface
->
period
=
timer_res
;
interface
->
parent_fv
=
fv
;
interface
->
wcet_high
=
1
0
;
interface
->
wcet_low
=
1
0
;
interface
->
wcet_high
=
1
;
interface
->
wcet_low
=
1
;
interface
->
wcet_low_unit
=
make_string
(
"ms"
);
interface
->
wcet_high_unit
=
make_string
(
"ms"
);
APPEND_TO_LIST
(
Interface
,
fv
->
interfaces
,
interface
);
...
...
@@ -101,9 +102,10 @@ FV *Add_timer_manager(Process *node, FV_list *fv_with_timer)
fv
->
name
);
fprintf
(
header
,
"void %s_startup();
\n\n
"
"void %s_PI_tick_
100
ms();
\n\n
"
,
"void %s_PI_tick_
%d
ms();
\n\n
"
,
fv
->
name
,
fv
->
name
);
fv
->
name
,
timer_res
);
fprintf
(
code
,
"#include <assert.h>
\n\n
"
"#include
\"
%s.h
\"\n\n
"
,
fv
->
name
);
...
...
@@ -145,8 +147,10 @@ FV *Add_timer_manager(Process *node, FV_list *fv_with_timer)
"}
\n\n
"
,
fv
->
name
);
/* Generate the timer manager code for the cyclic interface */
fprintf
(
code
,
"void %s_PI_tick_100ms()
\n
"
"{
\n
"
,
fv
->
name
);
fprintf
(
code
,
"void %s_PI_tick_%dms()
\n
"
"{
\n
"
,
fv
->
name
,
timer_res
);
FOREACH
(
timer
,
String
,
all_timers
,
{
fprintf
(
code
,
" if (timers[%s].state == active && "
...
...
@@ -175,12 +179,14 @@ void Add_timers_to_function (FV *fv, FV *timer_manager)
Interface
*
expire
=
NULL
,
*
set_timer
=
NULL
,
*
reset_timer
=
NULL
;
Parameter
*
param
=
NULL
;
Interface
*
cyclic_pi
=
NULL
;
int
timer_res
=
get_context
()
->
timer_resolution
;
char
*
cyclic_name
=
make_string
(
"tick_%dms"
,
timer_res
);
assert
(
NULL
!=
header
&&
NULL
!=
code
);
/* Find the cyclic interface of the timer manager */
FOREACH
(
pi
,
Interface
,
timer_manager
->
interfaces
,
{
if
(
!
strcmp
(
pi
->
name
,
"tick_100ms"
))
cyclic_pi
=
pi
;
if
(
!
strcmp
(
pi
->
name
,
cyclic_name
))
cyclic_pi
=
pi
;
});
...
...
@@ -192,18 +198,21 @@ void Add_timers_to_function (FV *fv, FV *timer_manager)
timer
);
fprintf
(
code
,
"void %s_PI_%s_SET_%s(const asn1SccT_UInt32 *val)
\n
"
"{
\n
"
" /* Timer value must be multiple of
100
ms */
\n
"
" assert (*val %%
100
== 0);
\n
"
" /* Timer value must be multiple of
%d
ms */
\n
"
" assert (*val %%
%d
== 0);
\n
"
" timers[%s_%s].state = active;
\n
"
" timers[%s_%s].value = *val /
100
;
\n
"
" timers[%s_%s].value = *val /
%d
;
\n
"
"}
\n\n
"
,
timer_manager
->
name
,
fv
->
name
,
timer
,
timer_res
,
timer_res
,
fv
->
name
,
timer
,
fv
->
name
,
timer
);
timer
,
timer_res
);
fprintf
(
header
,
"void %s_PI_%s_RESET_%s();
\n\n
"
,
timer_manager
->
name
,
fv
->
name
,
...
...
@@ -227,7 +236,7 @@ void Add_timers_to_function (FV *fv, FV *timer_manager)
expire
->
direction
=
PI
;
expire
->
synchronism
=
asynch
;
expire
->
rcm
=
sporadic
;
expire
->
period
=
100
;
expire
->
period
=
timer_res
;
expire
->
parent_fv
=
fv
;
expire
->
wcet_high
=
10
;
expire
->
wcet_low
=
10
;
...
...
include/c_ast_construction.h
View file @
43ecb12e
...
...
@@ -38,6 +38,7 @@ void Set_OutDir(char *o,size_t len);
void
Set_Interfaceview
(
char
*
name
,
size_t
len
);
void
Set_Dataview
(
char
*
name
,
size_t
len
);
void
Set_Test
();
void
Set_Timer_Resolution
(
char
*
val
,
size_t
len
);
void
Set_Future
();
void
Set_OnlyCV
();
void
Set_AADLV2
();
...
...
include/my_types.h
View file @
43ecb12e
...
...
@@ -204,6 +204,7 @@ DECLARE_LIST (Interface)
/*
* Type used to store context-dependent parameters (eg. output directory)
* (initialized in practical_functions.c, update it when you add a field)
*/
typedef
struct
t_context
{
char
*
output
;
...
...
@@ -221,6 +222,7 @@ typedef struct t_context {
char
*
stacksize
;
int
polyorb_hi_c
;
bool
needs_basictypes
;
int
timer_resolution
;
}
Context
;
/*
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment