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 |
| 16 | # |
| 17 | # Next function will return a string containing the command that is needed to |
| 18 | # to run a certain binary through qemu. For example, in order to make a certain |
| 19 | # postinstall scriptlet run at do_rootfs time and running the postinstall is |
| 20 | # architecture dependent, we can run it through qemu. For example, in the |
| 21 | # postinstall scriptlet, we could use the following: |
| 22 | # |
| 23 | # ${@qemu_run_binary(d, '$D', '/usr/bin/test_app')} [test_app arguments] |
| 24 | # |
| 25 | def qemu_run_binary(data, rootfs_path, binary): |
| 26 | qemu_binary = qemu_target_binary(data) |
| 27 | if qemu_binary == "qemu-allarch": |
| 28 | qemu_binary = "qemuwrapper" |
| 29 | |
| 30 | libdir = rootfs_path + data.getVar("libdir", False) |
| 31 | base_libdir = rootfs_path + data.getVar("base_libdir", False) |
| 32 | qemu_options = data.getVar("QEMU_OPTIONS", True) |
| 33 | |
| 34 | return "PSEUDO_UNLOAD=1 " + qemu_binary + " " + qemu_options + " -L " + rootfs_path\ |
| 35 | + " -E LD_LIBRARY_PATH=" + libdir + ":" + base_libdir + " "\ |
| 36 | + rootfs_path + binary |
| 37 | |
| 38 | # QEMU_EXTRAOPTIONS is not meant to be directly used, the extensions are |
| 39 | # PACKAGE_ARCH, not overrides and hence have to do this dance. Simply being arch |
| 40 | # specific isn't good enough. |
| 41 | QEMU_OPTIONS = "-r ${OLDEST_KERNEL} ${@d.getVar("QEMU_EXTRAOPTIONS_%s" % d.getVar('PACKAGE_ARCH', True), True) or ""}" |
| 42 | QEMU_EXTRAOPTIONS_iwmmxt = " -cpu pxa270-c5" |
| 43 | QEMU_EXTRAOPTIONS_armv6 = " -cpu arm1136" |
| 44 | QEMU_EXTRAOPTIONS_armv7a = " -cpu cortex-a8" |
| 45 | QEMU_EXTRAOPTIONS_e500v2 = " -cpu e500v2" |
| 46 | QEMU_EXTRAOPTIONS_e500mc = " -cpu e500mc" |
| 47 | QEMU_EXTRAOPTIONS_e5500 = " -cpu e5500" |
| 48 | QEMU_EXTRAOPTIONS_e5500-64b = " -cpu e5500" |
| 49 | QEMU_EXTRAOPTIONS_e6500 = " -cpu e6500" |
| 50 | QEMU_EXTRAOPTIONS_e6500-64b = " -cpu e6500" |
| 51 | QEMU_EXTRAOPTIONS_ppc7400 = " -cpu 7400" |