+# EFI:
+if [ "${grub_platform}" == "efi" ] ; then
+ # arm64 doesn't provide the cpuid command, and we also
+ # don't have any memtest* efi files available, so only
+ # run on architectures other than arm64 (amd64 + i386)
+ if [ "${grub_cpu}" != "arm64" ] ; then
+ # try to detect amd64 by checking whether CPU supports 64-bit (long) mode
+ if cpuid -l ; then
+ if test -e /boot/addons/memtest86+x64.efi ; then
+ menuentry "Memory test (memtest86+x64.efi)" {
+ chainloader /boot/addons/memtest86+x64.efi
+ }
+ fi
+ else # assume i386
+ if test -e /boot/addons/memtest86+ia32.efi ; then
+ menuentry "Memory test (memtest86+ia32.efi)" {
+ chainloader /boot/addons/memtest86+ia32.efi
+ }
+ fi
+ fi
+ fi
+fi
+
+# BIOS/non-EFI: