source: rtems/bsps/arm/raspberrypi/start/cmdline.c @ e0dd8a5a

5
Last change on this file since e0dd8a5a was 9964895, checked in by Sebastian Huber <sebastian.huber@…>, on 04/20/18 at 08:35:35

bsps: Move startup files to bsps

Adjust build support files to new directory layout.

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup raspberrypi
5 *
6 * @brief mailbox support.
7 */
8/*
9 * Copyright (c) 2015 Yang Qiao
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *
14 *  http://www.rtems.org/license/LICENSE
15 *
16 */
17
18#include <bsp.h>
19#include <bsp/vc.h>
20
21#include <string.h>
22
23#define MAX_CMDLINE_LENGTH 1024
24static int rpi_cmdline_ready = -1;
25static char rpi_cmdline_cached[MAX_CMDLINE_LENGTH] = "force .data placement";
26static bcm2835_get_cmdline_entries rpi_cmdline_entries;
27
28const char *rpi_cmdline_get_raw(void)
29{
30  memset(&rpi_cmdline_entries, 0, sizeof(rpi_cmdline_entries));
31  if (bcm2835_mailbox_get_cmdline(&rpi_cmdline_entries) < 0)
32     return NULL;
33  return rpi_cmdline_entries.cmdline;
34}
35
36const char *rpi_cmdline_get_cached(void)
37{
38  if (rpi_cmdline_ready <= 0) {
39    const char *line = rpi_cmdline_get_raw();
40    if (line != NULL)
41      strncpy(rpi_cmdline_cached, line, MAX_CMDLINE_LENGTH - 1);
42    rpi_cmdline_cached[MAX_CMDLINE_LENGTH - 1] = 0;
43    rpi_cmdline_ready = 1;
44  }
45  return rpi_cmdline_cached;
46}
47
48const char *rpi_cmdline_get_arg(const char* arg)
49{
50  const char *opt_data;
51  opt_data = strstr(rpi_cmdline_get_cached(), arg);
52  if (opt_data)
53    opt_data += strlen(arg);
54  return opt_data;
55}
Note: See TracBrowser for help on using the repository browser.