2
* GRUB -- GRand Unified Bootloader
3
* Copyright (C) 2013 Free Software Foundation, Inc.
5
* GRUB is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
10
* GRUB is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
21
#include <grub/util/install.h>
22
#include <grub/emu/exec.h>
23
#include <grub/emu/misc.h>
24
#include <sys/types.h>
28
#include <sys/utsname.h>
31
is_not_empty_directory (const char *dir)
39
while ((de = readdir (d)))
41
if (strcmp (de->d_name, ".") == 0
42
|| strcmp (de->d_name, "..") == 0)
60
return strcmp (un.machine, "x86_64") == 0;
64
grub_install_get_default_x86_platform (void)
67
On Linux, we need the efivars kernel modules.
68
If no EFI is available this module just does nothing
69
besides a small hello and if we detect efi we'll load it
70
anyway later. So it should be safe to
73
grub_util_exec_redirect_all ((const char * []){ "modprobe", "efivars", NULL },
74
NULL, NULL, "/dev/null");
76
grub_util_info ("Looking for /sys/firmware/efi ..");
77
if (is_not_empty_directory ("/sys/firmware/efi"))
79
grub_util_info ("...found");
86
grub_util_info ("... not found. Looking for /proc/device-tree ..");
87
if (is_not_empty_directory ("/proc/device-tree"))
89
grub_util_info ("...found");
90
return "i386-ieee1275";
93
grub_util_info ("... not found");