Lines Matching full:args

96 def get_recovery_dtbo_offset(args):  argument
99 num_kernel_pages = get_number_of_pages(filesize(args.kernel), args.pagesize)
100 num_ramdisk_pages = get_number_of_pages(filesize(args.ramdisk),
101 args.pagesize)
102 num_second_pages = get_number_of_pages(filesize(args.second), args.pagesize)
103 dtbo_offset = args.pagesize * (num_header_pages + num_kernel_pages +
108 def should_add_legacy_gki_boot_signature(args): argument
109 if args.gki_signing_key and args.gki_signing_algorithm:
114 def write_header_v3_and_above(args): argument
115 if args.header_version > 3:
120 args.output.write(pack(f'{BOOT_MAGIC_SIZE}s', BOOT_MAGIC.encode()))
122 args.output.write(pack('I', filesize(args.kernel)))
124 args.output.write(pack('I', filesize(args.ramdisk)))
126 args.output.write(pack('I', (args.os_version << 11) | args.os_patch_level))
127 args.output.write(pack('I', boot_header_size))
129 args.output.write(pack('4I', 0, 0, 0, 0))
131 args.output.write(pack('I', args.header_version))
132 args.output.write(pack(f'{BOOT_ARGS_SIZE + BOOT_EXTRA_ARGS_SIZE}s',
133 args.cmdline))
134 if args.header_version >= 4:
137 if should_add_legacy_gki_boot_signature(args):
139 args.output.write(pack('I', boot_signature_size))
140 pad_file(args.output, BOOT_IMAGE_HEADER_V3_PAGESIZE)
143 def write_vendor_boot_header(args): argument
144 if args.header_version > 3:
145 vendor_ramdisk_size = args.vendor_ramdisk_total_size
148 vendor_ramdisk_size = filesize(args.vendor_ramdisk)
151 args.vendor_boot.write(pack(f'{VENDOR_BOOT_MAGIC_SIZE}s',
154 args.vendor_boot.write(pack('I', args.header_version))
156 args.vendor_boot.write(pack('I', args.pagesize))
158 args.vendor_boot.write(pack('I', args.base + args.kernel_offset))
160 args.vendor_boot.write(pack('I', args.base + args.ramdisk_offset))
162 args.vendor_boot.write(pack('I', vendor_ramdisk_size))
163 args.vendor_boot.write(pack(f'{VENDOR_BOOT_ARGS_SIZE}s',
164 args.vendor_cmdline))
166 args.vendor_boot.write(pack('I', args.base + args.tags_offset))
168 args.vendor_boot.write(pack(f'{VENDOR_BOOT_NAME_SIZE}s', args.board))
171 args.vendor_boot.write(pack('I', vendor_boot_header_size))
174 args.vendor_boot.write(pack('I', filesize(args.dtb)))
176 args.vendor_boot.write(pack('Q', args.base + args.dtb_offset))
178 if args.header_version > 3:
179 vendor_ramdisk_table_size = (args.vendor_ramdisk_table_entry_num *
182 args.vendor_boot.write(pack('I', vendor_ramdisk_table_size))
184 args.vendor_boot.write(pack('I', args.vendor_ramdisk_table_entry_num))
186 args.vendor_boot.write(pack('I', VENDOR_RAMDISK_TABLE_ENTRY_V4_SIZE))
188 args.vendor_boot.write(pack('I', filesize(args.vendor_bootconfig)))
189 pad_file(args.vendor_boot, args.pagesize)
192 def write_header(args): argument
193 if args.header_version > 4:
195 f'Boot header version {args.header_version} not supported')
196 if args.header_version in {3, 4}:
197 return write_header_v3_and_above(args)
199 ramdisk_load_address = ((args.base + args.ramdisk_offset)
200 if filesize(args.ramdisk) > 0 else 0)
201 second_load_address = ((args.base + args.second_offset)
202 if filesize(args.second) > 0 else 0)
204 args.output.write(pack(f'{BOOT_MAGIC_SIZE}s', BOOT_MAGIC.encode()))
206 args.output.write(pack('I', filesize(args.kernel)))
208 args.output.write(pack('I', args.base + args.kernel_offset))
210 args.output.write(pack('I', filesize(args.ramdisk)))
212 args.output.write(pack('I', ramdisk_load_address))
214 args.output.write(pack('I', filesize(args.second)))
216 args.output.write(pack('I', second_load_address))
218 args.output.write(pack('I', args.base + args.tags_offset))
220 args.output.write(pack('I', args.pagesize))
222 args.output.write(pack('I', args.header_version))
224 args.output.write(pack('I', (args.os_version << 11) | args.os_patch_level))
226 args.output.write(pack(f'{BOOT_NAME_SIZE}s', args.board))
227 args.output.write(pack(f'{BOOT_ARGS_SIZE}s', args.cmdline))
230 update_sha(sha, args.kernel)
231 update_sha(sha, args.ramdisk)
232 update_sha(sha, args.second)
234 if args.header_version > 0:
235 update_sha(sha, args.recovery_dtbo)
236 if args.header_version > 1:
237 update_sha(sha, args.dtb)
241 args.output.write(img_id)
242 args.output.write(pack(f'{BOOT_EXTRA_ARGS_SIZE}s', args.extra_cmdline))
244 if args.header_version > 0:
245 if args.recovery_dtbo:
247 args.output.write(pack('I', filesize(args.recovery_dtbo)))
249 args.output.write(pack('Q', get_recovery_dtbo_offset(args)))
252 args.output.write(pack('I', 0))
253 args.output.write(pack('Q', 0))
256 if args.header_version == 1:
257 args.output.write(pack('I', BOOT_IMAGE_HEADER_V1_SIZE))
258 elif args.header_version == 2:
259 args.output.write(pack('I', BOOT_IMAGE_HEADER_V2_SIZE))
261 if args.header_version > 1:
262 if filesize(args.dtb) == 0:
266 args.output.write(pack('I', filesize(args.dtb)))
268 args.output.write(pack('Q', args.base + args.dtb_offset))
270 pad_file(args.output, args.pagesize)
428 def parse_vendor_ramdisk_args(args, args_list): argument
431 Args:
432 args: An argparse.Namespace object. Parsed results are stored into this
452 if args.vendor_ramdisk is not None:
454 args.vendor_ramdisk.name, VENDOR_RAMDISK_TYPE_PLATFORM, b'', None)
476 args.vendor_ramdisk_total_size = (vendor_ramdisk_table_builder
478 args.vendor_ramdisk_table_entry_num = len(vendor_ramdisk_table_builder
480 args.vendor_ramdisk_table_builder = vendor_ramdisk_table_builder
565 args, extra_args = parser.parse_known_args()
566 if args.vendor_boot is not None and args.header_version > 3:
567 extra_args = parse_vendor_ramdisk_args(args, extra_args)
571 if args.header_version < 3:
572 args.extra_cmdline = args.cmdline[BOOT_ARGS_SIZE-1:]
573 args.cmdline = args.cmdline[:BOOT_ARGS_SIZE-1] + b'\x00'
574 assert len(args.cmdline) <= BOOT_ARGS_SIZE
575 assert len(args.extra_cmdline) <= BOOT_EXTRA_ARGS_SIZE
577 return args
580 def add_boot_image_signature(args, pagesize): argument
591 args.output.flush()
598 image=args.output.name, avbtool=args.gki_signing_avbtool_path,
599 name='boot', algorithm=args.gki_signing_algorithm,
600 key=args.gki_signing_key, salt='d00df00d',
601 additional_avb_args=args.gki_signing_signature_args.split(),
612 args.output.write(boot_signature_bytes)
613 pad_file(args.output, pagesize)
616 def write_data(args, pagesize): argument
617 write_padded_file(args.output, args.kernel, pagesize)
618 write_padded_file(args.output, args.ramdisk, pagesize)
619 write_padded_file(args.output, args.second, pagesize)
621 if args.header_version > 0 and args.header_version < 3:
622 write_padded_file(args.output, args.recovery_dtbo, pagesize)
623 if args.header_version == 2:
624 write_padded_file(args.output, args.dtb, pagesize)
625 if args.header_version >= 4 and should_add_legacy_gki_boot_signature(args):
626 add_boot_image_signature(args, pagesize)
629 def write_vendor_boot_data(args): argument
630 if args.header_version > 3:
631 builder = args.vendor_ramdisk_table_builder
632 builder.write_ramdisks_padded(args.vendor_boot, args.pagesize)
633 write_padded_file(args.vendor_boot, args.dtb, args.pagesize)
634 builder.write_entries_padded(args.vendor_boot, args.pagesize)
635 write_padded_file(args.vendor_boot, args.vendor_bootconfig,
636 args.pagesize)
638 write_padded_file(args.vendor_boot, args.vendor_ramdisk, args.pagesize)
639 write_padded_file(args.vendor_boot, args.dtb, args.pagesize)
643 args = parse_cmdline()
644 if args.vendor_boot is not None:
645 if args.header_version not in {3, 4}:
648 if args.header_version == 3 and args.vendor_ramdisk is None:
650 write_vendor_boot_header(args)
651 write_vendor_boot_data(args)
652 if args.output is not None:
653 if args.second is not None and args.header_version > 2:
656 img_id = write_header(args)
657 if args.header_version > 2:
658 write_data(args, BOOT_IMAGE_HEADER_V3_PAGESIZE)
660 write_data(args, args.pagesize)
661 if args.id and img_id is not None: