[PATCH 06/32] bsp/leon3: Cleaner namespace for LEON3 debug UART
Daniel Hellstrom
daniel at gaisler.com
Thu May 11 14:25:51 UTC 2017
From: Martin Aberg <maberg at gaisler.com>
Prefix BSP specific symbols with BSP name:
dbg_uart -> leon3_debug_uart
debug_uart_index -> leon3_debug_uart_index
---
.../libbsp/sparc/leon3/console/printk_support.c | 34 +++++++++++-----------
c/src/lib/libbsp/sparc/leon3/include/leon.h | 2 +-
c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c | 8 +++--
3 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/c/src/lib/libbsp/sparc/leon3/console/printk_support.c b/c/src/lib/libbsp/sparc/leon3/console/printk_support.c
index 27c2a72..f7e1fb6 100644
--- a/c/src/lib/libbsp/sparc/leon3/console/printk_support.c
+++ b/c/src/lib/libbsp/sparc/leon3/console/printk_support.c
@@ -25,8 +25,8 @@
#include <bsp/apbuart.h>
#include <bsp/apbuart_termios.h>
-int debug_uart_index __attribute__((weak)) = 0;
-struct apbuart_regs *dbg_uart = NULL;
+int leon3_debug_uart_index __attribute__((weak)) = 0;
+struct apbuart_regs *leon3_debug_uart = NULL;
/* Before UART driver has registered (or when no UART is available), calls to
* printk that gets to bsp_out_char() will be filling data into the
@@ -45,24 +45,24 @@ static void bsp_debug_uart_init(void)
struct ambapp_dev *adev;
struct ambapp_apb_info *apb;
- /* Update debug_uart_index to index used as debug console.
- * Let user select Debug console by setting debug_uart_index. If the
- * BSP is to provide the default UART (debug_uart_index==0):
+ /* Update leon3_debug_uart_index to index used as debug console. Let user
+ * select Debug console by setting leon3_debug_uart_index. If the BSP is to
+ * provide the default UART (leon3_debug_uart_index==0):
* non-MP: APBUART[0] is debug console
* MP: LEON CPU index select UART
*/
- if (debug_uart_index == 0) {
+ if (leon3_debug_uart_index == 0) {
#if defined(RTEMS_MULTIPROCESSING)
- debug_uart_index = LEON3_Cpu_Index;
+ leon3_debug_uart_index = LEON3_Cpu_Index;
#else
- debug_uart_index = 0;
+ leon3_debug_uart_index = 0;
#endif
} else {
- debug_uart_index = debug_uart_index - 1; /* User selected dbg-console */
+ leon3_debug_uart_index--; /* User selected dbg-console */
}
/* Find APBUART core for System Debug Console */
- i = debug_uart_index;
+ i = leon3_debug_uart_index;
adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
VENDOR_GAISLER, GAISLER_APBUART,
ambapp_find_by_idx, (void *)&i);
@@ -71,9 +71,9 @@ static void bsp_debug_uart_init(void)
* for printk
*/
apb = (struct ambapp_apb_info *)adev->devinfo;
- dbg_uart = (struct apbuart_regs *)apb->start;
- dbg_uart->ctrl |= APBUART_CTRL_RE | APBUART_CTRL_TE;
- dbg_uart->status = 0;
+ leon3_debug_uart = (struct apbuart_regs *)apb->start;
+ leon3_debug_uart->ctrl |= APBUART_CTRL_RE | APBUART_CTRL_TE;
+ leon3_debug_uart->status = 0;
}
}
@@ -86,14 +86,14 @@ RTEMS_SYSINIT_ITEM(
/* putchar/getchar for printk */
static void bsp_out_char(char c)
{
- if (dbg_uart == NULL) {
+ if (leon3_debug_uart == NULL) {
/* Local debug buffer when UART driver has not registered */
pre_printk_dbgbuf[pre_printk_pos++] = c;
pre_printk_pos = pre_printk_pos & (sizeof(pre_printk_dbgbuf)-1);
return;
}
- apbuart_outbyte_polled(dbg_uart, c, 1, 1);
+ apbuart_outbyte_polled(leon3_debug_uart, c, 1, 1);
}
/*
@@ -108,10 +108,10 @@ static int bsp_in_char(void)
{
int tmp;
- if (dbg_uart == NULL)
+ if (leon3_debug_uart == NULL)
return EOF;
- while ((tmp = apbuart_inbyte_nonblocking(dbg_uart)) < 0)
+ while ((tmp = apbuart_inbyte_nonblocking(leon3_debug_uart)) < 0)
;
return tmp;
}
diff --git a/c/src/lib/libbsp/sparc/leon3/include/leon.h b/c/src/lib/libbsp/sparc/leon3/include/leon.h
index 36f9495..9b2597f 100644
--- a/c/src/lib/libbsp/sparc/leon3/include/leon.h
+++ b/c/src/lib/libbsp/sparc/leon3/include/leon.h
@@ -364,7 +364,7 @@ extern int syscon_uart_index;
* 3 = APBUART[2]
* ...
*/
-extern int debug_uart_index;
+extern int leon3_debug_uart_index;
/* Let user override which on-chip TIMER core will be used for system clock
* timer. This controls which timer core will be accociated with
diff --git a/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c b/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
index c79d408..e406bc0 100644
--- a/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
+++ b/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
@@ -48,7 +48,9 @@ extern void apbuart_outbyte_polled(
int do_cr_on_newline,
int wait_sent);
extern int apbuart_inbyte_nonblocking(struct apbuart_regs *regs);
-extern struct apbuart_regs *dbg_uart; /* The debug UART */
+#ifdef LEON3
+extern struct apbuart_regs *leon3_debug_uart; /* The debug UART */
+#endif
/* Probed hardware capabilities */
enum {
@@ -263,7 +265,7 @@ int apbuart_init1(struct drvmgr_dev *dev)
*/
db = 0;
#ifdef LEON3
- if (priv->regs == dbg_uart) {
+ if (priv->regs == leon3_debug_uart) {
db = priv->regs->ctrl & (LEON_REG_UART_CTRL_RE |
LEON_REG_UART_CTRL_TE |
LEON_REG_UART_CTRL_PE |
@@ -510,7 +512,7 @@ static void last_close(
#ifdef LEON3
/* Disable TX/RX if not used for DEBUG */
- if (uart->regs != dbg_uart)
+ if (uart->regs != leon3_debug_uart)
uart->regs->ctrl &= ~(APBUART_CTRL_RE | APBUART_CTRL_TE);
#endif
}
--
2.7.4
More information about the devel
mailing list