source: rtems/c/src/lib/libbsp/arm/shared/include/start.h @ f9c1e117

4.11
Last change on this file since f9c1e117 was f9c1e117, checked in by Pavel Pisa <pisa@…>, on 07/04/16 at 09:05:55

bsps/arm: Support recent bootloaders starting kernel in HYP mode

When HYP mode is detected at startup then setup HYP mode
vectors table (for future extensions) clean exceptions
switching to HYP mode and switch CPU to ARM SVC mode.

BSPs which want to use this support need to include next option
in their configure.ac

RTEMS_BSPOPTS_SET([BSP_START_IN_HYP_SUPPORT],[*],[1])
RTEMS_BSPOPTS_HELP([BSP_START_IN_HYP_SUPPORT], [Support start of BSP in ARM HYP mode])
AM_CONDITIONAL(BSP_START_IN_HYP_SUPPORT,test "$BSP_START_IN_HYP_SUPPORT" = "1")

and need to include next lines in corresponding Makefile.am

if BSP_START_IN_HYP_SUPPORT
libbsp_a_SOURCES += ../shared/startup/bsp-start-in-hyp-support.S
endif

Updates #2783

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup arm_start
5 *
6 * @brief ARM system low level start.
7 */
8
9/*
10 * Copyright (c) 2008-2013 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
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_ARM_SHARED_START_H
24#define LIBBSP_ARM_SHARED_START_H
25
26#include <string.h>
27
28#include <bsp/linker-symbols.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif /* __cplusplus */
33
34/**
35 * @defgroup arm_start System Start
36 *
37 * @ingroup arm_shared
38 *
39 * @brief ARM system low level start.
40 *
41 * @{
42 */
43
44#define BSP_START_TEXT_SECTION __attribute__((section(".bsp_start_text")))
45
46#define BSP_START_DATA_SECTION __attribute__((section(".bsp_start_data")))
47
48/*
49* Many ARM boot loaders pass arguments to loaded OS kernel
50*/
51#ifdef BSP_START_HOOKS_WITH_LOADER_ARGS
52#define BSP_START_HOOKS_LOADER_ARGS int saved_psr, int saved_machid, int saved_dtb_adr
53#else
54#define BSP_START_HOOKS_LOADER_ARGS void
55#endif
56
57/**
58* @brief System start entry.
59*/
60void _start(void);
61
62/**
63* @brief Start entry hook 0.
64*
65* This hook will be called from the start entry code after all modes and
66* stack pointers are initialized but before the copying of the exception
67* vectors.
68*/
69void bsp_start_hook_0(BSP_START_HOOKS_LOADER_ARGS);
70
71/**
72* @brief Start entry hook 1.
73*
74* This hook will be called from the start entry code after copying of the
75* exception vectors but before the call to boot_card().
76*/
77void bsp_start_hook_1(BSP_START_HOOKS_LOADER_ARGS);
78
79/**
80 * @brief Similar to standard memcpy().
81 *
82 * The memory areas must be word aligned.  Copy code will be executed from the
83 * stack.  If @a dest equals @a src nothing will be copied.
84 */
85void bsp_start_memcpy(int *dest, const int *src, size_t n);
86
87/**
88 * @brief ARM entry point to bsp_start_memcpy().
89 */
90void bsp_start_memcpy_arm(int *dest, const int *src, size_t n);
91
92/**
93 * @brief Copies all standard sections from the load to the runtime area.
94 */
95BSP_START_TEXT_SECTION static inline void bsp_start_copy_sections(void)
96{
97  /* Copy .text section */
98  bsp_start_memcpy(
99    (int *) bsp_section_text_begin,
100    (const int *) bsp_section_text_load_begin,
101    (size_t) bsp_section_text_size
102  );
103
104  /* Copy .rodata section */
105  bsp_start_memcpy(
106    (int *) bsp_section_rodata_begin,
107    (const int *) bsp_section_rodata_load_begin,
108    (size_t) bsp_section_rodata_size
109  );
110
111  /* Copy .data section */
112  bsp_start_memcpy(
113    (int *) bsp_section_data_begin,
114    (const int *) bsp_section_data_load_begin,
115    (size_t) bsp_section_data_size
116  );
117
118  /* Copy .fast_text section */
119  bsp_start_memcpy(
120    (int *) bsp_section_fast_text_begin,
121    (const int *) bsp_section_fast_text_load_begin,
122    (size_t) bsp_section_fast_text_size
123  );
124
125  /* Copy .fast_data section */
126  bsp_start_memcpy(
127    (int *) bsp_section_fast_data_begin,
128    (const int *) bsp_section_fast_data_load_begin,
129    (size_t) bsp_section_fast_data_size
130  );
131}
132
133BSP_START_TEXT_SECTION static inline void bsp_start_clear_bss(void)
134{
135  memset(bsp_section_bss_begin, 0, (size_t) bsp_section_bss_size);
136}
137
138/** @} */
139
140#ifdef __cplusplus
141}
142#endif /* __cplusplus */
143
144#endif /* LIBBSP_ARM_SHARED_START_H */
Note: See TracBrowser for help on using the repository browser.