]> git.ozlabs.org Git - petitboot/blobdiff - discover/platform-powerpc.c
discover: Enable 'url' pb-events
[petitboot] / discover / platform-powerpc.c
index a115e34bf38375a45243ec933243559f5317eb4d..24cc521c12c98c40f57c2fbec42400ee71f6f556 100644 (file)
@@ -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;
        }
 }