From ec51159d188c916873c770773101fdc1b91f84d6 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 10 Mar 2013 23:42:49 +0000 Subject: [PATCH] Remove user_map.h; replace with a header at the beginning of the user-space blob. User work queue no started by os_brinup() on behalf of the application git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5727 42af7a65-404d-4744-a932-0658087f49c3 --- arch/arm/src/sam3u/sam3u_allocateheap.c | 4 ---- arch/arm/src/sam3u/sam3u_internal.h | 10 ++------- arch/arm/src/sam3u/sam3u_mpuinit.c | 20 ++++++++---------- arch/arm/src/sam3u/sam3u_userspace.c | 27 ++++++++++++++++--------- 4 files changed, 28 insertions(+), 33 deletions(-) diff --git a/arch/arm/src/sam3u/sam3u_allocateheap.c b/arch/arm/src/sam3u/sam3u_allocateheap.c index 9ae97dfb414..5b5c6b81060 100644 --- a/arch/arm/src/sam3u/sam3u_allocateheap.c +++ b/arch/arm/src/sam3u/sam3u_allocateheap.c @@ -223,10 +223,6 @@ void up_allocate_kheap(FAR void **heap_start, size_t *heap_size) *heap_start = (FAR void*)kbase; *heap_size = KHEAP_SIZE; - - /* Prohibit user access to the kernel heap memory */ - - sam3u_mpu_kheap((uintptr_t)kbase, KHEAP_SIZE); } #endif diff --git a/arch/arm/src/sam3u/sam3u_internal.h b/arch/arm/src/sam3u/sam3u_internal.h index b0cf83cb049..14857bcf8ae 100644 --- a/arch/arm/src/sam3u/sam3u_internal.h +++ b/arch/arm/src/sam3u/sam3u_internal.h @@ -477,10 +477,10 @@ void sam3u_mpuinitialize(void); #endif /**************************************************************************** - * Name: sam3u_mpu_uheap and sam3u_mpu_uheap + * Name: sam3u_mpu_uheap * * Description: - * Map a user- or kernel-heap region. + * Map the user heap region. * ****************************************************************************/ @@ -490,12 +490,6 @@ void sam3u_mpu_uheap(uintptr_t start, size_t size); # define sam3u_mpu_uheap(start,size) #endif -#if defined(CONFIG_NUTTX_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) -void sam3u_mpu_kheap(uintptr_t start, size_t size); -#else -# define sam3u_mpu_kheap(start,size) -#endif - /************************************************************************************ * Name: sam3u_gpioirqinitialize * diff --git a/arch/arm/src/sam3u/sam3u_mpuinit.c b/arch/arm/src/sam3u/sam3u_mpuinit.c index b2d3850eac6..1e1a564d55f 100644 --- a/arch/arm/src/sam3u/sam3u_mpuinit.c +++ b/arch/arm/src/sam3u/sam3u_mpuinit.c @@ -41,7 +41,7 @@ #include -#include +#include #include "mpu.h" @@ -82,10 +82,11 @@ void sam3u_mpuinitialize(void) { - uintptr_t datastart = MIN(CONFIG_USER_DATADESTSTART, CONFIG_USER_BSSSTART); - uintptr_t dataend = MAX(CONFIG_USER_DATADESTEND, CONFIG_USER_BSSEND); + uintptr_t datastart = MIN(USERSPACE->us_datastart, USERSPACE->us_bssstart); + uintptr_t dataend = MAX(USERSPACE->us_dataend, USERSPACE->us_bssend); - DEBUGASSERT(CONFIG_USER_TEXTEND >= CONFIG_USER_TEXTSTART && dataend >= datastart); + DEBUGASSERT(USERSPACE->us_textend >= USERSPACE->us_textstart && + dataend >= datastart); /* Show MPU information */ @@ -93,7 +94,9 @@ void sam3u_mpuinitialize(void) /* Configure user flash and SRAM space */ - mpu_userflash(CONFIG_USER_TEXTSTART, CONFIG_USER_TEXTEND - CONFIG_USER_TEXTSTART); + mpu_userflash(USERSPACE->us_textstart, + USERSPACE->us_textend - USERSPACE->us_textstart); + mpu_userintsram(datastart, dataend - datastart); /* Then enable the MPU */ @@ -116,12 +119,5 @@ void sam3u_mpu_uheap(uintptr_t start, size_t size) mpu_userintsram(start, size); } -#ifdef CONFIG_MM_KERNEL_HEAP -void sam3u_mpu_kheap(uintptr_t start, size_t size) -{ - mpu_privintsram(start, size); -} -#endif - #endif /* CONFIG_NUTTX_KERNEL */ diff --git a/arch/arm/src/sam3u/sam3u_userspace.c b/arch/arm/src/sam3u/sam3u_userspace.c index 28f45afce36..89a2a27ed3f 100644 --- a/arch/arm/src/sam3u/sam3u_userspace.c +++ b/arch/arm/src/sam3u/sam3u_userspace.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/common/sam3u_userspace.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -42,7 +42,9 @@ #include #include -#include +#include + +#include "sam3u_internal.h" #ifdef CONFIG_NUTTX_KERNEL @@ -81,10 +83,11 @@ void sam3u_userspace(void) /* Clear all of user-space .bss */ - DEBUGASSERT((uintptr_t)CONFIG_USER_DATADESTSTART <= CONFIG_USER_DATADESTEND); + DEBUGASSERT(USERSPACE->us_bssstart != 0 && USERSPACE->us_bssend != 0 && + USERSPACE->us_bssstart <= USERSPACE->us_bssend); - dest = (uint8_t*)CONFIG_USER_BSSSTART; - end = (uint8_t*)CONFIG_USER_BSSEND; + dest = (uint8_t*)USERSPACE->us_bssstart; + end = (uint8_t*)USERSPACE->us_bssend; while (dest != end) { @@ -93,16 +96,22 @@ void sam3u_userspace(void) /* Initialize all of user-space .data */ - DEBUGASSERT((uintptr_t)CONFIG_USER_DATADESTSTART <= CONFIG_USER_DATADESTEND); + DEBUGASSERT(USERSPACE->us_datasource != 0 && + USERSPACE->us_datastart != 0 && USERSPACE->us_dataend != 0 && + USERSPACE->us_datastart <= USERSPACE->us_dataend); - src = (uint8_t*)CONFIG_USER_DATASOURCE; - dest = (uint8_t*)CONFIG_USER_DATADESTSTART; - end = (uint8_t*)CONFIG_USER_DATADESTEND; + src = (uint8_t*)USERSPACE->us_datasource; + dest = (uint8_t*)USERSPACE->us_datastart; + end = (uint8_t*)USERSPACE->us_dataend; while (dest != end) { *dest++ = *src++; } + + /* Configure the MPU to permit user-space access to its FLASH and RAM */ + + sam3u_mpuinitialize(); } #endif /* CONFIG_NUTTX_KERNEL */