summaryrefslogtreecommitdiffstats
path: root/c/src
diff options
context:
space:
mode:
authorChristian Mauderer <Christian.Mauderer@embedded-brains.de>2014-07-01 15:09:49 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-07-09 12:07:49 +0200
commit8448a4defcd2f41328628468c4f96547f98beb43 (patch)
treef78b256e24ec5480c0efc1639f3ce79539660937 /c/src
parentbsps/sparc: Add and use shared APBUART console (diff)
downloadrtems-8448a4defcd2f41328628468c4f96547f98beb43.tar.bz2
bsps/sparc: Move APBUART printk support
Diffstat (limited to 'c/src')
-rw-r--r--c/src/lib/libbsp/sparc/leon3/console/printk_support.c51
-rw-r--r--c/src/lib/libbsp/sparc/leon3/include/leon.h19
-rw-r--r--c/src/lib/libbsp/sparc/shared/include/apbuart_termios.h19
-rw-r--r--c/src/lib/libbsp/sparc/shared/uart/apbuart_termios.c51
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 d12099b1a6..03021c722b 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 d7048f3c23..1fc4e28e40 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 4b54252518..ba5f049e09 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 4b69e1b3d2..58822c522b 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,