qemu.bbclass 2.7 KB

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