Changeset ecf7dd9 in rtems


Ignore:
Timestamp:
May 2, 2013, 9:41:22 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
27690ec
Parents:
fd51f7e
git-author:
Sebastian Huber <sebastian.huber@…> (05/02/13 09:41:22)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/03/13 15:30:55)
Message:

bsps/arm: Move CP15 start initialization

Location:
c/src/lib/libbsp/arm
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/lpc32xx/Makefile.am

    rfd51f7e recf7dd9  
    3535include_bsp_HEADERS += ../../shared/tod.h
    3636include_bsp_HEADERS += ../shared/include/start.h
     37include_bsp_HEADERS += ../shared/include/arm-cp15-start.h
    3738include_bsp_HEADERS += ../shared/lpc/include/lpc-timer.h
    3839include_bsp_HEADERS += ../shared/lpc/include/lpc-dma.h
  • c/src/lib/libbsp/arm/lpc32xx/preinstall.am

    rfd51f7e recf7dd9  
    9191PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/start.h
    9292
     93$(PROJECT_INCLUDE)/bsp/arm-cp15-start.h: ../shared/include/arm-cp15-start.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     94        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/arm-cp15-start.h
     95PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/arm-cp15-start.h
     96
    9397$(PROJECT_INCLUDE)/bsp/lpc-timer.h: ../shared/lpc/include/lpc-timer.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
    9498        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/lpc-timer.h
  • c/src/lib/libbsp/arm/lpc32xx/startup/bspstarthooks.c

    rfd51f7e recf7dd9  
    88
    99/*
    10  * Copyright (c) 2009-2011 embedded brains GmbH.  All rights reserved.
     10 * Copyright (c) 2009-2013 embedded brains GmbH.  All rights reserved.
    1111 *
    1212 *  embedded brains GmbH
    13  *  Obere Lagerstr. 30
     13 *  Dornierstr. 4
    1414 *  82178 Puchheim
    1515 *  Germany
     
    2525#include <bsp/lpc32xx.h>
    2626#include <bsp/mmu.h>
     27#include <bsp/arm-cp15-start.h>
    2728#include <bsp/linker-symbols.h>
    2829#include <bsp/uart-output-char.h>
     
    4243#endif
    4344
    44 static BSP_START_TEXT_SECTION void clear_bss(void)
    45 {
    46   const int *end = (const int *) bsp_section_bss_end;
    47   int *out = (int *) bsp_section_bss_begin;
    48 
    49   /* Clear BSS */
    50   while (out != end) {
    51     *out = 0;
    52     ++out;
    53   }
    54 }
    55 
    5645#ifndef LPC32XX_DISABLE_MMU
    57   typedef struct {
    58     uint32_t begin;
    59     uint32_t end;
    60     uint32_t flags;
    61   } lpc32xx_mmu_config;
    62 
    63   static const BSP_START_DATA_SECTION lpc32xx_mmu_config
     46  static const BSP_START_DATA_SECTION arm_cp15_start_section_config
    6447    lpc32xx_mmu_config_table [] = {
    6548    {
     
    131114    }
    132115  };
    133 
    134   static BSP_START_TEXT_SECTION void set_translation_table_entries(
    135     uint32_t *ttb,
    136     const lpc32xx_mmu_config *config
    137   )
    138   {
    139     uint32_t i = ARM_MMU_SECT_GET_INDEX(config->begin);
    140     uint32_t iend =
    141       ARM_MMU_SECT_GET_INDEX(ARM_MMU_SECT_MVA_ALIGN_UP(config->end));
    142 
    143     if (config->begin != config->end) {
    144       while (i < iend) {
    145         ttb [i] = (i << ARM_MMU_SECT_BASE_SHIFT) | config->flags;
    146         ++i;
    147       }
    148     }
    149   }
    150 
    151   static BSP_START_TEXT_SECTION void
    152     setup_translation_table_and_enable_mmu(uint32_t ctrl)
    153   {
    154     uint32_t const dac =
    155       ARM_CP15_DAC_DOMAIN(LPC32XX_MMU_CLIENT_DOMAIN, ARM_CP15_DAC_CLIENT);
    156     uint32_t *const ttb = (uint32_t *) bsp_translation_table_base;
    157     size_t const config_entry_count =
    158       sizeof(lpc32xx_mmu_config_table) / sizeof(lpc32xx_mmu_config_table [0]);
    159     size_t i = 0;
    160 
    161     arm_cp15_set_domain_access_control(dac);
    162     arm_cp15_set_translation_table_base(ttb);
    163 
    164     /* Initialize translation table with invalid entries */
    165     for (i = 0; i < ARM_MMU_TRANSLATION_TABLE_ENTRY_COUNT; ++i) {
    166       ttb [i] = 0;
    167     }
    168 
    169     for (i = 0; i < config_entry_count; ++i) {
    170       set_translation_table_entries(ttb, &lpc32xx_mmu_config_table [i]);
    171     }
    172 
    173     /* Enable MMU and cache */
    174     ctrl |= ARM_CP15_CTRL_I | ARM_CP15_CTRL_C | ARM_CP15_CTRL_M;
    175     arm_cp15_set_control(ctrl);
    176   }
    177116#endif
    178117
    179118static BSP_START_TEXT_SECTION void setup_mmu_and_cache(void)
    180119{
    181   uint32_t ctrl = 0;
    182 
    183   /* Disable MMU and cache, basic settings */
    184   ctrl = arm_cp15_get_control();
    185   ctrl &= ~(ARM_CP15_CTRL_I | ARM_CP15_CTRL_R | ARM_CP15_CTRL_C
    186     | ARM_CP15_CTRL_V | ARM_CP15_CTRL_M);
    187   ctrl |= ARM_CP15_CTRL_S | ARM_CP15_CTRL_A;
    188   arm_cp15_set_control(ctrl);
     120  uint32_t ctrl = arm_cp15_start_setup_mmu_and_cache(
     121    ARM_CP15_CTRL_I | ARM_CP15_CTRL_R | ARM_CP15_CTRL_C
     122      | ARM_CP15_CTRL_V | ARM_CP15_CTRL_M,
     123    ARM_CP15_CTRL_S | ARM_CP15_CTRL_A
     124  );
    189125
    190126  arm_cp15_cache_invalidate();
    191   arm_cp15_tlb_invalidate();
    192127
    193128  #ifndef LPC32XX_DISABLE_MMU
    194     setup_translation_table_and_enable_mmu(ctrl);
     129    arm_cp15_start_setup_translation_table_and_enable_mmu(
     130      ctrl,
     131      (uint32_t *) bsp_translation_table_base,
     132      LPC32XX_MMU_CLIENT_DOMAIN,
     133      &lpc32xx_mmu_config_table [0],
     134      RTEMS_ARRAY_SIZE(lpc32xx_mmu_config_table)
     135    );
    195136  #endif
    196137}
     
    242183{
    243184  setup_pll();
    244   setup_mmu_and_cache();
    245185}
    246186
     
    291231{
    292232  stop_dma_activities();
     233  bsp_start_copy_sections();
     234  setup_mmu_and_cache();
    293235  setup_uarts();
    294236  setup_timer();
    295 
    296   /* Copy .text section */
    297   arm_cp15_instruction_cache_invalidate();
    298   bsp_start_memcpy(
    299     (int *) bsp_section_text_begin,
    300     (const int *) bsp_section_text_load_begin,
    301     (size_t) bsp_section_text_size
    302   );
    303 
    304   /* Copy .rodata section */
    305   arm_cp15_instruction_cache_invalidate();
    306   bsp_start_memcpy(
    307     (int *) bsp_section_rodata_begin,
    308     (const int *) bsp_section_rodata_load_begin,
    309     (size_t) bsp_section_rodata_size
    310   );
    311 
    312   /* Copy .data section */
    313   arm_cp15_instruction_cache_invalidate();
    314   bsp_start_memcpy(
    315     (int *) bsp_section_data_begin,
    316     (const int *) bsp_section_data_load_begin,
    317     (size_t) bsp_section_data_size
    318   );
    319 
    320   /* Copy .fast_text section */
    321   arm_cp15_instruction_cache_invalidate();
    322   bsp_start_memcpy(
    323     (int *) bsp_section_fast_text_begin,
    324     (const int *) bsp_section_fast_text_load_begin,
    325     (size_t) bsp_section_fast_text_size
    326   );
    327 
    328   /* Copy .fast_data section */
    329   arm_cp15_instruction_cache_invalidate();
    330   bsp_start_memcpy(
    331     (int *) bsp_section_fast_data_begin,
    332     (const int *) bsp_section_fast_data_load_begin,
    333     (size_t) bsp_section_fast_data_size
    334   );
    335 
    336   /* Clear .bss section */
    337   clear_bss();
    338 
    339   /* At this point we can use objects outside the .start section */
    340 }
     237  bsp_start_clear_bss();
     238}
Note: See TracChangeset for help on using the changeset viewer.