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

4.115
Last change on this file since 43ef7068 was e331e69, checked in by Ralf Kirchner <ralf.kirchner@…>, on 04/16/14 at 14:07:13

bsp/arm: RTEMS_SMP to arm erratum 764369 detection

Move the RTEMS_SMP conditional compilation to the detection method of arm erratum 764369

  • Property mode set to 100644
File size: 4.3 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 uint32_t
40arm_cp15_get_control(void);
41
42BSP_START_TEXT_SECTION static inline void
43arm_cp15_set_control(uint32_t val);
44
45BSP_START_TEXT_SECTION static inline uint32_t
46arm_cp15_get_auxiliary_control(void);
47
48BSP_START_TEXT_SECTION static inline void
49arm_cp15_set_auxiliary_control(uint32_t val);
50
51BSP_START_TEXT_SECTION static inline void
52arm_cp15_set_vector_base_address(void *base);
53
54BSP_START_TEXT_SECTION static inline arm_a9mpcore_start_set_vector_base(void)
55{
56  /*
57   * Do not use bsp_vector_table_begin == 0, since this will get optimized away.
58  */
59  if (bsp_vector_table_end != bsp_vector_table_size) {
60    uint32_t ctrl;
61
62    /*
63     * For now we assume that every Cortex-A9 MPCore has the Security Extensions.
64     * Later it might be necessary to evaluate the ID_PFR1 register.
65     */
66    arm_cp15_set_vector_base_address(bsp_vector_table_begin);
67
68    ctrl = arm_cp15_get_control();
69    ctrl &= ~ARM_CP15_CTRL_V;
70    arm_cp15_set_control(ctrl);
71  }
72}
73
74BSP_START_TEXT_SECTION static inline arm_a9mpcore_start_scu_invalidate(
75  volatile a9mpcore_scu *scu,
76  uint32_t cpu_id,
77  uint32_t ways
78)
79{
80  scu->invss = (ways & 0xf) << ((cpu_id & 0x3) * 4);
81}
82
83BSP_START_TEXT_SECTION static void inline
84arm_a9mpcore_start_errata_764369_handler(volatile a9mpcore_scu *scu)
85{
86  if (arm_errata_is_applicable_processor_errata_764369()) {
87    scu->diagn_ctrl |= A9MPCORE_SCU_DIAGN_CTRL_MIGRATORY_BIT_DISABLE;
88  }
89}
90
91BSP_START_TEXT_SECTION static inline
92arm_a9mpcore_start_scu_enable(volatile a9mpcore_scu *scu)
93{
94  scu->ctrl |= A9MPCORE_SCU_CTRL_SCU_EN;
95  arm_a9mpcore_start_errata_764369_handler(scu);
96}
97
98BSP_START_TEXT_SECTION static inline arm_a9mpcore_start_hook_0(void)
99{
100  volatile a9mpcore_scu *scu =
101    (volatile a9mpcore_scu *) BSP_ARM_A9MPCORE_SCU_BASE;
102  uint32_t cpu_id;
103
104  arm_a9mpcore_start_scu_enable(scu);
105
106#ifdef RTEMS_SMP
107  /* Enable cache coherency support for this processor */
108  {
109    uint32_t actlr = arm_cp15_get_auxiliary_control();
110    actlr |= ARM_CORTEX_A9_ACTL_SMP;
111    arm_cp15_set_auxiliary_control(actlr);
112  }
113#endif
114
115  cpu_id = arm_cortex_a9_get_multiprocessor_cpu_id();
116
117  arm_a9mpcore_start_scu_invalidate(scu, cpu_id, 0xf);
118
119#ifdef RTEMS_SMP
120  if (cpu_id != 0) {
121    arm_a9mpcore_start_set_vector_base();
122
123    if (cpu_id < rtems_configuration_get_maximum_processors()) {
124      uint32_t ctrl;
125
126      arm_gic_irq_initialize_secondary_cpu();
127
128      ctrl = arm_cp15_start_setup_mmu_and_cache(
129        0,
130        ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_Z
131      );
132
133      arm_cp15_set_domain_access_control(
134        ARM_CP15_DAC_DOMAIN(ARM_MMU_DEFAULT_CLIENT_DOMAIN, ARM_CP15_DAC_CLIENT)
135      );
136
137      /* FIXME: Sharing the translation table between processors is brittle */
138      arm_cp15_set_translation_table_base(
139        (uint32_t *) bsp_translation_table_base
140      );
141
142      ctrl |= ARM_CP15_CTRL_I | ARM_CP15_CTRL_C | ARM_CP15_CTRL_M;
143      arm_cp15_set_control(ctrl);
144
145      _SMP_Start_multitasking_on_secondary_processor();
146    } else {
147      /* FIXME: Shutdown processor */
148      while (1) {
149        __asm__ volatile ("wfi");
150      }
151    }
152  }
153#endif
154}
155
156BSP_START_TEXT_SECTION static inline arm_a9mpcore_start_global_timer(void)
157{
158  volatile a9mpcore_gt *gt = (volatile a9mpcore_gt *) BSP_ARM_A9MPCORE_GT_BASE;
159
160  gt->ctrl = 0;
161  gt->cntrlower = 0;
162  gt->cntrupper = 0;
163  gt->ctrl = A9MPCORE_GT_CTRL_TMR_EN;
164}
165
166BSP_START_TEXT_SECTION static inline arm_a9mpcore_start_hook_1(void)
167{
168  arm_a9mpcore_start_global_timer();
169  arm_a9mpcore_start_set_vector_base();
170}
171
172#ifdef __cplusplus
173}
174#endif /* __cplusplus */
175
176#endif /* LIBBSP_ARM_SHARED_ARM_A9MPCORE_START_H */
Note: See TracBrowser for help on using the repository browser.