blob: 7a236218dfce84d60b7284e75e8740b7ea083d4c [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
Ken Liu861b0782021-05-22 13:15:08 +080053def process_partition_manifests(manifest_list_files):
Mate Toth-Pal36f21842018-11-08 16:12:51 +010054 """
Kevin Peng655f2392019-11-27 16:33:02 +080055 Parse the input manifest, generate the data base for genereated files
56 and generate manifest header files.
Mate Toth-Pal36f21842018-11-08 16:12:51 +010057
58 Parameters
59 ----------
Raef Colesf42f0882020-07-10 10:01:58 +010060 manifest_list_files:
61 The manifest lists to parse.
Mate Toth-Pal36f21842018-11-08 16:12:51 +010062
63 Returns
64 -------
Kevin Peng578a8492020-12-31 10:22:59 +080065 The partition data base.
Edison Ai48b2d9e2019-06-24 14:39:45 +080066 """
Kevin Peng655f2392019-11-27 16:33:02 +080067
Ken Liu861b0782021-05-22 13:15:08 +080068 partition_list = []
Kevin Peng655f2392019-11-27 16:33:02 +080069 manifest_list = []
70
Raef Colesf42f0882020-07-10 10:01:58 +010071 for f in manifest_list_files:
72 with open(f) as manifest_list_yaml_file:
73 manifest_dic = yaml.safe_load(manifest_list_yaml_file)
Kevin Peng655f2392019-11-27 16:33:02 +080074 manifest_list.extend(manifest_dic["manifest_list"])
Ken Liu861b0782021-05-22 13:15:08 +080075 manifest_list_yaml_file.close()
Kevin Peng655f2392019-11-27 16:33:02 +080076
Xinyu Zhang19504a52021-03-31 16:26:20 +080077 pid_list = []
Xinyu Zhangc46ee1f2021-04-01 10:10:43 +080078 no_pid_manifest_idx = []
79 for i, manifest_item in enumerate(manifest_list):
80 # Check if partition ID is manually set
81 if 'pid' not in manifest_item.keys():
82 no_pid_manifest_idx.append(i)
83 continue
Xinyu Zhang19504a52021-03-31 16:26:20 +080084 # Check if partition ID is duplicated
85 if manifest_item['pid'] in pid_list:
86 raise Exception("PID No. {pid} has already been used!".format(pid=manifest_item['pid']))
87 pid_list.append(manifest_item['pid'])
Xinyu Zhangc46ee1f2021-04-01 10:10:43 +080088 # Automatically generate PIDs for partitions without PID
89 pid = 256
90 for idx in no_pid_manifest_idx:
91 while pid in pid_list:
92 pid += 1
93 manifest_list[idx]['pid'] = pid
94 pid_list.append(pid)
Xinyu Zhang19504a52021-03-31 16:26:20 +080095
Xinyu Zhangc46ee1f2021-04-01 10:10:43 +080096 for manifest_item in manifest_list:
Raef Coles558487a2020-10-29 13:09:44 +000097 # Replace environment variables in the manifest path
Kevin Peng655f2392019-11-27 16:33:02 +080098 manifest_path = os.path.expandvars(manifest_item['manifest'])
99 file = open(manifest_path)
100 manifest = yaml.safe_load(file)
Ken Liu861b0782021-05-22 13:15:08 +0800101 file.close()
Kevin Peng655f2392019-11-27 16:33:02 +0800102
103 manifest_dir, manifest_name = os.path.split(manifest_path)
Ken Liu861b0782021-05-22 13:15:08 +0800104 manifest_out_basename = manifest_name.replace('.yaml', '').replace('.json', '')
105 manifest_head_file = os.path.join(manifest_dir, "psa_manifest", manifest_out_basename + '.h').replace('\\', '/')
106 intermedia_file = os.path.join(manifest_dir, "auto_generated", 'intermedia_' + manifest_out_basename + '.c').replace('\\', '/')
107 load_info_file = os.path.join(manifest_dir, "auto_generated", 'load_info_' + manifest_out_basename + '.c').replace('\\', '/')
Kevin Peng655f2392019-11-27 16:33:02 +0800108
Mingyang Sun4f012692020-10-16 14:04:49 +0800109 """
110 Remove the `source_path` portion of the filepaths, so that it can be
111 interpreted as a relative path from the OUT_DIR.
112 """
113 if 'source_path' in manifest_item:
Raef Coles558487a2020-10-29 13:09:44 +0000114 # Replace environment variables in the source path
115 source_path = os.path.expandvars(manifest_item['source_path'])
Ken Liu861b0782021-05-22 13:15:08 +0800116 manifest_head_file = os.path.relpath(manifest_head_file, start = source_path)
117 intermedia_file = os.path.relpath(intermedia_file, start = source_path)
118 load_info_file = os.path.relpath(load_info_file, start = source_path)
Kevin Peng655f2392019-11-27 16:33:02 +0800119
120 if OUT_DIR is not None:
Ken Liu861b0782021-05-22 13:15:08 +0800121 manifest_head_file = os.path.join(OUT_DIR, manifest_head_file)
122 intermedia_file = os.path.join(OUT_DIR, intermedia_file)
123 load_info_file = os.path.join(OUT_DIR, load_info_file)
Kevin Peng655f2392019-11-27 16:33:02 +0800124
Ken Liu861b0782021-05-22 13:15:08 +0800125 partition_list.append({"manifest": manifest, "attr": manifest_item,
126 "manifest_out_basename": manifest_out_basename,
127 "header_file": manifest_head_file,
128 "intermedia_file": intermedia_file,
129 "loadinfo_file": load_info_file})
130
131 return partition_list
132
133def gen_per_partition_files(context):
134 """
135 Generate per-partition files
136
137 Parameters
138 ----------
139 context:
140 context contains partition infos
141 """
142
143 subutilities = {}
144 subutilities['donotedit_warning'] = donotedit_warning
145
146 subcontext = {}
147 subcontext['utilities'] = subutilities
148
149 manifesttemplate = ENV.get_template('secure_fw/partitions/manifestfilename.template')
150 memorytemplate = ENV.get_template('secure_fw/partitions/partition_intermedia.template')
151 infotemplate = ENV.get_template('secure_fw/partitions/partition_load_info.template')
152
153 print ("Start to generate partition files:")
154
155 for one_partition in context['partitions']:
156 subcontext['manifest'] = one_partition['manifest']
157 subcontext['attr'] = one_partition['attr']
158 subcontext['manifest_out_basename'] = one_partition['manifest_out_basename']
159
160 print ("Generating Header: " + one_partition['header_file'])
161 outfile_path = os.path.dirname(one_partition['header_file'])
Kevin Peng655f2392019-11-27 16:33:02 +0800162 if not os.path.exists(outfile_path):
163 os.makedirs(outfile_path)
164
Ken Liu861b0782021-05-22 13:15:08 +0800165 headerfile = io.open(one_partition['header_file'], "w", newline=None)
166 headerfile.write(manifesttemplate.render(subcontext))
167 headerfile.close()
Kevin Peng655f2392019-11-27 16:33:02 +0800168
Ken Liu861b0782021-05-22 13:15:08 +0800169 print ("Generating Intermedia: " + one_partition['intermedia_file'])
170 intermediafile_path = os.path.dirname(one_partition['intermedia_file'])
Mingyang Sund20999f2020-10-15 14:53:12 +0800171 if not os.path.exists(intermediafile_path):
172 os.makedirs(intermediafile_path)
Ken Liu861b0782021-05-22 13:15:08 +0800173 intermediafile = io.open(one_partition['intermedia_file'], "w", newline=None)
174 intermediafile.write(memorytemplate.render(subcontext))
175 intermediafile.close()
Mingyang Sund20999f2020-10-15 14:53:12 +0800176
Ken Liu861b0782021-05-22 13:15:08 +0800177 print ("Generating Loadinfo: " + one_partition['loadinfo_file'])
178 infofile_path = os.path.dirname(one_partition['loadinfo_file'])
Mingyang Sunf6a78572021-04-02 16:51:05 +0800179 if not os.path.exists(infofile_path):
180 os.makedirs(infofile_path)
Ken Liu861b0782021-05-22 13:15:08 +0800181 infooutfile = io.open(one_partition['loadinfo_file'], "w", newline=None)
182 infooutfile.write(infotemplate.render(subcontext))
183 infooutfile.close()
Mingyang Sunf6a78572021-04-02 16:51:05 +0800184
Ken Liu861b0782021-05-22 13:15:08 +0800185 print ("Per-partition files done:")
Mingyang Sunf6a78572021-04-02 16:51:05 +0800186
Ken Liu861b0782021-05-22 13:15:08 +0800187def gen_summary_files(context, gen_file_lists):
Kevin Peng655f2392019-11-27 16:33:02 +0800188 """
189 Generate files according to the gen_file_list
Edison Ai48b2d9e2019-06-24 14:39:45 +0800190
191 Parameters
192 ----------
Raef Colesf42f0882020-07-10 10:01:58 +0100193 gen_file_lists:
194 The lists of files to generate
Edison Ai48b2d9e2019-06-24 14:39:45 +0800195 """
Kevin Peng655f2392019-11-27 16:33:02 +0800196 file_list = []
Shawn Shana9ad1e02019-08-07 15:49:48 +0800197
Raef Colesf42f0882020-07-10 10:01:58 +0100198 for f in gen_file_lists:
199 with open(f) as file_list_yaml_file:
Kevin Peng655f2392019-11-27 16:33:02 +0800200 file_list_yaml = yaml.safe_load(file_list_yaml_file)
201 file_list.extend(file_list_yaml["file_list"])
Edison Ai48b2d9e2019-06-24 14:39:45 +0800202
edison.ai7b299f52020-07-16 15:44:18 +0800203 print("Start to generate file from the generated list:")
Kevin Peng655f2392019-11-27 16:33:02 +0800204 for file in file_list:
Raef Coles558487a2020-10-29 13:09:44 +0000205 # Replace environment variables in the output filepath
Ken Liu861b0782021-05-22 13:15:08 +0800206 manifest_out_file = os.path.expandvars(file["output"])
Raef Coles558487a2020-10-29 13:09:44 +0000207 # Replace environment variables in the template filepath
Kevin Peng1ec5e7c2019-11-29 10:52:00 +0800208 templatefile_name = os.path.expandvars(file["template"])
Edison Ai48b2d9e2019-06-24 14:39:45 +0800209
Kevin Peng655f2392019-11-27 16:33:02 +0800210 if OUT_DIR is not None:
Ken Liu861b0782021-05-22 13:15:08 +0800211 manifest_out_file = os.path.join(OUT_DIR, manifest_out_file)
Edison Ai48b2d9e2019-06-24 14:39:45 +0800212
Ken Liu861b0782021-05-22 13:15:08 +0800213 print ("Generating " + manifest_out_file)
edison.ai7b299f52020-07-16 15:44:18 +0800214
Ken Liu861b0782021-05-22 13:15:08 +0800215 outfile_path = os.path.dirname(manifest_out_file)
Kevin Peng655f2392019-11-27 16:33:02 +0800216 if not os.path.exists(outfile_path):
217 os.makedirs(outfile_path)
Edison Ai48b2d9e2019-06-24 14:39:45 +0800218
Kevin Peng655f2392019-11-27 16:33:02 +0800219 template = ENV.get_template(templatefile_name)
Edison Ai6e3f2a32019-06-11 15:29:05 +0800220
Ken Liu861b0782021-05-22 13:15:08 +0800221 outfile = io.open(manifest_out_file, "w", newline=None)
Kevin Peng655f2392019-11-27 16:33:02 +0800222 outfile.write(template.render(context))
223 outfile.close()
Edison Ai48b2d9e2019-06-24 14:39:45 +0800224
Kevin Peng655f2392019-11-27 16:33:02 +0800225 print ("Generation of files done")
Edison Ai48b2d9e2019-06-24 14:39:45 +0800226
Ken Liu861b0782021-05-22 13:15:08 +0800227def process_stateless_services(partitions, stateless_index_max_num):
Mingyang Suna1ca6112021-01-11 11:34:59 +0800228 """
229 This function collects all stateless services together, and allocates
Mingyang Sun4ecea992021-03-30 17:56:26 +0800230 stateless handles for them.
Kevin Pengc05319d2021-04-22 22:59:35 +0800231 Valid stateless handle in service will be converted to an index. If the
232 stateless handle is set as "auto", or not set, framework will allocate a
233 valid index for the service.
234 Framework puts each service into a reordered stateless service list at
235 position of "index". Other unused positions are left None.
Mingyang Suna1ca6112021-01-11 11:34:59 +0800236 """
Kevin Pengc05319d2021-04-22 22:59:35 +0800237 collected_stateless_services = []
Mingyang Suna1ca6112021-01-11 11:34:59 +0800238
239 # Collect all stateless services first.
240 for partition in partitions:
241 # Skip the FF-M 1.0 partitions
242 if partition['manifest']['psa_framework_version'] < 1.1:
243 continue
244 # Skip the Non-IPC partitions
245 if partition['attr']['tfm_partition_ipc'] is not True:
246 continue
247 for service in partition['manifest']['services']:
248 if 'connection_based' not in service:
249 raise Exception("'connection_based' is mandatory in FF-M 1.1 service!")
250 if service['connection_based'] is False:
Kevin Pengc05319d2021-04-22 22:59:35 +0800251 collected_stateless_services.append(service)
Mingyang Suna1ca6112021-01-11 11:34:59 +0800252
Kevin Pengc05319d2021-04-22 22:59:35 +0800253 if len(collected_stateless_services) == 0:
Mingyang Suna1ca6112021-01-11 11:34:59 +0800254 return []
255
Ken Liu861b0782021-05-22 13:15:08 +0800256 if len(collected_stateless_services) > stateless_index_max_num:
257 raise Exception("Stateless service numbers range exceed {number}.".format(number=stateless_index_max_num))
Mingyang Suna1ca6112021-01-11 11:34:59 +0800258
259 """
Kevin Pengc05319d2021-04-22 22:59:35 +0800260 Allocate an empty stateless service list to store services.
261 Use "handle - 1" as the index for service, since handle value starts from
262 1 and list index starts from 0.
Mingyang Suna1ca6112021-01-11 11:34:59 +0800263 """
Ken Liu861b0782021-05-22 13:15:08 +0800264 reordered_stateless_services = [None] * stateless_index_max_num
Kevin Pengc05319d2021-04-22 22:59:35 +0800265 auto_alloc_services = []
Mingyang Suna1ca6112021-01-11 11:34:59 +0800266
Kevin Pengc05319d2021-04-22 22:59:35 +0800267 for service in collected_stateless_services:
268 # If not set, it is "auto" by default
269 if 'stateless_handle' not in service:
270 auto_alloc_services.append(service)
271 continue
272
Mingyang Sun4ecea992021-03-30 17:56:26 +0800273 service_handle = service['stateless_handle']
Mingyang Suna1ca6112021-01-11 11:34:59 +0800274
Mingyang Sun4ecea992021-03-30 17:56:26 +0800275 # Fill in service list with specified stateless handle, otherwise skip
276 if isinstance(service_handle, int):
Ken Liu861b0782021-05-22 13:15:08 +0800277 if service_handle < 1 or service_handle > stateless_index_max_num:
Kevin Pengc05319d2021-04-22 22:59:35 +0800278 raise Exception("Invalid stateless_handle setting: {handle}.".format(handle=service['stateless_handle']))
Mingyang Sun4ecea992021-03-30 17:56:26 +0800279 # Convert handle index to reordered service list index
280 service_handle = service_handle - 1
281
282 if reordered_stateless_services[service_handle] is not None:
Kevin Pengc05319d2021-04-22 22:59:35 +0800283 raise Exception("Duplicated stateless_handle setting: {handle}.".format(handle=service['stateless_handle']))
Mingyang Sun4ecea992021-03-30 17:56:26 +0800284 reordered_stateless_services[service_handle] = service
Kevin Pengc05319d2021-04-22 22:59:35 +0800285 elif service_handle == 'auto':
286 auto_alloc_services.append(service)
287 else:
288 raise Exception("Invalid stateless_handle setting: {handle}.".format(handle=service['stateless_handle']))
Mingyang Sun4ecea992021-03-30 17:56:26 +0800289
290 # Auto-allocate stateless handle and encode the stateless handle
Ken Liu861b0782021-05-22 13:15:08 +0800291 for i in range(0, stateless_index_max_num):
Mingyang Sun4ecea992021-03-30 17:56:26 +0800292 service = reordered_stateless_services[i]
293
Kevin Pengc05319d2021-04-22 22:59:35 +0800294 if service == None and len(auto_alloc_services) > 0:
295 service = auto_alloc_services.pop(0)
Mingyang Sun4ecea992021-03-30 17:56:26 +0800296
Mingyang Sun453ad402021-03-17 17:58:33 +0800297 """
298 Encode stateless flag and version into stateless handle
299 bit 30: stateless handle indicator
300 bit 15-8: stateless service version
301 bit 7-0: stateless handle index
302 """
Mingyang Sun4ecea992021-03-30 17:56:26 +0800303 stateless_handle_value = 0
304 if service != None:
305 stateless_index = (i & 0xFF)
306 stateless_handle_value |= stateless_index
Mingyang Sun453ad402021-03-17 17:58:33 +0800307 stateless_flag = 1 << 30
308 stateless_handle_value |= stateless_flag
Mingyang Sun4ecea992021-03-30 17:56:26 +0800309 stateless_version = (service['version'] & 0xFF) << 8
Mingyang Sun453ad402021-03-17 17:58:33 +0800310 stateless_handle_value |= stateless_version
Mingyang Sun4ecea992021-03-30 17:56:26 +0800311 service['stateless_handle_value'] = '0x{0:08x}'.format(stateless_handle_value)
Ken Liu861b0782021-05-22 13:15:08 +0800312 service['stateless_handle_index'] = stateless_index
Mingyang Suna1ca6112021-01-11 11:34:59 +0800313
Mingyang Sun4ecea992021-03-30 17:56:26 +0800314 reordered_stateless_services[i] = service
315
316 return reordered_stateless_services
Mingyang Suna1ca6112021-01-11 11:34:59 +0800317
Kevin Peng655f2392019-11-27 16:33:02 +0800318def parse_args():
Raef Coles558487a2020-10-29 13:09:44 +0000319 parser = argparse.ArgumentParser(description='Parse secure partition manifest list and generate files listed by the file list',
320 epilog='Note that environment variables in template files will be replaced with their values')
321
Kevin Peng655f2392019-11-27 16:33:02 +0800322 parser.add_argument('-o', '--outdir'
323 , dest='outdir'
324 , required=False
325 , default=None
326 , metavar='out_dir'
327 , help='The root directory for generated files, the default is TF-M root folder.')
Shawn Shana9ad1e02019-08-07 15:49:48 +0800328
Kevin Peng655f2392019-11-27 16:33:02 +0800329 parser.add_argument('-m', '--manifest'
Raef Colesf42f0882020-07-10 10:01:58 +0100330 , nargs='+'
Kevin Peng655f2392019-11-27 16:33:02 +0800331 , dest='manifest_args'
Raef Colesf42f0882020-07-10 10:01:58 +0100332 , required=True
Kevin Peng655f2392019-11-27 16:33:02 +0800333 , metavar='manifest'
Raef Colesf42f0882020-07-10 10:01:58 +0100334 , help='A set of secure partition manifest lists to parse')
Kevin Peng655f2392019-11-27 16:33:02 +0800335
336 parser.add_argument('-f', '--file-list'
Raef Colesf42f0882020-07-10 10:01:58 +0100337 , nargs='+'
Kevin Peng655f2392019-11-27 16:33:02 +0800338 , dest='gen_file_args'
Raef Colesf42f0882020-07-10 10:01:58 +0100339 , required=True
Kevin Peng655f2392019-11-27 16:33:02 +0800340 , metavar='file-list'
Raef Colesf42f0882020-07-10 10:01:58 +0100341 , help='These files descripe the file list to generate')
Kevin Peng655f2392019-11-27 16:33:02 +0800342
343 args = parser.parse_args()
344 manifest_args = args.manifest_args
345 gen_file_args = args.gen_file_args
346
Kevin Peng655f2392019-11-27 16:33:02 +0800347 return args
348
349ENV = Environment(
350 loader = TemplateLoader(),
351 autoescape = select_autoescape(['html', 'xml']),
352 lstrip_blocks = True,
353 trim_blocks = True,
354 keep_trailing_newline = True
355 )
Mate Toth-Pal36f21842018-11-08 16:12:51 +0100356
Miklos Balint470919c2018-05-22 17:51:29 +0200357def main():
Mate Toth-Pal36f21842018-11-08 16:12:51 +0100358 """
359 The entry point of the script.
360
361 Generates the output files based on the templates and the manifests.
362 """
Shawn Shana9ad1e02019-08-07 15:49:48 +0800363
Kevin Peng655f2392019-11-27 16:33:02 +0800364 global OUT_DIR
Shawn Shana9ad1e02019-08-07 15:49:48 +0800365
Kevin Peng655f2392019-11-27 16:33:02 +0800366 args = parse_args()
Shawn Shana9ad1e02019-08-07 15:49:48 +0800367
Kevin Peng655f2392019-11-27 16:33:02 +0800368 manifest_args = args.manifest_args
369 gen_file_args = args.gen_file_args
370 OUT_DIR = args.outdir
Kevin Peng655f2392019-11-27 16:33:02 +0800371
Raef Coles558487a2020-10-29 13:09:44 +0000372 manifest_list = [os.path.abspath(x) for x in args.manifest_args]
373 gen_file_list = [os.path.abspath(x) for x in args.gen_file_args]
Shawn Shana9ad1e02019-08-07 15:49:48 +0800374
375 # Arguments could be relative path.
Kevin Peng655f2392019-11-27 16:33:02 +0800376 # Convert to absolute path as we are going to change diretory later
377 if OUT_DIR is not None:
378 OUT_DIR = os.path.abspath(OUT_DIR)
379
Shawn Shana9ad1e02019-08-07 15:49:48 +0800380 """
Kevin Peng655f2392019-11-27 16:33:02 +0800381 Relative path to TF-M root folder is supported in the manifests
382 and default value of manifest list and generated file list are relative to TF-M root folder as well,
383 so first change directory to TF-M root folder.
Shawn Shana9ad1e02019-08-07 15:49:48 +0800384 By doing this, the script can be executed anywhere
Kevin Peng655f2392019-11-27 16:33:02 +0800385 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 +0800386 """
387 os.chdir(os.path.join(sys.path[0], ".."))
388
Ken Liu861b0782021-05-22 13:15:08 +0800389 partition_list = process_partition_manifests(manifest_list)
Mate Toth-Pal36f21842018-11-08 16:12:51 +0100390
Edison Ai6e3f2a32019-06-11 15:29:05 +0800391 utilities = {}
Mingyang Suna1ca6112021-01-11 11:34:59 +0800392 utilities['donotedit_warning'] = donotedit_warning
Miklos Balint470919c2018-05-22 17:51:29 +0200393
Ken Liu861b0782021-05-22 13:15:08 +0800394 context = {}
395 context['partitions'] = partition_list
Kevin Peng655f2392019-11-27 16:33:02 +0800396 context['utilities'] = utilities
Ken Liu861b0782021-05-22 13:15:08 +0800397 context['stateless_services'] = process_stateless_services(partition_list, 32)
Mate Toth-Pal36f21842018-11-08 16:12:51 +0100398
Ken Liu861b0782021-05-22 13:15:08 +0800399 gen_per_partition_files(context)
400 gen_summary_files(context, gen_file_list)
Miklos Balint470919c2018-05-22 17:51:29 +0200401
402if __name__ == "__main__":
403 main()