annotate gsm-fw/services/ffs/mktarget.pl @ 858:4c6e7ada647b

compressed trace decoder almost fully implemented
author Space Falcon <falcon@ivan.Harhan.ORG>
date Sat, 02 May 2015 08:08:26 +0000
parents 30a173257f4a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
217
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 #!/usr/bin/perl -w
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 #
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 # mktarget.pl by Mads Meisner-Jensen (mmj@ti.com)
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 #
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 # Auto-generate target code from ffs.c source file.
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 $FFSPATH = shift;
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 if (!defined($FFSPATH) || $FFSPATH eq "") {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 $FFSPATH = ".";
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 $OUTPATH = shift;
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 if (!defined($OUTPATH) || $OUTPATH eq "") {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 $OUTPATH = $FFSPATH;
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 $verbose = 1;
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 $STATE_OUTSIDE = 0;
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 $STATE_IN_FUNCTION = 1;
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 $STATE_IN_TASK = 2;
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 $state = $STATE_OUTSIDE;
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 ############################################################################
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 # Main
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 ############################################################################
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 $verbose > 0 && print "mktarget.pl operating in directory '$FFSPATH'\n";
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 open (FFS, "<$FFSPATH/ffs.c") || die "Failed to open 'ffs.c'";
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 print $OUTPATH;
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 open (TARGETC, ">$OUTPATH/ffs_target.c") || die "Failed to open 'ffs_target.c'";
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 target_put("/**********************************************************\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 target_put(" *\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 target_put(" * This is an auto-generated file. Do NOT edit!\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 target_put(" *\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 target_put(" **********************************************************/\n\n\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 while (<FFS>)
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 if ($state == $STATE_OUTSIDE)
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 target_put($_);
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 if (/^{\s*$/) {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 $state = $STATE_IN_FUNCTION;
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 elsif ($state == $STATE_IN_FUNCTION)
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 if (/^\s*\/\/\s*TASKBEGIN\s*(\w+)\s*(\w+)\s*\((.*)\)(.*)$/m)
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 $state = $STATE_IN_TASK;
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 $rettype = $1;
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 $func = $2;
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 $funclc = lc($func);
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 @args = split(',', $3);
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 @values = ();
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 @reqmembers = ();
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 foreach (@args) {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 ($left, $right) = $_ =~ /(\w+)=(.+)/m;
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 push (@reqmembers, $left);
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 push (@values, $right);
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 @vars = split(';', $4);
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 task_begin();
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 else
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 target_put($_);
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 if (/^}\s*$/m) {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 $state = $STATE_OUTSIDE;
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 # Write the task_* code after the function
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 target_put("\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 target_put(@taskcode);
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 @taskcode = ();
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 elsif ($state == $STATE_IN_TASK)
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88 {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 if (/^.*TASKEND.*$/m)
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 $state = $STATE_IN_FUNCTION;
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 foreach (@values) {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
94 if (/^[a-zA-Z]+/m) {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 task_put("#undef $_\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 task_put("\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99 # task_put(" return EFFS_OK;\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 task_put("}\n\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102 else {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 task_put($_);
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
105 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
106 else
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
107 {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
108 die "Bad state!";
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 close (FFS) || die;
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113 close (TARGETC) || die;
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115 sub task_put
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117 push (@taskcode, @_);
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 sub target_put
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121 {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122 print TARGETC @_;
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
123 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
124
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
125 sub task_begin
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
126 {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127 $verbose > 0 && print "ffs_$funclc ($func)\n";
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128 $verbose > 1 && print " args = @args\n";
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
129 $verbose > 1 && print " left = @values, right = @reqmembers\n";
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
130 $verbose > 1 && print " vars = @vars\n";
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131 $verbose > 1 && print "\n";
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133 task_put("$rettype task_$funclc(struct ffs_req_s *p)\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 task_put("{\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135 foreach (@vars) {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 task_put(" $_;\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
137 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 task_put("\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139 for $i (0..$#args) {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140 # If value starts with alpha char, e.g. a variable name
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 if ($values[$i] =~ /^[a-zA-Z]+/m) {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142 task_put("#define $values[$i] p->$reqmembers[$i]\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146 target_put(" {\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147 target_put(" struct ffs_req_s *req;\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148 target_put(" MSG_ALLOC(req);\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 for $i (0..$#args) {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151 # Typecasting is necessary for the sake of the tms470 compiler
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
152 if ($reqmembers[$i] eq "src") {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153 target_put(" req->$reqmembers[$i] = (char *) $values[$i];\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
154 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155 else {
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 target_put(" req->$reqmembers[$i] = $values[$i];\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158 }
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
159 target_put(" req->request_id = request_id_get();\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
160 target_put(" req->fb = fb;\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
161 target_put(" req->cp = cp;\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
162 target_put(" req->cmd = $func;\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163 target_put(" MSG_SEND(req);\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
164 target_put(" return req->request_id;\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
165 target_put(" }\n");
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
166
30a173257f4a gsm-fw/services/ffs: ffs_target.c generation and compilation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
167 }