Changeset f4424cfb in rtems


Ignore:
Timestamp:
Aug 9, 2018, 7:20:33 AM (16 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
0e6f7dc4
Parents:
aac36d15
git-author:
Sebastian Huber <sebastian.huber@…> (08/09/18 07:20:33)
git-committer:
Sebastian Huber <sebastian.huber@…> (08/10/18 05:14:43)
Message:

bsps/sparc: Move polled APBUART functions

This reduces the link-time dependencies and avoids copy-and-paste.

Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • bsps/sparc/include/bsp/apbuart.h

    raac36d15 rf4424cfb  
    2121
    2222#include <ambapp.h>
     23#include <grlib.h>
    2324
    2425#ifdef __cplusplus
     
    5455#define APBUART_STATUS_RF 0x400
    5556
     57void apbuart_outbyte_polled(
     58  struct apbuart_regs *regs,
     59  unsigned char ch,
     60  int do_cr_on_newline,
     61  int wait_sent
     62);
     63
     64int apbuart_inbyte_nonblocking(struct apbuart_regs *regs);
     65
    5666#ifdef __cplusplus
    5767}
  • bsps/sparc/include/bsp/apbuart_termios.h

    raac36d15 rf4424cfb  
    3535const rtems_termios_device_handler apbuart_handler_polled;
    3636
    37 /*
    38  *  apbuart_outbyte_polled
    39  *
    40  *  This routine transmits a character using polling.
    41  */
    42 void apbuart_outbyte_polled(
    43   struct apbuart_regs *regs,
    44   unsigned char ch,
    45   int do_cr_on_newline,
    46   int wait_sent
    47 );
    48 
    49 /*
    50  *  apbuart_inbyte_nonblocking
    51  *
    52  *  This routine polls for a character.
    53  */
    54 int apbuart_inbyte_nonblocking(struct apbuart_regs *regs);
    55 
    5637#ifdef __cplusplus
    5738}
  • bsps/sparc/leon3/console/printk_support.c

    raac36d15 rf4424cfb  
    2424#include <stdio.h>
    2525#include <bsp/apbuart.h>
    26 #include <bsp/apbuart_termios.h>
    2726
    2827int leon3_debug_uart_index __attribute__((weak)) = 0;
  • bsps/sparc/shared/uart/apbuart_cons.c

    raac36d15 rf4424cfb  
    4343
    4444/* LEON3 Low level transmit/receive functions provided by debug-uart code */
    45 extern void apbuart_outbyte_polled(
    46   struct apbuart_regs *regs,
    47   unsigned char ch,
    48   int do_cr_on_newline,
    49   int wait_sent);
    50 extern int apbuart_inbyte_nonblocking(struct apbuart_regs *regs);
    5145#ifdef LEON3
    5246extern struct apbuart_regs *leon3_debug_uart; /* The debug UART */
     
    386380#endif
    387381
    388 #ifndef LEON3
    389 /* This routine transmits a character, it will busy-wait until on character
    390  * fits in the APBUART Transmit FIFO
    391  */
    392 void apbuart_outbyte_polled(
    393   struct apbuart_regs *regs,
    394   unsigned char ch,
    395   int do_cr_on_newline,
    396   int wait_sent)
    397 {
    398 send:
    399         while ((regs->status & LEON_REG_UART_STATUS_THE) == 0) {
    400                 /* Lower bus utilization while waiting for UART */
    401                 asm volatile ("nop"::); asm volatile ("nop"::);
    402                 asm volatile ("nop"::); asm volatile ("nop"::);
    403                 asm volatile ("nop"::); asm volatile ("nop"::);
    404                 asm volatile ("nop"::); asm volatile ("nop"::);
    405         }
    406         regs->data = (unsigned int) ch;
    407 
    408         if ((ch == '\n') && do_cr_on_newline) {
    409                 ch = '\r';
    410                 goto send;
    411         }
    412 
    413         /* Wait until the character has been sent? */
    414         if (wait_sent) {
    415                 while ((regs->status & LEON_REG_UART_STATUS_THE) == 0)
    416                         ;
    417         }
    418 }
    419 
    420 /* This routine polls for one character, return EOF if no character is available */
    421 int apbuart_inbyte_nonblocking(struct apbuart_regs *regs)
    422 {
    423         if (regs->status & LEON_REG_UART_STATUS_ERR) {
    424                 regs->status = ~LEON_REG_UART_STATUS_ERR;
    425         }
    426 
    427         if ((regs->status & LEON_REG_UART_STATUS_DR) == 0)
    428                 return EOF;
    429 
    430         return (int)regs->data;
    431 }
    432 #endif
    433 
    434382static bool first_open(
    435383        rtems_termios_tty *tty,
  • bsps/sparc/shared/uart/apbuart_termios.c

    raac36d15 rf4424cfb  
    243243}
    244244
    245 /*
    246  *  apbuart_outbyte_polled
    247  *
    248  *  This routine transmits a character using polling.
    249  */
    250 void apbuart_outbyte_polled(
    251   struct apbuart_regs *regs,
    252   unsigned char ch,
    253   int do_cr_on_newline,
    254   int wait_sent
    255 )
    256 {
    257 send:
    258   while ( (regs->status & APBUART_STATUS_TE) == 0 ) {
    259     /* Lower bus utilization while waiting for UART */
    260     __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
    261     __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
    262     __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
    263     __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
    264   }
    265 
    266   if ((ch == '\n') && do_cr_on_newline) {
    267     regs->data = (unsigned int) '\r';
    268     do_cr_on_newline = 0;
    269     goto send;
    270   }
    271   regs->data = (unsigned int) ch;
    272 
    273   /* Wait until the character has been sent? */
    274   if (wait_sent) {
    275     while ((regs->status & APBUART_STATUS_TE) == 0)
    276       ;
    277   }
    278 }
    279 
    280 /*
    281  *  apbuart_inbyte_nonblocking
    282  *
    283  *  This routine polls for a character.
    284  */
    285 int apbuart_inbyte_nonblocking(struct apbuart_regs *regs)
    286 {
    287   /* Clear errors */
    288   if (regs->status & APBUART_STATUS_ERR)
    289     regs->status = ~APBUART_STATUS_ERR;
    290 
    291   if ((regs->status & APBUART_STATUS_DR) == 0)
    292     return -1;
    293   else
    294     return (int) regs->data;
    295 }
    296 
    297245const rtems_termios_device_handler apbuart_handler_interrupt = {
    298246  .first_open = apbuart_first_open_interrupt,
  • c/src/lib/libbsp/sparc/leon3/Makefile.am

    raac36d15 rf4424cfb  
    6969librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc/shared/uart/cons.c
    7070librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc/shared/uart/apbuart_cons.c
     71librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc/shared/uart/apbuart_polled.c
     72librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc/shared/uart/apbuart_termios.c
    7173# debugio
    7274librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc/leon3/console/printk_support.c
     
    117119librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc/shared/spw/grspw_pkt.c
    118120librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc/shared/spw/grspw_router.c
    119 
    120 # UART
    121 librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc/shared/uart/apbuart_termios.c
    122121
    123122# I2CMST
Note: See TracChangeset for help on using the changeset viewer.