arch/arm/src/mps: implement Protected Build for mps2-an500
Summary 1. add Protected build Support for ARM MPS AN500 2. refine mps Memory layout configure and enable MPU support Note 1. ostest for an547:nsh 2. ostest for an500:nsh and an500:knsh Signed-off-by: qinwei1 <qinwei1@xiaomi.com> Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
parent
e763b0cfe6
commit
02f1d732a9
14 changed files with 1175 additions and 37 deletions
|
@ -25,3 +25,7 @@ include armv8-m/Make.defs
|
|||
endif
|
||||
|
||||
CHIP_CSRCS = mps_start.c mps_serial.c mps_irq.c mps_timer.c mps_allocateheap.c
|
||||
|
||||
ifeq ($(CONFIG_BUILD_PROTECTED),y)
|
||||
CHIP_CSRCS += mps_userspace.c
|
||||
endif
|
||||
|
|
157
arch/arm/src/mps/hardware/mps_memorymap.h
Normal file
157
arch/arm/src/mps/hardware/mps_memorymap.h
Normal file
|
@ -0,0 +1,157 @@
|
|||
/****************************************************************************
|
||||
* arch/arm/src/mps/hardware/mps_memorymap.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_MPS_HARDWARE_MPS_MEMORYMAP_H
|
||||
#define __ARCH_ARM_SRC_MPS_HARDWARE_MPS_MEMORYMAP_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* qemu/hw/arm/mps2.c
|
||||
*
|
||||
* The MPS2 and MPS2+ dev boards are FPGA based (the 2+ has a bigger
|
||||
* FPGA but is otherwise the same as the 2). Since the CPU itself
|
||||
* and most of the devices are in the FPGA, the details of the board
|
||||
* as seen by the guest depend significantly on the FPGA image.
|
||||
* We model the following FPGA images:
|
||||
* "mps2-an385" -- Cortex-M3 as documented in ARM Application Note AN385
|
||||
* "mps2-an386" -- Cortex-M4 as documented in ARM Application Note AN386
|
||||
* "mps2-an500" -- Cortex-M7 as documented in ARM Application Note AN500
|
||||
* "mps2-an511" -- Cortex-M3 'DesignStart' as documented in AN511
|
||||
*
|
||||
* Links to the TRM for the board itself and to the various Application
|
||||
*
|
||||
* System memory map
|
||||
*
|
||||
* The FPGA images have an odd combination of different RAMs,
|
||||
* because in hardware they are different implementations and
|
||||
* connected to different buses, giving varying performance/size
|
||||
* tradeoffs. For QEMU they're all just RAM, though. We arbitrarily
|
||||
* call the 16MB our "system memory", as it's the largest lump.
|
||||
*
|
||||
* AN385/AN386/AN511:
|
||||
* 0x21000000 .. 0x21ffffff : PSRAM (16MB)
|
||||
* AN385/AN386/AN500:
|
||||
* 0x00000000 .. 0x003fffff : ZBT SSRAM1 (4MB)
|
||||
* 0x00400000 .. 0x007fffff : mirror of ZBT SSRAM1
|
||||
* 0x20000000 .. 0x203fffff : ZBT SSRAM 2&3 (4MB)
|
||||
* 0x20400000 .. 0x207fffff : mirror of ZBT SSRAM 2&3
|
||||
* AN385/AN386 only:
|
||||
* 0x01000000 .. 0x01003fff : block RAM (16K)
|
||||
* 0x01004000 .. 0x01007fff : mirror of above
|
||||
* 0x01008000 .. 0x0100bfff : mirror of above
|
||||
* 0x0100c000 .. 0x0100ffff : mirror of above
|
||||
* AN511 only:
|
||||
* 0x00000000 .. 0x0003ffff : FPGA block RAM
|
||||
* 0x00400000 .. 0x007fffff : ZBT SSRAM1
|
||||
* 0x20000000 .. 0x2001ffff : SRAM
|
||||
* 0x20400000 .. 0x207fffff : ZBT SSRAM 2&3
|
||||
* AN500 only:
|
||||
* 0x60000000 .. 0x60ffffff : PSRAM (16MB)
|
||||
*
|
||||
* The AN385/AN386 has a feature where the lowest 16K can be mapped
|
||||
* either to the bottom of the ZBT SSRAM1 or to the block RAM.
|
||||
* This is of no use for QEMU so we don't implement it (as if
|
||||
* zbt_boot_ctrl is always zero).
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_ARCH_CHIP_MPS3_AN547)
|
||||
|
||||
/* flash (512KB) */
|
||||
#define MPS_ITCM_START 0x00000000
|
||||
#define MPS_ITCM_SIZE 0x00080000
|
||||
|
||||
/* SRAM1 (2MB) */
|
||||
#define MPS_SRAM1_START 0x01000000
|
||||
#define MPS_SRAM1_SIZE 0x00200000
|
||||
|
||||
/* SRAM2 (4MB) */
|
||||
#define MPS_SRAM2_START 0x21000000
|
||||
#define MPS_SRAM2_SIZE 0x00400000
|
||||
|
||||
#define PRIMARY_RAM_START MPS_SRAM1_START
|
||||
#define PRIMARY_RAM_SIZE MPS_SRAM1_SIZE
|
||||
|
||||
#if CONFIG_MM_REGIONS > 1
|
||||
#define REGION1_RAM_START MPS_SRAM2_START
|
||||
#define REGION1_RAM_SIZE MPS_SRAM2_SIZE
|
||||
|
||||
#endif /* CONFIG_MM_REGIONS > 1 */
|
||||
|
||||
#elif defined(CONFIG_ARCH_CHIP_MPS2_AN524)
|
||||
|
||||
/* Internal SRAM1 (16MB) */
|
||||
#define MPS_SRAM1_START 0x20000000
|
||||
#define MPS_SRAM1_SIZE 0x01000000
|
||||
|
||||
/* Internal SRAM2 (16MB) */
|
||||
#define MPS_SRAM2_START 0x30000000
|
||||
#define MPS_SRAM2_SIZE 0x01000000
|
||||
|
||||
#define PRIMARY_RAM_START MPS_SRAM1_START
|
||||
#define PRIMARY_RAM_SIZE MPS_SRAM1_SIZE
|
||||
|
||||
#if CONFIG_MM_REGIONS > 1
|
||||
#define REGION1_RAM_START MPS_SRAM2_START
|
||||
#define REGION1_RAM_SIZE MPS_SRAM2_SIZE
|
||||
|
||||
#endif /* CONFIG_MM_REGIONS > 1 */
|
||||
|
||||
#elif defined(CONFIG_ARCH_CHIP_MPS2_AN500) || \
|
||||
defined(CONFIG_ARCH_CHIP_MPS2_AN386)
|
||||
|
||||
/* ZBT SSRAM1 (4MB) */
|
||||
|
||||
#define MPS_SRAM1_START 0x00000000
|
||||
#define MPS_SRAM1_SIZE 0x00400000
|
||||
|
||||
/* ZBT SSRAM23 (4MB) */
|
||||
|
||||
#define MPS_SRAM2_START 0x20000000
|
||||
#define MPS_SRAM2_SIZE 0x00400000
|
||||
|
||||
/* PSRAM (16MB) */
|
||||
|
||||
#define MPS_PSRAM_START 0x60000000
|
||||
#define MPS_PSRAM_SIZE 0x01000000
|
||||
|
||||
#define PRIMARY_RAM_START MPS_PSRAM_START
|
||||
#define PRIMARY_RAM_SIZE MPS_PSRAM_SIZE
|
||||
|
||||
#if CONFIG_MM_REGIONS > 1
|
||||
#define REGION1_RAM_START MPS_SRAM2_START
|
||||
#define REGION1_RAM_SIZE MPS_SRAM2_SIZE
|
||||
|
||||
#endif /* CONFIG_MM_REGIONS > 1 */
|
||||
|
||||
#else
|
||||
# error Unrecognized Arm MPS2 and MPS3 architecture
|
||||
#endif
|
||||
|
||||
#define PRIMARY_RAM_END (PRIMARY_RAM_START + PRIMARY_RAM_SIZE)
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_MPS_HARDWARE_MPS_MEMORYMAP_H */
|
|
@ -24,48 +24,238 @@
|
|||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/userspace.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "arm_internal.h"
|
||||
#include "mpu.h"
|
||||
#include "chip.h"
|
||||
#include "hardware/mps_memorymap.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_BUILD_KERNEL)
|
||||
# define MM_ADDREGION kmm_addregion
|
||||
#else
|
||||
# define MM_ADDREGION umm_addregion
|
||||
#endif
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#define MPS3_DDR_BASE (void *)0x60000000
|
||||
#define MPS3_DDR_SIZE (2 * 1024 * 1024 * 1024UL)
|
||||
/* Terminology.
|
||||
* In the flat build (CONFIG_BUILD_FLAT=y), there is only a
|
||||
* single heap access with the standard allocations (malloc/free). This
|
||||
* heap is referred to as the user heap.
|
||||
* In the protected build (CONFIG_BUILD_PROTECTED=y) where an MPU is
|
||||
* used to protect a region of otherwise flat memory, there will
|
||||
* be two allocators: One that allocates protected (kernel) memory and
|
||||
* one that allocates unprotected (user) memory. These are referred to
|
||||
* as the kernel and user heaps, respectively.
|
||||
*
|
||||
* For processor(armv7-a/armv8-a) which has no MPU but does have an MMU.
|
||||
* Without an MMU, it cannot support the kernel
|
||||
* build (CONFIG_BUILD_KERNEL=y). In that configuration,
|
||||
* there would is one kernel heap but multiple user heaps: One per
|
||||
* task group. However, in this case, we need only be concerned
|
||||
* about initializing the single kernel heap here.
|
||||
*
|
||||
* Primary RAM: The Linker script positions the system BLOB's .data and
|
||||
* .bss in some RAM. We refer to that RAM as the primary RAM. It also
|
||||
* holds the IDLE threads stack and any remaining portion of the primary
|
||||
* OCRAM is automatically added to the heap. The linker provided address,
|
||||
* ... .sbss, .ebss, .sdat, etc. ... are expected to lie in the the region
|
||||
* defined by the OCRAM configuration settings.
|
||||
*
|
||||
* Other RAM regions must be selected use configuration options and the
|
||||
* start and end of those RAM regions must also be provided in the
|
||||
* configuration. CONFIG_MM_REGIONS must also be set to determined the
|
||||
* number of regions to be added to the heap.
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
/* _sbss is the start of the BSS region (see the linker script) _ebss is the
|
||||
* end of the BSS regions (see the linker script). The idle task stack starts
|
||||
* at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. The IDLE
|
||||
* thread is the thread that the system boots on and, eventually, becomes the
|
||||
* idle, do nothing task that runs only when there is nothing else to run.
|
||||
* The heap continues from there until the configured end of memory.
|
||||
* g_idle_topstack is the beginning of this heap region (not necessarily
|
||||
* aligned).
|
||||
*/
|
||||
|
||||
const uintptr_t g_idle_topstack = (uintptr_t)_ebss +
|
||||
CONFIG_IDLETHREAD_STACKSIZE;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_allocate_heap/up_allocate_kheap
|
||||
*
|
||||
* Description:
|
||||
* This function will be called to dynamically set aside the heap region.
|
||||
*
|
||||
* - For the normal "flat" build, this function returns the size of the
|
||||
* single heap.
|
||||
* - For the protected build (CONFIG_BUILD_PROTECTED=y) with both kernel-
|
||||
* and user-space heaps (CONFIG_MM_KERNEL_HEAP=y), this function
|
||||
* provides the size of the unprotected, user-space heap.
|
||||
* - For the kernel build (CONFIG_BUILD_KERNEL=y), this function provides
|
||||
* the size of the protected, kernel-space heap.
|
||||
*
|
||||
* If a protected kernel-space heap is provided, the kernel heap must be
|
||||
* allocated by an analogous up_allocate_kheap(). A custom version of this
|
||||
* file is needed if memory protection of the kernel heap is required.
|
||||
*
|
||||
* The following memory map is assumed for the flat build:
|
||||
*
|
||||
* .data region. Size determined at link time.
|
||||
* .bss region Size determined at link time.
|
||||
* IDLE thread stack. Size determined by CONFIG_IDLETHREAD_STACKSIZE.
|
||||
* Heap. Extends to the end of SRAM.
|
||||
*
|
||||
* The following memory map is assumed for the kernel build:
|
||||
*
|
||||
* Kernel .data region. Size determined at link time.
|
||||
* Kernel .bss region Size determined at link time.
|
||||
* Kernel IDLE thread stack. (size determined by
|
||||
* CONFIG_IDLETHREAD_STACKSIZE).
|
||||
* Padding for alignment
|
||||
* User .data region. Size determined at link time.
|
||||
* User .bss region Size determined at link time.
|
||||
* Kernel heap. Size determined by CONFIG_MM_KERNEL_HEAPSIZE.
|
||||
* User heap. Extends to the end of SRAM.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_allocate_heap(void **heap_start, size_t *heap_size)
|
||||
{
|
||||
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_MM_KERNEL_HEAP)
|
||||
/* Get the unaligned size and position of the user-space heap.
|
||||
* This heap begins after the user-space .bss section at an offset
|
||||
* of CONFIG_MM_KERNEL_HEAPSIZE (subject to alignment).
|
||||
*/
|
||||
|
||||
uintptr_t ubase = (uintptr_t)USERSPACE->us_bssend +
|
||||
CONFIG_MM_KERNEL_HEAPSIZE;
|
||||
size_t usize = PRIMARY_RAM_END - ubase;
|
||||
uint8_t log2;
|
||||
|
||||
DEBUGASSERT(ubase < PRIMARY_RAM_END);
|
||||
|
||||
/* Adjust that size to account for MPU alignment requirements.
|
||||
* NOTE that there is an implicit assumption that the PRIMARY_RAM_END
|
||||
* is aligned to the MPU requirement.
|
||||
*/
|
||||
|
||||
log2 = mpu_log2regionfloor(usize);
|
||||
DEBUGASSERT((PRIMARY_RAM_END & ((1 << log2) - 1)) == 0);
|
||||
|
||||
usize = (1 << log2);
|
||||
ubase = PRIMARY_RAM_END - usize;
|
||||
|
||||
/* Return the user-space heap settings */
|
||||
|
||||
*heap_start = (void *)ubase;
|
||||
*heap_size = usize;
|
||||
|
||||
/* Allow user-mode access to the user heap memory */
|
||||
|
||||
mpu_user_intsram(ubase, usize);
|
||||
#else
|
||||
|
||||
/* Return the heap settings */
|
||||
|
||||
*heap_start = (void *)g_idle_topstack;
|
||||
*heap_size = PRIMARY_RAM_END - g_idle_topstack;
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_allocate_kheap
|
||||
*
|
||||
* Description:
|
||||
* For the kernel build (CONFIG_BUILD_PROTECTED/KERNEL=y) with both kernel-
|
||||
* and user-space heaps (CONFIG_MM_KERNEL_HEAP=y), this function allocates
|
||||
* the kernel-space heap. A custom version of this function is needed if
|
||||
* memory protection of the kernel heap is required.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_MM_KERNEL_HEAP)
|
||||
void up_allocate_kheap(void **heap_start, size_t *heap_size)
|
||||
{
|
||||
/* Get the unaligned size and position of the user-space heap.
|
||||
* This heap begins after the user-space .bss section at an offset
|
||||
* of CONFIG_MM_KERNEL_HEAPSIZE (subject to alignment).
|
||||
*/
|
||||
|
||||
uintptr_t ubase = (uintptr_t)USERSPACE->us_bssend +
|
||||
CONFIG_MM_KERNEL_HEAPSIZE;
|
||||
size_t usize = PRIMARY_RAM_END - ubase;
|
||||
uint8_t log2;
|
||||
DEBUGASSERT(ubase < PRIMARY_RAM_END);
|
||||
|
||||
/* Adjust that size to account for MPU alignment requirements.
|
||||
* NOTE that there is an implicit assumption that the CONFIG_RAM_END
|
||||
* is aligned to the MPU requirement.
|
||||
*/
|
||||
|
||||
log2 = mpu_log2regionfloor(usize);
|
||||
DEBUGASSERT((PRIMARY_RAM_END & ((1 << log2) - 1)) == 0);
|
||||
|
||||
usize = (1 << log2);
|
||||
ubase = PRIMARY_RAM_END - usize;
|
||||
|
||||
/* Return the kernel heap settings (i.e., the part of the heap region
|
||||
* that was not dedicated to the user heap).
|
||||
*/
|
||||
|
||||
*heap_start = (void *)USERSPACE->us_bssend;
|
||||
*heap_size = ubase - (uintptr_t)USERSPACE->us_bssend;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arm_addregion
|
||||
*
|
||||
* Description:
|
||||
* Memory may be added in non-contiguous chunks. Additional chunks are
|
||||
* added by calling this function.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_MM_REGIONS > 1
|
||||
void arm_addregion(void)
|
||||
{
|
||||
MM_ADDREGION(MPS3_DDR_BASE, MPS3_DDR_SIZE);
|
||||
}
|
||||
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_MM_KERNEL_HEAP)
|
||||
/* Allow user-mode access to region 1 */
|
||||
|
||||
mpu_user_intsram(REGION1_RAM_START, REGION1_RAM_SIZE);
|
||||
#endif
|
||||
|
||||
/* Add region 1 to the user heap */
|
||||
|
||||
kumm_addregion((void *)REGION1_RAM_START, REGION1_RAM_SIZE);
|
||||
|
||||
#if CONFIG_MM_REGIONS > 2
|
||||
|
||||
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_MM_KERNEL_HEAP)
|
||||
/* Allow user-mode access to region 2 */
|
||||
|
||||
mpu_user_intsram(REGION2_RAM_START, REGION2_RAM_SIZE);
|
||||
#endif
|
||||
/* Add region 2 to the user heap */
|
||||
|
||||
kumm_addregion((void *)REGION2_RAM_START, REGION2_RAM_SIZE);
|
||||
|
||||
#endif /* CONFIG_MM_REGIONS > 2 */
|
||||
}
|
||||
#endif /* CONFIG_MM_REGIONS > 1 */
|
||||
|
|
|
@ -25,36 +25,65 @@
|
|||
#include <nuttx/config.h>
|
||||
#include <nuttx/init.h>
|
||||
|
||||
#include <nuttx/cache.h>
|
||||
#include <nuttx/init.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "arm_internal.h"
|
||||
#include "barriers.h"
|
||||
#include "nvic.h"
|
||||
#include "mps_irq.h"
|
||||
#include "mps_userspace.h"
|
||||
#include "mpu.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#define HEAP_BASE ((uintptr_t)_ebss + CONFIG_IDLETHREAD_STACKSIZE)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* g_idle_topstack: _sbss is the start of the BSS region as defined by the
|
||||
* linker script. _ebss lies at the end of the BSS region. The idle task
|
||||
* stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE.
|
||||
* The IDLE thread is the thread that the system boots on and, eventually,
|
||||
* becomes the IDLE, do nothing task that runs only when there is nothing
|
||||
* else to run. The heap continues from there until the end of memory.
|
||||
* g_idle_topstack is a read-only variable the provides this computed
|
||||
* address.
|
||||
*/
|
||||
|
||||
const uintptr_t g_idle_topstack = HEAP_BASE;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mps_tcmenable
|
||||
*
|
||||
* Description:
|
||||
* Enable/disable tightly coupled memories. Size of tightly coupled
|
||||
* memory regions is controlled by GPNVM Bits 7-8.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline void mps_tcmenable(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
ARM_DSB();
|
||||
ARM_ISB();
|
||||
|
||||
/* Enabled/disabled ITCM */
|
||||
|
||||
#ifdef CONFIG_ARMV7M_ITCM
|
||||
regval = NVIC_TCMCR_EN | NVIC_TCMCR_RMW | NVIC_TCMCR_RETEN;
|
||||
#else
|
||||
regval = getreg32(NVIC_ITCMCR);
|
||||
regval &= ~NVIC_TCMCR_EN;
|
||||
#endif
|
||||
putreg32(regval, NVIC_ITCMCR);
|
||||
|
||||
/* Enabled/disabled DTCM */
|
||||
|
||||
#ifdef CONFIG_ARMV7M_DTCM
|
||||
regval = NVIC_TCMCR_EN | NVIC_TCMCR_RMW | NVIC_TCMCR_RETEN;
|
||||
#else
|
||||
regval = getreg32(NVIC_DTCMCR);
|
||||
regval &= ~NVIC_TCMCR_EN;
|
||||
#endif
|
||||
putreg32(regval, NVIC_DTCMCR);
|
||||
|
||||
ARM_DSB();
|
||||
ARM_ISB();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: __start
|
||||
*
|
||||
|
@ -71,6 +100,9 @@ void __start(void)
|
|||
/* If enabled reset the MPU */
|
||||
|
||||
mpu_early_reset();
|
||||
#ifdef CONFIG_ARM_MPU
|
||||
mpu_showtype();
|
||||
#endif
|
||||
arm_fpuconfig();
|
||||
|
||||
/* Set bss to zero */
|
||||
|
@ -89,9 +121,49 @@ void __start(void)
|
|||
*dest++ = *src++;
|
||||
}
|
||||
|
||||
/* Perform early serial initialization */
|
||||
|
||||
#ifdef USE_EARLYSERIALINIT
|
||||
arm_earlyserialinit();
|
||||
#endif
|
||||
|
||||
/* Enable/disable tightly coupled memories */
|
||||
|
||||
mps_tcmenable();
|
||||
|
||||
#ifdef CONFIG_ARMV7M_DCACHE
|
||||
/* Memory barrier */
|
||||
|
||||
ARM_DMB();
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
/* For the case of the separate user-/kernel-space build, perform whatever
|
||||
* platform specific initialization of the user memory is required.
|
||||
* Normally this just means initializing the user space .data and .bss
|
||||
* segments.
|
||||
*/
|
||||
|
||||
mps_userspace();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ARM_MPU
|
||||
/* Then enable the MPU */
|
||||
|
||||
mpu_control(true, false, true);
|
||||
#endif
|
||||
|
||||
/* Enable I- and D-Caches */
|
||||
|
||||
up_enable_icache();
|
||||
up_enable_dcache();
|
||||
|
||||
/* Then start NuttX */
|
||||
|
||||
nx_start();
|
||||
|
||||
/* Shouldn't get here */
|
||||
|
||||
for (; ; );
|
||||
}
|
||||
|
|
106
arch/arm/src/mps/mps_userspace.c
Normal file
106
arch/arm/src/mps/mps_userspace.c
Normal file
|
@ -0,0 +1,106 @@
|
|||
/****************************************************************************
|
||||
* arch/arm/src/mps/mps_userspace.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
#include <sys/param.h>
|
||||
#include <nuttx/userspace.h>
|
||||
|
||||
#include "mpu.h"
|
||||
#include "barriers.h"
|
||||
#include "arm_internal.h"
|
||||
#include "mps_userspace.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mps_userspace
|
||||
*
|
||||
* Description:
|
||||
* For the case of the separate user-/kernel-space build, perform whatever
|
||||
* platform specific initialization of the user memory is required.
|
||||
* Normally this just means initializing the user space .data and .bss
|
||||
* segments.
|
||||
*
|
||||
* Assumptions:
|
||||
* The D-Cache has not yet been enabled.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void mps_userspace(void)
|
||||
{
|
||||
uint8_t *src;
|
||||
uint8_t *dest;
|
||||
uint8_t *end;
|
||||
uintptr_t datastart;
|
||||
uintptr_t dataend;
|
||||
|
||||
/* Clear all of user-space .bss */
|
||||
|
||||
DEBUGASSERT(USERSPACE->us_bssstart != 0 &&
|
||||
USERSPACE->us_bssend != 0 &&
|
||||
USERSPACE->us_bssstart <= USERSPACE->us_bssend);
|
||||
|
||||
dest = (uint8_t *)USERSPACE->us_bssstart;
|
||||
end = (uint8_t *)USERSPACE->us_bssend;
|
||||
|
||||
while (dest != end)
|
||||
{
|
||||
*dest++ = 0;
|
||||
}
|
||||
|
||||
/* Initialize all of user-space .data */
|
||||
|
||||
DEBUGASSERT(USERSPACE->us_datasource != 0 &&
|
||||
USERSPACE->us_datastart != 0 &&
|
||||
USERSPACE->us_dataend != 0 &&
|
||||
USERSPACE->us_datastart <= USERSPACE->us_dataend);
|
||||
|
||||
src = (uint8_t *)USERSPACE->us_datasource;
|
||||
dest = (uint8_t *)USERSPACE->us_datastart;
|
||||
end = (uint8_t *)USERSPACE->us_dataend;
|
||||
|
||||
while (dest != end)
|
||||
{
|
||||
*dest++ = *src++;
|
||||
}
|
||||
|
||||
/* Configure user flash and SRAM space */
|
||||
|
||||
DEBUGASSERT(USERSPACE->us_textend >= USERSPACE->us_textstart);
|
||||
|
||||
mpu_user_flash(USERSPACE->us_textstart,
|
||||
USERSPACE->us_textend - USERSPACE->us_textstart);
|
||||
|
||||
datastart = MIN(USERSPACE->us_datastart, USERSPACE->us_bssstart);
|
||||
dataend = MAX(USERSPACE->us_dataend, USERSPACE->us_bssend);
|
||||
|
||||
DEBUGASSERT(dataend >= datastart);
|
||||
|
||||
mpu_user_intsram(datastart, dataend - datastart);
|
||||
}
|
76
arch/arm/src/mps/mps_userspace.h
Normal file
76
arch/arm/src/mps/mps_userspace.h
Normal file
|
@ -0,0 +1,76 @@
|
|||
/****************************************************************************
|
||||
* arch/arm/src/mps/mps_userspace.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_MPS_MPS_USERSPACE_H
|
||||
#define __ARCH_ARM_SRC_MPS_MPS_USERSPACE_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "arm_internal.h"
|
||||
#include "chip.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mps_userspace
|
||||
*
|
||||
* Description:
|
||||
* For the case of the separate user-/kernel-space build, perform whatever
|
||||
* platform specific initialization of the user memory is required.
|
||||
* Normally this just means initializing the user space .data and .bss
|
||||
* segments.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void mps_userspace(void);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __ARCH_ARM_SRC_MPS_MPS_USERSPACE_H */
|
78
boards/arm/mps/mps2-an500/configs/knsh/defconfig
Normal file
78
boards/arm/mps/mps2-an500/configs/knsh/defconfig
Normal file
|
@ -0,0 +1,78 @@
|
|||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="mps2-an500"
|
||||
CONFIG_ARCH_BOARD_MPS2_AN500=y
|
||||
CONFIG_ARCH_CHIP="mps"
|
||||
CONFIG_ARCH_CHIP_MPS2_AN500=y
|
||||
CONFIG_ARCH_CHIP_MPS=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARMV7M_SYSTICK=y
|
||||
CONFIG_ARM_MPU=y
|
||||
CONFIG_ARM_MPU_EARLY_RESET=y
|
||||
CONFIG_BUILD_PROTECTED=y
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_CMSDK_UART0=y
|
||||
CONFIG_CMSDK_UART0_BASE=0x40004000
|
||||
CONFIG_CMSDK_UART0_CLOCK=25000000
|
||||
CONFIG_CMSDK_UART0_OV_IRQ=28
|
||||
CONFIG_CMSDK_UART0_RX_IRQ=16
|
||||
CONFIG_CMSDK_UART0_SERIAL_CONSOLE=y
|
||||
CONFIG_CMSDK_UART0_TX_IRQ=17
|
||||
CONFIG_CMSDK_UART=y
|
||||
CONFIG_DEBUG_ASSERTIONS=y
|
||||
CONFIG_DEBUG_FEATURES=y
|
||||
CONFIG_DEBUG_SCHED=y
|
||||
CONFIG_DEBUG_SCHED_ERROR=y
|
||||
CONFIG_DEBUG_SCHED_INFO=y
|
||||
CONFIG_DEBUG_SCHED_WARN=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_DEFAULT_TASK_STACKSIZE=4096
|
||||
CONFIG_DEV_ZERO=y
|
||||
CONFIG_EXAMPLES_HELLO=y
|
||||
CONFIG_EXPERIMENTAL=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_FS_ROMFS=y
|
||||
CONFIG_FS_TMPFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=4096
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_MEMFD_ERROR=y
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NUTTX_USERSPACE=0x20000000
|
||||
CONFIG_PASS1_BUILDIR="boards/arm/mps/mps2-an500/kernel"
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAMLOG=y
|
||||
CONFIG_RAM_SIZE=2097152
|
||||
CONFIG_RAM_START=0x60000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_READLINE_CMD_HISTORY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_HPWORKPRIORITY=192
|
||||
CONFIG_SPINLOCK=y
|
||||
CONFIG_STACK_COLORATION=y
|
||||
CONFIG_STANDARD_SERIAL=y
|
||||
CONFIG_START_DAY=25
|
||||
CONFIG_START_MONTH=4
|
||||
CONFIG_START_YEAR=2023
|
||||
CONFIG_SYMTAB_ORDEREDBYNAME=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_SYSTEM=y
|
||||
CONFIG_TESTING_GETPRIME=y
|
||||
CONFIG_TESTING_OSTEST=y
|
||||
CONFIG_TESTING_OSTEST_FPUTESTDISABLE=y
|
||||
CONFIG_TIMER=y
|
||||
CONFIG_TIMER_ARCH=y
|
||||
CONFIG_USEC_PER_TICK=1000
|
|
@ -14,6 +14,10 @@ CONFIG_ARCH_CHIP_MPS2_AN500=y
|
|||
CONFIG_ARCH_CHIP_MPS=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARMV7M_SYSTICK=y
|
||||
CONFIG_ARM_MPU=y
|
||||
CONFIG_ARM_MPU_NREGIONS=1
|
||||
CONFIG_ARM_MPU_RESET=y
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_CMSDK_UART0=y
|
||||
CONFIG_CMSDK_UART0_BASE=0x40004000
|
||||
|
|
92
boards/arm/mps/mps2-an500/kernel/Makefile
Normal file
92
boards/arm/mps/mps2-an500/kernel/Makefile
Normal file
|
@ -0,0 +1,92 @@
|
|||
############################################################################
|
||||
# boards/arm/mps/mps2-an500/kernel/Makefile
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership. The
|
||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance with the
|
||||
# License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
include $(TOPDIR)/Make.defs
|
||||
|
||||
# The entry point name (if none is provided in the .config file)
|
||||
|
||||
CONFIG_INIT_ENTRYPOINT ?= user_start
|
||||
ENTRYPT = $(patsubst "%",%,$(CONFIG_INIT_ENTRYPOINT))
|
||||
|
||||
# Get the paths to the libraries and the links script path in format that
|
||||
# is appropriate for the host OS
|
||||
|
||||
USER_LIBPATHS = $(addprefix -L,$(call CONVERT_PATH,$(addprefix $(TOPDIR)$(DELIM),$(dir $(USERLIBS)))))
|
||||
USER_LDSCRIPT = -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld)
|
||||
USER_LDSCRIPT += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)user-space.ld)
|
||||
USER_HEXFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.hex)
|
||||
USER_SRECFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.srec)
|
||||
USER_BINFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.bin)
|
||||
|
||||
USER_LDFLAGS = --undefined=$(ENTRYPT) --entry=$(ENTRYPT) $(USER_LDSCRIPT)
|
||||
USER_LDLIBS = $(patsubst lib%,-l%,$(basename $(notdir $(USERLIBS))))
|
||||
USER_LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}"
|
||||
|
||||
# Source files
|
||||
|
||||
CSRCS = mps_userspace.c
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
OBJS = $(COBJS)
|
||||
|
||||
# Targets:
|
||||
|
||||
all: $(TOPDIR)$(DELIM)nuttx_user.elf $(TOPDIR)$(DELIM)User.map
|
||||
.PHONY: nuttx_user.elf depend clean distclean
|
||||
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
# Create the nuttx_user.elf file containing all of the user-mode code
|
||||
|
||||
nuttx_user.elf: $(OBJS)
|
||||
$(Q) $(LD) -o $@ $(USER_LDFLAGS) $(USER_LIBPATHS) $(OBJS) --start-group $(USER_LDLIBS) --end-group $(USER_LIBGCC)
|
||||
|
||||
$(TOPDIR)$(DELIM)nuttx_user.elf: nuttx_user.elf
|
||||
@echo "LD: nuttx_user.elf"
|
||||
$(Q) cp -a nuttx_user.elf $(TOPDIR)$(DELIM)nuttx_user.elf
|
||||
ifeq ($(CONFIG_INTELHEX_BINARY),y)
|
||||
@echo "CP: nuttx_user.hex"
|
||||
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O ihex nuttx_user.elf $(USER_HEXFILE)
|
||||
endif
|
||||
ifeq ($(CONFIG_MOTOROLA_SREC),y)
|
||||
@echo "CP: nuttx_user.srec"
|
||||
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O srec nuttx_user.elf $(USER_SRECFILE)
|
||||
endif
|
||||
ifeq ($(CONFIG_RAW_BINARY),y)
|
||||
@echo "CP: nuttx_user.bin"
|
||||
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary nuttx_user.elf $(USER_BINFILE)
|
||||
endif
|
||||
|
||||
$(TOPDIR)$(DELIM)User.map: nuttx_user.elf
|
||||
@echo "MK: User.map"
|
||||
$(Q) $(NM) nuttx_user.elf >$(TOPDIR)$(DELIM)User.map
|
||||
$(Q) $(CROSSDEV)size nuttx_user.elf
|
||||
|
||||
.depend:
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
$(call DELFILE, nuttx_user.elf)
|
||||
$(call DELFILE, "$(TOPDIR)$(DELIM)nuttx_user.*")
|
||||
$(call DELFILE, "$(TOPDIR)$(DELIM)User.map")
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
115
boards/arm/mps/mps2-an500/kernel/mps_userspace.c
Normal file
115
boards/arm/mps/mps2-an500/kernel/mps_userspace.c
Normal file
|
@ -0,0 +1,115 @@
|
|||
/****************************************************************************
|
||||
* boards/arm/mps/mps2-an500/kernel/mps_userspace.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <nuttx/userspace.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
#include <nuttx/mm/mm.h>
|
||||
|
||||
#if defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#ifndef CONFIG_NUTTX_USERSPACE
|
||||
# error "CONFIG_NUTTX_USERSPACE not defined"
|
||||
#endif
|
||||
|
||||
#if CONFIG_NUTTX_USERSPACE != 0x20000000
|
||||
# error "CONFIG_NUTTX_USERSPACE must be 0x20000000 to match user-space.ld"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* These 'addresses' of these values are setup by the linker script.
|
||||
* They are not actual uint32_t storage locations!
|
||||
* They are only used meaningfully in the following way:
|
||||
*
|
||||
* - The linker script defines, for example, the symbol_sdata.
|
||||
* - The declaration extern uint32_t _sdata; makes C happy. C will believe
|
||||
* that the value _sdata is the address of a uint32_t variable _data (it
|
||||
* is not!).
|
||||
* - We can recover the linker value then by simply taking the address of
|
||||
* of _data. like: uint32_t *pdata = &_sdata;
|
||||
*/
|
||||
|
||||
/* These symbols are setup by the linker script. */
|
||||
|
||||
extern uint8_t _stext[]; /* Start of .text */
|
||||
extern uint8_t _etext[]; /* End_1 of .text + .rodata */
|
||||
extern const uint8_t _eronly[]; /* End+1 of read only section (.text + .rodata) */
|
||||
extern uint8_t _sdata[]; /* Start of .data */
|
||||
extern uint8_t _edata[]; /* End+1 of .data */
|
||||
extern uint8_t _sbss[]; /* Start of .bss */
|
||||
extern uint8_t _ebss[]; /* End+1 of .bss */
|
||||
|
||||
/* This is the user space entry point */
|
||||
|
||||
int CONFIG_INIT_ENTRYPOINT(int argc, char *argv[]);
|
||||
|
||||
const struct userspace_s userspace locate_data(".userspace") =
|
||||
{
|
||||
/* General memory map */
|
||||
|
||||
.us_entrypoint = (main_t)CONFIG_INIT_ENTRYPOINT,
|
||||
.us_textstart = (uintptr_t)&_stext,
|
||||
.us_textend = (uintptr_t)&_etext,
|
||||
.us_datasource = (uintptr_t)&_eronly,
|
||||
.us_datastart = (uintptr_t)&_sdata,
|
||||
.us_dataend = (uintptr_t)&_edata,
|
||||
.us_bssstart = (uintptr_t)&_sbss,
|
||||
.us_bssend = (uintptr_t)&_ebss,
|
||||
|
||||
/* Memory manager heap structure */
|
||||
|
||||
.us_heap = &g_mmheap,
|
||||
|
||||
/* Task/thread startup routines */
|
||||
|
||||
.task_startup = nxtask_startup,
|
||||
|
||||
/* Signal handler trampoline */
|
||||
|
||||
.signal_handler = up_signal_handler,
|
||||
|
||||
/* User-space work queue support (declared in include/nuttx/wqueue.h) */
|
||||
|
||||
#ifdef CONFIG_LIBC_USRWORK
|
||||
.work_usrstart = work_usrstart,
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#endif /* CONFIG_BUILD_PROTECTED && !__KERNEL__ */
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
MEMORY
|
||||
{
|
||||
flash (rx) : ORIGIN = 0x00000000, LENGTH = 512K
|
||||
flash (rx) : ORIGIN = 0x00000000, LENGTH = 4M
|
||||
sram1 (rwx) : ORIGIN = 0x60000000, LENGTH = 16M
|
||||
}
|
||||
|
||||
|
|
104
boards/arm/mps/mps2-an500/scripts/kernel-space.ld
Normal file
104
boards/arm/mps/mps2-an500/scripts/kernel-space.ld
Normal file
|
@ -0,0 +1,104 @@
|
|||
/****************************************************************************
|
||||
* boards/arm/mps/mps2-an500/scripts/kernel-space.ld
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* NOTE: This depends on the memory.ld script having been included prior to
|
||||
* this script.
|
||||
*/
|
||||
|
||||
OUTPUT_ARCH(arm)
|
||||
EXTERN(_vectors)
|
||||
ENTRY(_stext)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
_stext = ABSOLUTE(.);
|
||||
*(.vectors)
|
||||
*(.text .text.*)
|
||||
*(.fixup)
|
||||
*(.gnu.warning)
|
||||
*(.rodata .rodata.*)
|
||||
*(.gnu.linkonce.t.*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
*(.got)
|
||||
*(.gcc_except_table)
|
||||
*(.gnu.linkonce.r.*)
|
||||
_etext = ABSOLUTE(.);
|
||||
} > kflash
|
||||
|
||||
.init_section :
|
||||
{
|
||||
_sinit = ABSOLUTE(.);
|
||||
KEEP(*(.init_array .init_array.*))
|
||||
_einit = ABSOLUTE(.);
|
||||
} > kflash
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab*)
|
||||
} > kflash
|
||||
|
||||
__exidx_start = ABSOLUTE(.);
|
||||
.ARM.exidx :
|
||||
{
|
||||
*(.ARM.exidx*)
|
||||
} > kflash
|
||||
|
||||
__exidx_end = ABSOLUTE(.);
|
||||
|
||||
_eronly = ABSOLUTE(.);
|
||||
|
||||
.data :
|
||||
{
|
||||
_sdata = ABSOLUTE(.);
|
||||
*(.data .data.*)
|
||||
*(.gnu.linkonce.d.*)
|
||||
CONSTRUCTORS
|
||||
. = ALIGN(4);
|
||||
_edata = ABSOLUTE(.);
|
||||
} > kocram AT > kflash
|
||||
|
||||
.bss :
|
||||
{
|
||||
_sbss = ABSOLUTE(.);
|
||||
*(.bss .bss.*)
|
||||
*(.gnu.linkonce.b.*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
_ebss = ABSOLUTE(.);
|
||||
} > kocram
|
||||
|
||||
/* Stabs debugging sections */
|
||||
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_info 0 : { *(.debug_info) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
}
|
35
boards/arm/mps/mps2-an500/scripts/memory.ld
Normal file
35
boards/arm/mps/mps2-an500/scripts/memory.ld
Normal file
|
@ -0,0 +1,35 @@
|
|||
/****************************************************************************
|
||||
* boards/arm/mps/mps2-an500/scripts/memory.ld
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* Specify the memory areas
|
||||
* see arch/arm/src/mps/hardware/mps_memorymap.h for more details
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
|
||||
kflash (rx) : ORIGIN = 0x00000000, LENGTH = 4M
|
||||
uflash (rx) : ORIGIN = 0x20000000, LENGTH = 4M
|
||||
|
||||
kocram (rwx) : ORIGIN = 0x60000000, LENGTH = 8M
|
||||
uocram (rwx) : ORIGIN = 0x60800000, LENGTH = 8M
|
||||
}
|
||||
|
||||
_ram_size = LENGTH(kocram) + LENGTH(uocram);
|
105
boards/arm/mps/mps2-an500/scripts/user-space.ld
Normal file
105
boards/arm/mps/mps2-an500/scripts/user-space.ld
Normal file
|
@ -0,0 +1,105 @@
|
|||
/****************************************************************************
|
||||
* boards/arm/mps/mps2-an500/scripts/user-space.ld
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* NOTE: This depends on the memory.ld script having been included prior to
|
||||
* this script.
|
||||
*/
|
||||
|
||||
OUTPUT_ARCH(arm)
|
||||
SECTIONS
|
||||
{
|
||||
.userspace :
|
||||
{
|
||||
*(.userspace)
|
||||
} > uflash
|
||||
|
||||
.text :
|
||||
{
|
||||
_stext = ABSOLUTE(.);
|
||||
*(.text .text.*)
|
||||
*(.fixup)
|
||||
*(.gnu.warning)
|
||||
*(.rodata .rodata.*)
|
||||
*(.gnu.linkonce.t.*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
*(.got)
|
||||
*(.gcc_except_table)
|
||||
*(.gnu.linkonce.r.*)
|
||||
_etext = ABSOLUTE(.);
|
||||
} > uflash
|
||||
|
||||
.init_section :
|
||||
{
|
||||
_sinit = ABSOLUTE(.);
|
||||
KEEP(*(.init_array .init_array.*))
|
||||
_einit = ABSOLUTE(.);
|
||||
} > uflash
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab*)
|
||||
} > uflash
|
||||
|
||||
__exidx_start = ABSOLUTE(.);
|
||||
.ARM.exidx :
|
||||
{
|
||||
*(.ARM.exidx*)
|
||||
} > uflash
|
||||
|
||||
__exidx_end = ABSOLUTE(.);
|
||||
|
||||
_eronly = ABSOLUTE(.);
|
||||
|
||||
.data :
|
||||
{
|
||||
_sdata = ABSOLUTE(.);
|
||||
*(.data .data.*)
|
||||
*(.gnu.linkonce.d.*)
|
||||
CONSTRUCTORS
|
||||
. = ALIGN(4);
|
||||
_edata = ABSOLUTE(.);
|
||||
} > uocram AT > uflash
|
||||
|
||||
.bss :
|
||||
{
|
||||
_sbss = ABSOLUTE(.);
|
||||
*(.bss .bss.*)
|
||||
*(.gnu.linkonce.b.*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
_ebss = ABSOLUTE(.);
|
||||
} > uocram
|
||||
|
||||
/* Stabs debugging sections */
|
||||
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_info 0 : { *(.debug_info) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
}
|
Loading…
Reference in a new issue