pass disk image to baremetal if present

Why not? But this is mostly a cheap workaround for gem5 baremetal not
handling no disk images.
This commit is contained in:
Ciro Santilli 六四事件 法轮功
2020-04-03 01:00:00 +00:00
parent 253ba153c7
commit c0bc5cffed
2 changed files with 13 additions and 9 deletions

View File

@@ -1148,7 +1148,6 @@ Incompatible archs are skipped.
# Image # Image
if env['baremetal'] is not None: if env['baremetal'] is not None:
env['disk_image'] = None
env['image'] = self.resolve_baremetal_executable(env['baremetal']) env['image'] = self.resolve_baremetal_executable(env['baremetal'])
source_path_noext = os.path.splitext(join( source_path_noext = os.path.splitext(join(
env['root_dir'], env['root_dir'],
@@ -1176,16 +1175,18 @@ Incompatible archs are skipped.
if env['emulator'] == 'gem5': if env['emulator'] == 'gem5':
if not env['_args_given']['linux_exec']: if not env['_args_given']['linux_exec']:
env['image'] = env['vmlinux'] env['image'] = env['vmlinux']
if env['ramfs']:
env['disk_image'] = None
else:
env['disk_image'] = env['rootfs_raw_file']
else: else:
if not env['_args_given']['linux_exec']: if not env['_args_given']['linux_exec']:
env['image'] = env['linux_image'] env['image'] = env['linux_image']
env['disk_image'] = env['qcow2_file']
if env['_args_given']['linux_exec']: if env['_args_given']['linux_exec']:
env['image'] = env['linux_exec'] env['image'] = env['linux_exec']
if env['emulator'] == 'gem5':
if env['ramfs']:
env['disk_image'] = None
else:
env['disk_image'] = env['rootfs_raw_file']
else:
env['disk_image'] = env['qcow2_file']
# Android # Android
if not env['_args_given']['android_base_dir']: if not env['_args_given']['android_base_dir']:

9
run
View File

@@ -501,6 +501,9 @@ Extra options to append at the end of the emulator command line.
f.write(struct.pack('<{}'.format(self.python_struct_int_format(self.env['int_size'])), len(cli_args))) f.write(struct.pack('<{}'.format(self.python_struct_int_format(self.env['int_size'])), len(cli_args)))
f.write(b''.join(argv_addr_data)) f.write(b''.join(argv_addr_data))
f.write(b'\0'.join(arg.encode() for arg in cli_args) + b'\0') f.write(b'\0'.join(arg.encode() for arg in cli_args) + b'\0')
use_disk_image = self.env['disk_image'] is not None and \
os.path.exists(self.env['disk_image']) or \
self.env['baremetal'] is None
if self.env['emulator'] == 'gem5': if self.env['emulator'] == 'gem5':
if self.env['quiet']: if self.env['quiet']:
show_stdout = False show_stdout = False
@@ -569,7 +572,7 @@ Extra options to append at the end of the emulator command line.
'--num-cpus', str(self.env['cpus']), LF, '--num-cpus', str(self.env['cpus']), LF,
'--script', self.env['gem5_readfile_file'], LF, '--script', self.env['gem5_readfile_file'], LF,
]) ])
if self.env['disk_image'] is not None: if use_disk_image:
cmd.extend(['--disk-image', self.env['disk_image'], LF]) cmd.extend(['--disk-image', self.env['disk_image'], LF])
if not self.env['baremetal'] is None: if not self.env['baremetal'] is None:
cmd.extend([ cmd.extend([
@@ -646,7 +649,7 @@ Extra options to append at the end of the emulator command line.
'--little-cpus', str(self.env['cpus'] // 2), LF, '--little-cpus', str(self.env['cpus'] // 2), LF,
'--root', '/dev/vda', LF, '--root', '/dev/vda', LF,
]) ])
if self.env['disk_image'] is not None: if use_disk_image:
cmd.extend(['--disk', self.env['disk_image'], LF]) cmd.extend(['--disk', self.env['disk_image'], LF])
if self.env['dtb']: if self.env['dtb']:
cmd.extend([ cmd.extend([
@@ -796,7 +799,7 @@ Extra options to append at the end of the emulator command line.
'-drive', 'driver=blkreplay,if=none,image=img-direct,id=img-blkreplay', LF, '-drive', 'driver=blkreplay,if=none,image=img-direct,id=img-blkreplay', LF,
'-device', 'ide-hd,drive=img-blkreplay', LF, '-device', 'ide-hd,drive=img-blkreplay', LF,
]) ])
if self.env['disk_image'] is not None: if use_disk_image:
extra_emulator_args.extend([ extra_emulator_args.extend([
'-drive', '-drive',
'file={},format=qcow2,if={}{}{}'.format( 'file={},format=qcow2,if={}{}{}'.format(