blob: d2eae65152138d9b829ee125ce3fa74f708783ef [file] [log] [blame]
Miklos Balint470919c2018-05-22 17:51:29 +02001#-------------------------------------------------------------------------------
Kevin Peng578a8492020-12-31 10:22:59 +08002# Copyright (c) 2018-2021, Arm Limited. All rights reserved.
Miklos Balint470919c2018-05-22 17:51:29 +02003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8import os
Mate Toth-Pal36f21842018-11-08 16:12:51 +01009import io
Shawn Shana9ad1e02019-08-07 15:49:48 +080010import sys
11import argparse
Ken Liu1f345b02020-05-30 21:11:05 +080012from jinja2 import Environment, BaseLoader, select_autoescape, TemplateNotFound
Miklos Balint470919c2018-05-22 17:51:29 +020013
14try:
15 import yaml
16except ImportError as e:
Mate Toth-Pala99ec6b2019-05-07 11:00:56 +020017 print (str(e) + " To install it, type:")
Mate Toth-Pal36f21842018-11-08 16:12:51 +010018 print ("pip install PyYAML")
Miklos Balint470919c2018-05-22 17:51:29 +020019 exit(1)
20
Edison Ai48b2d9e2019-06-24 14:39:45 +080021donotedit_warning = \
22 "/*********** " + \
23 "WARNING: This is an auto-generated file. Do not edit!" + \
24 " ***********/"
Kevin Peng655f2392019-11-27 16:33:02 +080025
Kevin Peng655f2392019-11-27 16:33:02 +080026OUT_DIR = None # The root directory that files are generated to
Edison Ai48b2d9e2019-06-24 14:39:45 +080027
Mate Toth-Pal36f21842018-11-08 16:12:51 +010028class TemplateLoader(BaseLoader):
29 """
30 Template loader class.
Miklos Balint470919c2018-05-22 17:51:29 +020031
Mate Toth-Pal36f21842018-11-08 16:12:51 +010032 An instance of this class is passed to the template engine. It is
33 responsible for reading the template file
34 """
35 def __init__(self):
36 pass
Miklos Balint470919c2018-05-22 17:51:29 +020037
Mate Toth-Pal36f21842018-11-08 16:12:51 +010038 def get_source(self, environment, template):
39 """
40 This function reads the template files.
41 For detailed documentation see:
42 http://jinja.pocoo.org/docs/2.10/api/#jinja2.BaseLoader.get_source
43
44 Please note that this function always return 'false' as 'uptodate'
45 value, so the output file will always be generated.
46 """
47 if not os.path.isfile(template):
48 raise TemplateNotFound(template)
49 with open(template) as f:
50 source = f.read()
51 return source, template, False
52
Mingyang Sun294ce2e2021-06-11 11:58:24 +080053def manifest_validation(partition_manifest):
54 """
55 This function validates FF-M compliance for partition manifest, and sets
56 default values for optional attributes.
57 More validation items will be added.
58 """
59 # Service FF-M manifest validation
60 if 'services' not in partition_manifest.keys():
61 return partition_manifest
62
63 for service in partition_manifest['services']:
64 if 'version' not in service.keys():
65 service['version'] = 1
66 if 'version_policy' not in service.keys():
67 service['version_policy'] = "STRICT"
68
69 return partition_manifest
70
Ken Liu861b0782021-05-22 13:15:08 +080071def process_partition_manifests(manifest_list_files):
Mate Toth-Pal36f21842018-11-08 16:12:51 +010072 """
Kevin Peng655f2392019-11-27 16:33:02 +080073 Parse the input manifest, generate the data base for genereated files
74 and generate manifest header files.
Mate Toth-Pal36f21842018-11-08 16:12:51 +010075
76 Parameters
77 ----------
Raef Colesf42f0882020-07-10 10:01:58 +010078 manifest_list_files:
79 The manifest lists to parse.
Mate Toth-Pal36f21842018-11-08 16:12:51 +010080
81 Returns
82 -------
Kevin Peng578a8492020-12-31 10:22:59 +080083 The partition data base.
Edison Ai48b2d9e2019-06-24 14:39:45 +080084 """
Kevin Peng655f2392019-11-27 16:33:02 +080085
Ken Liu861b0782021-05-22 13:15:08 +080086 partition_list = []
Kevin Peng655f2392019-11-27 16:33:02 +080087 manifest_list = []
88
Raef Colesf42f0882020-07-10 10:01:58 +010089 for f in manifest_list_files:
90 with open(f) as manifest_list_yaml_file:
91 manifest_dic = yaml.safe_load(manifest_list_yaml_file)
Kevin Peng655f2392019-11-27 16:33:02 +080092 manifest_list.extend(manifest_dic["manifest_list"])
Ken Liu861b0782021-05-22 13:15:08 +080093 manifest_list_yaml_file.close()
Kevin Peng655f2392019-11-27 16:33:02 +080094
Xinyu Zhang19504a52021-03-31 16:26:20 +080095 pid_list = []
Xinyu Zhangc46ee1f2021-04-01 10:10:43 +080096 no_pid_manifest_idx = []
97 for i, manifest_item in enumerate(manifest_list):
98 # Check if partition ID is manually set
99 if 'pid' not in manifest_item.keys():
100 no_pid_manifest_idx.append(i)
101 continue
Xinyu Zhang19504a52021-03-31 16:26:20 +0800102 # Check if partition ID is duplicated
103 if manifest_item['pid'] in pid_list:
104 raise Exception("PID No. {pid} has already been used!".format(pid=manifest_item['pid']))
105 pid_list.append(manifest_item['pid'])
Xinyu Zhangc46ee1f2021-04-01 10:10:43 +0800106 # Automatically generate PIDs for partitions without PID
107 pid = 256
108 for idx in no_pid_manifest_idx:
109 while pid in pid_list:
110 pid += 1
111 manifest_list[idx]['pid'] = pid
112 pid_list.append(pid)
Xinyu Zhang19504a52021-03-31 16:26:20 +0800113
Xinyu Zhangc46ee1f2021-04-01 10:10:43 +0800114 for manifest_item in manifest_list:
Raef Coles558487a2020-10-29 13:09:44 +0000115 # Replace environment variables in the manifest path
Kevin Peng655f2392019-11-27 16:33:02 +0800116 manifest_path = os.path.expandvars(manifest_item['manifest'])
117 file = open(manifest_path)
Mingyang Sun294ce2e2021-06-11 11:58:24 +0800118 manifest = manifest_validation(yaml.safe_load(file))
Ken Liu861b0782021-05-22 13:15:08 +0800119 file.close()
Kevin Peng655f2392019-11-27 16:33:02 +0800120
121 manifest_dir, manifest_name = os.path.split(manifest_path)
Ken Liu861b0782021-05-22 13:15:08 +0800122 manifest_out_basename = manifest_name.replace('.yaml', '').replace('.json', '')
123 manifest_head_file = os.path.join(manifest_dir, "psa_manifest", manifest_out_basename + '.h').replace('\\', '/')
124 intermedia_file = os.path.join(manifest_dir, "auto_generated", 'intermedia_' + manifest_out_basename + '.c').replace('\\', '/')
125 load_info_file = os.path.join(manifest_dir, "auto_generated", 'load_info_' + manifest_out_basename + '.c').replace('\\', '/')
Kevin Peng655f2392019-11-27 16:33:02 +0800126
Kevin Peng655f2392019-11-27 16:33:02 +0800127 if OUT_DIR is not None:
MartinaHanusovaNXP35957f12021-07-14 15:30:15 +0200128 """
129 Remove the `source_path` portion of the filepaths, so that it can be
130 interpreted as a relative path from the OUT_DIR.
131 """
132 if 'source_path' in manifest_item:
133 # Replace environment variables in the source path
134 source_path = os.path.expandvars(manifest_item['source_path'])
135 manifest_head_file = os.path.relpath(manifest_head_file, start = source_path)
136 intermedia_file = os.path.relpath(intermedia_file, start = source_path)
137 load_info_file = os.path.relpath(load_info_file, start = source_path)
138
139 manifest_head_file = os.path.join(OUT_DIR, manifest_head_file).replace('\\', '/')
140 intermedia_file = os.path.join(OUT_DIR, intermedia_file).replace('\\', '/')
141 load_info_file = os.path.join(OUT_DIR, load_info_file).replace('\\', '/')
Kevin Peng655f2392019-11-27 16:33:02 +0800142
Ken Liu861b0782021-05-22 13:15:08 +0800143 partition_list.append({"manifest": manifest, "attr": manifest_item,
144 "manifest_out_basename": manifest_out_basename,
145 "header_file": manifest_head_file,
146 "intermedia_file": intermedia_file,
147 "loadinfo_file": load_info_file})
148
149 return partition_list
150
151def gen_per_partition_files(context):
152 """
153 Generate per-partition files
154
155 Parameters
156 ----------
157 context:
158 context contains partition infos
159 """
160
161 subutilities = {}
162 subutilities['donotedit_warning'] = donotedit_warning
163
164 subcontext = {}
165 subcontext['utilities'] = subutilities
166
Ken Liu72c031e2021-08-09 16:42:54 +0800167 manifesttemplate = ENV.get_template(os.path.join(os.path.relpath(os.path.dirname(__file__)), 'templates/manifestfilename.template'))
168 memorytemplate = ENV.get_template(os.path.join(os.path.relpath(os.path.dirname(__file__)), 'templates/partition_intermedia.template'))
169 infotemplate = ENV.get_template(os.path.join(os.path.relpath(os.path.dirname(__file__)), 'templates/partition_load_info.template'))
Ken Liu861b0782021-05-22 13:15:08 +0800170
171 print ("Start to generate partition files:")
172
173 for one_partition in context['partitions']:
174 subcontext['manifest'] = one_partition['manifest']
175 subcontext['attr'] = one_partition['attr']
176 subcontext['manifest_out_basename'] = one_partition['manifest_out_basename']
177
178 print ("Generating Header: " + one_partition['header_file'])
179 outfile_path = os.path.dirname(one_partition['header_file'])
Kevin Peng655f2392019-11-27 16:33:02 +0800180 if not os.path.exists(outfile_path):
181 os.makedirs(outfile_path)
182
Ken Liu861b0782021-05-22 13:15:08 +0800183 headerfile = io.open(one_partition['header_file'], "w", newline=None)
184 headerfile.write(manifesttemplate.render(subcontext))
185 headerfile.close()
Kevin Peng655f2392019-11-27 16:33:02 +0800186
Ken Liu861b0782021-05-22 13:15:08 +0800187 print ("Generating Intermedia: " + one_partition['intermedia_file'])
188 intermediafile_path = os.path.dirname(one_partition['intermedia_file'])
Mingyang Sund20999f2020-10-15 14:53:12 +0800189 if not os.path.exists(intermediafile_path):
190 os.makedirs(intermediafile_path)
Ken Liu861b0782021-05-22 13:15:08 +0800191 intermediafile = io.open(one_partition['intermedia_file'], "w", newline=None)
192 intermediafile.write(memorytemplate.render(subcontext))
193 intermediafile.close()
Mingyang Sund20999f2020-10-15 14:53:12 +0800194
Ken Liu861b0782021-05-22 13:15:08 +0800195 print ("Generating Loadinfo: " + one_partition['loadinfo_file'])
196 infofile_path = os.path.dirname(one_partition['loadinfo_file'])
Mingyang Sunf6a78572021-04-02 16:51:05 +0800197 if not os.path.exists(infofile_path):
198 os.makedirs(infofile_path)
Ken Liu861b0782021-05-22 13:15:08 +0800199 infooutfile = io.open(one_partition['loadinfo_file'], "w", newline=None)
200 infooutfile.write(infotemplate.render(subcontext))
201 infooutfile.close()
Mingyang Sunf6a78572021-04-02 16:51:05 +0800202
Ken Liu861b0782021-05-22 13:15:08 +0800203 print ("Per-partition files done:")
Mingyang Sunf6a78572021-04-02 16:51:05 +0800204
Ken Liu861b0782021-05-22 13:15:08 +0800205def gen_summary_files(context, gen_file_lists):
Kevin Peng655f2392019-11-27 16:33:02 +0800206 """
207 Generate files according to the gen_file_list
Edison Ai48b2d9e2019-06-24 14:39:45 +0800208
209 Parameters
210 ----------
Raef Colesf42f0882020-07-10 10:01:58 +0100211 gen_file_lists:
212 The lists of files to generate
Edison Ai48b2d9e2019-06-24 14:39:45 +0800213 """
Kevin Peng655f2392019-11-27 16:33:02 +0800214 file_list = []
Shawn Shana9ad1e02019-08-07 15:49:48 +0800215
Raef Colesf42f0882020-07-10 10:01:58 +0100216 for f in gen_file_lists:
217 with open(f) as file_list_yaml_file:
Kevin Peng655f2392019-11-27 16:33:02 +0800218 file_list_yaml = yaml.safe_load(file_list_yaml_file)
219 file_list.extend(file_list_yaml["file_list"])
Edison Ai48b2d9e2019-06-24 14:39:45 +0800220
edison.ai7b299f52020-07-16 15:44:18 +0800221 print("Start to generate file from the generated list:")
Kevin Peng655f2392019-11-27 16:33:02 +0800222 for file in file_list:
Raef Coles558487a2020-10-29 13:09:44 +0000223 # Replace environment variables in the output filepath
Ken Liu861b0782021-05-22 13:15:08 +0800224 manifest_out_file = os.path.expandvars(file["output"])
Raef Coles558487a2020-10-29 13:09:44 +0000225 # Replace environment variables in the template filepath
Kevin Peng1ec5e7c2019-11-29 10:52:00 +0800226 templatefile_name = os.path.expandvars(file["template"])
Edison Ai48b2d9e2019-06-24 14:39:45 +0800227
Kevin Peng655f2392019-11-27 16:33:02 +0800228 if OUT_DIR is not None:
Ken Liu861b0782021-05-22 13:15:08 +0800229 manifest_out_file = os.path.join(OUT_DIR, manifest_out_file)
Edison Ai48b2d9e2019-06-24 14:39:45 +0800230
Ken Liu861b0782021-05-22 13:15:08 +0800231 print ("Generating " + manifest_out_file)
edison.ai7b299f52020-07-16 15:44:18 +0800232
Ken Liu861b0782021-05-22 13:15:08 +0800233 outfile_path = os.path.dirname(manifest_out_file)
Kevin Peng655f2392019-11-27 16:33:02 +0800234 if not os.path.exists(outfile_path):
235 os.makedirs(outfile_path)
Edison Ai48b2d9e2019-06-24 14:39:45 +0800236
Kevin Peng655f2392019-11-27 16:33:02 +0800237 template = ENV.get_template(templatefile_name)
Edison Ai6e3f2a32019-06-11 15:29:05 +0800238
Ken Liu861b0782021-05-22 13:15:08 +0800239 outfile = io.open(manifest_out_file, "w", newline=None)
Kevin Peng655f2392019-11-27 16:33:02 +0800240 outfile.write(template.render(context))
241 outfile.close()
Edison Ai48b2d9e2019-06-24 14:39:45 +0800242
Kevin Peng655f2392019-11-27 16:33:02 +0800243 print ("Generation of files done")
Edison Ai48b2d9e2019-06-24 14:39:45 +0800244
Ken Liu861b0782021-05-22 13:15:08 +0800245def process_stateless_services(partitions, stateless_index_max_num):
Mingyang Suna1ca6112021-01-11 11:34:59 +0800246 """
247 This function collects all stateless services together, and allocates
Mingyang Sun4ecea992021-03-30 17:56:26 +0800248 stateless handles for them.
Kevin Pengc05319d2021-04-22 22:59:35 +0800249 Valid stateless handle in service will be converted to an index. If the
250 stateless handle is set as "auto", or not set, framework will allocate a
251 valid index for the service.
252 Framework puts each service into a reordered stateless service list at
253 position of "index". Other unused positions are left None.
Mingyang Suna1ca6112021-01-11 11:34:59 +0800254 """
Kevin Pengc05319d2021-04-22 22:59:35 +0800255 collected_stateless_services = []
Mingyang Suna1ca6112021-01-11 11:34:59 +0800256
257 # Collect all stateless services first.
258 for partition in partitions:
259 # Skip the FF-M 1.0 partitions
260 if partition['manifest']['psa_framework_version'] < 1.1:
261 continue
Mingyang Suna1ca6112021-01-11 11:34:59 +0800262 for service in partition['manifest']['services']:
263 if 'connection_based' not in service:
264 raise Exception("'connection_based' is mandatory in FF-M 1.1 service!")
265 if service['connection_based'] is False:
Kevin Pengc05319d2021-04-22 22:59:35 +0800266 collected_stateless_services.append(service)
Mingyang Suna1ca6112021-01-11 11:34:59 +0800267
Kevin Pengc05319d2021-04-22 22:59:35 +0800268 if len(collected_stateless_services) == 0:
Mingyang Suna1ca6112021-01-11 11:34:59 +0800269 return []
270
Ken Liu861b0782021-05-22 13:15:08 +0800271 if len(collected_stateless_services) > stateless_index_max_num:
272 raise Exception("Stateless service numbers range exceed {number}.".format(number=stateless_index_max_num))
Mingyang Suna1ca6112021-01-11 11:34:59 +0800273
274 """
Kevin Pengc05319d2021-04-22 22:59:35 +0800275 Allocate an empty stateless service list to store services.
276 Use "handle - 1" as the index for service, since handle value starts from
277 1 and list index starts from 0.
Mingyang Suna1ca6112021-01-11 11:34:59 +0800278 """
Ken Liu861b0782021-05-22 13:15:08 +0800279 reordered_stateless_services = [None] * stateless_index_max_num
Kevin Pengc05319d2021-04-22 22:59:35 +0800280 auto_alloc_services = []
Mingyang Suna1ca6112021-01-11 11:34:59 +0800281
Kevin Pengc05319d2021-04-22 22:59:35 +0800282 for service in collected_stateless_services:
283 # If not set, it is "auto" by default
284 if 'stateless_handle' not in service:
285 auto_alloc_services.append(service)
286 continue
287
Mingyang Sun4ecea992021-03-30 17:56:26 +0800288 service_handle = service['stateless_handle']
Mingyang Suna1ca6112021-01-11 11:34:59 +0800289
Mingyang Sun4ecea992021-03-30 17:56:26 +0800290 # Fill in service list with specified stateless handle, otherwise skip
291 if isinstance(service_handle, int):
Ken Liu861b0782021-05-22 13:15:08 +0800292 if service_handle < 1 or service_handle > stateless_index_max_num:
Kevin Pengc05319d2021-04-22 22:59:35 +0800293 raise Exception("Invalid stateless_handle setting: {handle}.".format(handle=service['stateless_handle']))
Mingyang Sun4ecea992021-03-30 17:56:26 +0800294 # Convert handle index to reordered service list index
295 service_handle = service_handle - 1
296
297 if reordered_stateless_services[service_handle] is not None:
Kevin Pengc05319d2021-04-22 22:59:35 +0800298 raise Exception("Duplicated stateless_handle setting: {handle}.".format(handle=service['stateless_handle']))
Mingyang Sun4ecea992021-03-30 17:56:26 +0800299 reordered_stateless_services[service_handle] = service
Kevin Pengc05319d2021-04-22 22:59:35 +0800300 elif service_handle == 'auto':
301 auto_alloc_services.append(service)
302 else:
303 raise Exception("Invalid stateless_handle setting: {handle}.".format(handle=service['stateless_handle']))
Mingyang Sun4ecea992021-03-30 17:56:26 +0800304
305 # Auto-allocate stateless handle and encode the stateless handle
Ken Liu861b0782021-05-22 13:15:08 +0800306 for i in range(0, stateless_index_max_num):
Mingyang Sun4ecea992021-03-30 17:56:26 +0800307 service = reordered_stateless_services[i]
308
Kevin Pengc05319d2021-04-22 22:59:35 +0800309 if service == None and len(auto_alloc_services) > 0:
310 service = auto_alloc_services.pop(0)
Mingyang Sun4ecea992021-03-30 17:56:26 +0800311
Mingyang Sun453ad402021-03-17 17:58:33 +0800312 """
313 Encode stateless flag and version into stateless handle
314 bit 30: stateless handle indicator
315 bit 15-8: stateless service version
316 bit 7-0: stateless handle index
317 """
Mingyang Sun4ecea992021-03-30 17:56:26 +0800318 stateless_handle_value = 0
319 if service != None:
320 stateless_index = (i & 0xFF)
321 stateless_handle_value |= stateless_index
Mingyang Sun453ad402021-03-17 17:58:33 +0800322 stateless_flag = 1 << 30
323 stateless_handle_value |= stateless_flag
Mingyang Sun4ecea992021-03-30 17:56:26 +0800324 stateless_version = (service['version'] & 0xFF) << 8
Mingyang Sun453ad402021-03-17 17:58:33 +0800325 stateless_handle_value |= stateless_version
Mingyang Sun4ecea992021-03-30 17:56:26 +0800326 service['stateless_handle_value'] = '0x{0:08x}'.format(stateless_handle_value)
Ken Liu861b0782021-05-22 13:15:08 +0800327 service['stateless_handle_index'] = stateless_index
Mingyang Suna1ca6112021-01-11 11:34:59 +0800328
Mingyang Sun4ecea992021-03-30 17:56:26 +0800329 reordered_stateless_services[i] = service
330
331 return reordered_stateless_services
Mingyang Suna1ca6112021-01-11 11:34:59 +0800332
Kevin Peng655f2392019-11-27 16:33:02 +0800333def parse_args():
Raef Coles558487a2020-10-29 13:09:44 +0000334 parser = argparse.ArgumentParser(description='Parse secure partition manifest list and generate files listed by the file list',
335 epilog='Note that environment variables in template files will be replaced with their values')
336
Kevin Peng655f2392019-11-27 16:33:02 +0800337 parser.add_argument('-o', '--outdir'
338 , dest='outdir'
339 , required=False
340 , default=None
341 , metavar='out_dir'
342 , help='The root directory for generated files, the default is TF-M root folder.')
Shawn Shana9ad1e02019-08-07 15:49:48 +0800343
Kevin Peng655f2392019-11-27 16:33:02 +0800344 parser.add_argument('-m', '--manifest'
Raef Colesf42f0882020-07-10 10:01:58 +0100345 , nargs='+'
Kevin Peng655f2392019-11-27 16:33:02 +0800346 , dest='manifest_args'
Raef Colesf42f0882020-07-10 10:01:58 +0100347 , required=True
Kevin Peng655f2392019-11-27 16:33:02 +0800348 , metavar='manifest'
Raef Colesf42f0882020-07-10 10:01:58 +0100349 , help='A set of secure partition manifest lists to parse')
Kevin Peng655f2392019-11-27 16:33:02 +0800350
351 parser.add_argument('-f', '--file-list'
Raef Colesf42f0882020-07-10 10:01:58 +0100352 , nargs='+'
Kevin Peng655f2392019-11-27 16:33:02 +0800353 , dest='gen_file_args'
Raef Colesf42f0882020-07-10 10:01:58 +0100354 , required=True
Kevin Peng655f2392019-11-27 16:33:02 +0800355 , metavar='file-list'
Raef Colesf42f0882020-07-10 10:01:58 +0100356 , help='These files descripe the file list to generate')
Kevin Peng655f2392019-11-27 16:33:02 +0800357
358 args = parser.parse_args()
359 manifest_args = args.manifest_args
360 gen_file_args = args.gen_file_args
361
Kevin Peng655f2392019-11-27 16:33:02 +0800362 return args
363
364ENV = Environment(
365 loader = TemplateLoader(),
366 autoescape = select_autoescape(['html', 'xml']),
367 lstrip_blocks = True,
368 trim_blocks = True,
369 keep_trailing_newline = True
370 )
Mate Toth-Pal36f21842018-11-08 16:12:51 +0100371
Miklos Balint470919c2018-05-22 17:51:29 +0200372def main():
Mate Toth-Pal36f21842018-11-08 16:12:51 +0100373 """
374 The entry point of the script.
375
376 Generates the output files based on the templates and the manifests.
377 """
Shawn Shana9ad1e02019-08-07 15:49:48 +0800378
Kevin Peng655f2392019-11-27 16:33:02 +0800379 global OUT_DIR
Shawn Shana9ad1e02019-08-07 15:49:48 +0800380
Kevin Peng655f2392019-11-27 16:33:02 +0800381 args = parse_args()
Shawn Shana9ad1e02019-08-07 15:49:48 +0800382
Kevin Peng655f2392019-11-27 16:33:02 +0800383 manifest_args = args.manifest_args
384 gen_file_args = args.gen_file_args
385 OUT_DIR = args.outdir
Kevin Peng655f2392019-11-27 16:33:02 +0800386
Raef Coles558487a2020-10-29 13:09:44 +0000387 manifest_list = [os.path.abspath(x) for x in args.manifest_args]
388 gen_file_list = [os.path.abspath(x) for x in args.gen_file_args]
Shawn Shana9ad1e02019-08-07 15:49:48 +0800389
Shawn Shana9ad1e02019-08-07 15:49:48 +0800390 """
Kevin Peng655f2392019-11-27 16:33:02 +0800391 Relative path to TF-M root folder is supported in the manifests
392 and default value of manifest list and generated file list are relative to TF-M root folder as well,
393 so first change directory to TF-M root folder.
Shawn Shana9ad1e02019-08-07 15:49:48 +0800394 By doing this, the script can be executed anywhere
Kevin Peng655f2392019-11-27 16:33:02 +0800395 The script is located in <TF-M root folder>/tools, so sys.path[0]<location of the script>/.. is TF-M root folder.
Shawn Shana9ad1e02019-08-07 15:49:48 +0800396 """
397 os.chdir(os.path.join(sys.path[0], ".."))
398
Ken Liu861b0782021-05-22 13:15:08 +0800399 partition_list = process_partition_manifests(manifest_list)
Mate Toth-Pal36f21842018-11-08 16:12:51 +0100400
Edison Ai6e3f2a32019-06-11 15:29:05 +0800401 utilities = {}
Mingyang Suna1ca6112021-01-11 11:34:59 +0800402 utilities['donotedit_warning'] = donotedit_warning
Miklos Balint470919c2018-05-22 17:51:29 +0200403
Ken Liu861b0782021-05-22 13:15:08 +0800404 context = {}
405 context['partitions'] = partition_list
Kevin Peng655f2392019-11-27 16:33:02 +0800406 context['utilities'] = utilities
Ken Liu861b0782021-05-22 13:15:08 +0800407 context['stateless_services'] = process_stateless_services(partition_list, 32)
Mate Toth-Pal36f21842018-11-08 16:12:51 +0100408
Ken Liu861b0782021-05-22 13:15:08 +0800409 gen_per_partition_files(context)
410 gen_summary_files(context, gen_file_list)
Miklos Balint470919c2018-05-22 17:51:29 +0200411
412if __name__ == "__main__":
413 main()