arm/raspberrypi: add cmdline support for rpi bsp.

This commit is contained in:
Pavel Pisa
2016-05-19 11:36:15 +02:00
parent 54c197a2af
commit 8830bfe65b
3 changed files with 54 additions and 0 deletions

View File

@@ -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

View File

@@ -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 */

View File

@@ -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);
}