<div dir="ltr"><div dir="ltr">On Sat, Dec 28, 2019 at 3:20 PM Christian Mauderer <<a href="mailto:list@c-mauderer.de">list@c-mauderer.de</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Missed your question further below in my first mail.<br>
<br>
On 28/12/2019 10:45, Christian Mauderer wrote:<br>
> On 28/12/2019 09:38, Niteesh wrote:<br>
>> I didn't get any of these warnings, which command did you use?<br>
> <br>
> Just the usual make in the build directory. I configured with the<br>
> following line:<br>
> <br>
> /home/christian/rtems/rtems-bbb/build/..//libs/rtems/configure<br>
> --target=arm-rtems5<br>
> --prefix=/home/christian/rtems/rtems-bbb/build/..//install/rtems/5/<br>
> --enable-rtemsbsp=raspberrypi --enable-maintainer-mode<br>
> --enable-tests=samples --disable-networking<br>
> <br>
> Don't let the "bbb" irritate you: I hacked my normal beagle build<br>
> environment for use with the raspberry.<br>
> <br>
> There are quite a lot of messages. So the warnings might are a bit<br>
> hidden. Also note that you only get them if the file is recompiled. So<br>
> either you have to change something or remove the console-config.o and<br>
> fbcons.o object file to trigger them on a re-make.<br>
> <br>
>><br>
>> On Sat, Dec 28, 2019 at 3:48 AM Christian Mauderer <<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a><br>
>> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>>> wrote:<br>
>><br>
>>     Hello,<br>
>><br>
>>     git complained about some whitespaces when applying the patch:<br>
>><br>
>>     ````````````<br>
>>     git am \[PATCH\]\ Raspberrypi:\ updated\ the\ console\ interface..eml<br>
>>     Applying: Raspberrypi: updated the console interface.<br>
>>     /home/christian/rtems/rtems-bbb/.git/modules/rtems/rebase-apply/patch:96:<br>
>>     trailing<br>
>>     whitespace.<br>
>><br>
>>     /home/christian/rtems/rtems-bbb/.git/modules/rtems/rebase-apply/patch:304:<br>
>>     trailing whitespace.<br>
>>     const rtems_termios_device_handler fbcons_fns =<br>
>>     /home/christian/rtems/rtems-bbb/.git/modules/rtems/rebase-apply/patch:481:<br>
>>     trailing whitespace.<br>
>>     bool fbcons_probe(<br>
>>     /home/christian/rtems/rtems-bbb/.git/modules/rtems/rebase-apply/patch:515:<br>
>>     trailing whitespace.<br>
>>      * @name Current Serial Device<br>
>>     warning: 4 lines add whitespace errors.<br>
>>     ````````````<br>
>><br>
>> Fixed all the whitespace erros. <br>
>><br>
>>     When compiling I get some warnings like<br>
>><br>
>>     ````````````<br>
>>     /home/christian/rtems/rtems-bbb/build/..//libs/rtems/c/src/lib/libbsp/arm/raspberrypi/../../../../../../bsps/arm/raspberrypi/console/console-config.c:<br>
>>     In function 'output_char':<br>
>>     /home/christian/rtems/rtems-bbb/build/..//libs/rtems/c/src/lib/libbsp/arm/raspberrypi/../../../../../../bsps/arm/raspberrypi/console/console-config.c:64:3:<br>
>>     warning: enumeration value 'AUX_UART' not handled in switch [-Wswitch]<br>
>>        switch(SERIAL){<br>
>>        ^~~~~~<br>
>>     ````````````<br>
>><br>
>>     and<br>
>><br>
>>     ````````````<br>
>>     /home/christian/rtems/rtems-bbb/build/..//libs/rtems/c/src/lib/libbsp/arm/raspberrypi/../../../../../../bsps/arm/raspberrypi/console/fbcons.c:174:17:<br>
>>     warning: initialization from incompatible pointer type<br>
>>     [-Wincompatible-pointer-types]<br>
>>        .first_open = fbcons_open,<br>
>>                      ^~~~~~~~~~~<br>
>>     ````````````<br>
>><br>
>>     Please fix these. I'm not entirely sure about the first warning. That<br>
>>     might has been there before. If possible it would be nice if you could<br>
>>     fix it anyway. In that case maybe in an extra commit.<br>
>><br>
>>     At least the PL011 works on a Pi2 on real hardware too. I haven't tested<br>
>>     the framebuffer yet. I'm still trying to find out how to select it<br>
>>     before or after the patch.<br>
>><br>
>>     Please see my notes in the patch below regarding some points.<br>
>><br>
>>     Best regards<br>
>><br>
>>     Christian<br>
>><br>
>>     On 27/12/2019 12:08, G S Niteesh wrote:<br>
>>     > The patch updates the older console interface used by the BSP,<br>
>>     > to newer one. It also replaces the custom usart(PL011) driver<br>
>>     > with arm-pl011. The fb functions signatures where also changed<br>
>>     > to accommodate with interface update.<br>
>>     > ---<br>
>>     >  bsps/arm/raspberrypi/console/console-config.c |  67 +++++----<br>
>>     >  bsps/arm/raspberrypi/console/console_select.c |  65 +-------<br>
>>     >  bsps/arm/raspberrypi/console/fbcons.c         |  50 +++---<br>
>>     >  bsps/arm/raspberrypi/console/usart.c          | 142<br>
>>     ------------------<br>
>>     >  bsps/arm/raspberrypi/include/bsp/fbcons.h     |  19 ++-<br>
>>     >  .../arm/raspberrypi/include/bsp/raspberrypi.h |  52 ++-----<br>
>>     >  bsps/arm/raspberrypi/include/bsp/usart.h      |   5 +-<br>
>>     >  c/src/lib/libbsp/arm/raspberrypi/Makefile.am  |   5 +-<br>
>>     >  8 files changed, 105 insertions(+), 300 deletions(-)<br>
>>     ><br>
>>     > diff --git a/bsps/arm/raspberrypi/console/console-config.c<br>
>>     b/bsps/arm/raspberrypi/console/console-config.c<br>
>>     > index d2186c918b..1f6dec384a 100644<br>
>>     > --- a/bsps/arm/raspberrypi/console/console-config.c<br>
>>     > +++ b/bsps/arm/raspberrypi/console/console-config.c<br>
>>     > @@ -22,45 +22,54 @@<br>
>>     > <br>
>>     >  #include <libchip/serial.h><br>
>>     > <br>
>>     > -#include <bspopts.h><br>
>>     > -#include <bsp/irq.h><br>
>>     > +#include <bsp.h><br>
>>     >  #include <bsp/usart.h><br>
>>     >  #include <bsp/raspberrypi.h><br>
>>     > +#include <bsp/arm-pl011.h><br>
>>     >  #include <bsp/fbcons.h><br>
>>     > +#include <bsp/console-termios.h><br>
>>     > +<br>
>>     > +#include <bspopts.h><br>
>>     > <br>
>>     > -console_tbl Console_Configuration_Ports [] = {<br>
>>     > -    {<br>
>>     > -      .sDeviceName = "/dev/ttyS0",<br>
>>     > -      .deviceType = SERIAL_CUSTOM,<br>
>>     > -      .pDeviceFns = &bcm2835_usart_fns,<br>
>>     > -      .deviceProbe = NULL,<br>
>>     > -      .pDeviceFlow = NULL,<br>
>>     > -      .ulCtrlPort1 = BCM2835_UART0_BASE,<br>
>>     > -      .ulCtrlPort2 = 0,<br>
>>     > -      .ulClock = USART0_DEFAULT_BAUD,<br>
>>     > -      .ulIntVector = BCM2835_IRQ_ID_UART<br>
>>     > -    },<br>
>>     > -    {<br>
>>     > -      .sDeviceName ="/dev/fbcons",<br>
>>     > -      .deviceType = SERIAL_CUSTOM,<br>
>>     > -      .pDeviceFns = &fbcons_fns,<br>
>>     > -      .deviceProbe = fbcons_probe,<br>
>>     > -      .pDeviceFlow = NULL,<br>
>>     > -    },<br>
>>     > +arm_pl011_context pl011_context = {<br>
>>     > +  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("PL011"),<br>
>>     > +  .regs = (volatile pl011 *) BCM2835_PL011_BASE,<br>
>>     > +  .initial_baud = PL011_DEFAULT_BAUD<br>
>>     >  };<br>
>>     > <br>
>>     > -#define PORT_COUNT \<br>
>>     > -  (sizeof(Console_Configuration_Ports) \<br>
>>     > -    / sizeof(Console_Configuration_Ports [0]))<br>
>>     > +rpi_fb_context fb_context = {<br>
>>     > +  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("FB")<br>
>>     > +};<br>
>>     > <br>
>>     > -unsigned long Console_Configuration_Count = PORT_COUNT;<br>
>>     > +const console_device console_device_table[] = {<br>
>>     > +  {<br>
>>     > +    .device_file = "/dev/ttyS0",<br>
>>     > +    .probe = console_device_probe_default,<br>
>>     > +    .handler = &arm_pl011_fns,<br>
>>     > +    .context = &pl011_context.base<br>
>>     > +  },<br>
>>     > +  {<br>
>>     > +    .device_file = "/dev/fbcons",<br>
>>     > +    // Should be changed to fbcons_probe (but it still use old<br>
>>     interface)<br>
>><br>
>>     What do you mean with that comment?<br>
>><br>
>> I am sorry, I actually forgot to remove the comment. Previously I was<br>
>> using default<br>
>> probe function. But then changed it to fbcons_probe.<br>
>><br>
>>      <br>
>><br>
>>     > +    .probe = fbcons_probe,<br>
>>     > +    .handler = &fbcons_fns,<br>
>>     > +    .context = &fb_context.base<br>
>>     > +  }<br>
>>     > +};<br>
>>     > +<br>
>>     > +const size_t console_device_count =<br>
>>     RTEMS_ARRAY_SIZE(console_device_table);<br>
>>     > <br>
>>     >  static void output_char(char c)<br>
>>     >  {<br>
>>     > -  const console_fns *con =<br>
>>     > -    Console_Configuration_Ports [Console_Port_Minor].pDeviceFns;<br>
>>     > -<br>
>>     > -  con->deviceWritePolled((int) Console_Port_Minor, c);<br>
>>     > +  switch(SERIAL){<br>
>>     > +    case FB:<br>
>>     > +      fbcons_write_polled(&fb_context.base, c);<br>
>>     > +      break;<br>
>>     > +    case PL011:<br>
>>     > +      arm_pl011_write_polled(&pl011_context.base, c);<br>
>>     > +      break;<br>
>><br>
>>     I don't like that selection method.<br>
>><br>
>>     1. I'm not happy with that naming. It's a variable so please write it in<br>
>>     lower case. Same is true for the type CURRENT_SERIAL. It should be a<br>
>>     lower case name.<br>
>><br>
>>     2. There is no default case.<br>
>><br>
>>     3. This adds lot's of overhead. It means that for every character a<br>
>>     switch case has to be evaluated. BSP_output_char is a pointer so you can<br>
>>     just change it's value to point to one of two functions.<br>
>><br>
>> Fixed this also. Removed the enum and switch, added a function pointer<br>
>> to the poll function, which is then called<br>
>> from outputchar by providing the right context.<br>
>><br>
>> I modified and added the is_bsp_available, which check's if the current<br>
>> serial is<br>
>> available, if not throws BSP_FATAL_CONSOLE_NO_DEV.<br>
>><br>
>> I was getting many warnings regarding incompatible pointer for eg: the<br>
>> write function in the device handler<br>
>> expects a void function, so I modified the fbcons_write_support_polled<br>
>> to void, which was previously returning<br>
>> the size of bytes written. Is that fine?<br>
<br>
If it isn't used anywhere else, it's OK. But isn't that function used<br>
for termios too?<br></blockquote><div>What do you mean by termios? I am talking about the </div><div>rterms_termios_device_handler,  this is responsible for termios right? And as per the doc</div><div>the write function returns void. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
You can also write a small wrapper function if you have to adapt<br>
something. That adds very few overhead. If the parameters match and only<br>
the return type should be ignored, a cast would be an alternative.<br></blockquote><div>I will go with the cast. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
>><br>
>> How should I now apply this modified patch? <br>
<br>
Add the changes to your previous patch ("git commit --amend" or "git<br>
rebase -i") and create a version 2 ("git format-patch -v2 HEAD^") and<br>
send that just like before with "git send-email". That will give you the<br>
[PATCH v2] headers that you find on our mailing list.<br>
<br>
>><br>
>>     > +  }<br>
>>     > + <br>
>>     >  }<br>
>>     > <br>
>>     >  BSP_output_char_function_type BSP_output_char = output_char;<br>
>>     > diff --git a/bsps/arm/raspberrypi/console/console_select.c<br>
>>     b/bsps/arm/raspberrypi/console/console_select.c<br>
>>     > index bd246ca868..a7bd844bb0 100644<br>
>>     > --- a/bsps/arm/raspberrypi/console/console_select.c<br>
>>     > +++ b/bsps/arm/raspberrypi/console/console_select.c<br>
>>     > @@ -15,7 +15,7 @@<br>
>>     >   *  <a href="http://www.rtems.org/license/LICENSE" rel="noreferrer" target="_blank">http://www.rtems.org/license/LICENSE</a><br>
>>     >   *<br>
>>     >   */<br>
>>     > -<br>
>>     > +#include <bsp/raspberrypi.h><br>
>>     >  #include <bsp.h><br>
>>     >  #include <bsp/fatal.h><br>
>>     >  #include <rtems/libio.h><br>
>>     > @@ -24,59 +24,12 @@<br>
>>     >  #include <assert.h><br>
>>     >  #include <termios.h><br>
>>     > <br>
>>     > -#include <rtems/termiostypes.h><br>
>>     >  #include <libchip/serial.h><br>
>>     >  #include "../../shared/dev/serial/legacy-console.h"<br>
>>     >  #include <bsp/rpi-fb.h><br>
>>     > <br>
>>     >  rtems_device_minor_number BSPPrintkPort = 0;<br>
>>     > -<br>
>>     > -/*<br>
>>     > - * Method to return true if the device associated with the<br>
>>     > - * minor number probs available.<br>
>>     > - */<br>
>>     > -static bool bsp_Is_Available( rtems_device_minor_number minor )<br>
>>     > -{<br>
>>     > -  console_tbl *cptr = Console_Port_Tbl[ minor ];<br>
>>     > -<br>
>>     > -  /*<br>
>>     > -   * First perform the configuration dependent probe, then the<br>
>>     > -   * device dependent probe<br>
>>     > -   */<br>
>>     > -  if ( ( !cptr->deviceProbe || cptr->deviceProbe( minor ) ) &&<br>
>>     > -       cptr->pDeviceFns->deviceProbe( minor ) ) {<br>
>>     > -    return true;<br>
>>     > -  }<br>
>>     > -<br>
>>     > -  return false;<br>
>>     > -}<br>
>>     > -<br>
>>     > -/*<br>
>>     > - * Method to return the first available device.<br>
>>     > - */<br>
>>     > -static rtems_device_minor_number bsp_First_Available_Device( void )<br>
>>     > -{<br>
>>     > -  rtems_device_minor_number minor;<br>
>>     > -<br>
>>     > -  for ( minor = 0; minor < Console_Port_Count; minor++ ) {<br>
>>     > -    console_tbl *cptr = Console_Port_Tbl[ minor ];<br>
>>     > -<br>
>>     > -    /*<br>
>>     > -     * First perform the configuration dependent probe, then the<br>
>>     > -     * device dependent probe<br>
>>     > -     */<br>
>>     > -<br>
>>     > -    if ( ( !cptr->deviceProbe || cptr->deviceProbe( minor ) ) &&<br>
>>     > -         cptr->pDeviceFns->deviceProbe( minor ) ) {<br>
>>     > -      return minor;<br>
>>     > -    }<br>
>>     > -  }<br>
>>     > -<br>
>>     > -  /*<br>
>>     > -   *  Error No devices were found.  We will want to bail here.<br>
>>     > -   */<br>
>>     > -  bsp_fatal( BSP_FATAL_CONSOLE_NO_DEV );<br>
>>     > -}<br>
>>     > +CURRENT_SERIAL SERIAL = PL011;><br>
>>     >  void bsp_console_select( void )<br>
>>     >  {<br>
>>     > @@ -90,25 +43,13 @@ void bsp_console_select( void )<br>
>>     >     */<br>
>>     >    const char *opt;<br>
>>     > <br>
>>     > -  Console_Port_Minor = BSP_CONSOLE_UART0;<br>
>>     > -  BSPPrintkPort = BSP_CONSOLE_UART0;<br>
>>     > -<br>
>>     >    opt = rpi_cmdline_get_arg( "--console=" );<br>
>>     > <br>
>>     >    if ( opt ) {<br>
>>     >      if ( strncmp( opt, "fbcons", sizeof( "fbcons" ) - 1 ) == 0 ) {<br>
>>     >        if ( rpi_video_is_initialized() > 0 ) {<br>
>>     > -        Console_Port_Minor = BSP_CONSOLE_FB;<br>
>>     > -        BSPPrintkPort = BSP_CONSOLE_FB;<br>
>>     > +        SERIAL = FB;<br>
>>     >        }<br>
>>     >      }<br>
>>     >    }<br>
>>     > -<br>
>>     > -  /*<br>
>>     > -   * If the device that was selected isn't available then<br>
>>     > -   * let the user know and select the first available device.<br>
>>     > -   */<br>
>>     > -  if ( !bsp_Is_Available( Console_Port_Minor ) ) {<br>
>>     > -    Console_Port_Minor = bsp_First_Available_Device();<br>
>>     > -  }<br>
>>     >  }<br>
>>     > diff --git a/bsps/arm/raspberrypi/console/fbcons.c<br>
>>     b/bsps/arm/raspberrypi/console/fbcons.c<br>
>>     > index 3669ba458d..99f2ab1aff 100644<br>
>>     > --- a/bsps/arm/raspberrypi/console/fbcons.c<br>
>>     > +++ b/bsps/arm/raspberrypi/console/fbcons.c<br>
>>     > @@ -18,6 +18,7 @@<br>
>>     > <br>
>>     >  #include <rtems.h><br>
>>     >  #include <rtems/libio.h><br>
>>     > +#include <rtems/termiostypes.h><br>
>>     > <br>
>>     >  #include <stdlib.h><br>
>>     > <br>
>>     > @@ -46,9 +47,10 @@ static void fbcons_init( int minor )<br>
>>     >   *  Default state is 9600 baud, 8 bits, No parity, and 1 stop bit.<br>
>>     >   */<br>
>>     >  static int fbcons_open(<br>
>>     > -  int   major,<br>
>>     > -  int   minor,<br>
>>     > -  void *arg<br>
>>     > +  struct rtems_termios_tty *tty,<br>
>>     > +  rtems_termios_device_context *base,<br>
>>     > +  struct termios *term,<br>
>>     > +  rtems_libio_open_close_args_t *args<br>
>>     >  )<br>
>>     >  {<br>
>>     >    return RTEMS_SUCCESSFUL;<br>
>>     > @@ -60,9 +62,9 @@ static int fbcons_open(<br>
>>     >   *  This function shuts down the requested port.<br>
>>     >   */<br>
>>     >  static int fbcons_close(<br>
>>     > -  int   major,<br>
>>     > -  int   minor,<br>
>>     > -  void *arg<br>
>>     > +  struct rtems_termios_tty *tty,<br>
>>     > +  rtems_termios_device_context *base,<br>
>>     > +  rtems_libio_open_close_args_t *args<br>
>>     >  )<br>
>>     >  {<br>
>>     >    return ( RTEMS_SUCCESSFUL );<br>
>>     > @@ -73,8 +75,8 @@ static int fbcons_close(<br>
>>     >   *<br>
>>     >   *  This routine polls out the requested character.<br>
>>     >   */<br>
>>     > -static void fbcons_write_polled(<br>
>>     > -  int  minor,<br>
>>     > +void fbcons_write_polled(<br>
>>     > +  rtems_termios_device_context *base,<br>
>>     >    char c<br>
>>     >  )<br>
>>     >  {<br>
>>     > @@ -91,7 +93,7 @@ static void fbcons_write_polled(<br>
>>     >   *<br>
>>     >   */<br>
>>     >  static ssize_t fbcons_write_support_polled(<br>
>>     > -  int         minor,<br>
>>     > +  rtems_termios_device_context *base,<br>
>>     >    const char *buf,<br>
>>     >    size_t      len<br>
>>     >  )<br>
>>     > @@ -102,7 +104,7 @@ static ssize_t fbcons_write_support_polled(<br>
>>     >     * poll each byte in the string out of the port.<br>
>>     >     */<br>
>>     >    while ( nwrite < len ) {<br>
>>     > -    fbcons_write_polled( minor, *buf++ );<br>
>>     > +    fbcons_write_polled( base, *buf++ );<br>
>>     >      nwrite++;<br>
>>     >    }<br>
>>     > <br>
>>     > @@ -117,7 +119,9 @@ static ssize_t fbcons_write_support_polled(<br>
>>     >   *<br>
>>     >   *  Console Termios polling input entry point.<br>
>>     >   */<br>
>>     > -static int fbcons_inbyte_nonblocking_polled( int minor )<br>
>>     > +int fbcons_inbyte_nonblocking_polled(<br>
>>     > +  rtems_termios_device_context *base<br>
>>     > +)<br>
>>     >  {<br>
>>     >    // if( rtems_kbpoll() ) {<br>
>>     >    //   int c = getch();<br>
>>     > @@ -134,14 +138,16 @@ static int fbcons_inbyte_nonblocking_polled(<br>
>>     int minor )<br>
>>     >   *  port settings.<br>
>>     >   */<br>
>>     >  static int fbcons_set_attributes(<br>
>>     > -  int                   minor,<br>
>>     > +  rtems_termios_device_context *base,<br>
>>     >    const struct termios *t<br>
>>     >  )<br>
>>     >  {<br>
>>     >    return 0;<br>
>>     >  }<br>
>>     > <br>
>>     > -bool fbcons_probe( int minor )<br>
>>     > +bool fbcons_probe(<br>
>>     > +  rtems_termios_device_context *base<br>
>>     > +)<br>
>>     >  {<br>
>>     >    // rtems_status_code status;<br>
>>     >    static bool firstTime = true;<br>
>>     > @@ -163,15 +169,11 @@ bool fbcons_probe( int minor )<br>
>>     >    return ret;<br>
>>     >  }<br>
>>     > <br>
>>     > -const console_fns fbcons_fns =<br>
>>     > +const rtems_termios_device_handler fbcons_fns =<br>
>>     >  {<br>
>>     > -  .deviceProbe = libchip_serial_default_probe,     /* deviceProbe */<br>
>>     > -  .deviceFirstOpen = fbcons_open,                 /*<br>
>>     deviceFirstOpen */<br>
>>     > -  .deviceLastClose = fbcons_close,                /*<br>
>>     deviceLastClose */<br>
>>     > -  .deviceRead = fbcons_inbyte_nonblocking_polled, /* deviceRead */<br>
>>     > -  .deviceWrite = fbcons_write_support_polled,     /* deviceWrite */<br>
>>     > -  .deviceInitialize = fbcons_init,                /*<br>
>>     deviceInitialize */<br>
>>     > -  .deviceWritePolled = fbcons_write_polled,       /*<br>
>>     deviceWritePolled */<br>
>>     > -  .deviceSetAttributes = fbcons_set_attributes,   /*<br>
>>     deviceSetAttributes */<br>
>>     > -  .deviceOutputUsesInterrupts = FALSE,           /*<br>
>>     deviceOutputUsesInterrupts*/<br>
>>     > -};<br>
>>     > +  .first_open = fbcons_open,<br>
>>     > +  .last_close = fbcons_close,<br>
>>     > +  .poll_read = fbcons_inbyte_nonblocking_polled,<br>
>>     > +  .write = fbcons_write_support_polled,<br>
>>     > +  .mode = TERMIOS_POLLED<br>
>>     > +};<br>
>>     > \ No newline at end of file<br>
>>     > diff --git a/bsps/arm/raspberrypi/console/usart.c<br>
>>     b/bsps/arm/raspberrypi/console/usart.c<br>
>>     > index 25fb523621..471d0c553f 100644<br>
>>     > --- a/bsps/arm/raspberrypi/console/usart.c<br>
>>     > +++ b/bsps/arm/raspberrypi/console/usart.c<br>
>>     > @@ -23,145 +23,3 @@<br>
>>     >  #include <bsp/usart.h><br>
>>     >  #include <bsp/raspberrypi.h><br>
>>     >  #include <rtems/bspIo.h><br>
>>     > -<br>
>>     > -static void usart_delay(uint32_t n)<br>
>>     > -{<br>
>>     > - volatile uint32_t i = 0;<br>
>>     > -<br>
>>     > - for(i = 0; i < n; i++)<br>
>>     > -   ;<br>
>>     > -}<br>
>>     > -<br>
>>     > -#if 0<br>
>>     > -/*<br>
>>     > - *  These will be useful when the driver supports interrupt<br>
>>     driven IO.<br>
>>     > - */<br>
>>     > -static rtems_vector_number usart_get_irq_number(const console_tbl<br>
>>     *ct)<br>
>>     > -{<br>
>>     > -  return ct->ulIntVector;<br>
>>     > -}<br>
>>     > -<br>
>>     > -static uint32_t usart_get_baud(const console_tbl *ct)<br>
>>     > -{<br>
>>     > -  return ct->ulClock;<br>
>>     > -}<br>
>>     > -#endif<br>
>>     > -<br>
>>     > -static void usart_set_baud(int minor, int baud)<br>
>>     > -{<br>
>>     > - /*<br>
>>     > -  * Nothing for now<br>
>>     > -  */<br>
>>     > - return;<br>
>>     > -}<br>
>>     > -<br>
>>     > -static void usart_initialize(int minor)<br>
>>     > -{<br>
>>     > -  unsigned int gpio_reg;<br>
>>     > -<br>
>>     > -  /*<br>
>>     > -  ** Program GPIO pins for UART 0<br>
>>     > -  */<br>
>>     > -  gpio_reg = BCM2835_REG(BCM2835_GPIO_GPFSEL1);<br>
>>     > -  gpio_reg &= ~(7<<12);    /* gpio14 */<br>
>>     > -  gpio_reg |=  (4<<12);    /* alt0   */<br>
>>     > -  gpio_reg &= ~(7<<15);    /* gpio15 */<br>
>>     > -  gpio_reg |=  (4<<15);    /* alt0   */<br>
>>     > -  BCM2835_REG(BCM2835_GPIO_GPFSEL1) = gpio_reg;<br>
>>     > -<br>
>>     > -  BCM2835_REG(BCM2835_GPIO_GPPUD) = 0;<br>
>>     > -  usart_delay(150);<br>
>>     > -  BCM2835_REG(BCM2835_GPIO_GPPUDCLK0) = (1<<14)|(1<<15);<br>
>>     > -  usart_delay(150);<br>
>>     > -  BCM2835_REG(BCM2835_GPIO_GPPUDCLK0) = 0;<br>
>>     > -<br>
>>     > -  /*<br>
>>     > -  ** Init the PL011 UART<br>
>>     > -  */<br>
>>     > -  BCM2835_REG(BCM2835_UART0_CR)   = 0;<br>
>>     > -  BCM2835_REG(BCM2835_UART0_ICR)  = 0x7FF;<br>
>>     > -  BCM2835_REG(BCM2835_UART0_IMSC) = 0;<br>
>>     > -  BCM2835_REG(BCM2835_UART0_IBRD) = 1;<br>
>>     > -  BCM2835_REG(BCM2835_UART0_FBRD) = 40;<br>
>>     > -  BCM2835_REG(BCM2835_UART0_LCRH) = 0x70;<br>
>>     > -  BCM2835_REG(BCM2835_UART0_RSRECR) =  0;<br>
>>     > -<br>
>>     > -  BCM2835_REG(BCM2835_UART0_CR)   = 0x301;<br>
>>     > -<br>
>>     > -  BCM2835_REG(BCM2835_UART0_IMSC) = BCM2835_UART0_IMSC_RX;<br>
>>     > -<br>
>>     > -  usart_set_baud(minor, 115000);<br>
>>     > -}<br>
>>     > -<br>
>>     > -static int usart_first_open(int major, int minor, void *arg)<br>
>>     > -{<br>
>>     > -  rtems_libio_open_close_args_t *oc =<br>
>>     (rtems_libio_open_close_args_t *) arg;<br>
>>     > -  struct rtems_termios_tty *tty = (struct rtems_termios_tty *)<br>
>>     oc->iop->data1;<br>
>>     > -  const console_tbl *ct = Console_Port_Tbl [minor];<br>
>>     > -  console_data *cd = &Console_Port_Data [minor];<br>
>>     > -<br>
>>     > -  cd->termios_data = tty;<br>
>>     > -  rtems_termios_set_initial_baud(tty, ct->ulClock);<br>
>>     > -<br>
>>     > -  return 0;<br>
>>     > -}<br>
>>     > -<br>
>>     > -static int usart_last_close(int major, int minor, void *arg)<br>
>>     > -{<br>
>>     > -  return 0;<br>
>>     > -}<br>
>>     > -<br>
>>     > -static int usart_read_polled(int minor)<br>
>>     > -{<br>
>>     > -  if (minor == 0) {<br>
>>     > -    if (((BCM2835_REG(BCM2835_UART0_FR)) & BCM2835_UART0_FR_RXFE)<br>
>>     == 0) {<br>
>>     > -       return((BCM2835_REG(BCM2835_UART0_DR)) & 0xFF );<br>
>>     > -    } else {<br>
>>     > -      return -1;<br>
>>     > -    }<br>
>>     > -  } else {<br>
>>     > -    printk("Unknown console minor number: %d\n", minor);<br>
>>     > -    return -1;<br>
>>     > -  }<br>
>>     > -}<br>
>>     > -<br>
>>     > -static void usart_write_polled(int minor, char c)<br>
>>     > -{<br>
>>     > -   while (1) {<br>
>>     > -     if ((BCM2835_REG(BCM2835_UART0_FR) & BCM2835_UART0_FR_TXFF)<br>
>>     == 0)<br>
>>     > -       break;<br>
>>     > -   }<br>
>>     > -   BCM2835_REG(BCM2835_UART0_DR) = c;<br>
>>     > -}<br>
>>     > -<br>
>>     > -static ssize_t usart_write_support_polled(<br>
>>     > -  int minor,<br>
>>     > -  const char *s,<br>
>>     > -  size_t n<br>
>>     > -)<br>
>>     > -{<br>
>>     > -  ssize_t i = 0;<br>
>>     > -<br>
>>     > -  for (i = 0; i < n; ++i) {<br>
>>     > -    usart_write_polled(minor, s [i]);<br>
>>     > -  }<br>
>>     > -<br>
>>     > -  return n;<br>
>>     > -}<br>
>>     > -<br>
>>     > -static int usart_set_attributes(int minor, const struct termios<br>
>>     *term)<br>
>>     > -{<br>
>>     > -  return -1;<br>
>>     > -}<br>
>>     > -<br>
>>     > -const console_fns bcm2835_usart_fns = {<br>
>>     > -  .deviceProbe = libchip_serial_default_probe,<br>
>>     > -  .deviceFirstOpen = usart_first_open,<br>
>>     > -  .deviceLastClose = usart_last_close,<br>
>>     > -  .deviceRead = usart_read_polled,<br>
>>     > -  .deviceWrite = usart_write_support_polled,<br>
>>     > -  .deviceInitialize = usart_initialize,<br>
>>     > -  .deviceWritePolled = usart_write_polled,<br>
>>     > -  .deviceSetAttributes = usart_set_attributes,<br>
>>     > -  .deviceOutputUsesInterrupts = false<br>
>>     > -};<br>
>>     > diff --git a/bsps/arm/raspberrypi/include/bsp/fbcons.h<br>
>>     b/bsps/arm/raspberrypi/include/bsp/fbcons.h<br>
>>     > index d0e126699a..85b16fafe9 100644<br>
>>     > --- a/bsps/arm/raspberrypi/include/bsp/fbcons.h<br>
>>     > +++ b/bsps/arm/raspberrypi/include/bsp/fbcons.h<br>
>>     > @@ -33,12 +33,27 @@ extern "C" {<br>
>>     > <br>
>>     >  #define FB_CONSOLE 0x50492835<br>
>>     > <br>
>>     > -bool fbcons_probe( int minor );<br>
>>     > +bool fbcons_probe(<br>
>>     > +  rtems_termios_device_context *base<br>
>>     > + );<br>
>>     > +<br>
>>     > +void fbcons_write_polled(<br>
>>     > +  rtems_termios_device_context *base,<br>
>>     > +  char c<br>
>>     > +);<br>
>>     > +<br>
>>     > +int fbcons_inbyte_nonblocking_polled(<br>
>>     > +  rtems_termios_device_context *base<br>
>>     > +);<br>
>>     > +<br>
>>     > +typedef struct {<br>
>>     > +    rtems_termios_device_context base;<br>
>>     > +} rpi_fb_context ;<br>
>>     > <br>
>>     >  /*<br>
>>     >   * Driver function table<br>
>>     >   */<br>
>>     > -extern const console_fns fbcons_fns;<br>
>>     > +extern const rtems_termios_device_handler fbcons_fns;<br>
>>     > <br>
>>     >  #ifdef __cplusplus<br>
>>     >  }<br>
>>     > diff --git a/bsps/arm/raspberrypi/include/bsp/raspberrypi.h<br>
>>     b/bsps/arm/raspberrypi/include/bsp/raspberrypi.h<br>
>>     > index 40c80cf408..4e5c84c741 100644<br>
>>     > --- a/bsps/arm/raspberrypi/include/bsp/raspberrypi.h<br>
>>     > +++ b/bsps/arm/raspberrypi/include/bsp/raspberrypi.h<br>
>>     > @@ -60,6 +60,22 @@<br>
>>     > <br>
>>     >  #define RPI_PERIPHERAL_SIZE         0x01000000<br>
>>     > <br>
>>     > +/**<br>
>>     > + * @name Current Serial Device<br>
>>     > + *<br>
>>     > + * @{<br>
>>     > + */<br>
>>     > +<br>
>>     > +typedef enum {<br>
>>     > +  PL011 = 0,<br>
>>     > +  AUX_UART,<br>
>>     > +  FB<br>
>>     > +}CURRENT_SERIAL;<br>
>>     > +<br>
>>     > +extern CURRENT_SERIAL SERIAL;<br>
>>     > +<br>
>>     > +/** @} */<br>
>>     > +<br>
>>     >  /**<br>
>>     >   * @name Internal ARM Timer Registers<br>
>>     >   *<br>
>>     > @@ -184,42 +200,6 @@<br>
>>     > <br>
>>     >  /** @} */<br>
>>     > <br>
>>     > -/**<br>
>>     > - * @name UART 0 (PL011) Registers<br>
>>     > - *<br>
>>     > - * @{<br>
>>     > - */<br>
>>     > -<br>
>>     > -#define BCM2835_UART0_BASE       (RPI_PERIPHERAL_BASE + 0x201000)<br>
>>     > -<br>
>>     > -#define BCM2835_UART0_DR         (BCM2835_UART0_BASE + 0x00)<br>
>>     > -#define BCM2835_UART0_RSRECR     (BCM2835_UART0_BASE + 0x04)<br>
>>     > -#define BCM2835_UART0_FR         (BCM2835_UART0_BASE + 0x18)<br>
>>     > -#define BCM2835_UART0_ILPR       (BCM2835_UART0_BASE + 0x20)<br>
>>     > -#define BCM2835_UART0_IBRD       (BCM2835_UART0_BASE + 0x24)<br>
>>     > -#define BCM2835_UART0_FBRD       (BCM2835_UART0_BASE + 0x28)<br>
>>     > -#define BCM2835_UART0_LCRH       (BCM2835_UART0_BASE + 0x2C)<br>
>>     > -#define BCM2835_UART0_CR         (BCM2835_UART0_BASE + 0x30)<br>
>>     > -#define BCM2835_UART0_IFLS       (BCM2835_UART0_BASE + 0x34)<br>
>>     > -#define BCM2835_UART0_IMSC       (BCM2835_UART0_BASE + 0x38)<br>
>>     > -#define BCM2835_UART0_RIS        (BCM2835_UART0_BASE + 0x3C)<br>
>>     > -#define BCM2835_UART0_MIS        (BCM2835_UART0_BASE + 0x40)<br>
>>     > -#define BCM2835_UART0_ICR        (BCM2835_UART0_BASE + 0x44)<br>
>>     > -#define BCM2835_UART0_DMACR      (BCM2835_UART0_BASE + 0x48)<br>
>>     > -#define BCM2835_UART0_ITCR       (BCM2835_UART0_BASE + 0x80)<br>
>>     > -#define BCM2835_UART0_ITIP       (BCM2835_UART0_BASE + 0x84)<br>
>>     > -#define BCM2835_UART0_ITOP       (BCM2835_UART0_BASE + 0x88)<br>
>>     > -#define BCM2835_UART0_TDR        (BCM2835_UART0_BASE + 0x8C)<br>
>>     > -<br>
>>     > -#define BCM2835_UART0_MIS_RX    0x10<br>
>>     > -#define BCM2835_UART0_MIS_TX    0x20<br>
>>     > -#define BCM2835_UART0_IMSC_RX   0x10<br>
>>     > -#define BCM2835_UART0_IMSC_TX   0x20<br>
>>     > -#define BCM2835_UART0_FR_RXFE   0x10<br>
>>     > -#define BCM2835_UART0_FR_TXFF   0x20<br>
>>     > -#define BCM2835_UART0_ICR_RX    0x10<br>
>>     > -#define BCM2835_UART0_ICR_TX    0x20<br>
>>     > -<br>
>>     >  /** @} */<br>
>>     > <br>
>>     >  /**<br>
>>     > diff --git a/bsps/arm/raspberrypi/include/bsp/usart.h<br>
>>     b/bsps/arm/raspberrypi/include/bsp/usart.h<br>
>>     > index d3e710c5e9..abbf53626c 100644<br>
>>     > --- a/bsps/arm/raspberrypi/include/bsp/usart.h<br>
>>     > +++ b/bsps/arm/raspberrypi/include/bsp/usart.h<br>
>>     > @@ -32,9 +32,8 @@<br>
>>     >  extern "C" {<br>
>>     >  #endif /* __cplusplus */<br>
>>     > <br>
>>     > -#define USART0_DEFAULT_BAUD 115000<br>
>>     > -<br>
>>     > -extern const console_fns bcm2835_usart_fns;<br>
>>     > +#define PL011_DEFAULT_BAUD 115000<br>
>>     > +#define BCM2835_PL011_BASE (RPI_PERIPHERAL_BASE + 0x201000)<br>
>>     > <br>
>>     >  #ifdef __cplusplus<br>
>>     >  }<br>
>>     > diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am<br>
>>     b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am<br>
>>     > index 11a22f89e3..ce91527f92 100644<br>
>>     > --- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am<br>
>>     > +++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am<br>
>>     > @@ -63,14 +63,15 @@ librtemsbsp_a_SOURCES +=<br>
>>     ../../../../../../bsps/arm/shared/cp15/arm-cp15-set-exc<br>
>>     >  librtemsbsp_a_SOURCES +=<br>
>>     ../../../../../../bsps/arm/raspberrypi/irq/irq.c<br>
>>     > <br>
>>     >  # Console<br>
>>     > -librtemsbsp_a_SOURCES +=<br>
>>     ../../../../../../bsps/shared/dev/serial/legacy-console.c<br>
>>     > -librtemsbsp_a_SOURCES +=<br>
>>     ../../../../../../bsps/shared/dev/serial/legacy-console-control.c<br>
>>     >  librtemsbsp_a_SOURCES +=<br>
>>     ../../../../../../bsps/arm/raspberrypi/console/console-config.c<br>
>>     >  librtemsbsp_a_SOURCES +=<br>
>>     ../../../../../../bsps/arm/raspberrypi/console/console_select.c<br>
>>     >  librtemsbsp_a_SOURCES +=<br>
>>     ../../../../../../bsps/arm/raspberrypi/console/usart.c<br>
>>     >  librtemsbsp_a_SOURCES +=<br>
>>     ../../../../../../bsps/arm/raspberrypi/console/fb.c<br>
>>     >  librtemsbsp_a_SOURCES +=<br>
>>     ../../../../../../bsps/arm/raspberrypi/console/fbcons.c<br>
>>     >  librtemsbsp_a_SOURCES +=<br>
>>     ../../../../../../bsps/arm/raspberrypi/console/outch.c<br>
>>     > +librtemsbsp_a_SOURCES +=<br>
>>     ../../../../../../bsps/shared/dev/serial/console-termios.c<br>
>>     > +librtemsbsp_a_SOURCES +=<br>
>>     ../../../../../../bsps/shared/dev/serial/console-termios-init.c<br>
>>     > +librtemsbsp_a_SOURCES +=<br>
>>     ../../../../../../bsps/arm/shared/serial/arm-pl011.c<br>
>>     > <br>
>>     >  # Mailbox<br>
>>     >  librtemsbsp_a_SOURCES +=<br>
>>     ../../../../../../bsps/arm/raspberrypi/start/mailbox.c<br>
>>     ><br>
>><br>
> _______________________________________________<br>
> devel mailing list<br>
> <a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
> <a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
> <br>
</blockquote></div></div>