All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: Jani Nikula <jani.nikula@intel.com>, intel-gfx@lists.freedesktop.org
Subject: [PATCH v2 6/6] intel_bios_reader: dump MIPI sequence block v3
Date: Thu, 14 Jan 2016 17:57:26 +0200	[thread overview]
Message-ID: <1452787046-7660-1-git-send-email-jani.nikula@intel.com> (raw)
In-Reply-To: <d06384ea7641c7fb607e27b8ec601147da2530f7.1452786403.git.jani.nikula@intel.com>

Similar to what's done in kernel. It's a bit artificial that the parsing
and dumping are two separate steps in the userspace tool, but it's
easier to follow and debug the code when both the kernel and userspace
are similar.

v2: don't segfault so much on dumping null pointers

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_bios_reader.c | 47 +++++++++++++++++++++++------------------------
 1 file changed, 23 insertions(+), 24 deletions(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index 944ad5315f3a..4cfd30afbb46 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -973,7 +973,7 @@ static const char *sequence_name(enum mipi_seq seq_id)
 		return "(unknown)";
 }
 
-static const uint8_t *dump_sequence(const uint8_t *data)
+static const uint8_t *dump_sequence(const uint8_t *data, uint8_t seq_version)
 {
 	fn_mipi_elem_dump mipi_elem_dump;
 
@@ -982,21 +982,33 @@ static const uint8_t *dump_sequence(const uint8_t *data)
 	/* Skip Sequence Byte. */
 	data++;
 
+	/* Skip Size of Sequence. */
+	if (seq_version >= 3)
+		data += 4;
+
 	while (1) {
 		uint8_t operation_byte = *data++;
+		uint8_t operation_size = 0;
 
 		if (operation_byte == MIPI_SEQ_ELEM_END)
 			break;
 
-		if (operation_byte < ARRAY_SIZE(dump_elem) &&
-		    dump_elem[operation_byte])
+		if (operation_byte < ARRAY_SIZE(dump_elem))
 			mipi_elem_dump = dump_elem[operation_byte];
 		else
 			mipi_elem_dump = NULL;
 
+		/* Size of Operation. */
+		if (seq_version >= 3)
+			operation_size = *data++;
+
 		if (mipi_elem_dump) {
 			data = mipi_elem_dump(data);
+		} else if (operation_size) {
+			/* We have size, skip. */
+			data += operation_size;
 		} else {
+			/* No size, can't skip without parsing. */
 			printf("Error: Unsupported MIPI element %u\n",
 			       operation_byte);
 			return NULL;
@@ -1167,7 +1179,8 @@ static void dump_mipi_sequence(const struct bdb_header *bdb,
 	const struct bdb_mipi_sequence *sequence = block->data;
 	const uint8_t *data;
 	uint32_t seq_size;
-	int index = 0;
+	int index = 0, i;
+	const uint8_t *sequence_ptrs[MIPI_SEQ_MAX] = {};
 
 	/* Check if we have sequence block as well */
 	if (!sequence) {
@@ -1200,6 +1213,8 @@ static void dump_mipi_sequence(const struct bdb_header *bdb,
 			return;
 		}
 
+		sequence_ptrs[seq_id] = data + index;
+
 		if (sequence->version >= 3)
 			index = goto_next_sequence_v3(data, index, seq_size);
 		else
@@ -1210,26 +1225,10 @@ static void dump_mipi_sequence(const struct bdb_header *bdb,
 		}
 	}
 
-	if (sequence->version >= 3) {
-		fprintf(stderr, "Unable to dump MIPI Sequence Block v%u\n",
-			sequence->version);
-		return;
-	}
-
-	/*
-	 * loop into the sequence data and split into multiple sequneces
-	 * There are only 5 types of sequences as of now
-	 */
-
-        while (1) {
-		int seq_id = *data;
-		if (seq_id == MIPI_SEQ_END)
-			break;
-
-		data = dump_sequence(data);
-		if (!data)
-			break;
-	}
+	/* Dump the sequences. Corresponds to sequence execution in kernel. */
+	for (i = 0; i < ARRAY_SIZE(sequence_ptrs); i++)
+		if (sequence_ptrs[i])
+			dump_sequence(sequence_ptrs[i], sequence->version);
 }
 
 static int
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2016-01-14 15:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-14 15:51 [i-g-t PATCH 0/6] intel_bios_reader: support MIPI sequence block v3 Jani Nikula
2016-01-14 15:51 ` [i-g-t PATCH 1/6] intel_bios_reader: pass bdb pointer around instead of having as global Jani Nikula
2016-01-14 15:51 ` [i-g-t PATCH 2/6] intel_bios_reader: fix size handling for 32-bit block size Jani Nikula
2016-01-14 15:51 ` [i-g-t PATCH 3/6] intel_bios_reader: make the VBT pointers more const Jani Nikula
2016-01-14 15:51 ` [i-g-t PATCH 4/6] intel_bios_reader: port find_panel_sequence_block from kernel Jani Nikula
2016-01-14 15:51 ` [i-g-t PATCH 5/6] intel_bios_reader: port the sequence block parsing " Jani Nikula
2016-01-14 15:51 ` [i-g-t PATCH 6/6] intel_bios_reader: dump MIPI sequence block v3 Jani Nikula
2016-01-14 15:57   ` Jani Nikula [this message]
2016-01-15 13:26 ` [i-g-t PATCH 0/6] intel_bios_reader: support " Jani Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1452787046-7660-1-git-send-email-jani.nikula@intel.com \
    --to=jani.nikula@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.