[RFC LINUX PATCH 08/19] remoteproc: add a function to set fw checksum rsc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Wendy Liang <wendy.liang@xxxxxxxxxx>

Add a function to set the firmware checksum resource.
The function will call the firmware loader to calculate
the firmware checksum and set it to the resource table.

Signed-off-by: Wendy Liang <jliang@xxxxxxxxxx>
Signed-off-by: Michal Simek <michal.simek@xxxxxxxxxx>
---
 drivers/remoteproc/remoteproc_core.c | 54 ++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index f13f56d..447c28b 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -897,6 +897,60 @@ static bool rproc_is_running(struct rproc *rproc)
 	return (rproc->state == RPROC_RUNNING) ? true : false;
 }
 
+/**
+ * rproc_handle_fw_chksum() - handle firmware checksum resource
+ * @rproc: rproc handle
+ * @fw: firmware
+ * @offset: returns fw_chksum resource offset.
+ *
+ * This function will handle request to set the firmware checksum.
+ */
+static
+struct fw_rsc_fw_chksum *rproc_handle_fw_chksum(struct rproc *rproc,
+				const struct firmware *fw, int *offset)
+{
+	struct fw_rsc_fw_chksum *rsc = NULL;
+	int i, tablesz;
+	struct device *dev = &rproc->dev;
+	struct resource_table *table;
+
+	/* look for the resource table */
+	table = rproc_find_rsc_table(rproc, fw, &tablesz);
+	if (!table) {
+		dev_err(dev, "Failed to find resource table\n");
+		return NULL;
+	}
+
+	for (i = 0; i < rproc->table_ptr->num; i++) {
+		int ret = 0;
+		int tmpoffset = rproc->table_ptr->offset[i];
+		struct fw_rsc_hdr *hdr = (void *)rproc->table_ptr + tmpoffset;
+		int avail = tablesz - tmpoffset - sizeof(*hdr);
+
+		if (hdr->type != RSC_FW_CHKSUM)
+			continue;
+
+		rsc = (struct fw_rsc_fw_chksum *)((void *)hdr + sizeof(*hdr));
+		if (sizeof(*rsc) > avail) {
+			dev_err(dev, "firmware checksum rsc is truncated\n");
+			return NULL;
+		}
+		if (rproc->fw_ops->get_chksum) {
+			ret = rproc->fw_ops->get_chksum(rproc, fw,
+				rsc->algo, rsc->chksum, sizeof(rsc->chksum));
+			if (ret) {
+				dev_err(dev,
+					"failed to get firmware chksum.\n");
+				return NULL;
+			}
+		}
+		*offset = tmpoffset + sizeof(*hdr);
+		return rsc;
+	}
+
+	return NULL;
+}
+
 /*
  * check if the remote needs start.
  */
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-remoteproc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux