]> git.ozlabs.org Git - petitboot/blobdiff - discover/platform-powerpc.c
Display VERSION partition info on BMC machines
[petitboot] / discover / platform-powerpc.c
index ce4eb8199ed33d01570e14aac57ce924fba3bb90..46f81d201a403bec565bb735d728aa1e661fbcc1 100644 (file)
@@ -14,7 +14,9 @@
 #include <list/list.h>
 #include <log/log.h>
 #include <process/process.h>
+#include <types/types.h>
 
+#include "hostboot.h"
 #include "platform.h"
 #include "ipmi.h"
 #include "dt.h"
@@ -43,6 +45,7 @@ struct platform_powerpc {
                                bool persistent);
        int             (*set_os_boot_sensor)(
                                struct platform_powerpc *platform);
+       void            (*get_platform_versions)(struct system_info *info);
 };
 
 static const char *known_params[] = {
@@ -310,7 +313,7 @@ static int parse_one_interface_config(struct config *config,
        } else if (!strcmp(tok, "static")) {
                ifconf->method = CONFIG_METHOD_STATIC;
 
-               /* ip/mask, [optional] gateway */
+               /* ip/mask, [optional] gateway, [optional] url */
                tok = strtok_r(NULL, ",", &saveptr);
                if (!tok)
                        goto out_err;
@@ -323,6 +326,12 @@ static int parse_one_interface_config(struct config *config,
                                talloc_strdup(ifconf, tok);
                }
 
+               tok = strtok_r(NULL, ",", &saveptr);
+               if (tok) {
+                       ifconf->static_config.url =
+                               talloc_strdup(ifconf, tok);
+               }
+
        } else {
                pb_log("Unknown network configuration method %s\n", tok);
                goto out_err;
@@ -438,7 +447,6 @@ static void populate_bootdev_config(struct platform_powerpc *platform,
 {
        struct autoboot_option *opt, *new = NULL;
        char *pos, *end, *old_dev = NULL;
-       const char delim = ' ';
        unsigned int n_new = 0;
        const char *val;
        bool conflict;
@@ -469,11 +477,9 @@ static void populate_bootdev_config(struct platform_powerpc *platform,
 
                if (read_bootdev(config, &pos, opt)) {
                        pb_log("bootdev config is in an unknown format "
-                              "(expected uuid:... or mac:...)");
+                              "(expected uuid:... or mac:...)\n");
                        talloc_free(opt);
-                       if (strchr(pos, delim))
-                               continue;
-                       return;
+                       continue;
                }
 
                new = talloc_realloc(config, new, struct autoboot_option,
@@ -578,10 +584,12 @@ static char *iface_config_str(void *ctx, struct interface_config *config)
                str = talloc_asprintf_append(str, "dhcp");
 
        } else if (config->method == CONFIG_METHOD_STATIC) {
-               str = talloc_asprintf_append(str, "static,%s%s%s",
+               str = talloc_asprintf_append(str, "static,%s%s%s%s%s",
                                config->static_config.address,
                                config->static_config.gateway ? "," : "",
-                               config->static_config.gateway ?: "");
+                               config->static_config.gateway ?: "",
+                               config->static_config.url ? "," : "",
+                               config->static_config.url ?: "");
        }
        return str;
 }
@@ -759,9 +767,8 @@ static int read_bootdev_sysparam(const char *name, uint8_t *val)
        char path[50];
        int fd, rc;
 
-       strcpy(path, sysparams_dir);
-       assert(strlen(name) < sizeof(path) - strlen(path));
-       strcat(path, name);
+       assert(strlen(sysparams_dir) + strlen(name) < sizeof(path));
+       snprintf(path, sizeof(path), "%s%s", sysparams_dir, name);
 
        fd = open(path, O_RDONLY);
        if (fd < 0) {
@@ -795,9 +802,8 @@ static int write_bootdev_sysparam(const char *name, uint8_t val)
        char path[50];
        int fd, rc;
 
-       strcpy(path, sysparams_dir);
-       assert(strlen(name) < sizeof(path) - strlen(path));
-       strcat(path, name);
+       assert(strlen(sysparams_dir) + strlen(name) < sizeof(path));
+       snprintf(path, sizeof(path), "%s%s", sysparams_dir, name);
 
        fd = open(path, O_WRONLY);
        if (fd < 0) {
@@ -920,6 +926,11 @@ static int get_ipmi_bootdev_ipmi(struct platform_powerpc *platform,
                return -1;
        }
 
+       pb_debug("IPMI get_bootdev response:\n");
+       for (int i = 0; i < resp_len; i++)
+               pb_debug("%x ", resp[i]);
+       pb_debug("\n");
+
        if (resp[0] != 0) {
                pb_log("platform: non-zero completion code %d from IPMI req\n",
                                resp[0]);
@@ -1086,6 +1097,9 @@ static int get_sysinfo(struct platform *p, struct system_info *sysinfo)
        if (platform->ipmi)
                get_ipmi_bmc_mac(p, sysinfo->bmc_mac);
 
+       if (platform->get_platform_versions)
+               platform->get_platform_versions(sysinfo);
+
        return 0;
 }
 
@@ -1123,6 +1137,10 @@ static bool probe(struct platform *p, void *ctx)
                pb_log("platform: no IPMI parameter support\n");
        }
 
+       rc = stat("/proc/device-tree/bmc", &statbuf);
+       if (!rc)
+               platform->get_platform_versions = hostboot_load_versions;
+
        return true;
 }