[PATCH 4/4] bsps/sparc: Move APBUART printk support
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Jul 7 11:39:19 UTC 2014
From: Christian Mauderer <Christian.Mauderer at embedded-brains.de>
---
.../libbsp/sparc/leon3/console/printk_support.c | 51 --------------------
c/src/lib/libbsp/sparc/leon3/include/leon.h | 19 -------
.../libbsp/sparc/shared/include/apbuart_termios.h | 19 +++++++
.../lib/libbsp/sparc/shared/uart/apbuart_termios.c | 51 ++++++++++++++++++++
4 files changed, 70 insertions(+), 70 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 d12099b..03021c7 100644
--- a/c/src/lib/libbsp/sparc/leon3/console/printk_support.c
+++ b/c/src/lib/libbsp/sparc/leon3/console/printk_support.c
@@ -75,57 +75,6 @@ void bsp_debug_uart_init(void)
}
}
-/*
- * apbuart_outbyte_polled
- *
- * This routine transmits a character using polling.
- */
-void apbuart_outbyte_polled(
- struct apbuart_regs *regs,
- unsigned char ch,
- int do_cr_on_newline,
- int wait_sent
-)
-{
-send:
- while ( (regs->status & APBUART_STATUS_TE) == 0 ) {
- /* Lower bus utilization while waiting for UART */
- __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
- __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
- __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
- __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
- }
- regs->data = (unsigned int) ch;
-
- if ((ch == '\n') && do_cr_on_newline) {
- ch = '\r';
- goto send;
- }
-
- /* Wait until the character has been sent? */
- if (wait_sent) {
- while ((regs->status & APBUART_STATUS_TE) == 0)
- ;
- }
-}
-
-/*
- * apbuart_inbyte_nonblocking
- *
- * This routine polls for a character.
- */
-int apbuart_inbyte_nonblocking(struct apbuart_regs *regs)
-{
- /* Clear errors */
- if (regs->status & APBUART_STATUS_ERR)
- regs->status = ~APBUART_STATUS_ERR;
-
- if ((regs->status & APBUART_STATUS_DR) == 0)
- return EOF;
- else
- return (int) regs->data;
-}
-
/* putchar/getchar for printk */
static void bsp_out_char(char c)
{
diff --git a/c/src/lib/libbsp/sparc/leon3/include/leon.h b/c/src/lib/libbsp/sparc/leon3/include/leon.h
index d7048f3..1fc4e28 100644
--- a/c/src/lib/libbsp/sparc/leon3/include/leon.h
+++ b/c/src/lib/libbsp/sparc/leon3/include/leon.h
@@ -278,25 +278,6 @@ extern int syscon_uart_index;
*/
extern int debug_uart_index;
-/*
- * apbuart_outbyte_polled
- *
- * This routine transmits a character using polling.
- */
-void apbuart_outbyte_polled(
- struct apbuart_regs *regs,
- unsigned char ch,
- int do_cr_on_newline,
- int wait_sent
-);
-
-/*
- * apbuart_inbyte_nonblocking
- *
- * This routine polls for a character.
- */
-int apbuart_inbyte_nonblocking(struct apbuart_regs *regs);
-
void leon3_cpu_counter_initialize(void);
/* GRLIB extended IRQ controller register */
diff --git a/c/src/lib/libbsp/sparc/shared/include/apbuart_termios.h b/c/src/lib/libbsp/sparc/shared/include/apbuart_termios.h
index 4b54252..ba5f049 100644
--- a/c/src/lib/libbsp/sparc/shared/include/apbuart_termios.h
+++ b/c/src/lib/libbsp/sparc/shared/include/apbuart_termios.h
@@ -33,6 +33,25 @@ const rtems_termios_device_handler apbuart_handler_interrupt;
const rtems_termios_device_handler apbuart_handler_polled;
+/*
+ * apbuart_outbyte_polled
+ *
+ * This routine transmits a character using polling.
+ */
+void apbuart_outbyte_polled(
+ struct apbuart_regs *regs,
+ unsigned char ch,
+ int do_cr_on_newline,
+ int wait_sent
+);
+
+/*
+ * apbuart_inbyte_nonblocking
+ *
+ * This routine polls for a character.
+ */
+int apbuart_inbyte_nonblocking(struct apbuart_regs *regs);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/c/src/lib/libbsp/sparc/shared/uart/apbuart_termios.c b/c/src/lib/libbsp/sparc/shared/uart/apbuart_termios.c
index 4b69e1b..58822c5 100644
--- a/c/src/lib/libbsp/sparc/shared/uart/apbuart_termios.c
+++ b/c/src/lib/libbsp/sparc/shared/uart/apbuart_termios.c
@@ -223,6 +223,57 @@ static void apbuart_last_close_interrupt(
rtems_interrupt_handler_remove(uart->irq, apbuart_isr, tty);
}
+/*
+ * apbuart_outbyte_polled
+ *
+ * This routine transmits a character using polling.
+ */
+void apbuart_outbyte_polled(
+ struct apbuart_regs *regs,
+ unsigned char ch,
+ int do_cr_on_newline,
+ int wait_sent
+)
+{
+send:
+ while ( (regs->status & APBUART_STATUS_TE) == 0 ) {
+ /* Lower bus utilization while waiting for UART */
+ __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
+ __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
+ __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
+ __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
+ }
+ regs->data = (unsigned int) ch;
+
+ if ((ch == '\n') && do_cr_on_newline) {
+ ch = '\r';
+ goto send;
+ }
+
+ /* Wait until the character has been sent? */
+ if (wait_sent) {
+ while ((regs->status & APBUART_STATUS_TE) == 0)
+ ;
+ }
+}
+
+/*
+ * apbuart_inbyte_nonblocking
+ *
+ * This routine polls for a character.
+ */
+int apbuart_inbyte_nonblocking(struct apbuart_regs *regs)
+{
+ /* Clear errors */
+ if (regs->status & APBUART_STATUS_ERR)
+ regs->status = ~APBUART_STATUS_ERR;
+
+ if ((regs->status & APBUART_STATUS_DR) == 0)
+ return -1;
+ else
+ return (int) regs->data;
+}
+
const rtems_termios_device_handler apbuart_handler_interrupt = {
.first_open = apbuart_first_open_interrupt,
.last_close = apbuart_last_close_interrupt,
--
1.7.7
More information about the devel
mailing list