mirror of
https://git.proxmox.com/git/grub2
synced 2025-10-29 17:31:06 +00:00
Port yaboot logic for various powerpc machine types
Some powerpc machines require not updating the NVRAM. This can be handled by existing grub-install command-line options, but it's friendlier to detect this automatically. On chrp_ibm machines, use the nvram utility rather than nvsetenv. (This is possibly suitable for other machines too, but that needs to be verified.) Forwarded: no Last-Update: 2014-10-15 Patch-Name: install_powerpc_machtypes.patch
This commit is contained in:
parent
d36baf7811
commit
6e18b4772a
@ -24,3 +24,8 @@ grub_install_get_default_x86_platform (void)
|
|||||||
return "i386-pc";
|
return "i386-pc";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
grub_install_get_default_powerpc_machtype (void)
|
||||||
|
{
|
||||||
|
return "generic";
|
||||||
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@
|
|||||||
#include <grub/emu/misc.h>
|
#include <grub/emu/misc.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -145,3 +146,74 @@ grub_install_get_default_x86_platform (void)
|
|||||||
grub_util_info ("... not found");
|
grub_util_info ("... not found");
|
||||||
return "i386-pc";
|
return "i386-pc";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
grub_install_get_default_powerpc_machtype (void)
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
char *buf = NULL;
|
||||||
|
size_t len = 0;
|
||||||
|
const char *machtype = "generic";
|
||||||
|
|
||||||
|
fp = grub_util_fopen ("/proc/cpuinfo", "r");
|
||||||
|
if (! fp)
|
||||||
|
return machtype;
|
||||||
|
|
||||||
|
while (getline (&buf, &len, fp) > 0)
|
||||||
|
{
|
||||||
|
if (strncmp (buf, "pmac-generation",
|
||||||
|
sizeof ("pmac-generation") - 1) == 0)
|
||||||
|
{
|
||||||
|
if (strstr (buf, "NewWorld"))
|
||||||
|
{
|
||||||
|
machtype = "pmac_newworld";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (strstr (buf, "OldWorld"))
|
||||||
|
{
|
||||||
|
machtype = "pmac_oldworld";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strncmp (buf, "motherboard", sizeof ("motherboard") - 1) == 0 &&
|
||||||
|
strstr (buf, "AAPL"))
|
||||||
|
{
|
||||||
|
machtype = "pmac_oldworld";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strncmp (buf, "machine", sizeof ("machine") - 1) == 0 &&
|
||||||
|
strstr (buf, "CHRP IBM"))
|
||||||
|
{
|
||||||
|
if (strstr (buf, "qemu"))
|
||||||
|
{
|
||||||
|
machtype = "chrp_ibm_qemu";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
machtype = "chrp_ibm";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strncmp (buf, "platform", sizeof ("platform") - 1) == 0)
|
||||||
|
{
|
||||||
|
if (strstr (buf, "Maple"))
|
||||||
|
{
|
||||||
|
machtype = "maple";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (strstr (buf, "Cell"))
|
||||||
|
{
|
||||||
|
machtype = "cell";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
fclose (fp);
|
||||||
|
return machtype;
|
||||||
|
}
|
||||||
|
|||||||
@ -212,13 +212,29 @@ grub_install_register_ieee1275 (int is_prep, const char *install_device,
|
|||||||
else
|
else
|
||||||
boot_device = get_ofpathname (install_device);
|
boot_device = get_ofpathname (install_device);
|
||||||
|
|
||||||
if (grub_util_exec ((const char * []){ "nvsetenv", "boot-device",
|
if (strcmp (grub_install_get_default_powerpc_machtype (), "chrp_ibm") == 0)
|
||||||
boot_device, NULL }))
|
|
||||||
{
|
{
|
||||||
char *cmd = xasprintf ("setenv boot-device %s", boot_device);
|
char *arg = xasprintf ("boot-device=%s", boot_device);
|
||||||
grub_util_error (_("`nvsetenv' failed. \nYou will have to set `boot-device' variable manually. At the IEEE1275 prompt, type:\n %s\n"),
|
if (grub_util_exec ((const char * []){ "nvram",
|
||||||
cmd);
|
"--update-config", arg, NULL }))
|
||||||
free (cmd);
|
{
|
||||||
|
char *cmd = xasprintf ("setenv boot-device %s", boot_device);
|
||||||
|
grub_util_error (_("`nvram' failed. \nYou will have to set `boot-device' variable manually. At the IEEE1275 prompt, type:\n %s\n"),
|
||||||
|
cmd);
|
||||||
|
free (cmd);
|
||||||
|
}
|
||||||
|
free (arg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (grub_util_exec ((const char * []){ "nvsetenv", "boot-device",
|
||||||
|
boot_device, NULL }))
|
||||||
|
{
|
||||||
|
char *cmd = xasprintf ("setenv boot-device %s", boot_device);
|
||||||
|
grub_util_error (_("`nvsetenv' failed. \nYou will have to set `boot-device' variable manually. At the IEEE1275 prompt, type:\n %s\n"),
|
||||||
|
cmd);
|
||||||
|
free (cmd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free (boot_device);
|
free (boot_device);
|
||||||
|
|||||||
@ -128,6 +128,12 @@ grub_install_get_default_x86_platform (void)
|
|||||||
return "i386-efi";
|
return "i386-efi";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
grub_install_get_default_powerpc_machtype (void)
|
||||||
|
{
|
||||||
|
return "generic";
|
||||||
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
get_efi_variable (const wchar_t *varname, ssize_t *len)
|
get_efi_variable (const wchar_t *varname, ssize_t *len)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -206,6 +206,9 @@ grub_install_create_envblk_file (const char *name);
|
|||||||
const char *
|
const char *
|
||||||
grub_install_get_default_x86_platform (void);
|
grub_install_get_default_x86_platform (void);
|
||||||
|
|
||||||
|
const char *
|
||||||
|
grub_install_get_default_powerpc_machtype (void);
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_install_register_efi (grub_device_t efidir_grub_dev,
|
grub_install_register_efi (grub_device_t efidir_grub_dev,
|
||||||
const char *efifile_path,
|
const char *efifile_path,
|
||||||
|
|||||||
@ -1155,7 +1155,18 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
if (platform == GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275)
|
if (platform == GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275)
|
||||||
{
|
{
|
||||||
|
const char *machtype = grub_install_get_default_powerpc_machtype ();
|
||||||
int is_guess = 0;
|
int is_guess = 0;
|
||||||
|
|
||||||
|
if (strcmp (machtype, "pmac_oldworld") == 0)
|
||||||
|
update_nvram = 0;
|
||||||
|
else if (strcmp (machtype, "cell") == 0)
|
||||||
|
update_nvram = 0;
|
||||||
|
else if (strcmp (machtype, "generic") == 0)
|
||||||
|
update_nvram = 0;
|
||||||
|
else if (strcmp (machtype, "chrp_ibm_qemu") == 0)
|
||||||
|
update_nvram = 0;
|
||||||
|
|
||||||
if (!macppcdir)
|
if (!macppcdir)
|
||||||
{
|
{
|
||||||
char *d;
|
char *d;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user