aboutsummaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2015-12-03 16:20:34 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-12-03 16:20:34 +1100
commit3ee71369bcc9c3b299586acb7f714d83c7447011 (patch)
tree525448c62cf0cfefbcae712cd1c99e80bc25c4d4 /external
parentc89400a0538394e87b60f29c3883d826f04ddc84 (diff)
parentd379d6d9f5ece1606d9fc89bbbdb56814d405116 (diff)
downloadskiboot-3ee71369bcc9c3b299586acb7f714d83c7447011.zip
skiboot-3ee71369bcc9c3b299586acb7f714d83c7447011.tar.gz
skiboot-3ee71369bcc9c3b299586acb7f714d83c7447011.tar.bz2
Merge branch 'stable'
Diffstat (limited to 'external')
-rw-r--r--external/opal-prd/opal-prd.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/external/opal-prd/opal-prd.c b/external/opal-prd/opal-prd.c
index 0004b3d..115443c 100644
--- a/external/opal-prd/opal-prd.c
+++ b/external/opal-prd/opal-prd.c
@@ -1032,6 +1032,52 @@ out_free:
return rc;
}
+bool find_string(const char *buffer, size_t len, const char *s)
+{
+ const char *c, *end;
+
+ if (!buffer)
+ return false;
+ c = buffer;
+ end = c + len;
+
+ while (c < end) {
+ if (!strcasecmp(s, c))
+ return true;
+ c += strlen(c) + 1;
+ }
+ return false;
+}
+
+static int is_prd_supported(void)
+{
+ char *path;
+ int rc;
+ int len;
+ char *buf;
+
+ rc = asprintf(&path, "%s/ibm,opal/diagnostics/compatible",
+ devicetree_base);
+ if (rc < 0) {
+ pr_log(LOG_ERR, "FW: error creating 'compatible' node path: %m");
+ return -1;
+ }
+
+ rc = open_and_read(path, (void *) &buf, &len);
+ if (rc)
+ goto out_free;
+
+ if (buf[len - 1] != '\0')
+ pr_log(LOG_INFO, "FW: node %s is not nul-terminated", path);
+
+ rc = find_string(buf, len, "ibm,opal-prd") ? 0 : -1;
+
+ free(buf);
+out_free:
+ free(path);
+ return rc;
+}
+
static int prd_init(struct opal_prd_ctx *ctx)
{
int rc;
@@ -1963,6 +2009,12 @@ int main(int argc, char *argv[])
action = ACTION_RUN_DAEMON;
}
+ if (is_prd_supported() < 0) {
+ pr_log(LOG_ERR, "CTRL: PowerNV OPAL runtime diagnostic "
+ "is not supported on this system");
+ return -1;
+ }
+
switch (action) {
case ACTION_RUN_DAEMON:
rc = run_prd_daemon(ctx);