>From af8508a8e97d3bb5d3be087ba8e8d31262d1d14e Mon Sep 17 00:00:00 2001
From: Tadas Slotkus <devtadas@gmail.com>
Date: Sun, 21 Aug 2011 13:42:42 +0300
Subject: [carFl mem 54/65] Move dmi and force_board... vars to globals

Now in globals struct:
int has_dmi_support;
int force_boardenable;
int force_boardmismatch;

Signed-off-by: Tadas Slotkus <devtadas@gmail.com>
---
 board_enable.c |    4 ++--
 dmi.c          |    8 +++-----
 flash.h        |    3 +++
 flashrom.c     |    3 +++
 internal.c     |    6 ++----
 layout.c       |    2 +-
 programmer.h   |    3 ---
 7 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/board_enable.c b/board_enable.c
index cc39964..7241675 100644
--- a/board_enable.c
+++ b/board_enable.c
@@ -2183,7 +2183,7 @@ const static struct board_pciid_enable *board_match_pci_card_ids(globals *g,
 		}
 
 		if (board->dmi_pattern) {
-			if (!has_dmi_support) {
+			if (!g->has_dmi_support) {
 				msg_perr("WARNING: Can't autodetect %s %s,"
 					 " DMI info unavailable.\n",
 					 board->vendor_name, board->board_name);
@@ -2208,7 +2208,7 @@ static int unsafe_board_handler(globals *g, const struct board_pciid_enable *boa
 	if (board->status == OK)
 		return 0;
 
-	if (!force_boardenable) {
+	if (!g->force_boardenable) {
 		msg_pinfo("WARNING: Your mainboard is %s %s, but the mainboard-specific\n"
 			  "code has not been tested, and thus will not be executed by default.\n"
 			  "Depending on your hardware environment, erasing, writing or even probing\n"
diff --git a/dmi.c b/dmi.c
index a75a4d9..7ec48a2 100644
--- a/dmi.c
+++ b/dmi.c
@@ -25,8 +25,6 @@
 #include "flash.h"
 #include "programmer.h"
 
-int has_dmi_support = 0;
-
 #if STANDALONE
 
 /* Stub to indicate missing DMI functionality.
@@ -151,11 +149,11 @@ void dmi_init(globals *g)
 	int i;
 	char *chassis_type;
 
-	has_dmi_support = 1;
+	g->has_dmi_support = 1;
 	for (i = 0; i < ARRAY_SIZE(dmidecode_names); i++) {
 		dmistrings[i] = get_dmi_string(dmidecode_names[i]);
 		if (!dmistrings[i]) {
-			has_dmi_support = 0;
+			g->has_dmi_support = 0;
 			return;
 		}
 	}
@@ -234,7 +232,7 @@ int dmi_match(globals *g, const char *pattern)
 {
 	int i;
 
-	if (!has_dmi_support)
+	if (!g->has_dmi_support)
 		return 0;
 
 	for (i = 0; i < ARRAY_SIZE(dmidecode_names); i++)
diff --git a/flash.h b/flash.h
index 6901288..54fb60d 100644
--- a/flash.h
+++ b/flash.h
@@ -302,6 +302,9 @@ struct globals {
 	int partvendor_from_cbtable;
 	int is_laptop;
 	int laptop_ok;
+	int force_boardenable;
+	int force_boardmismatch;
+	int has_dmi_support;
 };
 void init_globals(globals *g);
 
diff --git a/flashrom.c b/flashrom.c
index 924ecf8..2bbec8a 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -57,6 +57,9 @@ void init_globals(globals *g)
 	g->partvendor_from_cbtable = 0;
 	g->is_laptop = 0;
 	g->laptop_ok = 0;
+	g->force_boardenable = 0;
+	g->force_boardmismatch = 0;
+	g->has_dmi_support = 0;
 }
 
 static char *programmer_param = NULL;
diff --git a/internal.c b/internal.c
index e35e96f..94b9d0b 100644
--- a/internal.c
+++ b/internal.c
@@ -95,8 +95,6 @@ struct pci_dev *pci_card_find(globals *g, uint16_t vendor, uint16_t device,
 #endif
 
 #if CONFIG_INTERNAL == 1
-int force_boardenable = 0;
-int force_boardmismatch = 0;
 
 #if defined(__i386__) || defined(__x86_64__)
 void probe_superio(globals *g)
@@ -140,7 +138,7 @@ int internal_init(globals *g)
 
 	arg = extract_programmer_param(g, "boardenable");
 	if (arg && !strcmp(arg,"force")) {
-		force_boardenable = 1;
+		g->force_boardenable = 1;
 	} else if (arg && !strlen(arg)) {
 		msg_perr("Missing argument for boardenable.\n");
 //		free(arg);
@@ -154,7 +152,7 @@ int internal_init(globals *g)
 
 	arg = extract_programmer_param(g, "boardmismatch");
 	if (arg && !strcmp(arg,"force")) {
-		force_boardmismatch = 1;
+		g->force_boardmismatch = 1;
 	} else if (arg && !strlen(arg)) {
 		msg_perr("Missing argument for boardmismatch.\n");
 //		free(arg);
diff --git a/layout.c b/layout.c
index b481f04..05ff01c 100644
--- a/layout.c
+++ b/layout.c
@@ -115,7 +115,7 @@ int show_id(globals *g, uint8_t *bios, int size, int force)
 	    !strcasecmp(mainboard_part, g->lb_part)) {
 		msg_pdbg("This firmware image matches this mainboard.\n");
 	} else {
-		if (force_boardmismatch) {
+		if (g->force_boardmismatch) {
 			msg_pinfo("WARNING: This firmware image does not "
 			       "seem to fit to this machine - forcing it.\n");
 		} else {
diff --git a/programmer.h b/programmer.h
index 2fa8ee4..8c6b8df 100644
--- a/programmer.h
+++ b/programmer.h
@@ -209,7 +209,6 @@ void lb_vendor_dev_from_string(globals *g, char *boardstring);
 int coreboot_init(globals *g);
 
 /* dmi.c */
-extern int has_dmi_support;
 void dmi_init(globals *g);
 int dmi_match(globals *g, const char *pattern);
 
@@ -234,8 +233,6 @@ struct pci_dev *pci_card_find(globals *g, uint16_t vendor, uint16_t device,
 void get_io_perms(void);
 void release_io_perms(void);
 #if CONFIG_INTERNAL == 1
-extern int force_boardenable;
-extern int force_boardmismatch;
 void probe_superio(globals *g);
 int register_superio(globals *g, struct superio s);
 int internal_init(globals *g);
-- 
1.7.6

