Changeset f9648ba in rtems


Ignore:
Timestamp:
Oct 28, 2019, 9:15:28 AM (6 weeks ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
3859cd63
Parents:
3fb72b0f
git-author:
Sebastian Huber <sebastian.huber@…> (10/28/19 09:15:28)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/31/19 08:48:05)
Message:

bsps/arm: Add support for small pages MMU

The small page MMU support reduces the granularity for memory settings
through the MMU from 1MiB sections to 4KiB small pages.

Enable it by default on the realview_pbx_a9_qemu BSP.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • bsps/arm/include/bsp/arm-cp15-start.h

    r3fb72b0f rf9648ba  
    1010/*
    1111 * Copyright (c) 2013 Hesham AL-Matary.
    12  * Copyright (c) 2009-2014 embedded brains GmbH.  All rights reserved.
     12 * Copyright (c) 2009-2019 embedded brains GmbH.  All rights reserved.
    1313 *
    1414 *  embedded brains GmbH
     
    2929#include <bsp/start.h>
    3030#include <bsp/linker-symbols.h>
     31#include <bspopts.h>
    3132
    3233#ifdef __cplusplus
     
    107108)
    108109{
    109   uint32_t i = ARM_MMU_SECT_GET_INDEX(config->begin);
    110   uint32_t iend =
    111     ARM_MMU_SECT_GET_INDEX(ARM_MMU_SECT_MVA_ALIGN_UP(config->end));
    112   uint32_t index_mask = (1U << (32 - ARM_MMU_SECT_BASE_SHIFT)) - 1U;
    113 
    114110  if (config->begin != config->end) {
     111    uint32_t i;
     112    uint32_t iend;
     113    uint32_t index_mask;
     114    uint32_t flags;
     115#ifdef ARM_MMU_USE_SMALL_PAGES
     116    uint32_t *pt;
     117
     118    pt = &ttb[ARM_MMU_TRANSLATION_TABLE_ENTRY_COUNT];
     119    i = ARM_MMU_SMALL_PAGE_GET_INDEX(config->begin);
     120    iend = ARM_MMU_SMALL_PAGE_GET_INDEX(ARM_MMU_SECT_MVA_ALIGN_UP(config->end));
     121    index_mask = (1U << (32 - ARM_MMU_SMALL_PAGE_BASE_SHIFT)) - 1U;
     122    flags = ARM_MMU_SECT_FLAGS_TO_SMALL_PAGE(config->flags);
     123
    115124    while (i != iend) {
    116       ttb [i] = (i << ARM_MMU_SECT_BASE_SHIFT) | config->flags;
     125      pt[i] = (i << ARM_MMU_SMALL_PAGE_BASE_SHIFT) | flags;
    117126      i = (i + 1U) & index_mask;
    118127    }
     128#else
     129    i = ARM_MMU_SECT_GET_INDEX(config->begin);
     130    iend = ARM_MMU_SECT_GET_INDEX(ARM_MMU_SECT_MVA_ALIGN_UP(config->end));
     131    index_mask = (1U << (32 - ARM_MMU_SECT_BASE_SHIFT)) - 1U;
     132    flags = config->flags;
     133
     134    while (i != iend) {
     135      ttb[i] = (i << ARM_MMU_SECT_BASE_SHIFT) | flags;
     136      i = (i + 1U) & index_mask;
     137    }
     138#endif
    119139  }
    120140}
     
    128148)
    129149{
    130   uint32_t dac = ARM_CP15_DAC_DOMAIN(client_domain, ARM_CP15_DAC_CLIENT);
     150#ifdef ARM_MMU_USE_SMALL_PAGES
     151  uint32_t *pt;
     152#endif
     153  uint32_t dac;
    131154  size_t i;
    132155
     156  dac = ARM_CP15_DAC_DOMAIN(client_domain, ARM_CP15_DAC_CLIENT);
    133157  arm_cp15_set_domain_access_control(dac);
    134158  arm_cp15_set_translation_table_base(ttb);
    135159
    136160  /* Initialize translation table with invalid entries */
     161#ifdef ARM_MMU_USE_SMALL_PAGES
     162  pt = &ttb[ARM_MMU_TRANSLATION_TABLE_ENTRY_COUNT];
    137163  for (i = 0; i < ARM_MMU_TRANSLATION_TABLE_ENTRY_COUNT; ++i) {
    138     ttb [i] = 0;
    139   }
     164    size_t j;
     165
     166    for (j = 0; j < ARM_MMU_SMALL_PAGE_TABLE_ENTRY_COUNT; ++j) {
     167      pt[j] = 0;
     168    }
     169
     170    ttb[i] = (uint32_t) pt | (client_domain << ARM_MMU_SECT_DOMAIN_SHIFT)
     171      | ARM_MMU_PAGE_TABLE_DEFAULT;
     172    pt += ARM_MMU_SMALL_PAGE_TABLE_ENTRY_COUNT;
     173  }
     174#else
     175  for (i = 0; i < ARM_MMU_TRANSLATION_TABLE_ENTRY_COUNT; ++i) {
     176    ttb[i] = 0;
     177  }
     178#endif
    140179
    141180  for (i = 0; i < config_count; ++i) {
  • bsps/arm/realview-pbx-a9/start/linkcmds.realview_pbx_a9_qemu

    r3fb72b0f rf9648ba  
    11MEMORY {
    22        /* Waste the first 1MiB for NULL pointer protection */
    3         RAM : ORIGIN = 0x00100000, LENGTH = 255M - 16k
    4         RAM_MMU : ORIGIN = 0x0fffc000, LENGTH = 16k
     3        RAM : ORIGIN = 0x00100000, LENGTH = 0x0fafc000
     4        RAM_MMU : ORIGIN = 0x0fbfc000, LENGTH = 0x404000
    55}
    66
  • bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c

    r3fb72b0f rf9648ba  
    11/*
    2  * Copyright (c) 2010-2013 embedded brains GmbH.  All rights reserved.
     2 * Copyright (c) 2010-2019 embedded brains GmbH.  All rights reserved.
    33 *
    44 *  embedded brains GmbH
    5  *  Obere Lagerstr. 30
     5 *  Dornierstr. 4
    66 *  82178 Puchheim
    77 *  Germany
     
    1515#include <rtems.h>
    1616#include <libcpu/arm-cp15.h>
     17#include <bspopts.h>
    1718
    1819/*
     
    3637)
    3738{
    38   uint32_t *ttb = arm_cp15_get_translation_table_base();
    39   uint32_t istart = ARM_MMU_SECT_GET_INDEX(begin);
    40   uint32_t iend = ARM_MMU_SECT_GET_INDEX(ARM_MMU_SECT_MVA_ALIGN_UP(end));
    41   uint32_t index_mask = (1U << (32 - ARM_MMU_SECT_BASE_SHIFT)) - 1U;
    42   uint32_t ctrl;
     39  uint32_t *ttb;
     40#ifdef ARM_MMU_USE_SMALL_PAGES
     41  uint32_t *pt;
     42  uint32_t flags;
     43#endif
     44  uint32_t istart;
     45  uint32_t iend;
     46  uint32_t index_mask;
    4347  uint32_t section_flags_of_first_entry;
    4448  uint32_t i;
    45   void *first_ttb_addr;
    46   void *last_ttb_end;
     49  uint32_t *modified_begin;
     50  size_t modified_size;
    4751
    48   ctrl = arm_cp15_get_control();
    49   section_flags_of_first_entry = ttb [istart];
    50   last_ttb_end = first_ttb_addr = ttb + istart;
     52  ttb = arm_cp15_get_translation_table_base();
     53#ifdef ARM_MMU_USE_SMALL_PAGES
     54  pt = &ttb[ARM_MMU_TRANSLATION_TABLE_ENTRY_COUNT];
     55  istart = ARM_MMU_SMALL_PAGE_GET_INDEX(begin);
     56  iend = ARM_MMU_SMALL_PAGE_GET_INDEX(ARM_MMU_SMALL_PAGE_MVA_ALIGN_UP(end));
     57  index_mask = (1U << (32 - ARM_MMU_SMALL_PAGE_BASE_SHIFT)) - 1U;
     58  section_flags_of_first_entry = ARM_MMU_SMALL_PAGE_FLAGS_TO_SECT(pt[istart])
     59    | ARM_MMU_PAGE_TABLE_FLAGS_TO_SECT(ttb[ARM_MMU_SECT_GET_INDEX(begin)]);
     60  modified_begin = &pt[istart];
     61  flags = ARM_MMU_SECT_FLAGS_TO_SMALL_PAGE(section_flags);
     62#else
     63  istart = ARM_MMU_SECT_GET_INDEX(begin);
     64  iend = ARM_MMU_SECT_GET_INDEX(ARM_MMU_SECT_MVA_ALIGN_UP(end));
     65  index_mask = (1U << (32 - ARM_MMU_SECT_BASE_SHIFT)) - 1U;
     66  section_flags_of_first_entry = ttb[istart];
     67  modified_begin = &ttb[istart];
     68#endif
     69  modified_size = 0;
    5170
    5271  for ( i = istart; i != iend; i = (i + 1U) & index_mask ) {
    53     uint32_t addr = i << ARM_MMU_SECT_BASE_SHIFT;
     72    uint32_t pa;
    5473
    55     ttb [i] = addr | section_flags;
    56     last_ttb_end = ttb + i + 1;
     74#ifdef ARM_MMU_USE_SMALL_PAGES
     75    pa = i << ARM_MMU_SMALL_PAGE_BASE_SHIFT;
     76    pt[i] = pa | flags;
     77    modified_size += ARM_MMU_SMALL_PAGE_TABLE_ENTRY_SIZE;
     78#else
     79    pa = i << ARM_MMU_SECT_BASE_SHIFT;
     80    ttb[i] = pa | section_flags;
     81    modified_size += ARM_MMU_TRANSLATION_TABLE_ENTRY_SIZE;
     82#endif
    5783  }
    5884
    59   if ( ctrl & (ARM_CP15_CTRL_C | ARM_CP15_CTRL_M ) ) {
    60     rtems_cache_flush_multiple_data_lines(first_ttb_addr,
    61                 last_ttb_end - first_ttb_addr);
     85  if ((arm_cp15_get_control() & (ARM_CP15_CTRL_C | ARM_CP15_CTRL_M)) != 0) {
     86    rtems_cache_flush_multiple_data_lines(modified_begin, modified_size);
    6287  }
    6388
     
    6590
    6691  for ( i = istart; i != iend; i = (i + 1U) & index_mask ) {
    67     void *mva = (void *) (i << ARM_MMU_SECT_BASE_SHIFT);
     92    void *mva;
     93
     94#ifdef ARM_MMU_USE_SMALL_PAGES
     95    mva = (void *) (i << ARM_MMU_SMALL_PAGE_BASE_SHIFT);
     96#else
     97    mva = (void *) (i << ARM_MMU_SECT_BASE_SHIFT);
     98#endif
     99
    68100#if defined(__ARM_ARCH_7A__)
    69101    /*
  • c/src/lib/libbsp/arm/realview-pbx-a9/configure.ac

    r3fb72b0f rf9648ba  
    4444of all other processors.])
    4545
     46RTEMS_BSPOPTS_SET([ARM_MMU_USE_SMALL_PAGES],[*],[1])
     47RTEMS_BSPOPTS_HELP([ARM_MMU_USE_SMALL_PAGES],[use MMU with small pages (4KiB)])
    4648
    4749RTEMS_BSP_CLEANUP_OPTIONS
Note: See TracChangeset for help on using the changeset viewer.