[v9,13/25] MPIPL: Add OPAL API to register tags
diff mbox series

Message ID 20190712111802.23560-14-hegdevasant@linux.vnet.ibm.com
State Accepted
Headers show
Series
  • MPIPL support
Related show

Checks

Context Check Description
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (4db38a36b31045f0a116d388ddeac850b38c8680)

Commit Message

Vasant Hegde July 12, 2019, 11:17 a.m. UTC
This patch adds new API to register tags.
  opal_mpipl_register_tag(enum opal_mpipl_tags tag, uint64_t tag_val)

  tag:
    OPAL_MPIPL_TAG_KERNEL
      During first boot, kernel will setup its metadata area and asks
      OPAL to preserve metadata area pointer across MPIPL. Post MPIPL
      kernel requests OPAL to provide metadata pointer and it will use
      that pointer to retrieve metadata and create dump.

    OPAL_MPIPL_TAG_BOOT_MEM
      During MPIPL registration kernel will specify how much memory
      firmware can use for Post MPIPL load. Post MPIPL petitboot kernel
      will query for this tag to get boot memory size.

  Return values:
    OPAL_SUCCESS   : Operation success
    OPAL_PARAMETER : Payload passed invalid tag

Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
---
 core/opal-dump.c   | 29 +++++++++++++++++++++++++++++
 include/opal-api.h | 13 ++++++++++++-
 2 files changed, 41 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/core/opal-dump.c b/core/opal-dump.c
index 2db5775e9..775ec8161 100644
--- a/core/opal-dump.c
+++ b/core/opal-dump.c
@@ -299,6 +299,34 @@  static int64_t opal_mpipl_update(enum opal_mpipl_ops ops,
 	return rc;
 }
 
+static int64_t opal_mpipl_register_tag(enum opal_mpipl_tags tag,
+				       uint64_t tag_val)
+{
+	int rc = OPAL_SUCCESS;
+
+	switch (tag) {
+	case OPAL_MPIPL_TAG_BOOT_MEM:
+		if (tag_val <= 0 || tag_val > top_of_ram) {
+			prlog(PR_DEBUG, "Payload sent invalid boot mem size"
+			      " :  0x%llx\n", tag_val);
+			rc = OPAL_PARAMETER;
+		} else {
+			mpipl_metadata->boot_mem_size = tag_val;
+			prlog(PR_NOTICE, "Boot mem size : 0x%llx\n", tag_val);
+		}
+		break;
+	case OPAL_MPIPL_TAG_KERNEL:
+		mpipl_metadata->kernel_tag = tag_val;
+		prlog(PR_NOTICE, "Payload sent metadata tag : 0x%llx\n", tag_val);
+		break;
+	default:
+		prlog(PR_DEBUG, "Payload sent unsupported tag : 0x%x\n", tag);
+		rc = OPAL_PARAMETER;
+		break;
+	}
+	return rc;
+}
+
 void opal_mpipl_init(void)
 {
 	void *mdst_base = (void *)MDST_TABLE_BASE;
@@ -335,4 +363,5 @@  void opal_mpipl_init(void)
 
 	/* OPAL API for MPIPL update */
 	opal_register(OPAL_MPIPL_UPDATE, opal_mpipl_update, 4);
+	opal_register(OPAL_MPIPL_REGISTER_TAG, opal_mpipl_register_tag, 2);
 }
diff --git a/include/opal-api.h b/include/opal-api.h
index 20ce0a45e..d88703556 100644
--- a/include/opal-api.h
+++ b/include/opal-api.h
@@ -233,7 +233,8 @@ 
 #define OPAL_NPU_MEM_ALLOC			171
 #define OPAL_NPU_MEM_RELEASE			172
 #define OPAL_MPIPL_UPDATE			173
-#define OPAL_LAST				173
+#define OPAL_MPIPL_REGISTER_TAG			174
+#define OPAL_LAST				174
 
 #define QUIESCE_HOLD			1 /* Spin all calls at entry */
 #define QUIESCE_REJECT			2 /* Fail all calls with OPAL_BUSY */
@@ -1224,6 +1225,16 @@  enum opal_mpipl_ops {
 	OPAL_MPIPL_FREE_PRESERVED_MEMORY= 3,
 };
 
+/* Tag will point to various metadata area. Kernel will
+ * use tag to get metadata value.
+ */
+enum opal_mpipl_tags {
+	OPAL_MPIPL_TAG_CPU	= 0,
+	OPAL_MPIPL_TAG_OPAL	= 1,
+	OPAL_MPIPL_TAG_KERNEL	= 2,
+	OPAL_MPIPL_TAG_BOOT_MEM	= 3,
+};
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __OPAL_API_H */