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