[Intel-gfx] [i-g-t PATCH 1/6] intel_bios_reader: pass bdb pointer around instead of having as global

Jani Nikula jani.nikula at intel.com
Thu Jan 14 07:51:25 PST 2016


Signed-off-by: Jani Nikula <jani.nikula at intel.com>
---
 tools/intel_bios_reader.c | 88 ++++++++++++++++++++++++++++-------------------
 1 file changed, 52 insertions(+), 36 deletions(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index b31f648f0607..7b525f220f16 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -71,13 +71,13 @@ struct bdb_block {
 	void *data;
 };
 
-struct bdb_header *bdb;
 struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs;
 static int tv_present;
 static int lvds_present;
 static int panel_type;
 
-static struct bdb_block *find_section(int section_id, int length)
+static struct bdb_block *find_section(const struct bdb_header *bdb,
+				      int section_id, int length)
 {
 	struct bdb_block *block;
 	unsigned char *base = (unsigned char *)bdb;
@@ -118,7 +118,8 @@ static struct bdb_block *find_section(int section_id, int length)
 	return NULL;
 }
 
-static void dump_general_features(const struct bdb_block *block)
+static void dump_general_features(const struct bdb_header *bdb,
+				  const struct bdb_block *block)
 {
 	struct bdb_general_features *features = block->data;
 
@@ -170,7 +171,8 @@ static void dump_general_features(const struct bdb_block *block)
 	lvds_present = 1;	/* should be based on IS_MOBILE() */
 }
 
-static void dump_backlight_info(const struct bdb_block *block)
+static void dump_backlight_info(const struct bdb_header *bdb,
+				const struct bdb_block *block)
 {
 	struct bdb_lvds_backlight *backlight = block->data;
 	struct blc_struct *blc;
@@ -352,7 +354,8 @@ static const char *efp_conn(uint8_t type)
 
 
 
-static void dump_child_device(struct child_device_config *child)
+static void dump_child_device(const struct bdb_header *bdb,
+			      struct child_device_config *child)
 {
 	char child_id[11];
 
@@ -390,7 +393,8 @@ static void dump_child_device(struct child_device_config *child)
 	}
 }
 
-static void dump_general_definitions(const struct bdb_block *block)
+static void dump_general_definitions(const struct bdb_header *bdb,
+				     const struct bdb_block *block)
 {
 	struct bdb_general_definitions *defs = block->data;
 	int i;
@@ -409,10 +413,11 @@ static void dump_general_definitions(const struct bdb_block *block)
 	child_device_num = (block->size - sizeof(*defs)) /
 		defs->child_dev_size;
 	for (i = 0; i < child_device_num; i++)
-		dump_child_device((void*)&defs->devices[i * defs->child_dev_size]);
+		dump_child_device(bdb,(void*)&defs->devices[i * defs->child_dev_size]);
 }
 
-static void dump_child_devices(const struct bdb_block *block)
+static void dump_child_devices(const struct bdb_header *bdb,
+			       const struct bdb_block *block)
 {
 	struct bdb_child_devices *child_devs = block->data;
 	struct child_device_config *child;
@@ -435,7 +440,8 @@ static void dump_child_devices(const struct bdb_block *block)
 	}
 }
 
-static void dump_lvds_options(const struct bdb_block *block)
+static void dump_lvds_options(const struct bdb_header *bdb,
+			      const struct bdb_block *block)
 {
 	struct bdb_lvds_options *options = block->data;
 
@@ -451,7 +457,8 @@ static void dump_lvds_options(const struct bdb_block *block)
 	printf("\tPFIT mode: %d\n", options->pfit_mode);
 }
 
-static void dump_lvds_ptr_data(const struct bdb_block *block)
+static void dump_lvds_ptr_data(const struct bdb_header *bdb,
+			       const struct bdb_block *block)
 {
 	struct bdb_lvds_lfp_data_ptrs *ptrs = block->data;
 
@@ -461,7 +468,8 @@ static void dump_lvds_ptr_data(const struct bdb_block *block)
 	lvds_lfp_data_ptrs = ptrs;
 }
 
-static void dump_lvds_data(const struct bdb_block *block)
+static void dump_lvds_data(const struct bdb_header *bdb,
+			   const struct bdb_block *block)
 {
 	struct bdb_lvds_lfp_data *lvds_data = block->data;
 	struct bdb_lvds_lfp_data_ptrs *ptrs = lvds_lfp_data_ptrs;
@@ -533,7 +541,8 @@ static void dump_lvds_data(const struct bdb_block *block)
 	}
 }
 
-static void dump_driver_feature(const struct bdb_block *block)
+static void dump_driver_feature(const struct bdb_header *bdb,
+				const struct bdb_block *block)
 {
 	struct bdb_driver_feature *feature = block->data;
 
@@ -599,7 +608,8 @@ static void dump_driver_feature(const struct bdb_block *block)
 	       feature->legacy_crt_max_refresh);
 }
 
-static void dump_edp(const struct bdb_block *block)
+static void dump_edp(const struct bdb_header *bdb,
+		     const struct bdb_block *block)
 {
 	struct bdb_edp *edp = block->data;
 	int bpp, msa;
@@ -728,7 +738,8 @@ print_detail_timing_data(struct lvds_dvo_timing2 *dvo_timing)
 	printf("\tclock: %d\n", dvo_timing->clock * 10);
 }
 
