[PATCH v4] Raspberrypi: updated the console interface.

Vijay Kumar Banerjee vijaykumar9597 at gmail.com
Tue Dec 31 17:26:35 UTC 2019


On Tue, Dec 31, 2019 at 9:27 PM Niteesh <gsnb.gn at gmail.com> wrote:

> I tried the above thing it doesn't work :(
> Maybe lets stop with this. And try to get RTEMS working on rpi3
> this way, it will also be easier for me to work. Did you take a look at
> what
> caused the secondary cpu's not to halt? Is there something that I can do?
> Or shall we continue with this? I kind of feel lost and not at all happy
> with my progress.
>
> Hi Niteesh,

(Not commenting on anything technical)

Just wanted to add a famous quote:
"The first 90 percent of the code accounts for the first 90 percent of the
development time. The remaining 10 percent of the code accounts for the
other 90 percent of the development time" — Tom Cargill, Bell Labs
(Wikipedia explains this well
<https://en.wikipedia.org/wiki/Ninety-ninety_rule>)

It always takes more time and much more debugging than it was originally
planned,
you have made quite good progress in figuring out stuff and came up with the
implementation quite quickly. Seems like all that is left is debugging, and
with Christian
helping you, that will be solved quickly as well ;-)

Happy New year :)

PS: I have a pi3 as well, and would love to join the efforts on pi3 after
the exams ;-)

