[msm] fix dumb bugs in uart.c and debug.c
This gets the serial console working, provided the UART is initialized
when lk starts. UART initialization still needs some love.
diff --git a/platform/msm7k/debug.c b/platform/msm7k/debug.c
index 312d7f6..e991414 100644
--- a/platform/msm7k/debug.c
+++ b/platform/msm7k/debug.c
@@ -35,6 +35,7 @@
#include <dev/uart.h>
#define DCC_DEBUG 0
+#define DEBUG_UART 3
void _dputc(char c)
{
@@ -44,23 +45,24 @@
}
while (dcc_putc(c) < 0);
#else
- uart_putc(0, c);
+ uart_putc(DEBUG_UART, c);
#endif
}
int dgetc(char *c)
{
+ int n;
#if DCC_DEBUG
- int n = dcc_getc();
+ n = dcc_getc();
+#else
+ n = uart_getc(DEBUG_UART, 0);
+#endif
if (n < 0) {
return -1;
} else {
*c = n;
return 0;
}
-#else
- return uart_getc(0, 1);
-#endif
}
void platform_halt(void)
@@ -71,5 +73,5 @@
uint32_t debug_cycle_count(void)
{
- return 0;
+ return 0;
}
diff --git a/platform/msm_shared/uart.c b/platform/msm_shared/uart.c
index 8fc92bc..40b9dc9 100644
--- a/platform/msm_shared/uart.c
+++ b/platform/msm_shared/uart.c
@@ -29,6 +29,8 @@
* SUCH DAMAGE.
*/
+#include <debug.h>
+
#include <platform/iomap.h>
#include <dev/uart.h>
#include <reg.h>
@@ -177,11 +179,9 @@
int uart_getc(int port, bool wait)
{
- for (;;) {
- while (!(urd(UART_SR) & UART_SR_RX_READY)) ;
+ while (!(urd(UART_SR) & UART_SR_RX_READY))
if (!wait)
return -1;
- }
return urd(UART_RF);
}
diff --git a/platform/qsd8k/debug.c b/platform/qsd8k/debug.c
index 296f7ec..01ea628 100644
--- a/platform/qsd8k/debug.c
+++ b/platform/qsd8k/debug.c
@@ -35,7 +35,7 @@
#include <dev/uart.h>
#define DCC_DEBUG 1
-#define DEBUG_UART 2
+#define DEBUG_UART 3
void _dputc(char c)
{
@@ -51,17 +51,18 @@
int dgetc(char *c)
{
+ int n;
#if DCC_DEBUG
- int n = dcc_getc();
+ n = dcc_getc();
+#else
+ n = uart_getc(DEBUG_UART, 0);
+#endif
if (n < 0) {
return -1;
} else {
*c = n;
return 0;
}
-#else
- return uart_getc(DEBUG_UART, 1);
-#endif
}
void platform_halt(void)
@@ -72,5 +73,5 @@
uint32_t debug_cycle_count(void)
{
- return 0;
+ return 0;
}