@@ -62,6 +62,10 @@ static constexpr char kBootSrcPathIA32[] =
6262 " /usr/lib/grub/i386-efi/monolithic/grubia32.efi" ;
6363static constexpr char kBootDestPathIA32 [] = " /EFI/BOOT/BOOTIA32.EFI" ;
6464
65+ static constexpr char kBootSrcPathX64 [] =
66+ " /usr/lib/grub/x86_64-efi/monolithic/grubx64.efi" ;
67+ static constexpr char kBootDestPathX64 [] = " /EFI/BOOT/BOOTX64.EFI" ;
68+
6569static constexpr char kBootSrcPathAA64 [] =
6670 " /usr/lib/grub/arm64-efi/monolithic/grubaa64.efi" ;
6771static constexpr char kBootDestPathAA64 [] = " /EFI/BOOT/BOOTAA64.EFI" ;
@@ -73,6 +77,11 @@ static constexpr char kMultibootModuleSrcPathIA32[] =
7377static constexpr char kMultibootModuleDestPathIA32 [] =
7478 " /EFI/modules/multiboot.mod" ;
7579
80+ static constexpr char kMultibootModuleSrcPathX64 [] =
81+ " /usr/lib/grub/x86_64-efi/multiboot.mod" ;
82+ static constexpr char kMultibootModuleDestPathX64 [] =
83+ " /EFI/modules/multiboot.mod" ;
84+
7685static constexpr char kMultibootModuleSrcPathAA64 [] =
7786 " /usr/lib/grub/arm64-efi/multiboot.mod" ;
7887static constexpr char kMultibootModuleDestPathAA64 [] =
@@ -95,6 +104,7 @@ static constexpr std::array kGrubModulesX86{
95104 " cat" , " help" , " fat" , " part_msdos" , " part_gpt" };
96105static constexpr char kGrubModulesPath [] = " /usr/lib/grub/" ;
97106static constexpr char kGrubModulesX86Name [] = " i386-efi" ;
107+ static constexpr char kGrubModulesX64Name [] = " x86_64-efi" ;
98108
99109Result<void > MakeFatImage (const std::string& data_image, int data_image_mb,
100110 int offset_num_mb) {
@@ -318,22 +328,36 @@ EspBuilder PrepareESP(const std::string& image_path, Arch arch) {
318328 case Arch::RiscV64:
319329 // FIXME: Implement
320330 break ;
321- case Arch::X86:
322- case Arch::X86_64: {
331+ case Arch::X86: {
323332 const auto x86_modules = std::string (kGrubModulesPath ) + std::string (kGrubModulesX86Name );
324333
325334 if (GrubMakeImage (kGrubConfigDestDirectoryPath , kGrubModulesX86Name ,
326335 x86_modules, efi_path, kGrubModulesX86 )) {
327- LOG (INFO) << " Loading grub_mkimage generated EFI binary" ;
336+ LOG (INFO) << " Loading grub_mkimage generated EFI binary for X86 " ;
328337 builder.File (efi_path, kBootDestPathIA32 , /* required */ true );
329338 } else {
330- LOG (INFO) << " Loading prebuilt monolith EFI binary" ;
339+ LOG (INFO) << " Loading prebuilt monolith EFI binary for X86 " ;
331340 builder.File (kBootSrcPathIA32 , kBootDestPathIA32 , /* required */ true );
332341 builder.File (kMultibootModuleSrcPathIA32 , kMultibootModuleDestPathIA32 ,
333342 /* required */ true );
334343 }
335344 break ;
336345 }
346+ case Arch::X86_64: {
347+ const auto x64_modules = std::string (kGrubModulesPath ) + std::string (kGrubModulesX64Name );
348+
349+ if (GrubMakeImage (kGrubConfigDestDirectoryPath , kGrubModulesX64Name ,
350+ x64_modules, efi_path, kGrubModulesX86 )) {
351+ LOG (INFO) << " Loading grub_mkimage generated EFI binary for X86_64" ;
352+ builder.File (efi_path, kBootDestPathX64 , /* required */ true );
353+ } else {
354+ LOG (INFO) << " Loading prebuilt monolith EFI binary for X86_64" ;
355+ builder.File (kBootSrcPathX64 , kBootDestPathX64 , /* required */ true );
356+ builder.File (kMultibootModuleSrcPathX64 , kMultibootModuleDestPathX64 ,
357+ /* required */ true );
358+ }
359+ break ;
360+ }
337361 }
338362
339363 return builder;
@@ -386,13 +410,11 @@ bool AndroidEfiLoaderEspBuilder::Build() const {
386410 dest_path = kBootDestPathRiscV64 ;
387411 break ;
388412 case Arch::X86:
389- case Arch::X86_64: {
390413 dest_path = kBootDestPathIA32 ;
391414 break ;
392- default :
393- LOG (ERROR) << " Unknown architecture" ;
394- return false ;
395- }
415+ case Arch::X86_64:
416+ dest_path = kBootDestPathX64 ;
417+ break ;
396418 }
397419 builder.File (efi_loader_path_, dest_path, /* required */ true );
398420 return builder.Build ();
0 commit comments