source: rtems/bsps/arm/imx/start/bspstarthooks.c @ 07e2eac

5
Last change on this file since 07e2eac was c51f1fc5, checked in by Christian Mauderer <christian.mauderer@…>, on 12/27/19 at 21:08:11

bsps/arm: Define index of the workspace entry.

The imx BSP contained a hack to change the workspace entry of the MMU
table. This makes the used define visible for other BSPs too so that the
same hack can be used for example in raspberry pi too.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 * Copyright (c) 2013, 2018 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <info@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#define ARM_CP15_TEXT_SECTION BSP_START_TEXT_SECTION
16
17#include <bsp.h>
18#include <bsp/bootcard.h>
19#include <bsp/fdt.h>
20#include <bsp/linker-symbols.h>
21#include <bsp/start.h>
22#include <bsp/arm-cp15-start.h>
23#include <bsp/arm-a9mpcore-start.h>
24
25#include <libfdt.h>
26
27BSP_START_DATA_SECTION static arm_cp15_start_section_config
28imx_mmu_config_table[] = {
29  ARMV7_CP15_START_DEFAULT_SECTIONS,
30  {
31    .begin = 0x07000000U,
32    .end = 0x70000000U,
33    .flags = ARMV7_MMU_DEVICE
34  }
35};
36
37BSP_START_DATA_SECTION static char memory_path[] = "/memory";
38
39BSP_START_TEXT_SECTION static void setup_mmu_and_cache(void)
40{
41  const void *fdt;
42  int node;
43  uint32_t ctrl;
44
45  fdt = bsp_fdt_get();
46  node = fdt_path_offset_namelen(
47    fdt,
48    memory_path,
49    (int) sizeof(memory_path) - 1
50  );
51
52  if (node >= 0) {
53    int len;
54    const void *val;
55
56    val = fdt_getprop(fdt, node, "reg", &len);
57    if (len == 8) {
58      uint32_t begin;
59      uint32_t size;
60
61      begin = fdt32_to_cpu(((fdt32_t *) val)[0]);
62      size = fdt32_to_cpu(((fdt32_t *) val)[1]);
63
64      /* The heap code does not like an end address of zero */
65      if (begin + size == 0) {
66        size -= 4;
67      }
68
69      imx_mmu_config_table[ARMV7_CP15_START_WORKSPACE_ENTRY_INDEX].end =
70        begin + size;
71    }
72  }
73
74  ctrl = arm_cp15_start_setup_mmu_and_cache(
75    ARM_CP15_CTRL_A,
76    ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_Z
77  );
78
79  arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(
80    ctrl,
81    (uint32_t *) bsp_translation_table_base,
82    ARM_MMU_DEFAULT_CLIENT_DOMAIN,
83    &imx_mmu_config_table[0],
84    RTEMS_ARRAY_SIZE(imx_mmu_config_table)
85  );
86}
87
88BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
89{
90#ifdef RTEMS_SMP
91  uint32_t cpu_id = arm_cortex_a9_get_multiprocessor_cpu_id();
92
93  arm_a9mpcore_start_enable_smp_in_auxiliary_control();
94
95  if (cpu_id != 0) {
96    arm_a9mpcore_start_on_secondary_processor();
97  }
98#endif
99}
100
101BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
102{
103  arm_a9mpcore_start_set_vector_base();
104  bsp_start_copy_sections();
105  setup_mmu_and_cache();
106  bsp_start_clear_bss();
107}
108
109void bsp_work_area_initialize(void)
110{
111  uintptr_t begin;
112  uintptr_t end;
113
114  begin = imx_mmu_config_table[ARMV7_CP15_START_WORKSPACE_ENTRY_INDEX].begin;
115  end = imx_mmu_config_table[ARMV7_CP15_START_WORKSPACE_ENTRY_INDEX].end;
116
117  bsp_work_area_initialize_default((void *) begin, end - begin);
118}
Note: See TracBrowser for help on using the repository browser.