From patchwork Thu Jan 14 15:51:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 8033831 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4C25D9F744 for ; Thu, 14 Jan 2016 15:51:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7D2B220457 for ; Thu, 14 Jan 2016 15:51:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 90A5E20416 for ; Thu, 14 Jan 2016 15:51:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 08B8B7A0B4; Thu, 14 Jan 2016 07:51:49 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id 590F67A0B5 for ; Thu, 14 Jan 2016 07:51:46 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP; 14 Jan 2016 07:51:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,295,1449561600"; d="scan'208";a="893187815" Received: from jnikula-mobl.fi.intel.com (HELO localhost) ([10.237.72.67]) by fmsmga002.fm.intel.com with ESMTP; 14 Jan 2016 07:51:44 -0800 From: Jani Nikula To: intel-gfx@lists.freedesktop.org Date: Thu, 14 Jan 2016 17:51:30 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Cc: jani.nikula@intel.com Subject: [Intel-gfx] [i-g-t PATCH 6/6] intel_bios_reader: dump MIPI sequence block v3 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Jani Nikula --- tools/intel_bios_reader.c | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c index 944ad5315f3a..d73ff5b32e35 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,9 @@ 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++) + dump_sequence(sequence_ptrs[i], sequence->version); } static int