-static void dump_sdvo_panel_dtds(const struct bdb_block *block)
+static void dump_sdvo_panel_dtds(const struct bdb_header *bdb,
+				 const struct bdb_block *block)
 {
 	struct lvds_dvo_timing2 *dvo_timing = block->data;
 	int n, count;
@@ -740,7 +751,8 @@ static void dump_sdvo_panel_dtds(const struct bdb_block *block)
 	}
 }
 
-static void dump_sdvo_lvds_options(const struct bdb_block *block)
+static void dump_sdvo_lvds_options(const struct bdb_header *bdb,
+				   const struct bdb_block *block)
 {
 	struct bdb_sdvo_lvds_options *options = block->data;
 
@@ -761,7 +773,8 @@ static void dump_sdvo_lvds_options(const struct bdb_block *block)
 	printf("\tmisc[3]: %x\n", options->panel_misc_bits_4);
 }
 
-static void dump_mipi_config(const struct bdb_block *block)
+static void dump_mipi_config(const struct bdb_header *bdb,
+			     const struct bdb_block *block)
 {
 	struct bdb_mipi_config *start = block->data;
 	struct mipi_config *config;
@@ -989,7 +1002,8 @@ static uint16_t get_blocksize(void *p)
 	return block_size;
 }
 
-static void dump_mipi_sequence(const struct bdb_block *block)
+static void dump_mipi_sequence(const struct bdb_header *bdb,
+			       const struct bdb_block *block)
 {
 	struct bdb_mipi_sequence *sequence = block->data;
 	const uint8_t *data;
@@ -1075,7 +1089,8 @@ get_device_id(unsigned char *bios, int size)
 struct dumper {
 	uint8_t id;
 	const char *name;
-	void (*dump)(const struct bdb_block *block);
+	void (*dump)(const struct bdb_header *bdb,
+		     const struct bdb_block *block);
 };
 
 struct dumper dumpers[] = {
@@ -1167,7 +1182,7 @@ static void hex_dump(const struct bdb_block *block)
 	printf("\n\n");
 }
 
-static void dump_section(int section_id, int size)
+static void dump_section(const struct bdb_header *bdb, int section_id, int size)
 {
 	struct dumper *dumper = NULL;
 	const struct bdb_block *block;
@@ -1178,7 +1193,7 @@ static void dump_section(int section_id, int size)
 		return;
 	done[section_id] = 1;
 
-	block = find_section(section_id, size);
+	block = find_section(bdb, section_id, size);
 	if (!block)
 		return;
 
@@ -1196,7 +1211,7 @@ static void dump_section(int section_id, int size)
 
 	hex_dump(block);
 	if (dumper && dumper->dump)
-		dumper->dump(block);
+		dumper->dump(bdb, block);
 	printf("\n");
 }
 
@@ -1209,6 +1224,7 @@ int main(int argc, char **argv)
 	struct stat finfo;
 	int size;
 	struct bdb_block *block;
+	struct bdb_header *bdb;
 	char signature[17];
 	char *devid_string;
 
@@ -1291,7 +1307,7 @@ int main(int argc, char **argv)
 	printf("Available sections: ");
 
 	for (i = 0; i < 256; i++) {
-		block = find_section(i, size);
+		block = find_section(bdb, i, size);
 		if (!block)
 			continue;
 		printf("%d ", i);
@@ -1304,24 +1320,24 @@ int main(int argc, char **argv)
 	if (devid == -1)
 	    printf("Warning: could not find PCI device ID!\n");
 
-	dump_section(BDB_GENERAL_FEATURES, size);
-	dump_section(BDB_GENERAL_DEFINITIONS, size);
-	dump_section(BDB_CHILD_DEVICE_TABLE, size);
-	dump_section(BDB_LVDS_OPTIONS, size);
-	dump_section(BDB_LVDS_LFP_DATA_PTRS, size);
-	dump_section(BDB_LVDS_LFP_DATA, size);
-	dump_section(BDB_LVDS_BACKLIGHT, size);
+	dump_section(bdb, BDB_GENERAL_FEATURES, size);
+	dump_section(bdb, BDB_GENERAL_DEFINITIONS, size);
+	dump_section(bdb, BDB_CHILD_DEVICE_TABLE, size);
+	dump_section(bdb, BDB_LVDS_OPTIONS, size);
+	dump_section(bdb, BDB_LVDS_LFP_DATA_PTRS, size);
+	dump_section(bdb, BDB_LVDS_LFP_DATA, size);
+	dump_section(bdb, BDB_LVDS_BACKLIGHT, size);
 
-	dump_section(BDB_SDVO_LVDS_OPTIONS, size);
-	dump_section(BDB_SDVO_PANEL_DTDS, size);
+	dump_section(bdb, BDB_SDVO_LVDS_OPTIONS, size);
+	dump_section(bdb, BDB_SDVO_PANEL_DTDS, size);
 
-	dump_section(BDB_DRIVER_FEATURES, size);
-	dump_section(BDB_EDP, size);
-	dump_section(BDB_MIPI_CONFIG, size);
-	dump_section(BDB_MIPI_SEQUENCE, size);
+	dump_section(bdb, BDB_DRIVER_FEATURES, size);
+	dump_section(bdb, BDB_EDP, size);
+	dump_section(bdb, BDB_MIPI_CONFIG, size);
+	dump_section(bdb, BDB_MIPI_SEQUENCE, size);
 
 	for (i = 0; i < 256; i++)
-		dump_section(i, size);
+		dump_section(bdb, i, size);
 
 	return 0;
 }
-- 
2.1.4



More information about the Intel-gfx mailing list