[PATCH 7/7] arm/raspberrypi: add cmdline support for rpi bsp.

Gedare Bloom gedare at rtems.org
Thu May 19 22:15:20 UTC 2016


These all look fine to push. go ahead

On Thu, May 19, 2016 at 7:16 AM,  <ppisa4lists at pikron.com> wrote:
> From: Pavel Pisa <ppisa at pikron.com>
>
> ---
>  c/src/lib/libbsp/arm/raspberrypi/Makefile.am       |  1 +
>  c/src/lib/libbsp/arm/raspberrypi/include/bsp.h     |  6 +++
>  c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c | 47 ++++++++++++++++++++++
>  3 files changed, 54 insertions(+)
>  create mode 100644 c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c
>
> diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
> index 91f327e..258f8a0 100644
> --- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
> +++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
> @@ -95,6 +95,7 @@ libbsp_a_SOURCES += ../shared/arm-cp15-set-ttb-entries.c
>  # Startup
>  libbsp_a_SOURCES += ../../shared/bspreset_loop.c
>  libbsp_a_SOURCES += startup/bspstart.c
> +libbsp_a_SOURCES += startup/cmdline.c
>
>  # IRQ
>  libbsp_a_SOURCES += ../shared/arm-cp15-set-exception-handler.c
> diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h b/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h
> index 0abeed6..18a94ea 100644
> --- a/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h
> +++ b/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h
> @@ -7,6 +7,7 @@
>   */
>
>  /*
> + * Copyright (c) 2015 Yang Qiao
>   * Copyright (c) 2013 Alan Cudmore
>   *
>   *  The license and distribution terms for this file may be
> @@ -35,6 +36,11 @@ extern "C" {
>  #define BSP_GPIO_PINS_PER_BANK 32
>  #define BSP_GPIO_PINS_PER_SELECT_BANK 10
>
> +void rpi_init_cmdline(void);
> +const char *rpi_cmdline_get_cached(void);
> +const char *rpi_cmdline_get_raw(void);
> +const char *rpi_cmdline_get_arg(const char* arg);
> +
>  #ifdef __cplusplus
>  }
>  #endif /* __cplusplus */
> diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c b/c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c
> new file mode 100644
> index 0000000..f8a7182
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c
> @@ -0,0 +1,47 @@
> +/**
> + * @file
> + *
> + * @ingroup raspberrypi
> + *
> + * @brief mailbox support.
> + */
> +/*
> + * 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/vc.h>
> +
> +#define MAX_CMDLINE_LENGTH 1024
> +static int rpi_cmdline_ready;
> +static char rpi_cmdline_cached[MAX_CMDLINE_LENGTH];
> +static bcm2835_get_cmdline_entries rpi_cmdline_entries;
> +
> +const char *rpi_cmdline_get_raw(void)
> +{
> +  memset(&rpi_cmdline_entries, 0, sizeof(rpi_cmdline_entries));
> +  bcm2835_mailbox_get_cmdline(&rpi_cmdline_entries);
> +  return rpi_cmdline_entries.cmdline;
> +}
> +
> +const char *rpi_cmdline_get_cached(void)
> +{
> +  if (!rpi_cmdline_ready) {
> +    const char *line = rpi_cmdline_get_raw();
> +    strncpy(rpi_cmdline_cached, line, MAX_CMDLINE_LENGTH - 1);
> +    rpi_cmdline_cached[MAX_CMDLINE_LENGTH - 1] = 0;
> +    rpi_cmdline_ready = 1;
> +  }
> +  return rpi_cmdline_cached;
> +}
> +
> +const char *rpi_cmdline_get_arg(const char* arg)
> +{
> +  return strstr (rpi_cmdline_get_cached(), arg);
> +}
> --
> 1.9.1
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list