source: rtems/bsps/arm/imx/start/bspstarthooks.c @ 1b560731

Last change on this file since 1b560731 was 1b560731, checked in by Sebastian Huber <sebastian.huber@…>, on 07/07/21 at 07:52:56

bsp/imx: Fix pointer from integer warning

  • Property mode set to 100644
File size: 2.9 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 <rtems/sysinit.h>
26
27#include <libfdt.h>
28
29BSP_START_DATA_SECTION static arm_cp15_start_section_config
30imx_mmu_config_table[] = {
31  ARMV7_CP15_START_DEFAULT_SECTIONS,
32  {
33    .begin = 0x00a00000U,
34    .end = 0x70000000U,
35    .flags = ARMV7_MMU_DEVICE
36  }
37};
38
39BSP_START_DATA_SECTION static char memory_path[] = "/memory";
40
41BSP_START_TEXT_SECTION static void setup_mmu_and_cache(void)
42{
43  const void *fdt;
44  int node;
45  uint32_t ctrl;
46
47  fdt = bsp_fdt_get();
48  node = fdt_path_offset_namelen(
49    fdt,
50    memory_path,
51    (int) sizeof(memory_path) - 1
52  );
53
54  if (node >= 0) {
55    int len;
56    const void *val;
57
58    val = fdt_getprop(fdt, node, "reg", &len);
59    if (len == 8) {
60      uint32_t begin;
61      uint32_t size;
62
63      begin = fdt32_to_cpu(((fdt32_t *) val)[0]);
64      size = fdt32_to_cpu(((fdt32_t *) val)[1]);
65
66      /* The heap code does not like an end address of zero */
67      if (begin + size == 0) {
68        size -= 4;
69      }
70
71      imx_mmu_config_table[ARMV7_CP15_START_WORKSPACE_ENTRY_INDEX].end =
72        begin + size;
73    }
74  }
75
76  ctrl = arm_cp15_start_setup_mmu_and_cache(
77    ARM_CP15_CTRL_A,
78    ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_Z
79  );
80
81  arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(
82    ctrl,
83    (uint32_t *) bsp_translation_table_base,
84    ARM_MMU_DEFAULT_CLIENT_DOMAIN,
85    &imx_mmu_config_table[0],
86    RTEMS_ARRAY_SIZE(imx_mmu_config_table)
87  );
88}
89
90BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
91{
92#ifdef RTEMS_SMP
93  uint32_t cpu_id = arm_cortex_a9_get_multiprocessor_cpu_id();
94
95  arm_a9mpcore_start_enable_smp_in_auxiliary_control();
96
97  if (cpu_id != 0) {
98    arm_a9mpcore_start_on_secondary_processor();
99  }
100#endif
101}
102
103BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
104{
105  bsp_start_copy_sections();
106  setup_mmu_and_cache();
107  bsp_start_clear_bss();
108}
109
110static Memory_Area _Memory_Areas[1];
111
112static void bsp_memory_initialize(void)
113{
114  const arm_cp15_start_section_config *section;
115
116  section = &imx_mmu_config_table[ARMV7_CP15_START_WORKSPACE_ENTRY_INDEX];
117  _Memory_Initialize(
118    &_Memory_Areas[0],
119    (void *) section->begin,
120    (void *) section->end
121  );
122}
123
124RTEMS_SYSINIT_ITEM(
125  bsp_memory_initialize,
126  RTEMS_SYSINIT_MEMORY,
127  RTEMS_SYSINIT_ORDER_MIDDLE
128);
129
130static const Memory_Information _Memory_Information =
131  MEMORY_INFORMATION_INITIALIZER(_Memory_Areas);
132
133const Memory_Information *_Memory_Get(void)
134{
135  return &_Memory_Information;
136}
Note: See TracBrowser for help on using the repository browser.