summaryrefslogtreecommitdiffstats
path: root/discover
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2014-04-30 11:25:42 +0800
committerJeremy Kerr <jk@ozlabs.org>2014-07-21 17:20:09 +0800
commite0707ec2d66000a5de8ce6caf03fd8651a4bd916 (patch)
treec0e17bc2abed38c8e2fb527f80f5679683d6d695 /discover
parent1860aac29624b1cb292a7ca549dc063bcd3f9bb6 (diff)
downloadpetitboot-e0707ec2d66000a5de8ce6caf03fd8651a4bd916.zip
petitboot-e0707ec2d66000a5de8ce6caf03fd8651a4bd916.tar.gz
discover/powerpc: Parse & save default boot device parameter
This change implement load & save support for the default boot device configuration parameter. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover')
-rw-r--r--discover/platform-powerpc.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c
index a115e34..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);
}
OpenPOWER on IntegriCloud