arm/armv7-a: Add mmu_l1_map_regions() to remove the code duplication.

This commit is contained in:
Xiang Xiao 2019-03-19 11:30:37 -06:00 committed by Gregory Nutt
parent 75a97657be
commit cc1595f232
6 changed files with 56 additions and 62 deletions

View File

@ -132,14 +132,7 @@ static const struct section_mapping_s section_mapping[] =
#ifndef CONFIG_ARCH_ROMPGTABLE
static inline void a1x_setupmappings(void)
{
int i;
/* Set up each group of section mappings */
for (i = 0; i < NMAPPINGS; i++)
{
mmu_l1_map_region(&section_mapping[i]);
}
mmu_l1_map_regions(section_mapping, NMAPPINGS);
}
#endif

View File

@ -157,14 +157,7 @@ const size_t g_num_mappings = NMAPPINGS;
#ifndef CONFIG_ARCH_ROMPGTABLE
static inline void am335x_setupmappings(void)
{
int i;
/* Set up each group of section mappings */
for (i = 0; i < g_num_mappings; i++)
{
mmu_l1_map_region(&g_section_mapping[i]);
}
mmu_l1_map_regions(g_section_mapping, g_num_mappings);
}
#else
# define am335x_setupmappings()
@ -181,14 +174,7 @@ static inline void am335x_setupmappings(void)
#ifdef NEED_SDRAM_REMAPPING
static inline void am335x_remap(void)
{
int i;
/* Re-map each group of section */
for (i = 0; i < g_num_opmappings; i++)
{
mmu_l1_map_region(&g_operational_mapping[i]);
}
mmu_l1_map_regions(g_operational_mapping, g_num_opmappings);
}
#endif

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/armv7-a/arm_mmu.c
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2013, 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -199,6 +199,32 @@ void mmu_l1_map_region(const struct section_mapping_s *mapping)
}
#endif
/****************************************************************************
* Name: mmu_l1_map_regions
*
* Description:
* Set multiple level 1 translation table entries in order to map a region
* array of memory.
*
* Input Parameters:
* mappings - Describes the array of mappings to be performed.
* count - The number of mappings to be performed.
*
****************************************************************************/
#ifndef CONFIG_ARCH_ROMPGTABLE
void mmu_l1_map_regions(const struct section_mapping_s *mappings,
size_t count)
{
size_t i;
for (i = 0; i < count; i++)
{
mmu_l1_map_region(&mappings[i]);
}
}
#endif
/****************************************************************************
* Name: mmu_invalidate_region
*

View File

@ -2,7 +2,7 @@
* arch/arm/src/armv7-a/mmu.h
* CP15 MMU register definitions
*
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2013-2014, 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* References:
@ -1452,22 +1452,39 @@ void mmu_l2_setentry(uint32_t l2vaddr, uint32_t paddr, uint32_t vaddr,
uint32_t mmuflags);
#endif
/************************************************************************************
/****************************************************************************
* Name: mmu_l1_map_region
*
* Description:
* Set multiple level 1 translation table entries in order to map a region of
* memory.
* Set multiple level 1 translation table entries in order to map a region
* of memory.
*
* Input Parameters:
* mapping - Describes the mapping to be performed.
*
************************************************************************************/
****************************************************************************/
#ifndef CONFIG_ARCH_ROMPGTABLE
void mmu_l1_map_region(const struct section_mapping_s *mapping);
#endif
/****************************************************************************
* Name: mmu_l1_map_regions
*
* Description:
* Set multiple level 1 translation table entries in order to map a region
* array of memory.
*
* Input Parameters:
* mappings - Describes the array of mappings to be performed.
* count - The number of mappings to be performed.
*
****************************************************************************/
#ifndef CONFIG_ARCH_ROMPGTABLE
void mmu_l1_map_regions(const struct section_mapping_s *mappings,
size_t count);
#endif
/****************************************************************************
* Name: mmu_invalidate_region
*

View File

@ -99,14 +99,7 @@ extern uint32_t _vector_end; /* End+1 of vector block */
#ifndef CONFIG_ARCH_ROMPGTABLE
static inline void imx_setupmappings(void)
{
int i;
/* Set up each group of section mappings */
for (i = 0; i < g_num_mappings; i++)
{
mmu_l1_map_region(&g_section_mapping[i]);
}
mmu_l1_map_regions(g_section_mapping, g_num_mappings);
}
#else
# define imx_setupmappings()
@ -123,14 +116,7 @@ static inline void imx_setupmappings(void)
#ifdef NEED_SDRAM_REMAPPING
static inline void imx_remap(void)
{
int i;
/* Re-map each group of section */
for (i = 0; i < g_num_opmappings; i++)
{
mmu_l1_map_region(&g_operational_mapping[i]);
}
mmu_l1_map_regions(g_operational_mapping, g_num_opmappings);
}
#endif

View File

@ -92,14 +92,7 @@ extern uint32_t _vector_end; /* End+1 of vector block */
#ifndef CONFIG_ARCH_ROMPGTABLE
static inline void sam_setupmappings(void)
{
int i;
/* Set up each group of section mappings */
for (i = 0; i < g_num_mappings; i++)
{
mmu_l1_map_region(&g_section_mapping[i]);
}
mmu_l1_map_regions(g_section_mapping, g_num_mappings);
}
#endif
@ -114,14 +107,7 @@ static inline void sam_setupmappings(void)
#ifdef NEED_SDRAM_REMAPPING
static inline void sam_remap(void)
{
int i;
/* Re-map each group of section */
for (i = 0; i < g_num_opmappings; i++)
{
mmu_l1_map_region(&g_operational_mapping[i]);
}
mmu_l1_map_regions(g_operational_mapping, g_num_opmappings);
}
#endif