<div dir="ltr">Is there any way to test and debug this? Maybe using GDB to<div>see if a proper node is getting selected or not?</div><div><br></div><div>My plan is to remove console_select.c and usart.c files. And do all of the initialization in</div><div>the console-config.c. I looked at some of the device files from FreeBSD, the address for the</div><div>peripheral's are the virtual address or the bus address, so I will convert them to arm physical</div><div>addresses, using a macro, which subtracts an offset to get the physical address.</div><div>For finding the UART ports, we could traverse through the alias node. For rpi1 and rpi2 there should be just one(uart0), but</div><div>for newer models, there would two (uart0 and uart1). And then read the stdout-path to find the serial that has to be used.</div><div>And in console_initialize function, we should also parse the cmdline to find if FB is to be used. And link the appropriate</div><div>driver to /dev/console. But how to handle the different types of device instances? for all the bsp's that I used as reference,</div><div>all the uart devices were of same type, but here we have 3 different serial devices.</div><div>My idea is manually intialize the devices, that is to traverse the alias node, and intialize uart0 to pl011 and uart1 to aux if<br></div><div>it is available. and then seperately intialize the FB, Is there any better way to do it?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Dec 29, 2019 at 2:11 AM Christian Mauderer <<a href="mailto:list@c-mauderer.de">list@c-mauderer.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 28/12/2019 20:03, Niteesh wrote:<br>
> I will start working on a patch that uses FDT. Instead of merging this<br>
> I create a patch v3 that uses FDT. Shall I remove some files, I will be<br>
> heavily using<br>
> the imx and other FDT based drivers as a reference.<br>
<br>
You can remove everything that is no longer used. I expect that it will<br>
be mainly the files containing the table based selection and console<br>
selection code.<br>
<br>
> <br>
> On Sun, Dec 29, 2019 at 12:27 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>
> On 28/12/2019 19:48, Niteesh wrote:<br>
> > Is bsp_console_select legacy? And the new way will be by linking<br>
> > the correct serial device to /dev/console in<br>
> console_initialization, right?<br>
> > If so, shall I add one?<br>
> <br>
> The function is only called from legacy-console.c. So yes: This function<br>
> can be removed. The logic on the other hand should move to somewhere<br>
> else.<br>
> <br>
> The console-termios-init.c creates a link named CONSOLE_DEVICE_NAME. So<br>
> you can't use that code and create your link manually. If you use the<br>
> table based approach (which is OK as a first step) you can't really<br>
> select the console.<br>
> <br>
> I would suggest to either clean that patch up so it can be merged and<br>
> move to a fdt based approach simmilar to imx in a second patch. In that<br>
> case the console_initialize() function from console-termios-init.c will<br>
> be replaced by a custom function that searches the FDT for the devices.<br>
> The FDT will make it simpler to adapt to RPi3. Or if you prefere it you<br>
> can do that right now and create a patch v3 that directly uses FDT.<br>
> <br>
> ><br>
> > On Sat, Dec 28, 2019 at 11:50 PM Niteesh <<a href="mailto:gsnb.gn@gmail.com" target="_blank">gsnb.gn@gmail.com</a><br>
> <mailto:<a href="mailto:gsnb.gn@gmail.com" target="_blank">gsnb.gn@gmail.com</a>><br>
> > <mailto:<a href="mailto:gsnb.gn@gmail.com" target="_blank">gsnb.gn@gmail.com</a> <mailto:<a href="mailto:gsnb.gn@gmail.com" target="_blank">gsnb.gn@gmail.com</a>>>> wrote:<br>
> ><br>
> > I am sorry if this question sounds silly, but how can I access the<br>
> > output_char_fb if it<br>
> > is marked as static in console-select.c, currently the fb<br>
> context is<br>
> > in console-config.c<br>
> > Should I move the BSP_select_function to console-config? for<br>
> shall I<br>
> > remove the static qualifier<br>
> > from the function?<br>
> ><br>
> > Currently, the console_select has 2 functions,<br>
> bsp_Is_Available and<br>
> > bsp_console_select.<br>
> ><br>
> > On Sat, Dec 28, 2019 at 11:30 PM Niteesh <<a href="mailto:gsnb.gn@gmail.com" target="_blank">gsnb.gn@gmail.com</a><br>
> <mailto:<a href="mailto:gsnb.gn@gmail.com" target="_blank">gsnb.gn@gmail.com</a>><br>
> > <mailto:<a href="mailto:gsnb.gn@gmail.com" target="_blank">gsnb.gn@gmail.com</a> <mailto:<a href="mailto:gsnb.gn@gmail.com" target="_blank">gsnb.gn@gmail.com</a>>>> wrote:<br>
> ><br>
> > On Sat, Dec 28, 2019 at 11:12 PM Christian Mauderer<br>
> > <<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<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> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>>>> wrote:<br>
> ><br>
> > On 28/12/2019 17:22, Niteesh wrote:<br>
> > > I think you misunderstood, I was talking about the<br>
> casting<br>
> > in the<br>
> > > rtems_termios_device_handler<br>
> ><br>
> > Yes, I misunderstood you there.<br>
> ><br>
> > > const rtems_termios_device_handler fbcons_fns =<br>
> > > {<br>
> > > .first_open = fbcons_open,<br>
> > > .last_close = fbcons_close,<br>
> > > .poll_read = fbcons_inbyte_nonblocking_polled,<br>
> > > .write = (void (*)(rtems_termios_device_context *,<br>
> const<br>
> > char *,<br>
> > > size_t))fbcons_write_support_polled,<br>
> > > .set_attributes = fbcons_set_attributes,<br>
> > > .mode = TERMIOS_POLLED<br>
> > > };<br>
> > ><br>
> > > the write requires a function type of<br>
> > > *void (*write)(<br>
> > > rtems_termios_device_context *context,<br>
> > > const char *buf,<br>
> > > size_t len<br>
> > > );*<br>
> > ><br>
> > > but the fbcons function is of type<br>
> > > *static ssize_t fbcons_write_support_polled(<br>
> > > rtems_termios_device_context *base,<br>
> > > const char *buf,<br>
> > > size_t len<br>
> > > )*<br>
> > ><br>
> > > Well, if the above cast in the device handler causes a<br>
> > problem, can you<br>
> > > elaborate more on<br>
> > > what kind of a problem would it be?<br>
> ><br>
> > In that case it should work. But why do you need to<br>
> cast it<br>
> > there?<br>
> > Wouldn't it be simpler to just change the<br>
> > fbcons_write_support_polled<br>
> > function? It isn't used anywhere else or did I miss<br>
> something?<br>
> ><br>
> > No, it is not used anywhere. I'll change the function. <br>
> ><br>
> > ><br>
> > > And for the BSP_output_char function, I used a function<br>
> > pointer. The<br>
> > > console_select assigns the<br>
> > > appropriate function to the function pointer and the<br>
> > output_char call's<br>
> > > it by providing the context.<br>
> > > static void output_char(char c)<br>
> > > {<br>
> > > const console_device *dev =<br>
> > &console_device_table[console_select];<br>
> > > rtems_termios_device_context *con = dev->context;<br>
> > > console_instance(con, c);<br>
> > > }<br>
> > > console_instance is the function pointer, which is<br>
> assigned to<br>
> > > arm_pl011_write_polled by<br>
> > > default, or to fbcons_write_polled, if frame buffer is<br>
> > decided to be used.<br>
> ><br>
> ><br>
> > Yes it will work and it's resonable performant. We are<br>
> > talking about a<br>
> > slow serial interface in an exception case. But anyway I'm<br>
> > not entirely<br>
> > happy.<br>
> ><br>
> > The compiler should make something like the following<br>
> out of it:<br>
> ><br>
> > - Look up and call the value of BSP_output_char<br>
> > - Load the context (start of table + console_select +<br>
> fixed<br>
> > offset) into<br>
> > "con"<br>
> > - Look up and call the value of console_instance<br>
> ><br>
> > If you use the way I suggested below you will have<br>
> about the<br>
> > following:<br>
> ><br>
> > - Look up and call the value of BSP_output_char (one<br>
> of the<br>
> > wrappers)<br>
> > - Call the right function with a fixed parameter<br>
> ><br>
> > So it's a bit shorter and beneath that you save a global<br>
> > variable.<br>
> ><br>
> > Sure, will change it.<br>
> ><br>
> > ><br>
> > > On Sat, Dec 28, 2019 at 8:50 PM Christian Mauderer<br>
> > <<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<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> <mailto:<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><br>
> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>> <mailto:<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>>>>><br>
> > wrote:<br>
> > ><br>
> > > On 28/12/2019 14:10, G S Niteesh wrote:<br>
> > > > The patch updates the older console interface used<br>
> > by the BSP,<br>
> > > > to newer one. It also replaces the custom<br>
> > usart(PL011) driver<br>
> > > > with arm-pl011. The fb function's signatures where<br>
> > also changed<br>
> > > > to accommodate with interface update.<br>
> > > > Update #3034<br>
> > > > ---<br>
> > > > bsps/arm/raspberrypi/console/console-config.c<br>
> | 62<br>
> > ++++----<br>
> > > > bsps/arm/raspberrypi/console/console_select.c<br>
> | 68<br>
> > ++-------<br>
> > > > bsps/arm/raspberrypi/console/fbcons.c <br>
> | 71<br>
> > ++++-----<br>
> > > > bsps/arm/raspberrypi/console/usart.c <br>
> | 142<br>
> > > ------------------<br>
> > > > bsps/arm/raspberrypi/include/bsp/fbcons.h <br>
> | 19 ++-<br>
> > > > .../arm/raspberrypi/include/bsp/raspberrypi.h<br>
> | 70<br>
> > +++++----<br>
> > > > bsps/arm/raspberrypi/include/bsp/usart.h <br>
> | 5 +-<br>
> > > > c/src/lib/libbsp/arm/raspberrypi/Makefile.am <br>
> | 5 +-<br>
> > > > 8 files changed, 136 insertions(+), 306<br>
> deletions(-)<br>
> > > ><br>
> > > > diff --git<br>
> > a/bsps/arm/raspberrypi/console/console-config.c<br>
> > > b/bsps/arm/raspberrypi/console/console-config.c<br>
> > > > index d2186c918b..f479e19d99 100644<br>
> > > > ---<br>
> a/bsps/arm/raspberrypi/console/console-config.c<br>
> > > > +++<br>
> b/bsps/arm/raspberrypi/console/console-config.c<br>
> > > > @@ -22,45 +22,47 @@<br>
> > > > <br>
> > > > #include <libchip/serial.h><br>
> > > > <br>
> > > > -#include <bspopts.h><br>
> > > > -#include <bsp/irq.h><br>
> > > > -#include <bsp/usart.h><br>
> > > > +#include <bsp.h><br>
> > > > #include <bsp/raspberrypi.h><br>
> > > > +#include <bsp/usart.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 =<br>
> > 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 =<br>
> > RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("FB")<br>
> > > > +};<br>
> > > > +<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>
> > > > + .probe = fbcons_probe,<br>
> > > > + .handler = &fbcons_fns,<br>
> > > > + .context = &fb_context.base<br>
> > > > + }<br>
> > > > +};<br>
> > > > <br>
> > > > -unsigned long Console_Configuration_Count =<br>
> PORT_COUNT;<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<br>
> > [Console_Port_Minor].pDeviceFns;<br>
> > > > -<br>
> > > > - con->deviceWritePolled((int)<br>
> Console_Port_Minor, c);<br>
> > > > + const console_device *dev =<br>
> > &console_device_table[console_select];<br>
> > > > + rtems_termios_device_context *con =<br>
> dev->context;<br>
> > > > + console_instance(con, c);<br>
> > > > }<br>
> > ><br>
> > > I'm still not happy with that. What I had in<br>
> mind was<br>
> > more or less:<br>
> > ><br>
> > ><br>
> > > static void output_char_serial(char c)<br>
> > > {<br>
> > > arm_pl011_write_polled(&pl011_context.base, c);<br>
> > > }<br>
> > ><br>
> > > static void output_char_fb(char c)<br>
> > > {<br>
> > > fbcons_write_polled(&fb_context.base, c);<br>
> > > }<br>
> > ><br>
> > > BSP_output_char_function_type BSP_output_char =<br>
> > output_char_serial;<br>
> > ><br>
> > ><br>
> > > And if you decide that the frame buffer should<br>
> be used<br>
> > in the select<br>
> > > function you do a<br>
> > ><br>
> > > BSP_output_char = output_char_fb;<br>
> > ><br>
> > > > <br>
> > > > BSP_output_char_function_type BSP_output_char =<br>
> > output_char;<br>
> > > > diff --git<br>
> > a/bsps/arm/raspberrypi/console/console_select.c<br>
> > > b/bsps/arm/raspberrypi/console/console_select.c<br>
> > > > index bd246ca868..ea3325266f 100644<br>
> > > > ---<br>
> a/bsps/arm/raspberrypi/console/console_select.c<br>
> > > > +++<br>
> b/bsps/arm/raspberrypi/console/console_select.c<br>
> > > > @@ -15,69 +15,40 @@<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.h><br>
> > > > +#include <bsp/raspberrypi.h><br>
> > > > +#include <bsp/arm-pl011.h><br>
> > > > +#include <bsp/fbcons.h><br>
> > > > +#include <bsp/rpi-fb.h><br>
> > > > #include <bsp/fatal.h><br>
> > > > +#include <bsp/console-termios.h><br>
> > > > +<br>
> > > > #include <rtems/libio.h><br>
> > > > #include <stdlib.h><br>
> > > > #include <string.h><br>
> > > > #include <assert.h><br>
> > > > #include <termios.h><br>
> > > > <br>
> > > > -#include <rtems/termiostypes.h><br>
> > > > #include <libchip/serial.h><br>
> > > > -#include<br>
> "../../shared/dev/serial/legacy-console.h"<br>
> > > > -#include <bsp/rpi-fb.h><br>
> > > > <br>
> > > > -rtems_device_minor_number BSPPrintkPort = 0;<br>
> > > > +int console_select = PL011;<br>
> > > > +console console_instance =<br>
> arm_pl011_write_polled;<br>
> > > > <br>
> > > > -/*<br>
> > > > - * Method to return true if the device associated<br>
> > with the<br>
> > > > - * minor number probs available.<br>
> > > > - */<br>
> > > > -static bool bsp_Is_Available(<br>
> > rtems_device_minor_number minor )<br>
> > > > +static bool bsp_Is_Available( int index )<br>
> > > > {<br>
> > > > - console_tbl *cptr = Console_Port_Tbl[ minor ];<br>
> > > > -<br>
> > > > + const console_device *dev =<br>
> > &console_device_table[index];<br>
> > > > + rtems_termios_device_context *con =<br>
> dev->context;<br>
> > > > /*<br>
> > > > * First perform the configuration dependent<br>
> > probe, then the<br>
> > > > * device dependent probe<br>
> > > > */<br>
> > > > - if ( ( !cptr->deviceProbe || cptr->deviceProbe(<br>
> > minor ) ) &&<br>
> > > > - cptr->pDeviceFns->deviceProbe( minor ) ) {<br>
> > > > + if ( ( !dev->probe || dev->probe( con ) ) ){<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<br>
> > bsp_First_Available_Device( void )<br>
> > > > -{<br>
> > > > - rtems_device_minor_number minor;<br>
> > > > -<br>
> > > > - for ( minor = 0; minor < Console_Port_Count;<br>
> > minor++ ) {<br>
> > > > - console_tbl *cptr = Console_Port_Tbl[<br>
> minor ];<br>
> > > > -<br>
> > > > - /*<br>
> > > > - * First perform the configuration dependent<br>
> > probe, then the<br>
> > > > - * device dependent probe<br>
> > > > - */<br>
> > > > -<br>
> > > > - if ( ( !cptr->deviceProbe ||<br>
> cptr->deviceProbe(<br>
> > minor ) ) &&<br>
> > > > - cptr->pDeviceFns->deviceProbe( minor<br>
> ) ) {<br>
> > > > - return minor;<br>
> > > > - }<br>
> > > > - }<br>
> > > > -<br>
> > > > - /*<br>
> > > > - * Error No devices were found. We will<br>
> want to<br>
> > bail here.<br>
> > > > - */<br>
> > > > - bsp_fatal( BSP_FATAL_CONSOLE_NO_DEV );<br>
> > > > -}<br>
> > > > -<br>
> > > > void bsp_console_select( void )<br>
> > > > {<br>
> > > > /*<br>
> > > > @@ -90,25 +61,18 @@ void bsp_console_select(<br>
> 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(<br>
> "fbcons" )<br>
> > - 1 ) == 0 ) {<br>
> > > > if ( rpi_video_is_initialized() > 0 ) {<br>
> > > > - Console_Port_Minor = BSP_CONSOLE_FB;<br>
> > > > - BSPPrintkPort = BSP_CONSOLE_FB;<br>
> > > > + console_select = FB;<br>
> > > > + console_instance = fbcons_write_polled;<br>
> > > > }<br>
> > > > }<br>
> > > > }<br>
> > > > <br>
> > > > - /*<br>
> > > > - * If the device that was selected isn't<br>
> > available then<br>
> > > > - * let the user know and select the first<br>
> > available device.<br>
> > > > - */<br>
> > > > - if ( !bsp_Is_Available( Console_Port_Minor<br>
> ) ) {<br>
> > > > - Console_Port_Minor =<br>
> bsp_First_Available_Device();<br>
> > > > + if( !bsp_Is_Available( console_select ) ){<br>
> > > > + bsp_fatal( BSP_FATAL_CONSOLE_NO_DEV );<br>
> > > > }<br>
> > > > }<br>
> > > > diff --git a/bsps/arm/raspberrypi/console/fbcons.c<br>
> > > b/bsps/arm/raspberrypi/console/fbcons.c<br>
> > > > index 3669ba458d..6e710e252d 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>
> > > > @@ -29,15 +30,6 @@<br>
> > > > #include <bsp/vc.h><br>
> > > > #include <bsp/rpi-fb.h><br>
> > > > <br>
> > > > -/*<br>
> > > > - * fbcons_init<br>
> > > > - *<br>
> > > > - * This function initializes the fb console to a<br>
> > quiecsent state.<br>
> > > > - */<br>
> > > > -static void fbcons_init( int minor )<br>
> > > > -{<br>
> > > > -}<br>
> > > > -<br>
> > > > /*<br>
> > > > * fbcons_open<br>
> > > > *<br>
> > > > @@ -45,13 +37,14 @@ static void fbcons_init(<br>
> int minor )<br>
> > > > *<br>
> > > > * Default state is 9600 baud, 8 bits, No<br>
> parity,<br>
> > and 1 stop bit.<br>
> > > > */<br>
> > > > -static int fbcons_open(<br>
> > > > - int major,<br>
> > > > - int minor,<br>
> > > > - void *arg<br>
> > > > +static bool fbcons_open(<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>
> > > > + return true;<br>
> > > > }<br>
> > > > <br>
> > > > /*<br>
> > > > @@ -59,13 +52,12 @@ static int fbcons_open(<br>
> > > > *<br>
> > > > * This function shuts down the requested port.<br>
> > > > */<br>
> > > > -static int fbcons_close(<br>
> > > > - int major,<br>
> > > > - int minor,<br>
> > > > - void *arg<br>
> > > > +static void fbcons_close(<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>
> > > > }<br>
> > > > <br>
> > > > /*<br>
> > > > @@ -73,8 +65,8 @@ static int fbcons_close(<br>
> > > > *<br>
> > > > * This routine polls out the requested<br>
> 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 +83,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 +94,7 @@ static ssize_t<br>
> > fbcons_write_support_polled(<br>
> > > > * poll each byte in the string out of the<br>
> 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 +109,9 @@ static ssize_t<br>
> > fbcons_write_support_polled(<br>
> > > > *<br>
> > > > * Console Termios polling input entry point.<br>
> > > > */<br>
> > > > -static int fbcons_inbyte_nonblocking_polled( int<br>
> > minor )<br>
> > > > +int fbcons_inbyte_nonblocking_polled(<br>
> > > > + rtems_termios_device_context *base<br>
> > > > +)<br>
> > > > {<br>
> > > > // if( rtems_kbpoll() ) {<br>
> > > > // int c = getch();<br>
> > > > @@ -133,15 +127,17 @@ static int<br>
> > fbcons_inbyte_nonblocking_polled(<br>
> > > int minor )<br>
> > > > * This function sets the UART channel to<br>
> reflect<br>
> > the requested<br>
> > > termios<br>
> > > > * port settings.<br>
> > > > */<br>
> > > > -static int fbcons_set_attributes(<br>
> > > > - int minor,<br>
> > > > +static bool fbcons_set_attributes(<br>
> > > > + rtems_termios_device_context *base,<br>
> > > > const struct termios *t<br>
> > > > )<br>
> > > > {<br>
> > > > - return 0;<br>
> > > > + return true;<br>
> > > > }<br>
> > > > <br>
> > > > -bool fbcons_probe( int minor )<br>
> > > > +bool fbcons_probe(<br>
> > > > + rtems_termios_device_context *context<br>
> > > > +)<br>
> > > > {<br>
> > > > // rtems_status_code status;<br>
> > > > static bool firstTime = true;<br>
> > > > @@ -163,15 +159,12 @@ bool fbcons_probe( int<br>
> 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, <br>
> > /* deviceProbe */<br>
> > > > - .deviceFirstOpen = fbcons_open, <br>
> /*<br>
> > > deviceFirstOpen */<br>
> > > > - .deviceLastClose = fbcons_close, <br>
> /*<br>
> > > deviceLastClose */<br>
> > > > - .deviceRead = fbcons_inbyte_nonblocking_polled,<br>
> > /* deviceRead */<br>
> > > > - .deviceWrite = fbcons_write_support_polled, <br>
> > /* deviceWrite */<br>
> > > > - .deviceInitialize = fbcons_init, <br>
> /*<br>
> > > deviceInitialize */<br>
> > > > - .deviceWritePolled = fbcons_write_polled, <br>
> /*<br>
> > > deviceWritePolled */<br>
> > > > - .deviceSetAttributes =<br>
> fbcons_set_attributes, /*<br>
> > > deviceSetAttributes */<br>
> > > > - .deviceOutputUsesInterrupts = FALSE, <br>
> /*<br>
> > > deviceOutputUsesInterrupts*/<br>
> > > > -};<br>
> > > > + .first_open = fbcons_open,<br>
> > > > + .last_close = fbcons_close,<br>
> > > > + .poll_read = fbcons_inbyte_nonblocking_polled,<br>
> > > > + .write = (void (*)(rtems_termios_device_context<br>
> > *, const char<br>
> > > *, size_t))fbcons_write_support_polled,<br>
> > > > + .set_attributes = fbcons_set_attributes,<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<br>
> > interrupt<br>
> > > driven IO.<br>
> > > > - */<br>
> > > > -static rtems_vector_number<br>
> > usart_get_irq_number(const console_tbl<br>
> > > *ct)<br>
> > > > -{<br>
> > > > - return ct->ulIntVector;<br>
> > > > -}<br>
> > > > -<br>
> > > > -static uint32_t usart_get_baud(const<br>
> 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) =<br>
> > (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) =<br>
> > BCM2835_UART0_IMSC_RX;<br>
> > > > -<br>
> > > > - usart_set_baud(minor, 115000);<br>
> > > > -}<br>
> > > > -<br>
> > > > -static int usart_first_open(int major, int minor,<br>
> > 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<br>
> > rtems_termios_tty *)<br>
> > > oc->iop->data1;<br>
> > > > - const console_tbl *ct = Console_Port_Tbl<br>
> [minor];<br>
> > > > - console_data *cd = &Console_Port_Data [minor];<br>
> > > > -<br>
> > > > - cd->termios_data = tty;<br>
> > > > - rtems_termios_set_initial_baud(tty,<br>
> ct->ulClock);<br>
> > > > -<br>
> > > > - return 0;<br>
> > > > -}<br>
> > > > -<br>
> > > > -static int usart_last_close(int major, int minor,<br>
> > 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)) &<br>
> > BCM2835_UART0_FR_RXFE)<br>
> > > == 0) {<br>
> > > > - return((BCM2835_REG(BCM2835_UART0_DR))<br>
> & 0xFF );<br>
> > > > - } else {<br>
> > > > - return -1;<br>
> > > > - }<br>
> > > > - } else {<br>
> > > > - printk("Unknown console minor number: %d\n",<br>
> > 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) &<br>
> > 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<br>
> > 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<br>
> a/bsps/arm/raspberrypi/include/bsp/fbcons.h<br>
> > > b/bsps/arm/raspberrypi/include/bsp/fbcons.h<br>
> > > > index d0e126699a..e3d9e69ff5 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<br>
> fbcons_fns;<br>
> > > > <br>
> > > > #ifdef __cplusplus<br>
> > > > }<br>
> > > > diff --git<br>
> > a/bsps/arm/raspberrypi/include/bsp/raspberrypi.h<br>
> > > b/bsps/arm/raspberrypi/include/bsp/raspberrypi.h<br>
> > > > index 40c80cf408..2ccc49846c 100644<br>
> > > > ---<br>
> a/bsps/arm/raspberrypi/include/bsp/raspberrypi.h<br>
> > > > +++<br>
> b/bsps/arm/raspberrypi/include/bsp/raspberrypi.h<br>
> > > > @@ -24,6 +24,7 @@<br>
> > > > #include <bspopts.h><br>
> > > > #include <stdint.h><br>
> > > > #include <bsp/utility.h><br>
> > > > +#include <rtems/termiostypes.h><br>
> > > > <br>
> > > > /**<br>
> > > > * @defgroup raspberrypi_reg Register Definitions<br>
> > > > @@ -60,6 +61,39 @@<br>
> > > > <br>
> > > > #define RPI_PERIPHERAL_SIZE 0x01000000<br>
> > > > <br>
> > > > +/**<br>
> > > > + * @name Console select definitions<br>
> > > > + *<br>
> > > > + * @{<br>
> > > > + */<br>
> > > > +<br>
> > > > +#define PL011 0<br>
> > > > +#define FB 1<br>
> > > > +<br>
> > > > +/** @} */<br>
> > > > +<br>
> > > > +/**<br>
> > > > + * @name Console select<br>
> > > > + *<br>
> > > > + * @{<br>
> > > > + */<br>
> > > > +<br>
> > > > +extern int console_select;<br>
> > > > +<br>
> > > > +/** @} */<br>
> > > > +<br>
> > > > +/**<br>
> > > > + * @name Console select<br>
> > > > + *<br>
> > > > + * @{<br>
> > > > + */<br>
> > > > +<br>
> > > > +typedef void<br>
> > (*console)(rtems_termios_device_context *, char c);<br>
> > > > +extern console console_instance;<br>
> > > > +<br>
> > > > +/** @} */<br>
> > > > +<br>
> > > > +/** @} */<br>
> > > > /**<br>
> > > > * @name Internal ARM Timer Registers<br>
> > > > *<br>
> > > > @@ -184,42 +218,6 @@<br>
> > > > <br>
> > > > /** @} */<br>
> > > > <br>
> > > > -/**<br>
> > > > - * @name UART 0 (PL011) Registers<br>
> > > > - *<br>
> > > > - * @{<br>
> > > > - */<br>
> > > > -<br>
> > > > -#define BCM2835_UART0_BASE <br>
> > (RPI_PERIPHERAL_BASE + 0x201000)<br>
> > > > -<br>
> > > > -#define BCM2835_UART0_DR <br>
> > (BCM2835_UART0_BASE + 0x00)<br>
> > > > -#define BCM2835_UART0_RSRECR <br>
> > (BCM2835_UART0_BASE + 0x04)<br>
> > > > -#define BCM2835_UART0_FR <br>
> > (BCM2835_UART0_BASE + 0x18)<br>
> > > > -#define BCM2835_UART0_ILPR <br>
> > (BCM2835_UART0_BASE + 0x20)<br>
> > > > -#define BCM2835_UART0_IBRD <br>
> > (BCM2835_UART0_BASE + 0x24)<br>
> > > > -#define BCM2835_UART0_FBRD <br>
> > (BCM2835_UART0_BASE + 0x28)<br>
> > > > -#define BCM2835_UART0_LCRH <br>
> > (BCM2835_UART0_BASE + 0x2C)<br>
> > > > -#define BCM2835_UART0_CR <br>
> > (BCM2835_UART0_BASE + 0x30)<br>
> > > > -#define BCM2835_UART0_IFLS <br>
> > (BCM2835_UART0_BASE + 0x34)<br>
> > > > -#define BCM2835_UART0_IMSC <br>
> > (BCM2835_UART0_BASE + 0x38)<br>
> > > > -#define BCM2835_UART0_RIS <br>
> > (BCM2835_UART0_BASE + 0x3C)<br>
> > > > -#define BCM2835_UART0_MIS <br>
> > (BCM2835_UART0_BASE + 0x40)<br>
> > > > -#define BCM2835_UART0_ICR <br>
> > (BCM2835_UART0_BASE + 0x44)<br>
> > > > -#define BCM2835_UART0_DMACR <br>
> > (BCM2835_UART0_BASE + 0x48)<br>
> > > > -#define BCM2835_UART0_ITCR <br>
> > (BCM2835_UART0_BASE + 0x80)<br>
> > > > -#define BCM2835_UART0_ITIP <br>
> > (BCM2835_UART0_BASE + 0x84)<br>
> > > > -#define BCM2835_UART0_ITOP <br>
> > (BCM2835_UART0_BASE + 0x88)<br>
> > > > -#define BCM2835_UART0_TDR <br>
> > (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<br>
> 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 +<br>
> > 0x201000)<br>
> > > > <br>
> > > > #ifdef __cplusplus<br>
> > > > }<br>
> > > > diff --git<br>
> > 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>
> > > <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>
> > > <br>
> ../../../../../../bsps/shared/dev/serial/legacy-console.c<br>
> > > > -librtemsbsp_a_SOURCES +=<br>
> > > <br>
> > <br>
> ../../../../../../bsps/shared/dev/serial/legacy-console-control.c<br>
> > > > librtemsbsp_a_SOURCES +=<br>
> > > <br>
> > <br>
> ../../../../../../bsps/arm/raspberrypi/console/console-config.c<br>
> > > > librtemsbsp_a_SOURCES +=<br>
> > > <br>
> > <br>
> ../../../../../../bsps/arm/raspberrypi/console/console_select.c<br>
> > > > librtemsbsp_a_SOURCES +=<br>
> > > <br>
> ../../../../../../bsps/arm/raspberrypi/console/usart.c<br>
> > > > librtemsbsp_a_SOURCES +=<br>
> > > ../../../../../../bsps/arm/raspberrypi/console/fb.c<br>
> > > > librtemsbsp_a_SOURCES +=<br>
> > > <br>
> ../../../../../../bsps/arm/raspberrypi/console/fbcons.c<br>
> > > > librtemsbsp_a_SOURCES +=<br>
> > > <br>
> ../../../../../../bsps/arm/raspberrypi/console/outch.c<br>
> > > > +librtemsbsp_a_SOURCES +=<br>
> > > <br>
> ../../../../../../bsps/shared/dev/serial/console-termios.c<br>
> > > > +librtemsbsp_a_SOURCES +=<br>
> > > <br>
> > <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>
> > > <br>
> ../../../../../../bsps/arm/raspberrypi/start/mailbox.c<br>
> > > ><br>
> > ><br>
> ><br>
> <br>
</blockquote></div>