source: rtems/c/src/lib/libbsp/arm/xilinx-zynq/startup/bspstarthooks.c @ 13c985c

5
Last change on this file since 13c985c was 13c985c, checked in by Pavel Pisa <pisa@…>, on 08/31/16 at 14:49:15

arm/xilinx_zynq: ensure that cache is cleaned and MMU disabled when initialization starts.

The u-boot loader enables the MMU plus the data and instruction caches
in some versions which results in RTEMS boot failure.

Closes #2774.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 * Copyright (c) 2013-2014 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/start.h>
19#include <bsp/arm-cp15-start.h>
20#include <bsp/arm-a9mpcore-start.h>
21
22BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
23{
24  uint32_t sctlr_val;
25
26  sctlr_val = arm_cp15_get_control();
27
28  /*
29   * Current U-boot loader seems to start kernel image
30   * with I and D caches on and MMU enabled.
31   * If RTEMS application image finds that cache is on
32   * during startup then disable caches.
33   */
34  if ( sctlr_val & (ARM_CP15_CTRL_I | ARM_CP15_CTRL_C | ARM_CP15_CTRL_M ) ) {
35    if ( sctlr_val & (ARM_CP15_CTRL_C | ARM_CP15_CTRL_M ) ) {
36      /*
37       * If the data cache is on then ensure that it is clean
38       * before switching off to be extra carefull.
39       */
40      arm_cp15_data_cache_clean_all_levels();
41    }
42    arm_cp15_flush_prefetch_buffer();
43    sctlr_val &= ~ ( ARM_CP15_CTRL_I | ARM_CP15_CTRL_C | ARM_CP15_CTRL_M | ARM_CP15_CTRL_A );
44    arm_cp15_set_control( sctlr_val );
45  }
46  arm_cp15_instruction_cache_invalidate();
47  /*
48   * The care should be taken there that no shared levels
49   * are invalidated by secondary CPUs in SMP case.
50   * It is not problem on Zynq because level of coherency
51   * is L1 only and higher level is not maintained and seen
52   * by CP15. So no special care to limit levels on the secondary
53   * are required there.
54   */
55  arm_cp15_data_cache_invalidate_all_levels();
56  arm_cp15_branch_predictor_invalidate_all();
57  arm_cp15_tlb_invalidate();
58  arm_cp15_flush_prefetch_buffer();
59  arm_a9mpcore_start_hook_0();
60}
61
62BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
63{
64  arm_a9mpcore_start_hook_1();
65  bsp_start_copy_sections();
66  zynq_setup_mmu_and_cache();
67
68#if !defined(RTEMS_SMP) \
69  && (defined(BSP_DATA_CACHE_ENABLED) \
70    || defined(BSP_INSTRUCTION_CACHE_ENABLED))
71  /* Enable unified L2 cache */
72  rtems_cache_enable_data();
73#endif
74
75  bsp_start_clear_bss();
76}
Note: See TracBrowser for help on using the repository browser.