bios_emulator: Add an option to enable debugging

At present there are DEBUG options spread around the place. If you enable
one and not another you can end up with an emulator that does not work,
since each file can have a different view of what the registers look like.
To fix this, create a global CONFIG_X86EMU_DEBUG option that keeps
everything consistent.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/drivers/bios_emulator/x86emu/debug.c b/drivers/bios_emulator/x86emu/debug.c
index 2ec64c2..27e90e4 100644
--- a/drivers/bios_emulator/x86emu/debug.c
+++ b/drivers/bios_emulator/x86emu/debug.c
@@ -44,7 +44,7 @@
 
 /*----------------------------- Implementation ----------------------------*/
 
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
 
 static void print_encoded_bytes(u16 s, u16 o);
 static void print_decoded_instruction(void);
diff --git a/drivers/bios_emulator/x86emu/decode.c b/drivers/bios_emulator/x86emu/decode.c
index a782b81..da44c3d 100644
--- a/drivers/bios_emulator/x86emu/decode.c
+++ b/drivers/bios_emulator/x86emu/decode.c
@@ -303,7 +303,7 @@
 u8 fetch_data_byte(
     uint offset)
 {
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (CHECK_DATA_ACCESS())
 	x86emu_check_data_access((u16)get_data_segment(), offset);
 #endif
@@ -322,7 +322,7 @@
 u16 fetch_data_word(
     uint offset)
 {
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (CHECK_DATA_ACCESS())
 	x86emu_check_data_access((u16)get_data_segment(), offset);
 #endif
@@ -341,7 +341,7 @@
 u32 fetch_data_long(
     uint offset)
 {
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (CHECK_DATA_ACCESS())
 	x86emu_check_data_access((u16)get_data_segment(), offset);
 #endif
@@ -362,7 +362,7 @@
     uint segment,
     uint offset)
 {
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (CHECK_DATA_ACCESS())
 	x86emu_check_data_access(segment, offset);
 #endif
@@ -383,7 +383,7 @@
     uint segment,
     uint offset)
 {
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (CHECK_DATA_ACCESS())
 	x86emu_check_data_access(segment, offset);
 #endif
@@ -404,7 +404,7 @@
     uint segment,
     uint offset)
 {
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (CHECK_DATA_ACCESS())
 	x86emu_check_data_access(segment, offset);
 #endif
@@ -426,7 +426,7 @@
     uint offset,
     u8 val)
 {
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (CHECK_DATA_ACCESS())
 	x86emu_check_data_access((u16)get_data_segment(), offset);
 #endif
@@ -448,7 +448,7 @@
     uint offset,
     u16 val)
 {
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (CHECK_DATA_ACCESS())
 	x86emu_check_data_access((u16)get_data_segment(), offset);
 #endif
@@ -470,7 +470,7 @@
     uint offset,
     u32 val)
 {
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (CHECK_DATA_ACCESS())
 	x86emu_check_data_access((u16)get_data_segment(), offset);
 #endif
@@ -493,7 +493,7 @@
     uint offset,
     u8 val)
 {
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (CHECK_DATA_ACCESS())
 	x86emu_check_data_access(segment, offset);
 #endif
@@ -516,7 +516,7 @@
     uint offset,
     u16 val)
 {
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (CHECK_DATA_ACCESS())
 	x86emu_check_data_access(segment, offset);
 #endif
@@ -539,7 +539,7 @@
     uint offset,
     u32 val)
 {
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (CHECK_DATA_ACCESS())
 	x86emu_check_data_access(segment, offset);
 #endif
diff --git a/drivers/bios_emulator/x86emu/ops.c b/drivers/bios_emulator/x86emu/ops.c
index f8e093d..c853260 100644
--- a/drivers/bios_emulator/x86emu/ops.c
+++ b/drivers/bios_emulator/x86emu/ops.c
@@ -79,7 +79,7 @@
 
 /* constant arrays to do several instructions in just one function */
 
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
 static char *x86emu_GenOpName[8] = {
     "ADD", "OR", "ADC", "SBB", "AND", "SUB", "XOR", "CMP"};
 #endif
@@ -160,7 +160,7 @@
     sar_long,
 };
 
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
 
 static char *opF6_names[8] =
   { "TEST\t", "", "NOT\t", "NEG\t", "MUL\t", "IMUL\t", "DIV\t", "IDIV\t" };
@@ -1281,7 +1281,7 @@
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
 	/* XXX DECODE_PRINTF may be changed to something more
 	   general, so that it is important to leave the strings
@@ -1359,7 +1359,7 @@
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
 	/* XXX DECODE_PRINTF may be changed to something more
 	   general, so that it is important to leave the strings
@@ -1475,7 +1475,7 @@
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
 	/* XXX DECODE_PRINTF may be changed to something more
 	   general, so that it is important to leave the strings
@@ -1551,7 +1551,7 @@
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
 	/* XXX DECODE_PRINTF may be changed to something more
 	   general, so that it is important to leave the strings
@@ -3083,7 +3083,7 @@
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
 	/* XXX DECODE_PRINTF may be changed to something more
 	   general, so that it is important to leave the strings
@@ -3158,7 +3158,7 @@
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
 	/* XXX DECODE_PRINTF may be changed to something more
 	   general, so that it is important to leave the strings
@@ -3630,7 +3630,7 @@
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
 	/* XXX DECODE_PRINTF may be changed to something more
 	   general, so that it is important to leave the strings
@@ -3701,7 +3701,7 @@
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
 	/* XXX DECODE_PRINTF may be changed to something more
 	   general, so that it is important to leave the strings
@@ -3803,7 +3803,7 @@
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
 	/* XXX DECODE_PRINTF may be changed to something more
 	   general, so that it is important to leave the strings
@@ -3876,7 +3876,7 @@
      */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
 	/* XXX DECODE_PRINTF may be changed to something more
 	   general, so that it is important to leave the strings
@@ -4859,7 +4859,7 @@
     /* Yet another special case instruction. */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
 	/* XXX DECODE_PRINTF may be changed to something more
 	   general, so that it is important to leave the strings
@@ -4923,7 +4923,7 @@
     /* Yet another special case instruction. */
     START_OF_INSTR();
     FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
+#ifdef CONFIG_X86EMU_DEBUG
     if (DEBUG_DECODE()) {
 	/* XXX DECODE_PRINTF may be changed to something more
 	   general, so that it is important to leave the strings