On Tue, Dec 31, 2019 at 8:29 PM Niteesh <gsnb.gn at gmail.com> wrote:
>
>> I have an idea to debug this, but not sure whether it will work or not, I
>> could
>> run raspbian on versatilepb using arm1176 as cpu and 256mb ram
>> this is very much similar to raspi1, I think this one also uses pl011, I
>> remember
>> seeing it in the linux bootup msgs.
>> I could run the examples using qemu using raspi2 as the machine but the
>> dtb
>> file never gets passed to it. The register r2 is 0.
>> qemu-system-arm -M raspi2 -m 1G -kernel fileio.exe -serial mon:stdio
>> -nographic -dtb bcm2709-rpi-2-b.dtb -S -s
>> This is the command I use to run my examples and connect to gdb.
>>
>> On Tue, Dec 31, 2019 at 7:31 PM Christian Mauderer <list at c-mauderer.de>
>> wrote:
>>
>>> On 31/12/2019 14:56, Niteesh wrote:
>>> > If moving uart_probe to output char, then should I move
>>> > rtems_device_handler_install to console_initialize because, my guess
>>> > is that the IO initialization system would not be initialized properly
>>> > at that stage.
>>>
>>> The uart_probe in the output char function should do a really minimal
>>> initialization. Only what is necessary to get the polled uart working.
>>> That one will only be called if you have an exception at a very early
>>> stage. In that case you are working in an exception context.
>>>
>>> >
>>> > When I rename the register_arm_pl011 to init_context_pl011 since it's
>>> is
>>> > only initializing
>>> > the pl011 context, rather than registering it.
>>> >
>>> > On Tue, Dec 31, 2019 at 6:32 PM Christian Mauderer <list at c-mauderer.de
>>> > <mailto:list at c-mauderer.de>> wrote:
>>> >
>>> >     On 31/12/2019 13:22, Niteesh wrote:
>>> >     > It works now, the functions are getting called when used with
>>> >     fileio.exe.
>>> >     > The function bsp_start wants to print information about the
>>> board,
>>> >
>>> >     That print maybe should be moved to a later point. It just fetches
>>> some
>>> >     information and prints it. It doesn't even do anything usefull
>>> >     besides that.
>>> >
>>> >     > but
>>> >     > the console
>>> >     > initialization function is called after bsp_start, assuming that
>>> >     the FDT
>>> >     > works it still
>>> >     > crash since the console still isn't initialized, one way of
>>> fixing
>>> >     this
>>> >     > would be to add uart_probe into
>>> >     > output_char just like in imx, or we could move the printing to
>>> >     somewhere
>>> >     > else.
>>> >
>>> >     That might would be a good idea regardless whether the print is
>>> moved or
>>> >     not. It would allow an early exception to print anything.
>>> >
>>> >     >
>>> >     > On Tue, Dec 31, 2019 at 4:08 PM Christian Mauderer
>>> >     <list at c-mauderer.de <mailto:list at c-mauderer.de>
>>> >     > <mailto:list at c-mauderer.de <mailto:list at c-mauderer.de>>> wrote:
>>> >     >
>>> >     >
>>> >     >
>>> >     >     On 31/12/2019 11:37, Christian Mauderer wrote:
>>> >     >     > On 31/12/2019 06:11, Niteesh wrote:
>>> >     >     >> On Tue, Dec 31, 2019 at 1:13 AM Christian Mauderer
>>> >     >     <list at c-mauderer.de <mailto:list at c-mauderer.de>
>>> >     <mailto:list at c-mauderer.de <mailto:list at c-mauderer.de>>
>>> >     >     >> <mailto:list at c-mauderer.de <mailto:list at c-mauderer.de>
>>> >     <mailto:list at c-mauderer.de <mailto:list at c-mauderer.de>>>> wrote:
>>> >     >     >>
>>> >     >     >>     On 30/12/2019 19:32, Niteesh wrote:
>>> >     >     >>     > Just to make sure that console_initialize and
>>> uart_probe
>>> >     >     are being
>>> >     >     >>     > called, I manually initialized the pl011 context to
>>> print
>>> >     >     something on
>>> >     >     >>     > serial. But they never got called. Can you just
>>> make sure
>>> >     >     that if I am
>>> >     >     >>     > missing something?
>>> >     >     >>
>>> >     >     >>     I don't think that you are missing something but the
>>> >     >     executable is
>>> >     >     >>     missing something: The functions are not linked into
>>> it.
>>> >     >     >>
>>> >     >     >>     C linker can be an odd thing: It links only object
>>> >     files that are
>>> >     >     >>     referenced. You seem to have no reference to
>>> >     >     console-config.c/o from
>>> >     >     >>     anywhere else.
>>> >     >     >>
>>> >     >     >>     RTEMS_SYSINIT_ITEM(
>>> >     >     >>       uart_probe,
>>> >     >     >>       RTEMS_SYSINIT_BSP_START,
>>> >     >     >>       RTEMS_SYSINIT_ORDER_LAST
>>> >     >     >>     );
>>> >     >     >>
>>> >     >     >>     will be only added to the linker set if the file is
>>> >     linked in
>>> >     >     anyway.
>>> >     >     >>
>>> >     >     >>     That is a bit anoying. For the imx BSP there is a UART
>>> >     drain
>>> >     >     function
>>> >     >     >>     that is called from somewhere else. Thats enough to
>>> >     bring the
>>> >     >     file in.
>>> >     >     >>
>>> >     >     >>     I think you'll need to add a reference from somewhere
>>> >     or move
>>> >     >     that stuff
>>> >     >     >>     into another file that is referenced.
>>> >     >     >>
>>> >     >     >>     If you have some init function that has to be called
>>> in
>>> >     every
>>> >     >     case you
>>> >     >     >>     can call it from some other c file where it would fit
>>> too.
>>> >     >     >>
>>> >     >     >>     Otherwise it might is necessary to construct some odd
>>> >     stuff.
>>> >     >     I'm not
>>> >     >     >>     sure whether we already had a case like this. Most
>>> >     likely it
>>> >     >     would be
>>> >     >     >>     necessary to use a RTEMS_LINKER_ROSET_ITEM_REFERENCE
>>> >     for the
>>> >     >     >>     SYSINIT_ITEM. Maybe to define a new
>>> >     >     RTEMS_SYSINIT_ITEM_REFERENCE or
>>> >     >     >>     simmilar. This should be definitively a separate
>>> commit.
>>> >     >     Please ask
>>> >     >     >>     again if you have to go that way.
>>> >     >     >>
>>> >     >     >> I didn't understand the above part. So what I did was
>>> >     created a dummy
>>> >     >     >> function in console-config.c
>>> >     >     >> and referenced in places that I know we're going to be
>>> >     called. But
>>> >     >     >> still, it didn't work.
>>> >     >     >>
>>> >     >     >
>>> >     >     > That's a really mean bug to find:
>>> >     >     >
>>> >     >     > 1. My assumption was wrong. The file is linked in. Most
>>> >     likely due to
>>> >     >     > BSP_output_char which is defined in this file.
>>> >     >     >
>>> >     >     > 2. Please remove console-termios-init.c. It would define
>>> the
>>> >     same
>>> >     >     > console_initialize() function.
>>> >     >
>>> >     >     Just to be clear: Remove it from the
>>> >     >     c/src/lib/libbsp/arm/raspberrypi/Makefile.am file.
>>> >     >
>>> >     >     >
>>> >     >     > 3. The real proble just caused a warning which was a bit
>>> >     hard to spot:
>>> >     >     > The compile doesn't know RTEMS_SYSINIT_ITEM. It thinks it's
>>> >     a function
>>> >     >     > body and warns that it defaults the return type to int. In
>>> other
>>> >     >     words:
>>> >     >     > You missed to include <rtems/sysinit.h>. If you add that
>>> the
>>> >     >     > RTEMS_SYSINIT_ITEM works and uart_probe is linked in.
>>> >     >     >
>>> >     >     > 4. console_initialize is still not used. It is really hard
>>> >     to spot
>>> >     >     why:
>>> >     >     > Most of the tests only use the configuration:
>>> >     >     >
>>> >     >     >     CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
>>> >     >     >
>>> >     >     > This is a simplified polled console driver. From the
>>> samples
>>> >     only
>>> >     >     > capture, fileio and pppd are using the normal console with:
>>> >     >     >
>>> >     >     >     CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
>>> >     >     >
>>> >     >     > So only for these three the console_initialize will be
>>> called.
>>> >     >     >
>>> >     >     > By the way: You can use objdump to analyze your elf-files.
>>> >     For example
>>> >     >     > to get a symbol table use:
>>> >     >     >
>>> >     >     >     arm-rtems5-objdump -t path/to/ticker.exe
>>> >     >     >
>>> >     >     > To get the disassembled code with intermixed c-sources use
>>> >     >     >
>>> >     >     >     arm-rtems5-objdump -dS path/to/ticker.exe
>>> >     >     >
>>> >     >     > That's very usefull to find whether a symbol is linked in
>>> or
>>> >     not.
>>> >     >     >
>>> >     >     >>
>>> >     >     >>
>>> >     >     >>     >
>>> >     >     >>     > While going through the messages from
>>> devel-request, Joel
>>> >     >     mentioned
>>> >     >     >>     > about qemu4 rsb package
>>> >     >     >>     > how is it different from the official qemu?
>>> >     >     >>     >
>>> >     >     >>     > On Mon, Dec 30, 2019 at 11:53 PM G S Niteesh
>>> >     >     <gsnb.gn at gmail.com <mailto:gsnb.gn at gmail.com>
>>> >     <mailto:gsnb.gn at gmail.com <mailto:gsnb.gn at gmail.com>>
>>> >     >     >>     <mailto:gsnb.gn at gmail.com <mailto:gsnb.gn at gmail.com>
>>> >     <mailto:gsnb.gn at gmail.com <mailto:gsnb.gn at gmail.com>>>
>>> >     >     >>     > <mailto:gsnb.gn at gmail.com <mailto:gsnb.gn at gmail.com
>>> >
>>> >     <mailto:gsnb.gn at gmail.com <mailto:gsnb.gn at gmail.com>>
>>> >     >     <mailto:gsnb.gn at gmail.com <mailto:gsnb.gn at gmail.com>
>>> >     <mailto:gsnb.gn at gmail.com <mailto:gsnb.gn at gmail.com>>>>> wrote:
>>> >     >     >>     >
>>> >     >     >>     >     The patch updates the older console interface
>>> used by
>>> >     >     the BSP,
>>> >     >     >>     >     to newer one. It also replaces the custom
>>> >     usart(PL011)
>>> >     >     driver
>>> >     >     >>     >     with arm-pl011. The fb function's signatures
>>> >     where also
>>> >     >     changed
>>> >     >     >>     >     to accommodate with interface update.
>>> >     >     >>     >     Update #3034
>>> >     >     >>     >     ---
>>> >     >     >>     >      bsps/arm/raspberrypi/console/console-config.c
>>> | 186
>>> >     >     >>     ++++++++++++++----
>>> >     >     >>     >      bsps/arm/raspberrypi/console/console_select.c
>>> | 114
>>> >     >     -----------
>>> >     >     >>     >      bsps/arm/raspberrypi/console/fbcons.c
>>>  |  78
>>> >     >     ++++----
>>> >     >     >>     >      bsps/arm/raspberrypi/console/usart.c
>>> | 167
>>> >     >     >>     ----------------
>>> >     >     >>     >      bsps/arm/raspberrypi/include/bsp/fbcons.h
>>>  |
>>> >     21 +-
>>> >     >     >>     >      .../arm/raspberrypi/include/bsp/raspberrypi.h
>>> |
>>> >     48 ++---
>>> >     >     >>     >      bsps/arm/raspberrypi/include/bsp/usart.h
>>> |
>>> >      5 +-
>>> >     >     >>     >      c/src/lib/libbsp/arm/raspberrypi/Makefile.am
>>> |
>>> >      8 +-
>>> >     >     >>     >      8 files changed, 220 insertions(+), 407
>>> deletions(-)
>>> >     >     >>     >      delete mode 100644
>>> >     >     bsps/arm/raspberrypi/console/console_select.c
>>> >     >     >>     >      delete mode 100644
>>> >     bsps/arm/raspberrypi/console/usart.c
>>> >     >     >>     >
>>> >     >     >>     >     diff --git
>>> >     a/bsps/arm/raspberrypi/console/console-config.c
>>> >     >     >>     >     b/bsps/arm/raspberrypi/console/console-config.c
>>> >     >     >>     >     index d2186c918b..021428ff4b 100644
>>> >     >     >>     >     ---
>>> a/bsps/arm/raspberrypi/console/console-config.c
>>> >     >     >>     >     +++
>>> b/bsps/arm/raspberrypi/console/console-config.c
>>> >     >     >>     >     @@ -19,50 +19,164 @@
>>> >     >     >>     >       */
>>> >     >     >>     >
>>> >     >     >>     >      #include <rtems/bspIo.h>
>>> >     >     >>     >     +#include <rtems/console.h>
>>> >     >     >>     >
>>> >     >     >>     >     -#include <libchip/serial.h>
>>> >     >     >>     >
>>> >     >     >>     >     -#include <bspopts.h>
>>> >     >     >>     >     -#include <bsp/irq.h>
>>> >     >     >>     >     -#include <bsp/usart.h>
>>> >     >     >>     >     +#include <bsp.h>
>>> >     >     >>     >      #include <bsp/raspberrypi.h>
>>> >     >     >>     >     +#include <bsp/usart.h>
>>> >     >     >>     >     +#include <bsp/arm-pl011.h>
>>> >     >     >>     >      #include <bsp/fbcons.h>
>>> >     >     >>     >     +#include <bsp/console-termios.h>
>>> >     >     >>     >     +#include <bsp/fdt.h>
>>> >     >     >>     >     +#include <bsp/fatal.h>
>>> >     >     >>     >     +
>>> >     >     >>     >     +#include <bspopts.h>
>>> >     >     >>     >     +
>>> >     >     >>     >     +#include <libfdt.h>
>>> >     >     >>     >     +#include <libchip/serial.h>
>>> >     >     >>     >     +
>>> >     >     >>     >     +arm_pl011_context pl011_context;
>>> >     >     >>     >     +rpi_fb_context fb_context;
>>> >     >     >>
>>> >     >     >>     These could be static.
>>> >     >     >>
>>> >     >     >>     >     +
>>> >     >     >>     >     +static void output_char_serial(char c)
>>> >     >     >>     >     +{
>>> >     >     >>     >     +  arm_pl011_write_polled(&pl011_context.base,
>>> c);
>>> >     >     >>     >     +}
>>> >     >     >>     >     +
>>> >     >     >>     >     +void output_char_fb(char c)
>>> >     >     >>     >     +{
>>> >     >     >>     >     +  fbcons_write_polled(&fb_context.base, c);
>>> >     >     >>     >     +}
>>> >     >     >>     >
>>> >     >     >>     >     -console_tbl Console_Configuration_Ports [] = {
>>> >     >     >>     >     -    {
>>> >     >     >>     >     -      .sDeviceName = "/dev/ttyS0",
>>> >     >     >>     >     -      .deviceType = SERIAL_CUSTOM,
>>> >     >     >>     >     -      .pDeviceFns = &bcm2835_usart_fns,
>>> >     >     >>     >     -      .deviceProbe = NULL,
>>> >     >     >>     >     -      .pDeviceFlow = NULL,
>>> >     >     >>     >     -      .ulCtrlPort1 = BCM2835_UART0_BASE,
>>> >     >     >>     >     -      .ulCtrlPort2 = 0,
>>> >     >     >>     >     -      .ulClock = USART0_DEFAULT_BAUD,
>>> >     >     >>     >     -      .ulIntVector = BCM2835_IRQ_ID_UART
>>> >     >     >>     >     -    },
>>> >     >     >>     >     -    {
>>> >     >     >>     >     -      .sDeviceName ="/dev/fbcons",
>>> >     >     >>     >     -      .deviceType = SERIAL_CUSTOM,
>>> >     >     >>     >     -      .pDeviceFns = &fbcons_fns,
>>> >     >     >>     >     -      .deviceProbe = fbcons_probe,
>>> >     >     >>     >     -      .pDeviceFlow = NULL,
>>> >     >     >>     >     -    },
>>> >     >     >>     >     -};
>>> >     >     >>     >     -
>>> >     >     >>     >     -#define PORT_COUNT \
>>> >     >     >>     >     -  (sizeof(Console_Configuration_Ports) \
>>> >     >     >>     >     -    / sizeof(Console_Configuration_Ports [0]))
>>> >     >     >>     >     -
>>> >     >     >>     >     -unsigned long Console_Configuration_Count =
>>> >     PORT_COUNT;
>>> >     >     >>     >     -
>>> >     >     >>     >     -static void output_char(char c)
>>> >     >     >>     >     +
>>> >     >     >>     >     +static void *get_reg_of_node(const void *fdt,
>>> >     int node)
>>> >     >     >>     >      {
>>> >     >     >>     >     -  const console_fns *con =
>>> >     >     >>     >     -    Console_Configuration_Ports
>>> >     >     [Console_Port_Minor].pDeviceFns;
>>> >     >     >>     >     +  int len;
>>> >     >     >>     >     +  const uint32_t *val;
>>> >     >     >>     >     +
>>> >     >     >>     >     +  val = fdt_getprop(fdt, node, "reg", &len);
>>> >     >     >>     >     +  if (val == NULL || len < 4) {
>>> >     >     >>     >     +    return NULL;
>>> >     >     >>     >     +  }
>>> >     >     >>     >
>>> >     >     >>     >     -  con->deviceWritePolled((int)
>>> >     Console_Port_Minor, c);
>>> >     >     >>     >     +  return (void *) fdt32_to_cpu(val[0]);
>>> >     >     >>     >      }
>>> >     >     >>     >
>>> >     >     >>     >     -BSP_output_char_function_type BSP_output_char =
>>> >     >     output_char;
>>> >     >     >>     >     +static void register_arm_pl011(
>>> >     >     >>     >     +  const void *fdt,
>>> >     >     >>     >     +  const char *serial
>>> >     >     >>     >     +)
>>> >     >     >>     >     +{
>>> >     >     >>     >     +  arm_pl011_context *ctx = &pl011_context;
>>> >     >     >>     >     +  int node;
>>> >     >     >>     >     +
>>> >     >     >>     >     +  if (strcmp(serial, "uart0") == 0) {
>>> >     >     >>     >     +
>>> >     >     >>     >     +
>>> >     >     rtems_termios_device_context_initialize(&ctx->base, "UART");
>>> >     >     >>     >     +    node = fdt_path_offset(fdt, serial);
>>> >     >     >>     >     +    ctx->regs = get_reg_of_node(fdt, node);
>>> >     >     >>     >     +  }
>>> >     >     >>     >     +
>>> >     >     >>     >     +  rtems_termios_device_install(
>>> >     >     >>     >     +    "/dev/ttyuart0",
>>> >     >     >>     >     +    &arm_pl011_fns,
>>> >     >     >>     >     +    NULL,
>>> >     >     >>     >     +    &pl011_context.base
>>> >     >     >>     >     +  );
>>> >     >     >>     >     +}
>>> >     >     >>     >     +
>>> >     >     >>     >     +static void register_fb( void )
>>> >     >     >>     >     +{
>>> >     >     >>     >     +  if (fbcons_probe(&fb_context.base) == true) {
>>> >     >     >>     >     +    rtems_termios_device_install(
>>> >     >     >>     >     +      "/dev/fbcons",
>>> >     >     >>     >     +      &fbcons_fns,
>>> >     >     >>     >     +      NULL,
>>> >     >     >>     >     +      &fb_context.base);
>>> >     >     >>     >     +  }
>>> >     >     >>     >     +}
>>> >     >     >>     >     +
>>> >     >     >>     >     +static void console_select( const char
>>> *console )
>>> >     >     >>     >     +{
>>> >     >     >>     >     +  const char *opt;
>>> >     >     >>     >     +
>>> >     >     >>     >     +  opt = rpi_cmdline_get_arg("--console=");
>>> >     >     >>     >     +
>>> >     >     >>     >     +  if ( opt ) {
>>> >     >     >>     >     +    if ( strncmp( opt, "fbcons", sizeof(
>>> >     "fbcons" ) -
>>> >     >     1 ) ==
>>> >     >     >>     0 ) {
>>> >     >     >>     >     +      if ( rpi_video_is_initialized() > 0 ) {
>>> >     >     >>     >     +        BSP_output_char = output_char_fb;
>>> >     >     >>     >     +        link("/dev/fbcons",
>>> CONSOLE_DEVICE_NAME);
>>> >     >     >>     >     +      }
>>> >     >     >>     >     +    }else{
>>> >     >     >>     >     +
>>> >     >     >>     >     +      if ( console == NULL ){
>>> >     >     >>     >     +        bsp_fatal( BSP_FATAL_CONSOLE_NO_DEV );
>>> >     >     >>     >     +      }
>>> >     >     >>     >     +      BSP_output_char = output_char_serial;
>>> >     >     >>     >     +      link("/dev/ttyuart0",
>>> CONSOLE_DEVICE_NAME);
>>> >     >     >>     >     +    }
>>> >     >     >>     >     +  }
>>> >     >     >>     >     +}
>>> >     >     >>     >     +
>>> >     >     >>     >     +static void uart_probe(void)
>>> >     >     >>     >     +{
>>> >     >     >>     >     +  const void *fdt;
>>> >     >     >>     >     +  const char *console;
>>> >     >     >>     >     +  int node;
>>> >     >     >>     >     +
>>> >     >     >>     >     +  fdt = bsp_fdt_get();
>>> >     >     >>     >     +  node = fdt_path_offset(fdt, "/chosen");
>>> >     >     >>     >     +
>>> >     >     >>     >     +  console = fdt_getprop(fdt, node,
>>> >     "stdout-path", NULL);
>>> >     >     >>     >     +
>>> >     >     >>     >     +  node = fdt_path_offset(fdt, "/aliases");
>>> >     >     >>     >     +
>>> >     >     >>     >     +  int offset = fdt_first_property_offset(fdt,
>>> node);
>>> >     >     >>     >     +
>>> >     >     >>     >     +  while (offset >= 0) {
>>> >     >     >>     >     +    const struct fdt_property *prop;
>>> >     >     >>     >     +
>>> >     >     >>     >     +    prop = fdt_get_property_by_offset(fdt,
>>> >     offset, NULL);
>>> >     >     >>     >     +
>>> >     >     >>     >     +    if (prop != NULL) {
>>> >     >     >>     >     +      const char *name;
>>> >     >     >>     >     +
>>> >     >     >>     >     +      name = fdt_string(fdt,
>>> >     fdt32_to_cpu(prop->nameoff));
>>> >     >     >>     >     +      if(strstr(name, "serial") != NULL) {
>>> >     >     >>     >     +        const char *serial;
>>> >     >     >>     >     +        serial = prop->data;
>>> >     >     >>     >     +
>>> >     >     >>     >     +        register_arm_pl011(fdt, serial);
>>> >     >     >>     >     +      }
>>> >     >     >>     >     +    }
>>> >     >     >>     >     +
>>> >     >     >>     >     +    offset = fdt_next_property_offset(fdt,
>>> offset);
>>> >     >     >>     >     +  }
>>> >     >     >>     >     +  console_select(console);
>>> >     >     >>     >     +}
>>> >     >     >>     >     +
>>> >     >     >>     >     +
>>> >     >     >>     >     +rtems_status_code console_initialize(
>>> >     >     >>     >     +  rtems_device_major_number major,
>>> >     >     >>     >     +  rtems_device_minor_number minor,
>>> >     >     >>     >     +  void *arg
>>> >     >     >>     >     +)
>>> >     >     >>     >     +{
>>> >     >     >>     >     +  rtems_termios_initialize();
>>> >     >     >>     >     +  uart_probe();
>>> >     >     >>     >     +  register_fb();
>>> >     >     >>     >     +
>>> >     >     >>     >     +  return RTEMS_SUCCESSFUL;
>>> >     >     >>     >     +}
>>> >     >     >>     >     +
>>> >     >     >>     >     +BSP_output_char_function_type BSP_output_char =
>>> >     >     >>     output_char_serial;
>>> >     >     >>     >
>>> >     >     >>     >      BSP_polling_getchar_function_type BSP_poll_char
>>> >     = NULL;
>>> >     >     >>     >     +
>>> >     >     >>     >     +RTEMS_SYSINIT_ITEM(
>>> >     >     >>     >     +  uart_probe,
>>> >     >     >>     >     +  RTEMS_SYSINIT_BSP_START,
>>> >     >     >>     >     +  RTEMS_SYSINIT_ORDER_LAST
>>> >     >     >>     >     +);
>>> >     >     >>     >     \ No newline at end of file
>>> >     >     >>     >     diff --git
>>> >     a/bsps/arm/raspberrypi/console/console_select.c
>>> >     >     >>     >     b/bsps/arm/raspberrypi/console/console_select.c
>>> >     >     >>     >     deleted file mode 100644
>>> >     >     >>     >     index bd246ca868..0000000000
>>> >     >     >>     >     ---
>>> a/bsps/arm/raspberrypi/console/console_select.c
>>> >     >     >>     >     +++ /dev/null
>>> >     >     >>     >     @@ -1,114 +0,0 @@
>>> >     >     >>     >     -/**
>>> >     >     >>     >     - * @file
>>> >     >     >>     >     - *
>>> >     >     >>     >     - * @ingroup raspberrypi_console
>>> >     >     >>     >     - *
>>> >     >     >>     >     - * @brief console select
>>> >     >     >>     >     - */
>>> >     >     >>     >     -
>>> >     >     >>     >     -/*
>>> >     >     >>     >     - * Copyright (c) 2015 Yang Qiao
>>> >     >     >>     >     - *
>>> >     >     >>     >     - *  The license and distribution terms for
>>> this file
>>> >     >     may be
>>> >     >     >>     >     - *  found in the file LICENSE in this
>>> >     distribution or at
>>> >     >     >>     >     - *
>>> >     >     >>     >     - *  http://www.rtems.org/license/LICENSE
>>> >     >     >>     >     - *
>>> >     >     >>     >     - */
>>> >     >     >>     >     -
>>> >     >     >>     >     -#include <bsp.h>
>>> >     >     >>     >     -#include <bsp/fatal.h>
>>> >     >     >>     >     -#include <rtems/libio.h>
>>> >     >     >>     >     -#include <stdlib.h>
>>> >     >     >>     >     -#include <string.h>
>>> >     >     >>     >     -#include <assert.h>
>>> >     >     >>     >     -#include <termios.h>
>>> >     >     >>     >     -
>>> >     >     >>     >     -#include <rtems/termiostypes.h>
>>> >     >     >>     >     -#include <libchip/serial.h>
>>> >     >     >>     >     -#include
>>> "../../shared/dev/serial/legacy-console.h"
>>> >     >     >>     >     -#include <bsp/rpi-fb.h>
>>> >     >     >>     >     -
>>> >     >     >>     >     -rtems_device_minor_number BSPPrintkPort = 0;
>>> >     >     >>     >     -
>>> >     >     >>     >     -/*
>>> >     >     >>     >     - * Method to return true if the device
>>> >     associated with the
>>> >     >     >>     >     - * minor number probs available.
>>> >     >     >>     >     - */
>>> >     >     >>     >     -static bool bsp_Is_Available(
>>> >     >     rtems_device_minor_number minor )
>>> >     >     >>     >     -{
>>> >     >     >>     >     -  console_tbl *cptr = Console_Port_Tbl[ minor
>>> ];
>>> >     >     >>     >     -
>>> >     >     >>     >     -  /*
>>> >     >     >>     >     -   * First perform the configuration dependent
>>> >     probe,
>>> >     >     then the
>>> >     >     >>     >     -   * device dependent probe
>>> >     >     >>     >     -   */
>>> >     >     >>     >     -  if ( ( !cptr->deviceProbe ||
>>> cptr->deviceProbe(
>>> >     >     minor ) ) &&
>>> >     >     >>     >     -       cptr->pDeviceFns->deviceProbe( minor )
>>> ) {
>>> >     >     >>     >     -    return true;
>>> >     >     >>     >     -  }
>>> >     >     >>     >     -
>>> >     >     >>     >     -  return false;
>>> >     >     >>     >     -}
>>> >     >     >>     >     -
>>> >     >     >>     >     -/*
>>> >     >     >>     >     - * Method to return the first available device.
>>> >     >     >>     >     - */
>>> >     >     >>     >     -static rtems_device_minor_number
>>> >     >     bsp_First_Available_Device(
>>> >     >     >>     void )
>>> >     >     >>     >     -{
>>> >     >     >>     >     -  rtems_device_minor_number minor;
>>> >     >     >>     >     -
>>> >     >     >>     >     -  for ( minor = 0; minor < Console_Port_Count;
>>> >     minor++ ) {
>>> >     >     >>     >     -    console_tbl *cptr = Console_Port_Tbl[
>>> minor ];
>>> >     >     >>     >     -
>>> >     >     >>     >     -    /*
>>> >     >     >>     >     -     * First perform the configuration
>>> dependent
>>> >     >     probe, then the
>>> >     >     >>     >     -     * device dependent probe
>>> >     >     >>     >     -     */
>>> >     >     >>     >     -
>>> >     >     >>     >     -    if ( ( !cptr->deviceProbe ||
>>> cptr->deviceProbe(
>>> >     >     minor ) ) &&
>>> >     >     >>     >     -         cptr->pDeviceFns->deviceProbe( minor
>>> ) ) {
>>> >     >     >>     >     -      return minor;
>>> >     >     >>     >     -    }
>>> >     >     >>     >     -  }
>>> >     >     >>     >     -
>>> >     >     >>     >     -  /*
>>> >     >     >>     >     -   *  Error No devices were found.  We will
>>> want to
>>> >     >     bail here.
>>> >     >     >>     >     -   */
>>> >     >     >>     >     -  bsp_fatal( BSP_FATAL_CONSOLE_NO_DEV );
>>> >     >     >>     >     -}
>>> >     >     >>     >     -
>>> >     >     >>     >     -void bsp_console_select( void )
>>> >     >     >>     >     -{
>>> >     >     >>     >     -  /*
>>> >     >     >>     >     -   *  Reset Console_Port_Minor and
>>> >     >     >>     >     -   *  BSPPrintkPort here if desired.
>>> >     >     >>     >     -   *
>>> >     >     >>     >     -   *  This default version allows the bsp to
>>> set
>>> >     these
>>> >     >     >>     >     -   *  values at creation and will not touch
>>> them
>>> >     again
>>> >     >     >>     >     -   *  unless the selected port number is not
>>> >     available.
>>> >     >     >>     >     -   */
>>> >     >     >>     >     -  const char *opt;
>>> >     >     >>     >     -
>>> >     >     >>     >     -  Console_Port_Minor = BSP_CONSOLE_UART0;
>>> >     >     >>     >     -  BSPPrintkPort = BSP_CONSOLE_UART0;
>>> >     >     >>     >     -
>>> >     >     >>     >     -  opt = rpi_cmdline_get_arg( "--console=" );
>>> >     >     >>     >     -
>>> >     >     >>     >     -  if ( opt ) {
>>> >     >     >>     >     -    if ( strncmp( opt, "fbcons", sizeof(
>>> >     "fbcons" ) -
>>> >     >     1 ) ==
>>> >     >     >>     0 ) {
>>> >     >     >>     >     -      if ( rpi_video_is_initialized() > 0 ) {
>>> >     >     >>     >     -        Console_Port_Minor = BSP_CONSOLE_FB;
>>> >     >     >>     >     -        BSPPrintkPort = BSP_CONSOLE_FB;
>>> >     >     >>     >     -      }
>>> >     >     >>     >     -    }
>>> >     >     >>     >     -  }
>>> >     >     >>     >     -
>>> >     >     >>     >     -  /*
>>> >     >     >>     >     -   * If the device that was selected isn't
>>> >     available then
>>> >     >     >>     >     -   * let the user know and select the first
>>> >     available
>>> >     >     device.
>>> >     >     >>     >     -   */
>>> >     >     >>     >     -  if ( !bsp_Is_Available( Console_Port_Minor )
>>> ) {
>>> >     >     >>     >     -    Console_Port_Minor =
>>> >     bsp_First_Available_Device();
>>> >     >     >>     >     -  }
>>> >     >     >>     >     -}
>>> >     >     >>     >     diff --git
>>> a/bsps/arm/raspberrypi/console/fbcons.c
>>> >     >     >>     >     b/bsps/arm/raspberrypi/console/fbcons.c
>>> >     >     >>     >     index 3669ba458d..0e6a430c54 100644
>>> >     >     >>     >     --- a/bsps/arm/raspberrypi/console/fbcons.c
>>> >     >     >>     >     +++ b/bsps/arm/raspberrypi/console/fbcons.c
>>> >     >     >>     >     @@ -18,6 +18,7 @@
>>> >     >     >>     >
>>> >     >     >>     >      #include <rtems.h>
>>> >     >     >>     >      #include <rtems/libio.h>
>>> >     >     >>     >     +#include <rtems/termiostypes.h>
>>> >     >     >>     >
>>> >     >     >>     >      #include <stdlib.h>
>>> >     >     >>     >
>>> >     >     >>     >     @@ -29,15 +30,6 @@
>>> >     >     >>     >      #include <bsp/vc.h>
>>> >     >     >>     >      #include <bsp/rpi-fb.h>
>>> >     >     >>     >
>>> >     >     >>     >     -/*
>>> >     >     >>     >     - *  fbcons_init
>>> >     >     >>     >     - *
>>> >     >     >>     >     - *  This function initializes the fb console
>>> to a
>>> >     >     quiecsent
>>> >     >     >>     state.
>>> >     >     >>     >     - */
>>> >     >     >>     >     -static void fbcons_init( int minor )
>>> >     >     >>     >     -{
>>> >     >     >>     >     -}
>>> >     >     >>     >     -
>>> >     >     >>     >      /*
>>> >     >     >>     >       *  fbcons_open
>>> >     >     >>     >       *
>>> >     >     >>     >     @@ -45,13 +37,14 @@ static void fbcons_init( int
>>> >     minor )
>>> >     >     >>     >       *
>>> >     >     >>     >       *  Default state is 9600 baud, 8 bits, No
>>> >     parity, and
>>> >     >     1 stop
>>> >     >     >>     bit.
>>> >     >     >>     >       */
>>> >     >     >>     >     -static int fbcons_open(
>>> >     >     >>     >     -  int   major,
>>> >     >     >>     >     -  int   minor,
>>> >     >     >>     >     -  void *arg
>>> >     >     >>     >     +static bool fbcons_open(
>>> >     >     >>     >     +  struct rtems_termios_tty *tty,
>>> >     >     >>     >     +  rtems_termios_device_context *base,
>>> >     >     >>     >     +  struct termios *term,
>>> >     >     >>     >     +  rtems_libio_open_close_args_t *args
>>> >     >     >>     >      )
>>> >     >     >>     >      {
>>> >     >     >>     >     -  return RTEMS_SUCCESSFUL;
>>> >     >     >>     >     +  return true;
>>> >     >     >>     >      }
>>> >     >     >>     >
>>> >     >     >>     >      /*
>>> >     >     >>     >     @@ -59,13 +52,12 @@ static int fbcons_open(
>>> >     >     >>     >       *
>>> >     >     >>     >       *  This function shuts down the requested
>>> port.
>>> >     >     >>     >       */
>>> >     >     >>     >     -static int fbcons_close(
>>> >     >     >>     >     -  int   major,
>>> >     >     >>     >     -  int   minor,
>>> >     >     >>     >     -  void *arg
>>> >     >     >>     >     +static void fbcons_close(
>>> >     >     >>     >     +  struct rtems_termios_tty *tty,
>>> >     >     >>     >     +  rtems_termios_device_context *base,
>>> >     >     >>     >     +  rtems_libio_open_close_args_t *args
>>> >     >     >>     >      )
>>> >     >     >>     >      {
>>> >     >     >>     >     -  return ( RTEMS_SUCCESSFUL );
>>> >     >     >>     >      }
>>> >     >     >>     >
>>> >     >     >>     >      /*
>>> >     >     >>     >     @@ -73,8 +65,8 @@ static int fbcons_close(
>>> >     >     >>     >       *
>>> >     >     >>     >       *  This routine polls out the requested
>>> character.
>>> >     >     >>     >       */
>>> >     >     >>     >     -static void fbcons_write_polled(
>>> >     >     >>     >     -  int  minor,
>>> >     >     >>     >     +void fbcons_write_polled(
>>> >     >     >>     >     +  rtems_termios_device_context *base,
>>> >     >     >>     >        char c
>>> >     >     >>     >      )
>>> >     >     >>     >      {
>>> >     >     >>     >     @@ -90,8 +82,8 @@ static void
>>> fbcons_write_polled(
>>> >     >     >>     >       *  Console Termios output entry point when
>>> using
>>> >     >     polled output.
>>> >     >     >>     >       *
>>> >     >     >>     >       */
>>> >     >     >>     >     -static ssize_t fbcons_write_support_polled(
>>> >     >     >>     >     -  int         minor,
>>> >     >     >>     >     +static void fbcons_write_support_polled(
>>> >     >     >>     >     +  rtems_termios_device_context *base,
>>> >     >     >>     >        const char *buf,
>>> >     >     >>     >        size_t      len
>>> >     >     >>     >      )
>>> >     >     >>     >     @@ -102,14 +94,9 @@ static ssize_t
>>> >     >     fbcons_write_support_polled(
>>> >     >     >>     >         * poll each byte in the string out of the
>>> port.
>>> >     >     >>     >         */
>>> >     >     >>     >        while ( nwrite < len ) {
>>> >     >     >>     >     -    fbcons_write_polled( minor, *buf++ );
>>> >     >     >>     >     +    fbcons_write_polled( base, *buf++ );
>>> >     >     >>     >          nwrite++;
>>> >     >     >>     >        }
>>> >     >     >>     >     -
>>> >     >     >>     >     -  /*
>>> >     >     >>     >     -   * return the number of bytes written.
>>> >     >     >>     >     -   */
>>> >     >     >>     >     -  return nwrite;
>>> >     >     >>     >      }
>>> >     >     >>     >
>>> >     >     >>     >      /*
>>> >     >     >>     >     @@ -117,7 +104,9 @@ static ssize_t
>>> >     >     fbcons_write_support_polled(
>>> >     >     >>     >       *
>>> >     >     >>     >       *  Console Termios polling input entry point.
>>> >     >     >>     >       */
>>> >     >     >>     >     -static int fbcons_inbyte_nonblocking_polled(
>>> int
>>> >     minor )
>>> >     >     >>     >     +int fbcons_inbyte_nonblocking_polled(
>>> >     >     >>     >     +  rtems_termios_device_context *base
>>> >     >     >>     >     +)
>>> >     >     >>     >      {
>>> >     >     >>     >        // if( rtems_kbpoll() ) {
>>> >     >     >>     >        //   int c = getch();
>>> >     >     >>     >     @@ -133,15 +122,17 @@ static int
>>> >     >     fbcons_inbyte_nonblocking_polled(
>>> >     >     >>     >     int minor )
>>> >     >     >>     >       *  This function sets the UART channel to
>>> >     reflect the
>>> >     >     requested
>>> >     >     >>     >     termios
>>> >     >     >>     >       *  port settings.
>>> >     >     >>     >       */
>>> >     >     >>     >     -static int fbcons_set_attributes(
>>> >     >     >>     >     -  int                   minor,
>>> >     >     >>     >     +static bool fbcons_set_attributes(
>>> >     >     >>     >     +  rtems_termios_device_context *base,
>>> >     >     >>     >        const struct termios *t
>>> >     >     >>     >      )
>>> >     >     >>     >      {
>>> >     >     >>     >     -  return 0;
>>> >     >     >>     >     +  return true;
>>> >     >     >>     >      }
>>> >     >     >>     >
>>> >     >     >>     >     -bool fbcons_probe( int minor )
>>> >     >     >>     >     +bool fbcons_probe(
>>> >     >     >>     >     +  rtems_termios_device_context *context
>>> >     >     >>     >     +)
>>> >     >     >>     >      {
>>> >     >     >>     >        // rtems_status_code status;
>>> >     >     >>     >        static bool firstTime = true;
>>> >     >     >>     >     @@ -163,15 +154,12 @@ bool fbcons_probe( int
>>> minor )
>>> >     >     >>     >        return ret;
>>> >     >     >>     >      }
>>> >     >     >>     >
>>> >     >     >>     >     -const console_fns fbcons_fns =
>>> >     >     >>     >     +const rtems_termios_device_handler fbcons_fns =
>>> >     >     >>     >      {
>>> >     >     >>     >     -  .deviceProbe = libchip_serial_default_probe,
>>> >        /*
>>> >     >     >>     deviceProbe */
>>> >     >     >>     >     -  .deviceFirstOpen = fbcons_open,
>>>    /*
>>> >     >     >>     deviceFirstOpen */
>>> >     >     >>     >     -  .deviceLastClose = fbcons_close,
>>>     /*
>>> >     >     >>     deviceLastClose */
>>> >     >     >>     >     -  .deviceRead =
>>> fbcons_inbyte_nonblocking_polled, /*
>>> >     >     >>     deviceRead */
>>> >     >     >>     >     -  .deviceWrite = fbcons_write_support_polled,
>>>    /*
>>> >     >     >>     deviceWrite */
>>> >     >     >>     >     -  .deviceInitialize = fbcons_init,
>>>     /*
>>> >     >     >>     >     deviceInitialize */
>>> >     >     >>     >     -  .deviceWritePolled = fbcons_write_polled,
>>>    /*
>>> >     >     >>     >     deviceWritePolled */
>>> >     >     >>     >     -  .deviceSetAttributes =
>>> fbcons_set_attributes,   /*
>>> >     >     >>     >     deviceSetAttributes */
>>> >     >     >>     >     -  .deviceOutputUsesInterrupts = FALSE,
>>>    /*
>>> >     >     >>     >     deviceOutputUsesInterrupts*/
>>> >     >     >>     >     -};
>>> >     >     >>     >     +  .first_open = fbcons_open,
>>> >     >     >>     >     +  .last_close = fbcons_close,
>>> >     >     >>     >     +  .poll_read =
>>> fbcons_inbyte_nonblocking_polled,
>>> >     >     >>     >     +  .write = fbcons_write_support_polled,
>>> >     >     >>     >     +  .set_attributes = fbcons_set_attributes,
>>> >     >     >>     >     +  .mode = TERMIOS_POLLED
>>> >     >     >>     >     +};
>>> >     >     >>     >     \ No newline at end of file
>>> >     >     >>     >     diff --git
>>> a/bsps/arm/raspberrypi/console/usart.c
>>> >     >     >>     >     b/bsps/arm/raspberrypi/console/usart.c
>>> >     >     >>     >     deleted file mode 100644
>>> >     >     >>     >     index 25fb523621..0000000000
>>> >     >     >>     >     --- a/bsps/arm/raspberrypi/console/usart.c
>>> >     >     >>     >     +++ /dev/null
>>> >     >     >>     >     @@ -1,167 +0,0 @@
>>> >     >     >>     >     -/**
>>> >     >     >>     >     - * @file
>>> >     >     >>     >     - *
>>> >     >     >>     >     - * @ingroup raspberrypi_usart
>>> >     >     >>     >     - *
>>> >     >     >>     >     - * @brief USART support.
>>> >     >     >>     >     - */
>>> >     >     >>     >     -
>>> >     >     >>     >     -/*
>>> >     >     >>     >     - * Copyright (c) 2013 Alan Cudmore
>>> >     >     >>     >     - *
>>> >     >     >>     >     - *  The license and distribution terms for
>>> this file
>>> >     >     may be
>>> >     >     >>     >     - *  found in the file LICENSE in this
>>> >     distribution or at
>>> >     >     >>     >     - *
>>> >     >     >>     >     - *  http://www.rtems.org/license/LICENSE
>>> >     >     >>     >     - *
>>> >     >     >>     >     - */
>>> >     >     >>     >     -
>>> >     >     >>     >     -#include <libchip/sersupp.h>
>>> >     >     >>     >     -
>>> >     >     >>     >     -#include <bsp.h>
>>> >     >     >>     >     -#include <bsp/irq.h>
>>> >     >     >>     >     -#include <bsp/usart.h>
>>> >     >     >>     >     -#include <bsp/raspberrypi.h>
>>> >     >     >>     >     -#include <rtems/bspIo.h>
>>> >     >     >>     >     -
>>> >     >     >>     >     -static void usart_delay(uint32_t n)
>>> >     >     >>     >     -{
>>> >     >     >>     >     - volatile uint32_t i = 0;
>>> >     >     >>     >     -
>>> >     >     >>     >     - for(i = 0; i < n; i++)
>>> >     >     >>     >     -   ;
>>> >     >     >>     >     -}
>>> >     >     >>     >     -
>>> >     >     >>     >     -#if 0
>>> >     >     >>     >     -/*
>>> >     >     >>     >     - *  These will be useful when the driver
>>> supports
>>> >     >     interrupt
>>> >     >     >>     driven IO.
>>> >     >     >>     >     - */
>>> >     >     >>     >     -static rtems_vector_number
>>> >     usart_get_irq_number(const
>>> >     >     >>     console_tbl *ct)
>>> >     >     >>     >     -{
>>> >     >     >>     >     -  return ct->ulIntVector;
>>> >     >     >>     >     -}
>>> >     >     >>     >     -
>>> >     >     >>     >     -static uint32_t usart_get_baud(const
>>> console_tbl
>>> >     *ct)
>>> >     >     >>     >     -{
>>> >     >     >>     >     -  return ct->ulClock;
>>> >     >     >>     >     -}
>>> >     >     >>     >     -#endif
>>> >     >     >>     >     -
>>> >     >     >>     >     -static void usart_set_baud(int minor, int baud)
>>> >     >     >>     >     -{
>>> >     >     >>     >     - /*
>>> >     >     >>     >     -  * Nothing for now
>>> >     >     >>     >     -  */
>>> >     >     >>     >     - return;
>>> >     >     >>     >     -}
>>> >     >     >>     >     -
>>> >     >     >>     >     -static void usart_initialize(int minor)
>>> >     >     >>     >     -{
>>> >     >     >>     >     -  unsigned int gpio_reg;
>>> >     >     >>     >     -
>>> >     >     >>     >     -  /*
>>> >     >     >>     >     -  ** Program GPIO pins for UART 0
>>> >     >     >>     >     -  */
>>> >     >     >>     >     -  gpio_reg = BCM2835_REG(BCM2835_GPIO_GPFSEL1);
>>> >     >     >>     >     -  gpio_reg &= ~(7<<12);    /* gpio14 */
>>> >     >     >>     >     -  gpio_reg |=  (4<<12);    /* alt0   */
>>> >     >     >>     >     -  gpio_reg &= ~(7<<15);    /* gpio15 */
>>> >     >     >>     >     -  gpio_reg |=  (4<<15);    /* alt0   */
>>> >     >     >>     >     -  BCM2835_REG(BCM2835_GPIO_GPFSEL1) = gpio_reg;
>>> >     >     >>     >     -
>>> >     >     >>     >     -  BCM2835_REG(BCM2835_GPIO_GPPUD) = 0;
>>> >     >     >>     >     -  usart_delay(150);
>>> >     >     >>     >     -  BCM2835_REG(BCM2835_GPIO_GPPUDCLK0) =
>>> >     (1<<14)|(1<<15);
>>> >     >     >>     >     -  usart_delay(150);
>>> >     >     >>     >     -  BCM2835_REG(BCM2835_GPIO_GPPUDCLK0) = 0;
>>> >     >     >>     >     -
>>> >     >     >>     >     -  /*
>>> >     >     >>     >     -  ** Init the PL011 UART
>>> >     >     >>     >     -  */
>>> >     >     >>     >     -  BCM2835_REG(BCM2835_UART0_CR)   = 0;
>>> >     >     >>     >     -  BCM2835_REG(BCM2835_UART0_ICR)  = 0x7FF;
>>> >     >     >>     >     -  BCM2835_REG(BCM2835_UART0_IMSC) = 0;
>>> >     >     >>     >     -  BCM2835_REG(BCM2835_UART0_IBRD) = 1;
>>> >     >     >>     >     -  BCM2835_REG(BCM2835_UART0_FBRD) = 40;
>>> >     >     >>     >     -  BCM2835_REG(BCM2835_UART0_LCRH) = 0x70;
>>> >     >     >>     >     -  BCM2835_REG(BCM2835_UART0_RSRECR) =  0;
>>> >     >     >>     >     -
>>> >     >     >>     >     -  BCM2835_REG(BCM2835_UART0_CR)   = 0x301;
>>> >     >     >>     >     -
>>> >     >     >>     >     -  BCM2835_REG(BCM2835_UART0_IMSC) =
>>> >     BCM2835_UART0_IMSC_RX;
>>> >     >     >>     >     -
>>> >     >     >>     >     -  usart_set_baud(minor, 115000);
>>> >     >     >>     >     -}
>>> >     >     >>     >     -
>>> >     >     >>     >     -static int usart_first_open(int major, int
>>> >     minor, void
>>> >     >     *arg)
>>> >     >     >>     >     -{
>>> >     >     >>     >     -  rtems_libio_open_close_args_t *oc =
>>> >     >     >>     >     (rtems_libio_open_close_args_t *) arg;
>>> >     >     >>     >     -  struct rtems_termios_tty *tty = (struct
>>> >     >     rtems_termios_tty *)
>>> >     >     >>     >     oc->iop->data1;
>>> >     >     >>     >     -  const console_tbl *ct = Console_Port_Tbl
>>> [minor];
>>> >     >     >>     >     -  console_data *cd = &Console_Port_Data
>>> [minor];
>>> >     >     >>     >     -
>>> >     >     >>     >     -  cd->termios_data = tty;
>>> >     >     >>     >     -  rtems_termios_set_initial_baud(tty,
>>> ct->ulClock);
>>> >     >     >>     >     -
>>> >     >     >>     >     -  return 0;
>>> >     >     >>     >     -}
>>> >     >     >>     >     -
>>> >     >     >>     >     -static int usart_last_close(int major, int
>>> >     minor, void
>>> >     >     *arg)
>>> >     >     >>     >     -{
>>> >     >     >>     >     -  return 0;
>>> >     >     >>     >     -}
>>> >     >     >>     >     -
>>> >     >     >>     >     -static int usart_read_polled(int minor)
>>> >     >     >>     >     -{
>>> >     >     >>     >     -  if (minor == 0) {
>>> >     >     >>     >     -    if (((BCM2835_REG(BCM2835_UART0_FR)) &
>>> >     >     BCM2835_UART0_FR_RXFE)
>>> >     >     >>     >     == 0) {
>>> >     >     >>     >     -       return((BCM2835_REG(BCM2835_UART0_DR)) &
>>> >     0xFF );
>>> >     >     >>     >     -    } else {
>>> >     >     >>     >     -      return -1;
>>> >     >     >>     >     -    }
>>> >     >     >>     >     -  } else {
>>> >     >     >>     >     -    printk("Unknown console minor number:
>>> %d\n",
>>> >     minor);
>>> >     >     >>     >     -    return -1;
>>> >     >     >>     >     -  }
>>> >     >     >>     >     -}
>>> >     >     >>     >     -
>>> >     >     >>     >     -static void usart_write_polled(int minor, char
>>> c)
>>> >     >     >>     >     -{
>>> >     >     >>     >     -   while (1) {
>>> >     >     >>     >     -     if ((BCM2835_REG(BCM2835_UART0_FR) &
>>> >     >     >>     BCM2835_UART0_FR_TXFF) == 0)
>>> >     >     >>     >     -       break;
>>> >     >     >>     >     -   }
>>> >     >     >>     >     -   BCM2835_REG(BCM2835_UART0_DR) = c;
>>> >     >     >>     >     -}
>>> >     >     >>     >     -
>>> >     >     >>     >     -static ssize_t usart_write_support_polled(
>>> >     >     >>     >     -  int minor,
>>> >     >     >>     >     -  const char *s,
>>> >     >     >>     >     -  size_t n
>>> >     >     >>     >     -)
>>> >     >     >>     >     -{
>>> >     >     >>     >     -  ssize_t i = 0;
>>> >     >     >>     >     -
>>> >     >     >>     >     -  for (i = 0; i < n; ++i) {
>>> >     >     >>     >     -    usart_write_polled(minor, s [i]);
>>> >     >     >>     >     -  }
>>> >     >     >>     >     -
>>> >     >     >>     >     -  return n;
>>> >     >     >>     >     -}
>>> >     >     >>     >     -
>>> >     >     >>     >     -static int usart_set_attributes(int minor,
>>> const
>>> >     struct
>>> >     >     >>     termios *term)
>>> >     >     >>     >     -{
>>> >     >     >>     >     -  return -1;
>>> >     >     >>     >     -}
>>> >     >     >>     >     -
>>> >     >     >>     >     -const console_fns bcm2835_usart_fns = {
>>> >     >     >>     >     -  .deviceProbe = libchip_serial_default_probe,
>>> >     >     >>     >     -  .deviceFirstOpen = usart_first_open,
>>> >     >     >>     >     -  .deviceLastClose = usart_last_close,
>>> >     >     >>     >     -  .deviceRead = usart_read_polled,
>>> >     >     >>     >     -  .deviceWrite = usart_write_support_polled,
>>> >     >     >>     >     -  .deviceInitialize = usart_initialize,
>>> >     >     >>     >     -  .deviceWritePolled = usart_write_polled,
>>> >     >     >>     >     -  .deviceSetAttributes = usart_set_attributes,
>>> >     >     >>     >     -  .deviceOutputUsesInterrupts = false
>>> >     >     >>     >     -};
>>> >     >     >>     >     diff --git
>>> >     a/bsps/arm/raspberrypi/include/bsp/fbcons.h
>>> >     >     >>     >     b/bsps/arm/raspberrypi/include/bsp/fbcons.h
>>> >     >     >>     >     index d0e126699a..9bdb4b115e 100644
>>> >     >     >>     >     --- a/bsps/arm/raspberrypi/include/bsp/fbcons.h
>>> >     >     >>     >     +++ b/bsps/arm/raspberrypi/include/bsp/fbcons.h
>>> >     >     >>     >     @@ -33,12 +33,29 @@ extern "C" {
>>> >     >     >>     >
>>> >     >     >>     >      #define FB_CONSOLE 0x50492835
>>> >     >     >>     >
>>> >     >     >>     >     -bool fbcons_probe( int minor );
>>> >     >     >>     >     +bool fbcons_probe(
>>> >     >     >>     >     +  rtems_termios_device_context *base
>>> >     >     >>     >     + );
>>> >     >     >>     >     +
>>> >     >     >>     >     +void fbcons_write_polled(
>>> >     >     >>     >     +  rtems_termios_device_context *base,
>>> >     >     >>     >     +  char c
>>> >     >     >>     >     +);
>>> >     >     >>     >     +
>>> >     >     >>     >     +int fbcons_inbyte_nonblocking_polled(
>>> >     >     >>     >     +  rtems_termios_device_context *base
>>> >     >     >>     >     +);
>>> >     >     >>     >     +
>>> >     >     >>     >     +void output_char_fb(char c);
>>> >     >     >>     >     +
>>> >     >     >>     >     +typedef struct {
>>> >     >     >>     >     +    rtems_termios_device_context base;
>>> >     >     >>     >     +} rpi_fb_context ;
>>> >     >     >>     >
>>> >     >     >>     >      /*
>>> >     >     >>     >       * Driver function table
>>> >     >     >>     >       */
>>> >     >     >>     >     -extern const console_fns fbcons_fns;
>>> >     >     >>     >     +extern const rtems_termios_device_handler
>>> >     fbcons_fns;
>>> >     >     >>     >
>>> >     >     >>     >      #ifdef __cplusplus
>>> >     >     >>     >      }
>>> >     >     >>     >     diff --git
>>> >     a/bsps/arm/raspberrypi/include/bsp/raspberrypi.h
>>> >     >     >>     >     b/bsps/arm/raspberrypi/include/bsp/raspberrypi.h
>>> >     >     >>     >     index 40c80cf408..e052c2becb 100644
>>> >     >     >>     >     ---
>>> a/bsps/arm/raspberrypi/include/bsp/raspberrypi.h
>>> >     >     >>     >     +++
>>> b/bsps/arm/raspberrypi/include/bsp/raspberrypi.h
>>> >     >     >>     >     @@ -24,6 +24,7 @@
>>> >     >     >>     >      #include <bspopts.h>
>>> >     >     >>     >      #include <stdint.h>
>>> >     >     >>     >      #include <bsp/utility.h>
>>> >     >     >>     >     +#include <rtems/termiostypes.h>
>>> >     >     >>     >
>>> >     >     >>     >      /**
>>> >     >     >>     >       * @defgroup raspberrypi_reg Register
>>> Definitions
>>> >     >     >>     >     @@ -60,6 +61,17 @@
>>> >     >     >>     >
>>> >     >     >>     >      #define RPI_PERIPHERAL_SIZE         0x01000000
>>> >     >     >>     >
>>> >     >     >>     >     +/**
>>> >     >     >>     >     + * @name Console select definitions
>>> >     >     >>     >     + *
>>> >     >     >>     >     + * @{
>>> >     >     >>     >     + */
>>> >     >     >>     >     +
>>> >     >     >>     >     +#define PL011 0
>>> >     >     >>     >     +#define FB    1
>>> >     >     >>     >     +
>>> >     >     >>     >     +/** @} */
>>> >     >     >>     >     +
>>> >     >     >>     >      /**
>>> >     >     >>     >       * @name Internal ARM Timer Registers
>>> >     >     >>     >       *
>>> >     >     >>     >     @@ -184,42 +196,6 @@
>>> >     >     >>     >
>>> >     >     >>     >      /** @} */
>>> >     >     >>     >
>>> >     >     >>     >     -/**
>>> >     >     >>     >     - * @name UART 0 (PL011) Registers
>>> >     >     >>     >     - *
>>> >     >     >>     >     - * @{
>>> >     >     >>     >     - */
>>> >     >     >>     >     -
>>> >     >     >>     >     -#define BCM2835_UART0_BASE
>>> >      (RPI_PERIPHERAL_BASE
>>> >     >     + 0x201000)
>>> >     >     >>     >     -
>>> >     >     >>     >     -#define BCM2835_UART0_DR
>>> >      (BCM2835_UART0_BASE +
>>> >     >     0x00)
>>> >     >     >>     >     -#define BCM2835_UART0_RSRECR
>>> >      (BCM2835_UART0_BASE +
>>> >     >     0x04)
>>> >     >     >>     >     -#define BCM2835_UART0_FR
>>> >      (BCM2835_UART0_BASE +
>>> >     >     0x18)
>>> >     >     >>     >     -#define BCM2835_UART0_ILPR
>>> >      (BCM2835_UART0_BASE +
>>> >     >     0x20)
>>> >     >     >>     >     -#define BCM2835_UART0_IBRD
>>> >      (BCM2835_UART0_BASE +
>>> >     >     0x24)
>>> >     >     >>     >     -#define BCM2835_UART0_FBRD
>>> >      (BCM2835_UART0_BASE +
>>> >     >     0x28)
>>> >     >     >>     >     -#define BCM2835_UART0_LCRH
>>> >      (BCM2835_UART0_BASE +
>>> >     >     0x2C)
>>> >     >     >>     >     -#define BCM2835_UART0_CR
>>> >      (BCM2835_UART0_BASE +
>>> >     >     0x30)
>>> >     >     >>     >     -#define BCM2835_UART0_IFLS
>>> >      (BCM2835_UART0_BASE +
>>> >     >     0x34)
>>> >     >     >>     >     -#define BCM2835_UART0_IMSC
>>> >      (BCM2835_UART0_BASE +
>>> >     >     0x38)
>>> >     >     >>     >     -#define BCM2835_UART0_RIS
>>> >     (BCM2835_UART0_BASE +
>>> >     >     0x3C)
>>> >     >     >>     >     -#define BCM2835_UART0_MIS
>>> >     (BCM2835_UART0_BASE +
>>> >     >     0x40)
>>> >     >     >>     >     -#define BCM2835_UART0_ICR
>>> >     (BCM2835_UART0_BASE +
>>> >     >     0x44)
>>> >     >     >>     >     -#define BCM2835_UART0_DMACR
>>> >     (BCM2835_UART0_BASE +
>>> >     >     0x48)
>>> >     >     >>     >     -#define BCM2835_UART0_ITCR
>>> >      (BCM2835_UART0_BASE +
>>> >     >     0x80)
>>> >     >     >>     >     -#define BCM2835_UART0_ITIP
>>> >      (BCM2835_UART0_BASE +
>>> >     >     0x84)
>>> >     >     >>     >     -#define BCM2835_UART0_ITOP
>>> >      (BCM2835_UART0_BASE +
>>> >     >     0x88)
>>> >     >     >>     >     -#define BCM2835_UART0_TDR
>>> >     (BCM2835_UART0_BASE +
>>> >     >     0x8C)
>>> >     >     >>     >     -
>>> >     >     >>     >     -#define BCM2835_UART0_MIS_RX    0x10
>>> >     >     >>     >     -#define BCM2835_UART0_MIS_TX    0x20
>>> >     >     >>     >     -#define BCM2835_UART0_IMSC_RX   0x10
>>> >     >     >>     >     -#define BCM2835_UART0_IMSC_TX   0x20
>>> >     >     >>     >     -#define BCM2835_UART0_FR_RXFE   0x10
>>> >     >     >>     >     -#define BCM2835_UART0_FR_TXFF   0x20
>>> >     >     >>     >     -#define BCM2835_UART0_ICR_RX    0x10
>>> >     >     >>     >     -#define BCM2835_UART0_ICR_TX    0x20
>>> >     >     >>     >     -
>>> >     >     >>     >      /** @} */
>>> >     >     >>     >
>>> >     >     >>     >      /**
>>> >     >     >>     >     diff --git
>>> a/bsps/arm/raspberrypi/include/bsp/usart.h
>>> >     >     >>     >     b/bsps/arm/raspberrypi/include/bsp/usart.h
>>> >     >     >>     >     index d3e710c5e9..abbf53626c 100644
>>> >     >     >>     >     --- a/bsps/arm/raspberrypi/include/bsp/usart.h
>>> >     >     >>     >     +++ b/bsps/arm/raspberrypi/include/bsp/usart.h
>>> >     >     >>     >     @@ -32,9 +32,8 @@
>>> >     >     >>     >      extern "C" {
>>> >     >     >>     >      #endif /* __cplusplus */
>>> >     >     >>     >
>>> >     >     >>     >     -#define USART0_DEFAULT_BAUD 115000
>>> >     >     >>     >     -
>>> >     >     >>     >     -extern const console_fns bcm2835_usart_fns;
>>> >     >     >>     >     +#define PL011_DEFAULT_BAUD 115000
>>> >     >     >>     >     +#define BCM2835_PL011_BASE
>>> (RPI_PERIPHERAL_BASE +
>>> >     >     0x201000)
>>> >     >     >>     >
>>> >     >     >>     >      #ifdef __cplusplus
>>> >     >     >>     >      }
>>> >     >     >>     >     diff --git
>>> >     a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
>>> >     >     >>     >     b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
>>> >     >     >>     >     index 11a22f89e3..0e0d5bef67 100644
>>> >     >     >>     >     ---
>>> a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
>>> >     >     >>     >     +++
>>> b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
>>> >     >     >>     >     @@ -42,6 +42,7 @@ librtemsbsp_a_SOURCES +=
>>> >     >     >>     >
>>> >      ../../../../../../bsps/shared/start/bspfatal-default.c
>>> >     >     >>     >      librtemsbsp_a_SOURCES +=
>>> >     >     >>     >
>>> >     >
>>> >
>>>    ../../../../../../bsps/shared/dev/cpucounter/cpucounterfrequency.c
>>> >     >     >>     >      librtemsbsp_a_SOURCES +=
>>> >     >     >>     >
>>> >     >
>>>   ../../../../../../bsps/shared/dev/cpucounter/cpucounterread.c
>>> >     >     >>     >      librtemsbsp_a_SOURCES +=
>>> >     >     >>     ../../../../../../bsps/shared/start/sbrk.c
>>> >     >     >>     >     +librtemsbsp_a_SOURCES +=
>>> >     >     >>     ../../../../../../bsps/shared/start/bsp-fdt.c
>>> >     >     >>     >      librtemsbsp_a_SOURCES +=
>>> >     >     >>     >     ../../../../../../bsps/shared/start/stackalloc.c
>>> >     >     >>     >      librtemsbsp_a_SOURCES +=
>>> >     >     >>     >
>>> >      ../../../../../../bsps/arm/shared/start/bsp-start-memcpy.S
>>> >     >     >>     >      librtemsbsp_a_SOURCES +=
>>> >     >     >>     >
>>> >     >
>>>   ../../../../../../bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
>>> >     >     >>     >     @@ -63,14 +64,13 @@ librtemsbsp_a_SOURCES +=
>>> >     >     >>     >
>>> >      ../../../../../../bsps/arm/shared/cp15/arm-cp15-set-exc
>>> >     >     >>     >      librtemsbsp_a_SOURCES +=
>>> >     >     >>     >     ../../../../../../bsps/arm/raspberrypi/irq/irq.c
>>> >     >     >>     >
>>> >     >     >>     >      # Console
>>> >     >     >>     >     -librtemsbsp_a_SOURCES +=
>>> >     >     >>     >
>>> >      ../../../../../../bsps/shared/dev/serial/legacy-console.c
>>> >     >     >>     >     -librtemsbsp_a_SOURCES +=
>>> >     >     >>     >
>>> >     >
>>>   ../../../../../../bsps/shared/dev/serial/legacy-console-control.c
>>> >     >     >>     >      librtemsbsp_a_SOURCES +=
>>> >     >     >>     >
>>> >     >
>>>   ../../../../../../bsps/arm/raspberrypi/console/console-config.c
>>> >     >     >>     >     -librtemsbsp_a_SOURCES +=
>>> >     >     >>     >
>>> >     >
>>>   ../../../../../../bsps/arm/raspberrypi/console/console_select.c
>>> >     >     >>     >     -librtemsbsp_a_SOURCES +=
>>> >     >     >>     >
>>> >      ../../../../../../bsps/arm/raspberrypi/console/usart.c
>>> >     >     >>     >      librtemsbsp_a_SOURCES +=
>>> >     >     >>     >
>>>  ../../../../../../bsps/arm/raspberrypi/console/fb.c
>>> >     >     >>     >      librtemsbsp_a_SOURCES +=
>>> >     >     >>     >
>>> >      ../../../../../../bsps/arm/raspberrypi/console/fbcons.c
>>> >     >     >>     >      librtemsbsp_a_SOURCES +=
>>> >     >     >>     >
>>> >      ../../../../../../bsps/arm/raspberrypi/console/outch.c
>>> >     >     >>     >     +librtemsbsp_a_SOURCES +=
>>> >     >     >>     >
>>> >      ../../../../../../bsps/shared/dev/serial/console-termios.c
>>> >     >     >>     >     +librtemsbsp_a_SOURCES +=
>>> >     >     >>     >
>>> >     >
>>>   ../../../../../../bsps/shared/dev/serial/console-termios-init.c
>>> >     >     >>     >     +librtemsbsp_a_SOURCES +=
>>> >     >     >>     >
>>>  ../../../../../../bsps/arm/shared/serial/arm-pl011.c
>>> >     >     >>     >
>>> >     >     >>     >      # Mailbox
>>> >     >     >>     >      librtemsbsp_a_SOURCES +=
>>> >     >     >>     >
>>> >      ../../../../../../bsps/arm/raspberrypi/start/mailbox.c
>>> >     >     >>     >     --
>>> >     >     >>     >     2.17.1
>>> >     >     >>     >
>>> >     >     >>
>>> >     >
>>> >
>>>
>> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20191231/89d14302/attachment-0001.html>


More information about the devel mailing list