Merged in masayuki2009/nuttx.nuttx/lc823450_mpu_for_flat (pull request #728)

arch/arm/src/lc823450: MPU support for FLAT build

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

Approved-by: GregoryN <gnutt@nuttx.org>
This commit is contained in:
Masayuki Ishikawa 2018-09-27 11:34:22 +00:00 committed by GregoryN
parent 7a2f70495a
commit b154c81255
6 changed files with 39 additions and 9 deletions

View File

@ -63,7 +63,7 @@ CMN_CSRCS += up_ramvec_initialize.c up_ramvec_attach.c
endif
ifeq ($(CONFIG_BUILD_PROTECTED),y)
CMN_CSRCS += up_mpu.c up_task_start.c up_pthread_start.c
CMN_CSRCS += up_task_start.c up_pthread_start.c
ifneq ($(CONFIG_DISABLE_SIGNALS),y)
CMN_CSRCS += up_signal_dispatch.c
CMN_UASRCS += up_signal_handler.S
@ -184,5 +184,9 @@ endif
ifeq ($(CONFIG_BUILD_PROTECTED),y)
CHIP_CSRCS += lc823450_userspace.c
endif
ifeq ($(CONFIG_ARM_MPU),y)
CMN_CSRCS += up_mpu.c
CHIP_CSRCS += lc823450_mpuinit2.c
endif

View File

@ -60,6 +60,10 @@
#include "lc823450_syscontrol.h"
#if defined(CONFIG_BUILD_FLAT) && defined(CONFIG_ARM_MPU)
# include "lc823450_mpuinit2.h"
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -113,6 +117,13 @@ static void cpu1_boot(void)
{
putreg32((uint32_t)&_stext, NVIC_VECTAB); /* use CPU0 vectors */
#if defined(CONFIG_BUILD_FLAT) && defined(CONFIG_ARM_MPU)
lc823450_mpuinitialize();
irq_attach(LC823450_IRQ_MEMFAULT, up_memfault, NULL);
up_enable_irq(LC823450_IRQ_MEMFAULT);
#endif
irq_attach(LC823450_IRQ_CTXM3_01, lc823450_pause_handler, NULL);
up_enable_irq(LC823450_IRQ_CTXM3_01);
}

View File

@ -547,7 +547,7 @@ void up_irqinitialize(void)
* Fault handler.
*/
#ifdef CONFIG_ARMV7M_MPU
#ifdef CONFIG_ARM_MPU
irq_attach(LC823450_IRQ_MEMFAULT, up_memfault, NULL);
up_enable_irq(LC823450_IRQ_MEMFAULT);
#endif
@ -556,9 +556,6 @@ void up_irqinitialize(void)
#ifdef CONFIG_DEBUG
irq_attach(LC823450_IRQ_NMI, lc823450_nmi, NULL);
#ifndef CONFIG_ARMV7M_MPU
irq_attach(LC823450_IRQ_MEMFAULT, up_memfault, NULL);
#endif
irq_attach(LC823450_IRQ_BUSFAULT, lc823450_busfault, NULL);
irq_attach(LC823450_IRQ_USAGEFAULT, lc823450_usagefault, NULL);
irq_attach(LC823450_IRQ_PENDSV, lc823450_pendsv, NULL);

View File

@ -46,9 +46,10 @@
#include <nuttx/userspace.h>
#include "mpu.h"
#include "up_internal.h"
#include "lc823450_mpuinit2.h"
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ARM_MPU)
#ifdef CONFIG_ARM_MPU
/****************************************************************************
* Pre-processor Definitions
@ -85,6 +86,7 @@
void lc823450_mpuinitialize(void)
{
#ifdef CONFIG_BUILD_PROTECTED
uintptr_t datastart = MIN(USERSPACE->us_datastart, USERSPACE->us_bssstart);
uintptr_t dataend = MAX(USERSPACE->us_dataend, USERSPACE->us_bssend);
@ -101,6 +103,19 @@ void lc823450_mpuinitialize(void)
USERSPACE->us_textend - USERSPACE->us_textstart);
mpu_user_intsram(datastart, dataend - datastart);
#endif
#ifdef CONFIG_BUILD_FLAT
uint32_t size = (uint32_t)((uint32_t)&_eronly - (uint32_t)&_stext);
/* 128KB align */
size = size & 0x20000;
/* Protect text area in SRAM as privileged flash */
mpu_priv_flash((uintptr_t)&_stext, size);
#endif
/* Then enable the MPU */
@ -122,5 +137,5 @@ void lc823450_mpu_uheap(uintptr_t start, size_t size)
mpu_user_intsram(start, size);
}
#endif /* CONFIG_BUILD_PROTECTED && CONFIG_ARM_MPU */
#endif /* CONFIG_ARM_MPU */

View File

@ -69,7 +69,7 @@
*
****************************************************************************/
#ifdef CONFIG_BUILD_PROTECTED
#ifdef CONFIG_ARM_MPU
void lc823450_mpuinitialize(void);
#else
# define lc823450_mpuinitialize()
@ -83,7 +83,7 @@ void lc823450_mpuinitialize(void);
*
****************************************************************************/
#ifdef CONFIG_BUILD_PROTECTED
#ifdef CONFIG_ARM_MPU
void lc823450_mpu_uheap(uintptr_t start, size_t size);
#else
# define lc823450_mpu_uheap(start,size)

View File

@ -351,6 +351,9 @@ void __start(void)
#ifdef CONFIG_BUILD_PROTECTED
lc823450_userspace();
#endif
#if defined(CONFIG_BUILD_FLAT) && defined(CONFIG_ARM_MPU)
lc823450_mpuinitialize();
#endif
showprogress('E');