source: rtems/bsps/include/bsp/bootcard.h @ 4678d1a

5
Last change on this file since 4678d1a was 4678d1a, checked in by Sebastian Huber <sebastian.huber@…>, on 07/24/18 at 08:50:39

bsps: bsp_start_on_secondary_processor()

Pass current processor control as first parameter in
bsp_start_on_secondary_processor() and qoriq_start_thread() to make
dependency more explicit.

  • Property mode set to 100644
File size: 4.7 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup bsp_bootcard
5 *
6 * @brief Standard system startup.
7 */
8
9/*
10 * Copyright (c) 2008-2014 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Dornierstr. 4
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.org/license/LICENSE.
21 */
22
23#ifndef LIBBSP_SHARED_BOOTCARD_H
24#define LIBBSP_SHARED_BOOTCARD_H
25
26#include <string.h>
27
28#include <rtems/config.h>
29#include <rtems/bspIo.h>
30#include <rtems/malloc.h>
31#include <rtems/score/wkspace.h>
32
33#include <bspopts.h>
34
35#ifdef __cplusplus
36extern "C" {
37#endif /* __cplusplus */
38
39/**
40 * @defgroup shared_bootcard Bootcard
41 *
42 * @ingroup bsp_shared
43 *
44 * @brief Standard system startup.
45 *
46 * @{
47 */
48
49/**
50 * @brief Global pointer to the command line of boot_card().
51 */
52extern const char *bsp_boot_cmdline;
53
54void bsp_start(void);
55
56void bsp_reset(void);
57
58/**
59 * @brief Standard system initialization procedure.
60 *
61 * You may pass a command line in @a cmdline.  It is later available via the
62 * global @ref bsp_boot_cmdline variable.
63 *
64 * This is the C entry point for ALL RTEMS BSPs.  It is invoked from the
65 * assembly language initialization file usually called @c start.S which does
66 * the basic CPU setup (stack, C runtime environment, zero BSS, load other
67 * sections) and calls afterwards boot_card().  The boot card function provides
68 * the framework for the BSP initialization sequence.  For the basic flow of
69 * initialization see RTEMS C User's Guide, Initialization Manager.
70 *
71 * This style of initialization ensures that the C++ global constructors are
72 * executed after RTEMS is initialized.
73 */
74void boot_card(const char *cmdline) RTEMS_NO_RETURN;
75
76#ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
77  /**
78   * @brief Gives the BSP a chance to reduce the work area size with sbrk()
79   * adding more later.
80   *
81   * bsp_sbrk_init() may reduce the work area size passed in. The routine
82   * returns the 'sbrk_amount' to be used when extending the heap.  Note that
83   * the return value may be zero.
84   *
85   * In case the @a area size is altered, then the remaining size of the
86   * @a area must be greater than or equal to @a min_size.
87   */
88  ptrdiff_t bsp_sbrk_init(Heap_Area *area, uintptr_t min_size);
89#endif
90
91static inline void bsp_work_area_initialize_default(
92  void *area_begin,
93  uintptr_t area_size
94)
95{
96  Heap_Area area = {
97    .begin = area_begin,
98    .size = area_size
99  };
100
101  #if BSP_DIRTY_MEMORY == 1
102    memset(area.begin, 0xCF,  area.size);
103  #endif
104
105  #ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
106    {
107      uintptr_t overhead = _Heap_Area_overhead(CPU_HEAP_ALIGNMENT);
108      uintptr_t work_space_size = rtems_configuration_get_work_space_size();
109      ptrdiff_t sbrk_amount = bsp_sbrk_init(
110        &area,
111        work_space_size
112          + overhead
113          + (rtems_configuration_get_unified_work_area() ? 0 : overhead)
114      );
115
116      rtems_heap_set_sbrk_amount(sbrk_amount);
117    }
118  #endif
119
120  /*
121   *  The following may be helpful in debugging what goes wrong when
122   *  you are allocating the Work Area in a new BSP.
123   */
124  #ifdef BSP_GET_WORK_AREA_DEBUG
125    {
126      void *sp = __builtin_frame_address(0);
127      void *end = (char *) area.begin + area.size;
128      printk(
129        "work_area_start = 0x%p\n"
130        "work_area_size = %lu 0x%08lx\n"
131        "end = 0x%p\n"
132        "current stack pointer = 0x%p%s\n",
133        area.begin,
134        (unsigned long) area.size,  /* decimal */
135        (unsigned long) area.size,  /* hexadecimal */
136        end,
137        sp,
138        (uintptr_t) sp >= (uintptr_t) area.begin
139          && (uintptr_t) sp <= (uintptr_t) end ?
140            " OVERLAPS!" : ""
141      );
142    }
143  #endif
144
145  _Workspace_Handler_initialization(&area, 1, NULL);
146
147  #ifdef BSP_GET_WORK_AREA_DEBUG
148    printk(
149      "heap_start = 0x%p\n"
150      "heap_size = %lu\n",
151      area.begin,
152      (unsigned long) area.size
153    );
154  #endif
155
156  RTEMS_Malloc_Initialize(&area, 1, NULL);
157}
158
159static inline void bsp_work_area_initialize_with_table(
160  Heap_Area *areas,
161  size_t area_count
162)
163{
164  _Workspace_Handler_initialization(areas, area_count, _Heap_Extend);
165  RTEMS_Malloc_Initialize(areas, area_count, _Heap_Extend);
166}
167
168void bsp_work_area_initialize(void);
169
170struct Per_CPU_Control;
171
172/**
173 * @brief Standard start routine for secondary processors.
174 *
175 * This function is usually called by low-level startup code of secondary
176 * processors or boot loaders starting a secondary processor.  The final step
177 * of this function is a call to
178 * _SMP_Start_multitasking_on_secondary_processor().
179 */
180void bsp_start_on_secondary_processor(struct Per_CPU_Control *cpu_self);
181
182/** @} */
183
184#ifdef __cplusplus
185}
186#endif /* __cplusplus */
187
188#endif /* LIBBSP_SHARED_BOOTCARD_H */
Note: See TracBrowser for help on using the repository browser.