[msm] factor out debug code into shared area, make configurable

The defines WITH_DEBUG_DCC, WITH_DEBUG_UART, and WITH_DEBUG_FBCON
are used to determine where dputc output goes.  Duplicated code
merged to msm_shared.  Configuration added to project files.
diff --git a/platform/msm7k/rules.mk b/platform/msm7k/rules.mk
index 5c96a32..0523c4a 100644
--- a/platform/msm7k/rules.mk
+++ b/platform/msm7k/rules.mk
@@ -12,8 +12,7 @@
 	$(LOCAL_DIR)/platform.o \
 	$(LOCAL_DIR)/interrupts.o \
 	$(LOCAL_DIR)/mddi.o \
-	$(LOCAL_DIR)/gpio.o \
-	$(LOCAL_DIR)/debug.o
+	$(LOCAL_DIR)/gpio.o 
 
 LINKER_SCRIPT += $(BUILDDIR)/system-onesegment.ld
 
diff --git a/platform/msm7k/debug.c b/platform/msm_shared/debug.c
similarity index 87%
rename from platform/msm7k/debug.c
rename to platform/msm_shared/debug.c
index c0e4d0c..ebe7361 100644
--- a/platform/msm7k/debug.c
+++ b/platform/msm_shared/debug.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Google Inc.
+ * Copyright (c) 2009, Google Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -35,22 +35,18 @@
 #include <dev/fbcon.h>
 #include <dev/uart.h>
 
-#define DCC_DEBUG 1
-#define DEBUG_UART 3
-#define FBCON_DEBUG 1
-
 void _dputc(char c)
 {
-#if DCC_DEBUG
+#if WITH_DEBUG_DCC
 	if (c == '\n') {
 		while (dcc_putc('\r') < 0);
 	}
 	while (dcc_putc(c) < 0);
-#else
-	uart_putc(DEBUG_UART, c);
 #endif
-
-#if FBCON_DEBUG && WITH_DEV_FBCON
+#if WITH_DEBUG_UART
+	uart_putc(0, c);
+#endif
+#if WITH_DEBUG_FBCON && WITH_DEV_FBCON
 	fbcon_putc(c);
 #endif
 }
@@ -58,10 +54,12 @@
 int dgetc(char *c)
 {
 	int n;
-#if DCC_DEBUG
+#if WITH_DEBUG_DCC
 	n = dcc_getc();
+#elif WITH_DEBUG_UART
+	n = uart_getc(0, 0);
 #else
-	n = uart_getc(DEBUG_UART, 0);
+	n = -1;
 #endif
 	if (n < 0) {
 		return -1;
@@ -77,7 +75,3 @@
 	for(;;);
 }
 
-uint32_t debug_cycle_count(void)
-{
-	return 0;
-}
diff --git a/platform/msm_shared/rules.mk b/platform/msm_shared/rules.mk
index dc706bb..c0de0b4 100644
--- a/platform/msm_shared/rules.mk
+++ b/platform/msm_shared/rules.mk
@@ -4,6 +4,7 @@
 	$(LOCAL_DIR)/uart.o \
 	$(LOCAL_DIR)/timer.o \
 	$(LOCAL_DIR)/proc_comm.o \
+	$(LOCAL_DIR)/debug.o \
 	$(LOCAL_DIR)/smem.o \
 	$(LOCAL_DIR)/smem_ptable.o \
 	$(LOCAL_DIR)/hsusb.o \
diff --git a/platform/qsd8k/debug.c b/platform/qsd8k/debug.c
deleted file mode 100644
index 9d64ffc..0000000
--- a/platform/qsd8k/debug.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *  * Neither the name of Google, Inc. nor the names of its contributors
- *    may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <debug.h>
-#include <printf.h>
-#include <arch/arm/dcc.h>
-#include <dev/fbcon.h>
-#include <dev/uart.h>
-
-#ifndef WITH_DEBUG_UART3
-#define WITH_DEBUG_UART3 1
-#define DEBUG_UART 2
-#endif
-
-#ifndef WITH_DEBUG_DCC
-#define WITH_DEBUG_DCC 0
-#endif
-
-void _dputc(char c)
-{
-#if WITH_DEBUG_DCC
-	if (c == '\n') {
-		while (dcc_putc('\r') < 0);
-	}
-	while (dcc_putc(c) < 0);
-#endif
-#if WITH_DEBUG_UART3
-	uart_putc(DEBUG_UART, c);
-#endif
-#if WITH_DEV_FBCON
-	fbcon_putc(c);
-#endif
-}
-
-int dgetc(char *c)
-{
-	int n;
-#if WITH_DEBUG_DCC
-	n = dcc_getc();
-#elif WITH_DEBUG_UART3
-	n = uart_getc(DEBUG_UART, 0);
-#else
-	n = -1;
-#endif
-	if (n < 0) {
-		return -1;
-	} else {
-		*c = n;
-		return 0;
-	}
-}
-
-void platform_halt(void)
-{
-	dprintf(INFO, "HALT: spinning forever...\n");
-	for(;;);
-}
-
-uint32_t debug_cycle_count(void)
-{
-	return 0;
-}
diff --git a/platform/qsd8k/rules.mk b/platform/qsd8k/rules.mk
index 7d893f0..93d80c8 100644
--- a/platform/qsd8k/rules.mk
+++ b/platform/qsd8k/rules.mk
@@ -16,7 +16,6 @@
 	$(LOCAL_DIR)/arch_init.o \
 	$(LOCAL_DIR)/platform.o \
 	$(LOCAL_DIR)/interrupts.o \
-	$(LOCAL_DIR)/debug.o \
 	$(LOCAL_DIR)/gpio.o \
 	$(LOCAL_DIR)/lcdc.o
 
diff --git a/project/aboot-surf7k.mk b/project/aboot-surf7k.mk
index a1f748c..70750dc 100644
--- a/project/aboot-surf7k.mk
+++ b/project/aboot-surf7k.mk
@@ -1,4 +1,4 @@
-# top level project rules for the armemu-test project
+# top level project rules for the aboot-surf7k project
 #
 LOCAL_DIR := $(GET_LOCAL_DIR)
 
@@ -6,3 +6,6 @@
 
 MODULES += app/aboot
 
+#DEFINES += WITH_DEBUG_DCC=1
+DEFINES += WITH_DEBUG_UART=1
+DEFINES += WITH_DEBUG_FBCON=1
\ No newline at end of file
diff --git a/project/aboot-surf8k.mk b/project/aboot-surf8k.mk
index 9ee9181..7f52726 100644
--- a/project/aboot-surf8k.mk
+++ b/project/aboot-surf8k.mk
@@ -1,4 +1,4 @@
-# top level project rules for the armemu-test project
+# top level project rules for the aboot-surf8k project
 #
 LOCAL_DIR := $(GET_LOCAL_DIR)
 
@@ -6,3 +6,6 @@
 
 MODULES += app/aboot
 
+#DEFINES += WITH_DEBUG_DCC=1
+DEFINES += WITH_DEBUG_UART=1
+DEFINES += WITH_DEBUG_FBCON=1