source: rtems/bsps/arm/realview-pbx-a9/start/bspstarthooks.c

Last change on this file was bcef89f2, checked in by Sebastian Huber <sebastian.huber@…>, on 05/19/23 at 06:18:25

Update company name

The embedded brains GmbH & Co. KG is the legal successor of embedded
brains GmbH.

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*
4 * Copyright (c) 2013 embedded brains GmbH & Co. KG
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#define ARM_CP15_TEXT_SECTION BSP_START_TEXT_SECTION
29
30#include <bsp.h>
31#include <bsp/start.h>
32#include <bsp/arm-cp15-start.h>
33#include <bsp/arm-a9mpcore-start.h>
34
35#ifdef RTEMS_SMP
36#include <rtems/score/smpimpl.h>
37#endif
38
39BSP_START_DATA_SECTION static const arm_cp15_start_section_config
40rvpbxa9_mmu_config_table[] = {
41  ARMV7_CP15_START_DEFAULT_SECTIONS,
42  {
43    .begin = 0x10000000U,
44    .end = 0x10020000U,
45    .flags = ARMV7_MMU_DEVICE
46  }, {
47    .begin = 0x1f000000U,
48    .end = 0x20000000U,
49    .flags = ARMV7_MMU_DEVICE
50  }, {
51    .begin = 0x4e000000U,
52    .end = 0x4f000000U,
53    .flags = ARMV7_MMU_DEVICE
54  }
55};
56
57BSP_START_TEXT_SECTION static void setup_mmu_and_cache(void)
58{
59  uint32_t ctrl = arm_cp15_start_setup_mmu_and_cache(
60    ARM_CP15_CTRL_A,
61    ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_Z
62  );
63
64  arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(
65    ctrl,
66    (uint32_t *) bsp_translation_table_base,
67    ARM_MMU_DEFAULT_CLIENT_DOMAIN,
68    &rvpbxa9_mmu_config_table[0],
69    RTEMS_ARRAY_SIZE(rvpbxa9_mmu_config_table)
70  );
71}
72
73BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
74{
75#ifdef RTEMS_SMP
76  uint32_t cpu_index_self = _SMP_Get_current_processor();
77
78  /*
79   * QEMU jumps to the entry point of the ELF file on all processors.  Prevent
80   * the fatal errors SMP_FATAL_MULTITASKING_START_ON_INVALID_PROCESSOR and
81   * SMP_FATAL_MULTITASKING_START_ON_UNASSIGNED_PROCESSOR this way.
82   */
83  if (cpu_index_self != 0 && !_SMP_Should_start_processor(cpu_index_self)) {
84    while (true) {
85      _ARM_Wait_for_event();
86    }
87  }
88#endif
89
90  arm_a9mpcore_start_hook_0();
91}
92
93BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
94{
95  arm_a9mpcore_start_hook_1();
96  bsp_start_copy_sections();
97  setup_mmu_and_cache();
98  bsp_start_clear_bss();
99}
Note: See TracBrowser for help on using the repository browser.