X-Git-Url: https://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fplatform-powerpc.c;h=6ed65221c84b1ac14d5a7491e7e948bf7256e7be;hp=28c081d7540332281e972609f935496141905a21;hb=e0707ec2d66000a5de8ce6caf03fd8651a4bd916;hpb=cf651e02fb7a34545211708c2a285cd228645531 diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index 28c081d..6ed6522 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); } @@ -692,7 +738,7 @@ static bool probe(struct platform *p, void *ctx) struct stat statbuf; int rc; - /* we need a device tree and a working nvram binary */ + /* we need a device tree */ rc = stat("/proc/device-tree", &statbuf); if (rc) return false; @@ -700,10 +746,6 @@ static bool probe(struct platform *p, void *ctx) if (!S_ISDIR(statbuf.st_mode)) return false; - rc = process_run_simple(ctx, "nvram", "--print-config", NULL); - if (!WIFEXITED(rc) || WEXITSTATUS(rc) != 0) - return false; - platform = talloc(ctx, struct platform_powerpc); list_init(&platform->params);