diff options
author | Lokesh Vutla | 2020-08-11 16:33:01 -0500 |
---|---|---|
committer | Dave Gerlach | 2020-08-14 12:11:07 -0500 |
commit | 339852e73d79d6f282ab6be690063116baa8b642 (patch) | |
tree | a61027f33e4746e649724a59818c233a200f6faf | |
parent | d2af2398933151864f4868acc88a49cfb5878d45 (diff) | |
download | k3-image-gen-339852e73d79d6f282ab6be690063116baa8b642.tar.gz k3-image-gen-339852e73d79d6f282ab6be690063116baa8b642.tar.xz k3-image-gen-339852e73d79d6f282ab6be690063116baa8b642.zip |
scripts: sysfw_boardcfg_validator: Update to validate resasg entries
Update the sysfw_boardcfg_validator to the latest version to validate
the number of resasg entries using the 'max_resource_entries' constraint.
The sysfw_boardcfg_rules file is also updated to add the constraint
value for each of the existing AM65x, AM65x SR2.0 and J721E SoCs.
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
[s-anna@ti.com: refactor patch]
Signed-off-by: Suman Anna <s-anna@ti.com>
-rw-r--r-- | scripts/sysfw_boardcfg_rules.json | 15 | ||||
-rwxr-xr-x | scripts/sysfw_boardcfg_validator.py | 72 |
2 files changed, 60 insertions, 27 deletions
diff --git a/scripts/sysfw_boardcfg_rules.json b/scripts/sysfw_boardcfg_rules.json index 09da3d8aa..f11da6eb8 100644 --- a/scripts/sysfw_boardcfg_rules.json +++ b/scripts/sysfw_boardcfg_rules.json | |||
@@ -621,6 +621,11 @@ | |||
621 | "start_resource": 0, | 621 | "start_resource": 0, |
622 | "num_resource": 32 | 622 | "num_resource": 32 |
623 | } | 623 | } |
624 | ], | ||
625 | "constraints": [ | ||
626 | { | ||
627 | "max_resource_entries": 104 | ||
628 | } | ||
624 | ] | 629 | ] |
625 | }, | 630 | }, |
626 | "am65x_sr2": { | 631 | "am65x_sr2": { |
@@ -943,6 +948,11 @@ | |||
943 | "start_resource": 0, | 948 | "start_resource": 0, |
944 | "num_resource": 32 | 949 | "num_resource": 32 |
945 | } | 950 | } |
951 | ], | ||
952 | "constraints": [ | ||
953 | { | ||
954 | "max_resource_entries": 104 | ||
955 | } | ||
946 | ] | 956 | ] |
947 | }, | 957 | }, |
948 | "j721e": { | 958 | "j721e": { |
@@ -1349,6 +1359,11 @@ | |||
1349 | "start_resource": 36, | 1359 | "start_resource": 36, |
1350 | "num_resource": 28 | 1360 | "num_resource": 28 |
1351 | } | 1361 | } |
1362 | ], | ||
1363 | "constraints": [ | ||
1364 | { | ||
1365 | "max_resource_entries": 420 | ||
1366 | } | ||
1352 | ] | 1367 | ] |
1353 | } | 1368 | } |
1354 | } | 1369 | } |
diff --git a/scripts/sysfw_boardcfg_validator.py b/scripts/sysfw_boardcfg_validator.py index 1cc2a6b41..6f9f37d05 100755 --- a/scripts/sysfw_boardcfg_validator.py +++ b/scripts/sysfw_boardcfg_validator.py | |||
@@ -145,40 +145,58 @@ class sysfw_boardcfg_rules: | |||
145 | 145 | ||
146 | def validate_rm_resources(self, resources, validator): | 146 | def validate_rm_resources(self, resources, validator): |
147 | r_dict = [r._asdict() for r in resources] | 147 | r_dict = [r._asdict() for r in resources] |
148 | num_entries = len(r_dict) | ||
149 | max_entries = 0 | ||
148 | 150 | ||
149 | for entry in r_dict: | 151 | for constraint in validator['constraints']: |
152 | for k, v in constraint.items(): | ||
153 | if k == 'max_resource_entries': | ||
154 | max_entries = v | ||
155 | break | ||
156 | if max_entries: | ||
157 | break | ||
158 | |||
159 | if num_entries > max_entries: | ||
160 | self.output_class.send_next_line( | ||
161 | 'ERROR: Found %s resource entries when only %s allowed!' % (num_entries, max_entries)) | ||
150 | valid = False | 162 | valid = False |
151 | closest_matches = list() | 163 | else: |
152 | e_start = entry['start_resource'] | 164 | self.output_class.send_next_line( |
153 | e_end = entry['start_resource'] + entry['num_resource'] - 1 | 165 | 'Found %s resource entries' % num_entries) |
154 | 166 | ||
155 | for v_entry in validator['values']: | 167 | for entry in r_dict: |
156 | if entry['type'] == v_entry['type']: | 168 | valid = False |
157 | v_start = v_entry['start_resource'] | 169 | closest_matches = list() |
158 | v_end = v_entry['start_resource'] + \ | 170 | e_start = entry['start_resource'] |
159 | v_entry['num_resource'] - 1 | 171 | e_end = entry['start_resource'] + entry['num_resource'] - 1 |
160 | closest_matches.append(v_entry) | ||
161 | 172 | ||
162 | if e_start >= v_start and e_end <= v_end: | 173 | for v_entry in validator['values']: |
163 | valid = True | 174 | if entry['type'] == v_entry['type']: |
175 | v_start = v_entry['start_resource'] | ||
176 | v_end = v_entry['start_resource'] + \ | ||
177 | v_entry['num_resource'] - 1 | ||
178 | closest_matches.append(v_entry) | ||
164 | 179 | ||
165 | if not valid: | 180 | if e_start >= v_start and e_end <= v_end: |
166 | self.output_class.send_next_line( | 181 | valid = True |
167 | 'ERROR: Entry does not match any valid entries!') | ||
168 | for k, v in entry.items(): | ||
169 | self.output_class.send_next_line('%s - %s' % (k, v)) | ||
170 | 182 | ||
171 | self.output_class.send_next_line( | 183 | if not valid: |
172 | 'Closest validation matches...') | 184 | self.output_class.send_next_line( |
173 | if closest_matches: | 185 | 'ERROR: Entry does not match any valid entries!') |
174 | for cm in closest_matches: | 186 | for k, v in entry.items(): |
175 | for k, v in cm.items(): | 187 | self.output_class.send_next_line('%s - %s' % (k, v)) |
176 | self.output_class.send_next_line( | ||
177 | '%s - %s' % (k, v)) | ||
178 | else: | ||
179 | self.output_class.send_next_line('None') | ||
180 | 188 | ||
181 | break | 189 | self.output_class.send_next_line( |
190 | 'Closest validation matches...') | ||
191 | if closest_matches: | ||
192 | for cm in closest_matches: | ||
193 | for k, v in cm.items(): | ||
194 | self.output_class.send_next_line( | ||
195 | '%s - %s' % (k, v)) | ||
196 | else: | ||
197 | self.output_class.send_next_line('None') | ||
198 | |||
199 | break | ||
182 | 200 | ||
183 | if valid: | 201 | if valid: |
184 | host_id_all = 128 | 202 | host_id_all = 128 |