| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # | 
|  | 2 | # This class contains functions for recipes that need QEMU or test for its | 
|  | 3 | # existence. | 
|  | 4 | # | 
|  | 5 |  | 
|  | 6 | def qemu_target_binary(data): | 
|  | 7 | target_arch = data.getVar("TARGET_ARCH", True) | 
|  | 8 | if target_arch in ("i486", "i586", "i686"): | 
|  | 9 | target_arch = "i386" | 
|  | 10 | elif target_arch == "powerpc": | 
|  | 11 | target_arch = "ppc" | 
|  | 12 | elif target_arch == "powerpc64": | 
|  | 13 | target_arch = "ppc64" | 
|  | 14 |  | 
|  | 15 | return "qemu-" + target_arch | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame^] | 16 |  | 
|  | 17 | def qemu_wrapper_cmdline(data, rootfs_path, library_paths): | 
|  | 18 | import string | 
|  | 19 |  | 
|  | 20 | qemu_binary = qemu_target_binary(data) | 
|  | 21 | if qemu_binary == "qemu-allarch": | 
|  | 22 | qemu_binary = "qemuwrapper" | 
|  | 23 |  | 
|  | 24 | qemu_options = data.getVar("QEMU_OPTIONS", True) | 
|  | 25 |  | 
|  | 26 | return "PSEUDO_UNLOAD=1 " + qemu_binary + " " + qemu_options + " -L " + rootfs_path\ | 
|  | 27 | + " -E LD_LIBRARY_PATH=" + ":".join(library_paths) + " " | 
|  | 28 |  | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 29 | # Next function will return a string containing the command that is needed to | 
|  | 30 | # to run a certain binary through qemu. For example, in order to make a certain | 
|  | 31 | # postinstall scriptlet run at do_rootfs time and running the postinstall is | 
|  | 32 | # architecture dependent, we can run it through qemu. For example, in the | 
|  | 33 | # postinstall scriptlet, we could use the following: | 
|  | 34 | # | 
|  | 35 | # ${@qemu_run_binary(d, '$D', '/usr/bin/test_app')} [test_app arguments] | 
|  | 36 | # | 
|  | 37 | def qemu_run_binary(data, rootfs_path, binary): | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 38 | libdir = rootfs_path + data.getVar("libdir", False) | 
|  | 39 | base_libdir = rootfs_path + data.getVar("base_libdir", False) | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 40 |  | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame^] | 41 | return qemu_wrapper_cmdline(data, rootfs_path, [libdir, base_libdir]) + rootfs_path + binary | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 42 |  | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame^] | 43 | # QEMU_EXTRAOPTIONS is not meant to be directly used, the extensions are | 
|  | 44 | # PACKAGE_ARCH, *NOT* overrides. | 
|  | 45 | # In some cases (e.g. ppc) simply being arch specific (apparently) isn't good | 
|  | 46 | # enough and a PACKAGE_ARCH specific -cpu option is needed (hence we have to do | 
|  | 47 | # this dance). For others (e.g. arm) a -cpu option is not necessary, since the | 
|  | 48 | # qemu-arm default CPU supports all required architecture levels. | 
|  | 49 |  | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 50 | QEMU_OPTIONS = "-r ${OLDEST_KERNEL} ${@d.getVar("QEMU_EXTRAOPTIONS_%s" % d.getVar('PACKAGE_ARCH', True), True) or ""}" | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame^] | 51 | QEMU_OPTIONS[vardeps] += "QEMU_EXTRAOPTIONS_${PACKAGE_ARCH}" | 
|  | 52 |  | 
|  | 53 | QEMU_EXTRAOPTIONS_ppce500v2 = " -cpu e500v2" | 
|  | 54 | QEMU_EXTRAOPTIONS_ppce500mc = " -cpu e500mc" | 
|  | 55 | QEMU_EXTRAOPTIONS_ppce5500 = " -cpu e500mc" | 
|  | 56 | QEMU_EXTRAOPTIONS_ppc64e5500 = " -cpu e500mc" | 
|  | 57 | QEMU_EXTRAOPTIONS_ppce6500 = " -cpu e500mc" | 
|  | 58 | QEMU_EXTRAOPTIONS_ppc64e6500 = " -cpu e500mc" | 
|  | 59 | QEMU_EXTRAOPTIONS_ppc7400 = " -cpu 7400" |