blob: c1c7c05deed4c8a9e7404f4c0ec8894da426c76a [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001
2
3package taskHisrParaCheckingAndReport;
4
5use Exporter qw(import);
6our @EXPORT_OK = qw(checkingPriority);
7
8sub checkingTaskPriority
9{
10
11 my $g_task_number = $_[0];
12 my $g_hisr_number = $_[1];
13 my @task_config = @{$_[2]};
14 my @hisr_config = @{$_[3]};
15 my $g_ATEST_DRV_ENABLE = $_[4];
16 my $modem_arch = $_[5];
17
18 my $i=0;
19 my $j=0;
20 my $priority1;
21 my $priority2;
22 my $priority_j1;
23 my $priority_j2;
24 my $priority_max;
25 my $reserved_prio_1;
26 my $reserved_prio_2;
27 my $reserved_prio_3;
28 $ERR_DUPLICATE_TASK_PRIORITY = 14;
29
30 #print "Hello $g_task_number,$g_hisr_number, $task_config,$hisr_config, $g_ATEST_DRV_ENABLE\n";
31
32
33 if($g_ATEST_DRV_ENABLE == 0)
34 {
35 if($modem_arch eq "MT6295"){
36 $priority_max = 256;
37 $reserved_prio_1 = 255;
38 $reserved_prio_2 = 254;
39 $reserved_prio_3 = 253;
40 } else {
41 $priority_max = 512;
42 $reserved_prio_1 = 505;
43 $reserved_prio_2 = 504;
44 $reserved_prio_3 = 503;
45 }
46 #check task priority from next to the end
47 #Even though the task is not created, we will also compare it with others !!
48 while($i < $g_task_number){
49
50 #printf("%-20s %-5d %-5d %-5d\n", $task_config[$i]{'name'}, $task_config[$i]{'prio_1'}, $task_config[$i]{'affinity'}, $task_config[$i]{'exist'});
51
52 $j = $i+1;
53 #bypass task which is not created.
54 if ($task_config[$i]{'exist'} != 0xF0F0F0F0)
55 {
56 $priority1 = $task_config[$i]{'prio_1'};
57 $priority2 = $task_config[$i]{'prio_2'};
58
59 if( $priority1 > $priority_max)
60 {
61 printf "task index %d 1st priority %d > %d\n", $i, $priority1, $priority_max;
62 print "Please check task config or contact config owner!!!";
63 exit $ERR_DUPLICATE_TASK_PRIORITY;
64 }
65
66 if( $priority2 > $priority_max)
67 {
68 printf "task index %d 2nd priority %d > %d\n", $i, $priority2, $priority_max;
69 print "Please check task config or contact config owner!!!";
70 exit $ERR_DUPLICATE_TASK_PRIORITY;
71 }
72
73 while ($j < $g_task_number)
74 {
75
76 $priority_j1 = $task_config[$j]{'prio_1'};
77 $priority_j2 = $task_config[$j]{'prio_2'};
78 # priority 256 means start or tail task. e.g. TASK_ID_SRV_CODE_BEGIN.
79 # 255, 254, 253 reserved for IDLE tasks in Gen97.
80 if ( $priority1 != $priority_max && $priority1 != $reserved_prio_1 && $priority1 != $reserved_prio_2 && $priority1 != $reserved_prio_3)
81 {
82 if( ($priority1 == $priority2) || ($priority1 == $priority_j1) || ($priority1 == $priority_j2)
83 || (($priority2 != $priority_max) && (($priority2 == $priority_j1) || ($priority2 == $priority_j2))) )
84 {
85 #printf "KAL task config Error: duplicate task index %d priority 0x%08X, index %d priority 0x%08X\n",
86 #$i, $priority, $j, $priority_j;
87
88 if($priority1 == $priority2)
89 {
90 printf "task index %d name: %s 1st priority %d == 2nd priority %d \n", $i, $task_config[$i]{'name'}, $priority1, $priority2;
91 }
92 if($priority1 == $priority_j1)
93 {
94 printf "task index %d name: %s 1st priority %d == task index %d name: %s 1st priority %d \n", $i, $task_config[$i]{'name'}, $priority1, $j, $task_config[$j]{'name'}, $priority_j1;
95 }
96 if($priority1 == $priority_j2)
97 {
98 printf "task index %d name: %s 1st priority %d == task index %d name: %s 2nd priority %d \n", $i, $task_config[$i]{'name'}, $priority1, $j, $task_config[$j]{'name'}, $priority_j2;
99 }
100 if(($priority2 != $priority_max) && ($priority2 == $priority_j1))
101 {
102 printf "task index %d name: %s 2nd priority %d == task index %d name: %s 1st priority %d \n", $i, $task_config[$i]{'name'}, $priority2, $j, $task_config[$j]{'name'}, $priority_j1;
103 }
104 if(($priority2 != $priority_max) && ($priority2 == $priority_j2))
105 {
106 printf "task index %d name: %s 2nd priority %d == task index %d name: %s 2nd priority %d \n", $i, $task_config[$i]{'name'}, $priority2, $j, $task_config[$j]{'name'}, $priority_j2;
107 }
108 print "Please check task config or contact config owner!!!";
109 exit $ERR_DUPLICATE_TASK_PRIORITY;
110 }
111 }
112
113 $j++;
114 }
115 }
116 $i++;
117 }
118
119
120 }
121}
122
123sub checkingHISRIndexDuplicated
124{
125 my $g_task_number = $_[0];
126 my $g_hisr_number = $_[1];
127 my @task_config = @{$_[2]};
128 my @hisr_config = @{$_[3]};
129 my $g_ATEST_DRV_ENABLE = $_[4];
130
131 my $i=0;
132 my $j=0;
133 my $i_index;
134 my $j_index;
135 $ERR_HISR_INDEX = 13;
136
137 #check if duplicate hisr index is inside hisr_info
138 while($i < $g_hisr_number)
139 {
140 $j = $i+1;
141 $i_index = $hisr_config[$i]{'index'};
142 while($j < $g_hisr_number)
143 {
144 $j_index = $hisr_config[$j]{'index'};
145 if($i_index == $j_index)
146 {
147 printf "KAL hisr config Error: %s and %s has duplicate hisr index %d\n", $hisr_config[$i]{'name'}, $hisr_config[$j]{'name'}, $i_index;
148 print "Please check hisr config or contact config owner!!!";
149 exit $ERR_HISR_INDEX;
150 }
151 $j++;
152 }
153 $i++;
154 }
155
156}
157
158sub checking4charOfTaskHisrName
159{
160
161 my $g_task_number = $_[0];
162 my $g_hisr_number = $_[1];
163 my @task_config = @{$_[2]};
164 my @hisr_config = @{$_[3]};
165 my $g_ATEST_DRV_ENABLE = $_[4];
166
167 my $i=0;
168 my $j=0;
169 $ERR_DUPLICATE_TASKHISR_NAME = 17;
170
171 if($g_ATEST_DRV_ENABLE == 0)
172 {
173
174 # Check firt 4 characters of Task/Hisr names for SWLA
175 $i = 0;
176 my $name_1;
177 my $name_2;
178 while($i < $g_task_number){
179
180 $name_1 = substr $task_config[$i]{'name'}, 0, 4;
181
182 if( $name_1 ne ""){
183
184 # Tasks compare Tasks
185 $j = $i+1;
186 while( $j < $g_task_number){
187
188 $name_2 = substr $task_config[$j]{'name'}, 0, 4;
189 if( $name_1 eq $name_2 ){
190
191 printf "Dup name found!! Task:$task_config[$i]{'name'}, Index:$i <==> Task:$task_config[$j]{'name'}, Index:$j\n";
192 exit $ERR_DUPLICATE_TASKHISR_NAME;
193 }
194 $j++;
195 }
196
197 # Tasks compare HISRs
198 $j = 0;
199 while( $j < $g_hisr_number){
200 $name_2 = substr $hisr_config[$j]{'name'}, 0, 4;
201 if( $name_1 eq $name_2 ){
202 printf "Dup name found!! Task:$task_config[$i]{'name'}, Index:$i <==> HISR: $hisr_config[$j]{'name'}, hisr_index:$hisr_config[$j]{'index'}\n";
203 exit $ERR_DUPLICATE_TASKHISR_NAME;
204 }
205 $j++;
206 }
207
208 }
209
210 $i++;
211 }
212
213 # HISRs compare HISRs
214 $i = 0;
215 while( $i < $g_hisr_number){
216
217 $name_1 = substr $hisr_config[$i]{'name'}, 0, 4;
218
219 if( $name_1 ne ""){
220
221 $j = $i+1;
222 while( $j < $g_hisr_number){
223
224 $name_2 = substr $hisr_config[$j]{'name'}, 0, 4;
225 if( $name_1 eq $name_2 ){
226
227 printf "Dup name found!! HISR:$hisr_config[$i]{'name'}, hisr_index:$hisr_config[$i]{'index'} <==> HISR:$hisr_config[$j]{'name'}, hisr_index:$hisr_config[$j]{'index'}\n";
228 exit $ERR_DUPLICATE_TASKHISR_NAME;
229 }
230 $j++;
231 }
232 }
233 $i ++;
234 }
235
236 }
237}
238
239# TODO
240sub checkingTaskIndexRange
241{
242 my $task_number = $_[0];
243 my @task_config = @{$_[1]};
244 my $task_real_module_num = $_[2];
245 my $task_expected_module_num = $_[3];
246 my $ATEST_DRV_ENABLE = $_[4];
247
248 # printf "task_real_module_num: $task_real_module_num";
249 # printf "task_expected_module_num: $task_expected_module_num";
250 # printf "ATEST_DRV_ENABLE: $ATEST_DRV_ENABLE";
251
252
253
254}
255
2561;