[PATCH 34.5 6/6] LEON3: added TX-wait-complete and CR on NL support for UART

Daniel Hellstrom daniel at gaisler.com
Thu Apr 19 16:03:01 UTC 2012


On 04/19/2012 05:36 PM, Gedare Bloom wrote:
> On Thu, Apr 19, 2012 at 8:19 AM, Joel Sherrill
> <joel.sherrill at oarcorp.com>  wrote:
>> I think this is ok if you rename debugputs.c to something else. I am on my phone but other bsps have a support file for printk so just use that name. I don't remember it.
>>
>> Debug_puts() is just old, sparc specific, and predates printk. If this kills it, then one less inconsistency.
>>
> I think Daniel's intention is to rename the file later. If so I think
> we can proceed after the style fixes and deal with this inconsistency
> after his next big batch.
Yes, that was my initial intension, but then I posted PATCH37 that should be applied after PATCH35 that deals with the renaming.

>> Thanks for being receptive to all this. I have been working BSP consistency and framework issues slowly since before 4.8 and there is just so much code. You have to kill things enmasse or nibble when you make other changes.
>>
> Yeah. My experience has been the hardest parts are dealing with the
> automake files and testing to ensure nothing broke ;)
>
>> Daniel Hellstrom<daniel at gaisler.com>  wrote:
>>
>>> On 04/18/2012 05:38 PM, Joel Sherrill wrote:
>>>> apbuart_outbyte_polled prototype should still have closing
>>>> parenthesis on separate line.
>>>>
>>>> rtems_io_register_name spacing on parentheses is inconsistent.
>>> Sorry, I missed those. Will update the patch.
>>>
>>>> Is debugputs.c really the right name? There should no longer
>>>> be a method with that name. Only printk() support.
>>> You're right, I never thought about that actually, it have always been named that way... don't know why.
>>>
>>> I can submit a new patch after ChunkF, since PATCH 35 depends upon debugputs.c. I can rename it to printk_support.c.
>>>
>>>
>>>> And I
>>>> don't know why you would need the cr/lf translation.
>>> Since printk() doesn't translate \n into \r\n the driver must do it? Before this patch all terminal output was on one line, which was overwritten all the time. It did however work in simulators like
>>> TSIM/GRSIM since the terminal they run within understand only newline.
>>>
>>> Thanks,
>>> Daniel
>>>
>>>>
>>>> On 04/18/2012 10:19 AM, Daniel Hellstrom wrote:
>>>>> Signed-off-by: Daniel Hellstrom<daniel at gaisler.com>
>>>>> ---
>>>>>    c/src/lib/libbsp/sparc/leon3/console/console.c   |   10 ++++++----
>>>>>    c/src/lib/libbsp/sparc/leon3/console/debugputs.c |   18 ++++++++++++++++--
>>>>>    2 files changed, 22 insertions(+), 6 deletions(-)
>>>>>
>>>>> diff --git a/c/src/lib/libbsp/sparc/leon3/console/console.c b/c/src/lib/libbsp/sparc/leon3/console/console.c
>>>>> index 068aced..c095979 100644
>>>>> --- a/c/src/lib/libbsp/sparc/leon3/console/console.c
>>>>> +++ b/c/src/lib/libbsp/sparc/leon3/console/console.c
>>>>> @@ -50,8 +50,10 @@ int syscon_uart_index __attribute__((weak)) = 0;
>>>>>
>>>>>    extern void apbuart_outbyte_polled(
>>>>>      ambapp_apb_uart *regs,
>>>>> -  char ch
>>>>> -);
>>>>> +  unsigned char ch,
>>>>> +  int do_cr_on_newline,
>>>>> +  int wait_sent);
>>>>> +
>>>>>
>>>>>    /* body is in debugputs.c */
>>>>>
>>>>> @@ -157,7 +159,7 @@ ssize_t console_write_polled (int minor, const char *buf, size_t len)
>>>>>        port = minor - 1;
>>>>>
>>>>>      while (nwrite<    len) {
>>>>> -    apbuart_outbyte_polled(apbuarts[port].regs, *buf++);
>>>>> +    apbuart_outbyte_polled(apbuarts[port].regs, *buf++, 1, 0);
>>>>>        nwrite++;
>>>>>      }
>>>>>      return nwrite;
>>>>> @@ -346,7 +348,7 @@ rtems_device_driver console_initialize(
>>>>>       * On a MP system one should not open UARTs that other OS instances use.
>>>>>       */
>>>>>      if (syscon_uart_index<    uarts) {
>>>>> -    status = rtems_io_register_name( "/dev/console", major, 0 );
>>>>> +    status = rtems_io_register_name( "/dev/console", major, 0);
>>>>>        if (status != RTEMS_SUCCESSFUL)
>>>>>          rtems_fatal_error_occurred(status);
>>>>>      }
>>>>> diff --git a/c/src/lib/libbsp/sparc/leon3/console/debugputs.c b/c/src/lib/libbsp/sparc/leon3/console/debugputs.c
>>>>> index 7058cf8..080d4fa 100644
>>>>> --- a/c/src/lib/libbsp/sparc/leon3/console/debugputs.c
>>>>> +++ b/c/src/lib/libbsp/sparc/leon3/console/debugputs.c
>>>>> @@ -89,9 +89,12 @@ int bsp_debug_uart_init(void)
>>>>>     */
>>>>>    void apbuart_outbyte_polled(
>>>>>      ambapp_apb_uart *regs,
>>>>> -  unsigned char ch
>>>>> +  unsigned char ch,
>>>>> +  int do_cr_on_newline,
>>>>> +  int wait_sent
>>>>>    )
>>>>>    {
>>>>> +send:
>>>>>      while ( (regs->status&    LEON_REG_UART_STATUS_THE) == 0 ) {
>>>>>        /* Lower bus utilization while waiting for UART */
>>>>>        asm volatile ("nop"::); asm volatile ("nop"::);
>>>>> @@ -100,6 +103,17 @@ void apbuart_outbyte_polled(
>>>>>        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&    LEON_REG_UART_STATUS_THE) == 0)
>>>>> +      ;
>>>>> +  }
>>>>>    }
>>>>>
>>>>>    /*
>>>>> @@ -129,7 +143,7 @@ static void bsp_out_char(char c)
>>>>>        return;
>>>>>      }
>>>>>
>>>>> -  apbuart_outbyte_polled(dbg_uart, c);
>>>>> +  apbuart_outbyte_polled(dbg_uart, c, 1, 1);
>>>>>    }
>>>>>
>>>>>    /*
>>>>
>




More information about the devel mailing list