source: rtems/c/src/lib/libbsp/arm/shared/include/arm-a9mpcore-start.h @ 2d3caccf

4.115
Last change on this file since 2d3caccf was 2d3caccf, checked in by Sebastian Huber <sebastian.huber@…>, on 06/05/14 at 11:22:08

bsps/arm: Define ARM_CP15_TEXT_SECTION

Define ARM_CP15_TEXT_SECTION to BSP_START_TEXT_SECTION so that the
start code is in the right section.

  • Property mode set to 100644
File size: 4.1 KB
Line 
1/**
2 *  @file
3 *
4 *  @ingroup arm_shared
5 *
6 *  @brief A9MPCORE_START Support
7 */
8
9/*
10 * Copyright (c) 2013-2014 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Dornierstr. 4
14 *  82178 Puchheim
15 *  Germany
16 *  <info@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_ARM_A9MPCORE_START_H
24#define LIBBSP_ARM_SHARED_ARM_A9MPCORE_START_H
25
26#include <rtems/score/smpimpl.h>
27
28#include <libcpu/arm-cp15.h>
29
30#include <bsp.h>
31#include <bsp/start.h>
32#include <bsp/arm-a9mpcore-regs.h>
33#include <bsp/arm-errata.h>
34
35#ifdef __cplusplus
36extern "C" {
37#endif /* __cplusplus */
38
39BSP_START_TEXT_SECTION static inline void
40arm_a9mpcore_start_set_vector_base(void)
41{
42  /*
43   * Do not use bsp_vector_table_begin == 0, since this will get optimized away.
44  */
45  if (bsp_vector_table_end != bsp_vector_table_size) {
46    uint32_t ctrl;
47
48    /*
49     * For now we assume that every Cortex-A9 MPCore has the Security Extensions.
50     * Later it might be necessary to evaluate the ID_PFR1 register.
51     */
52    arm_cp15_set_vector_base_address(bsp_vector_table_begin);
53
54    ctrl = arm_cp15_get_control();
55    ctrl &= ~ARM_CP15_CTRL_V;
56    arm_cp15_set_control(ctrl);
57  }
58}
59
60BSP_START_TEXT_SECTION static inline void arm_a9mpcore_start_scu_invalidate(
61  volatile a9mpcore_scu *scu,
62  uint32_t cpu_id,
63  uint32_t ways
64)
65{
66  scu->invss = (ways & 0xf) << ((cpu_id & 0x3) * 4);
67}
68
69BSP_START_TEXT_SECTION static inline void
70arm_a9mpcore_start_errata_764369_handler(volatile a9mpcore_scu *scu)
71{
72  if (arm_errata_is_applicable_processor_errata_764369()) {
73    scu->diagn_ctrl |= A9MPCORE_SCU_DIAGN_CTRL_MIGRATORY_BIT_DISABLE;
74  }
75}
76
77BSP_START_TEXT_SECTION static inline void
78arm_a9mpcore_start_scu_enable(volatile a9mpcore_scu *scu)
79{
80  scu->ctrl |= A9MPCORE_SCU_CTRL_SCU_EN;
81  arm_a9mpcore_start_errata_764369_handler(scu);
82}
83
84#ifdef RTEMS_SMP
85BSP_START_TEXT_SECTION static inline void
86arm_a9mpcore_start_on_secondary_processor(void)
87{
88  uint32_t ctrl;
89
90  arm_a9mpcore_start_set_vector_base();
91
92  arm_gic_irq_initialize_secondary_cpu();
93
94  ctrl = arm_cp15_start_setup_mmu_and_cache(
95    0,
96    ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_Z
97  );
98
99  arm_cp15_set_domain_access_control(
100    ARM_CP15_DAC_DOMAIN(ARM_MMU_DEFAULT_CLIENT_DOMAIN, ARM_CP15_DAC_CLIENT)
101  );
102
103  /* FIXME: Sharing the translation table between processors is brittle */
104  arm_cp15_set_translation_table_base(
105    (uint32_t *) bsp_translation_table_base
106  );
107
108  ctrl |= ARM_CP15_CTRL_I | ARM_CP15_CTRL_C | ARM_CP15_CTRL_M;
109  arm_cp15_set_control(ctrl);
110
111  _SMP_Start_multitasking_on_secondary_processor();
112}
113
114BSP_START_TEXT_SECTION static inline void
115arm_a9mpcore_start_enable_smp_in_auxiliary_control(void)
116{
117  /*
118   * Enable cache coherency support and cache/MMU maintenance broadcasts for
119   * this processor.
120   */
121  uint32_t actlr = arm_cp15_get_auxiliary_control();
122  actlr |= ARM_CORTEX_A9_ACTL_SMP | ARM_CORTEX_A9_ACTL_FW;
123  arm_cp15_set_auxiliary_control(actlr);
124}
125#endif
126
127BSP_START_TEXT_SECTION static inline void arm_a9mpcore_start_hook_0(void)
128{
129  volatile a9mpcore_scu *scu =
130    (volatile a9mpcore_scu *) BSP_ARM_A9MPCORE_SCU_BASE;
131  uint32_t cpu_id = arm_cortex_a9_get_multiprocessor_cpu_id();
132
133  arm_cp15_branch_predictor_invalidate_all();
134
135  if (cpu_id == 0) {
136    arm_a9mpcore_start_scu_enable(scu);
137  }
138
139#ifdef RTEMS_SMP
140  arm_a9mpcore_start_enable_smp_in_auxiliary_control();
141#endif
142
143  arm_a9mpcore_start_scu_invalidate(scu, cpu_id, 0xf);
144
145#ifdef RTEMS_SMP
146  if (cpu_id != 0) {
147    arm_a9mpcore_start_on_secondary_processor();
148  }
149#endif
150}
151
152BSP_START_TEXT_SECTION static inline void arm_a9mpcore_start_global_timer(void)
153{
154  volatile a9mpcore_gt *gt = (volatile a9mpcore_gt *) BSP_ARM_A9MPCORE_GT_BASE;
155
156  gt->ctrl = 0;
157  gt->cntrlower = 0;
158  gt->cntrupper = 0;
159  gt->ctrl = A9MPCORE_GT_CTRL_TMR_EN;
160}
161
162BSP_START_TEXT_SECTION static inline void arm_a9mpcore_start_hook_1(void)
163{
164  arm_a9mpcore_start_global_timer();
165  arm_a9mpcore_start_set_vector_base();
166}
167
168#ifdef __cplusplus
169}
170#endif /* __cplusplus */
171
172#endif /* LIBBSP_ARM_SHARED_ARM_A9MPCORE_START_H */
Note: See TracBrowser for help on using the repository browser.