X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fplatform-powerpc.c;h=24cc521c12c98c40f57c2fbec42400ee71f6f556;hp=a115e34bf38375a45243ec933243559f5317eb4d;hb=dde15c729cb9430325dee7899c73542cba4ca81a;hpb=a70b45006752970840fdfff0a595d293b67a8548 diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index a115e34..24cc521 100644 --- a/discover/platform-powerpc.c +++ b/discover/platform-powerpc.c @@ -34,6 +34,7 @@ static const char *known_params[] = { "auto-boot?", "petitboot,network", "petitboot,timeout", + "petitboot,bootdev", NULL, }; @@ -371,6 +372,32 @@ static void populate_network_config(struct platform_powerpc *platform, talloc_free(val); } +static void populate_bootdev_config(struct platform_powerpc *platform, + struct config *config) + +{ + const char *val; + + config->boot_device = NULL; + + val = get_param(platform, "petitboot,bootdev"); + if (!val || !strlen(val)) + return; + + if (!strncmp(val, "uuid:", strlen("uuid:"))) { + config->boot_device = talloc_strdup(config, + val + strlen("uuid:")); + + } else if (!strncmp(val, "mac:", strlen("mac:"))) { + config->boot_device = talloc_strdup(config, + val + strlen("mac:")); + + } else { + pb_log("bootdev config is in an unknown format " + "(expected uuid:... or mac:...)"); + } +} + static void populate_config(struct platform_powerpc *platform, struct config *config) { @@ -394,6 +421,8 @@ static void populate_config(struct platform_powerpc *platform, } populate_network_config(platform, config); + + populate_bootdev_config(platform, config); } static char *iface_config_str(void *ctx, struct interface_config *config) @@ -481,6 +510,21 @@ static void update_network_config(struct platform_powerpc *platform, talloc_free(val); } +static void update_bootdev_config(struct platform_powerpc *platform, + struct config *config) +{ + char *val, *tmp = NULL; + + if (!config->boot_device) + val = ""; + else + tmp = val = talloc_asprintf(platform, + "uuid:%s", config->boot_device); + + update_string_config(platform, "petitboot,bootdev", val); + talloc_free(tmp); +} + static int update_config(struct platform_powerpc *platform, struct config *config, struct config *defaults) { @@ -505,6 +549,8 @@ static int update_config(struct platform_powerpc *platform, update_network_config(platform, config); + update_bootdev_config(platform, config); + return write_nvram(platform); } @@ -526,6 +572,7 @@ enum ipmi_bootdev { IPMI_BOOTDEV_NONE = 0x00, IPMI_BOOTDEV_NETWORK = 0x01, IPMI_BOOTDEV_DISK = 0x2, + IPMI_BOOTDEV_SAFE = 0x3, IPMI_BOOTDEV_CDROM = 0x5, IPMI_BOOTDEV_SETUP = 0x6, }; @@ -566,6 +613,7 @@ static int read_bootdev_sysparam(const char *name, uint8_t *val) case IPMI_BOOTDEV_NONE: case IPMI_BOOTDEV_NETWORK: case IPMI_BOOTDEV_DISK: + case IPMI_BOOTDEV_SAFE: case IPMI_BOOTDEV_CDROM: case IPMI_BOOTDEV_SETUP: *val = buf[0]; @@ -652,6 +700,10 @@ static void parse_opal_sysparams(struct config *config) case IPMI_BOOTDEV_SETUP: config->autoboot_enabled = false; break; + case IPMI_BOOTDEV_SAFE: + config->autoboot_enabled = false; + config->safe_mode = true; + break; } }