mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
mps3-an547:support protect mode
add mps3-an547:knsh configs ./tools/configure.sh mps3-an547:knsh make -j20 qemu-system-arm -M mps3-an547 -m 2G -device loader,file=nuttx.hex -device loader,file=nuttx_user.hex -gdb tcp::1129 -nographic nsh>ostest Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
@@ -315,6 +315,62 @@ void mpu_initialize(const struct mpu_region_s *table, size_t count,
|
|||||||
mpu_control(true, hfnmiena, privdefena);
|
mpu_control(true, hfnmiena, privdefena);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: mpu_log2regionceil
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Determine the smallest value of l2size (log base 2 size) such that the
|
||||||
|
* following is true:
|
||||||
|
*
|
||||||
|
* size <= (1 << l2size)
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* size - The size of the region.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* The logarithm base 2 of the ceiling value for the MPU region size.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
uint8_t mpu_log2regionceil(size_t size)
|
||||||
|
{
|
||||||
|
uint8_t l2size;
|
||||||
|
|
||||||
|
/* The minimum permitted region size is 32 bytes (log2(32) = 5. */
|
||||||
|
|
||||||
|
for (l2size = 5; l2size < 32 && size > (1 << l2size); l2size++);
|
||||||
|
return l2size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: mpu_log2regionfloor
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Determine the largest value of l2size (log base 2 size) such that the
|
||||||
|
* following is true:
|
||||||
|
*
|
||||||
|
* size >= (1 << l2size)
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* size - The size of the region.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* The logarithm base 2 of the floor value for the MPU region size.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
uint8_t mpu_log2regionfloor(size_t size)
|
||||||
|
{
|
||||||
|
uint8_t l2size = mpu_log2regionceil(size);
|
||||||
|
|
||||||
|
if (l2size > 4 && size < (1 << l2size))
|
||||||
|
{
|
||||||
|
l2size--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return l2size;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: mpu_dump_region
|
* Name: mpu_dump_region
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -284,6 +284,44 @@ void mpu_freeregion(unsigned int region);
|
|||||||
|
|
||||||
void mpu_control(bool enable, bool hfnmiena, bool privdefena);
|
void mpu_control(bool enable, bool hfnmiena, bool privdefena);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: mpu_log2regionceil
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Determine the smallest value of l2size (log base 2 size) such that the
|
||||||
|
* following is true:
|
||||||
|
*
|
||||||
|
* size <= (1 << l2size)
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* size - The size of the region.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* The logarithm base 2 of the ceiling value for the MPU region size.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
uint8_t mpu_log2regionceil(size_t size);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: mpu_log2regionfloor
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Determine the largest value of l2size (log base 2 size) such that the
|
||||||
|
* following is true:
|
||||||
|
*
|
||||||
|
* size >= (1 << l2size)
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* size - The size of the region.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* The logarithm base 2 of the floor value for the MPU region size.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
uint8_t mpu_log2regionfloor(size_t size);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: mpu_dump_region
|
* Name: mpu_dump_region
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ config ARCH_CHIP_MPS3_AN524
|
|||||||
config ARCH_CHIP_MPS3_AN547
|
config ARCH_CHIP_MPS3_AN547
|
||||||
bool "MPS3 AN547 Processor Cortexm55"
|
bool "MPS3 AN547 Processor Cortexm55"
|
||||||
select ARCH_CORTEXM55
|
select ARCH_CORTEXM55
|
||||||
|
select ARCH_HAVE_MPU
|
||||||
select ARCH_HAVE_FPU
|
select ARCH_HAVE_FPU
|
||||||
select ARM_HAVE_MVE
|
select ARM_HAVE_MVE
|
||||||
select ARCH_HAVE_TEXT_HEAP
|
select ARCH_HAVE_TEXT_HEAP
|
||||||
|
|||||||
@@ -99,8 +99,11 @@
|
|||||||
#define MPS_EXTMEM_START 0x60000000
|
#define MPS_EXTMEM_START 0x60000000
|
||||||
#define MPS_EXTMEM_SIZE 0x80000000
|
#define MPS_EXTMEM_SIZE 0x80000000
|
||||||
|
|
||||||
#define PRIMARY_RAM_START MPS_SRAM2_START
|
#define MPS_PSRAM_START 0x60000000
|
||||||
#define PRIMARY_RAM_SIZE MPS_SRAM2_SIZE
|
#define MPS_PSRAM_SIZE 0x01000000
|
||||||
|
|
||||||
|
#define PRIMARY_RAM_START MPS_PSRAM_START
|
||||||
|
#define PRIMARY_RAM_SIZE MPS_PSRAM_SIZE
|
||||||
|
|
||||||
#if CONFIG_MM_REGIONS > 1
|
#if CONFIG_MM_REGIONS > 1
|
||||||
#define REGION1_RAM_START MPS_EXTMEM_START
|
#define REGION1_RAM_START MPS_EXTMEM_START
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ static uintptr_t g_alloc_count;
|
|||||||
|
|
||||||
void up_allocate_heap(void **heap_start, size_t *heap_size)
|
void up_allocate_heap(void **heap_start, size_t *heap_size)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_MM_KERNEL_HEAP)
|
#if defined(CONFIG_BUILD_PROTECTED)
|
||||||
/* Get the unaligned size and position of the user-space heap.
|
/* Get the unaligned size and position of the user-space heap.
|
||||||
* This heap begins after the user-space .bss section at an offset
|
* This heap begins after the user-space .bss section at an offset
|
||||||
* of CONFIG_MM_KERNEL_HEAPSIZE (subject to alignment).
|
* of CONFIG_MM_KERNEL_HEAPSIZE (subject to alignment).
|
||||||
@@ -187,6 +187,10 @@ void up_allocate_heap(void **heap_start, size_t *heap_size)
|
|||||||
*heap_size = MPS_SRAM1_START + MPS_SRAM1_SIZE - g_idle_topstack;
|
*heap_size = MPS_SRAM1_START + MPS_SRAM1_SIZE - g_idle_topstack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# if defined(CONFIG_MM_KERNEL_HEAP)
|
||||||
|
*heap_size -= CONFIG_MM_KERNEL_HEAPSIZE;
|
||||||
|
# endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,9 +205,10 @@ void up_allocate_heap(void **heap_start, size_t *heap_size)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_MM_KERNEL_HEAP)
|
#if defined(CONFIG_MM_KERNEL_HEAP)
|
||||||
void up_allocate_kheap(void **heap_start, size_t *heap_size)
|
void up_allocate_kheap(void **heap_start, size_t *heap_size)
|
||||||
{
|
{
|
||||||
|
# if defined(CONFIG_BUILD_PROTECTED)
|
||||||
/* Get the unaligned size and position of the user-space heap.
|
/* Get the unaligned size and position of the user-space heap.
|
||||||
* This heap begins after the user-space .bss section at an offset
|
* This heap begins after the user-space .bss section at an offset
|
||||||
* of CONFIG_MM_KERNEL_HEAPSIZE (subject to alignment).
|
* of CONFIG_MM_KERNEL_HEAPSIZE (subject to alignment).
|
||||||
@@ -232,6 +237,25 @@ void up_allocate_kheap(void **heap_start, size_t *heap_size)
|
|||||||
|
|
||||||
*heap_start = (void *)USERSPACE->us_bssend;
|
*heap_start = (void *)USERSPACE->us_bssend;
|
||||||
*heap_size = ubase - (uintptr_t)USERSPACE->us_bssend;
|
*heap_size = ubase - (uintptr_t)USERSPACE->us_bssend;
|
||||||
|
# else
|
||||||
|
if (g_idle_topstack > MPS_SRAM1_START + MPS_SRAM1_SIZE)
|
||||||
|
{
|
||||||
|
/* If the range of SRAM1 is exceeded, we think that the extern REGION
|
||||||
|
* is enabled
|
||||||
|
*/
|
||||||
|
|
||||||
|
*heap_size = PRIMARY_RAM_END - g_idle_topstack;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*heap_size = MPS_SRAM1_START + MPS_SRAM1_SIZE - g_idle_topstack;
|
||||||
|
}
|
||||||
|
|
||||||
|
*heap_size -= CONFIG_MM_KERNEL_HEAPSIZE;
|
||||||
|
*heap_start = (void *)g_idle_topstack + *heap_size;
|
||||||
|
*heap_size = CONFIG_MM_KERNEL_HEAPSIZE;
|
||||||
|
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
#
|
||||||
|
# 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_NSH_DISABLE_MW is not set
|
||||||
|
CONFIG_ARCH="arm"
|
||||||
|
CONFIG_ARCH_BOARD="mps3-an547"
|
||||||
|
CONFIG_ARCH_BOARD_MPS3_AN547=y
|
||||||
|
CONFIG_ARCH_CHIP="mps"
|
||||||
|
CONFIG_ARCH_CHIP_MPS3_AN547=y
|
||||||
|
CONFIG_ARCH_CHIP_MPS=y
|
||||||
|
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||||
|
CONFIG_ARCH_STACKDUMP=y
|
||||||
|
CONFIG_ARMV8M_STACKCHECK_NONE=y
|
||||||
|
CONFIG_ARMV8M_SYSTICK=y
|
||||||
|
CONFIG_ARM_MPU=y
|
||||||
|
CONFIG_BUILD_PROTECTED=y
|
||||||
|
CONFIG_BUILTIN=y
|
||||||
|
CONFIG_CMSDK_UART0=y
|
||||||
|
CONFIG_CMSDK_UART0_BASE=0x49303000
|
||||||
|
CONFIG_CMSDK_UART0_CLOCK=25000000
|
||||||
|
CONFIG_CMSDK_UART0_OV_IRQ=59
|
||||||
|
CONFIG_CMSDK_UART0_RX_IRQ=50
|
||||||
|
CONFIG_CMSDK_UART0_SERIAL_CONSOLE=y
|
||||||
|
CONFIG_CMSDK_UART0_TX_IRQ=49
|
||||||
|
CONFIG_CMSDK_UART=y
|
||||||
|
CONFIG_COVERAGE_TOOLCHAIN=y
|
||||||
|
CONFIG_DEBUG_ASSERTIONS=y
|
||||||
|
CONFIG_DEBUG_BUSFAULT=y
|
||||||
|
CONFIG_DEBUG_FEATURES=y
|
||||||
|
CONFIG_DEBUG_HARDFAULT_ALERT=y
|
||||||
|
CONFIG_DEBUG_SCHED=y
|
||||||
|
CONFIG_DEBUG_SCHED_ERROR=y
|
||||||
|
CONFIG_DEBUG_SYMBOLS=y
|
||||||
|
CONFIG_DEBUG_USAGEFAULT=y
|
||||||
|
CONFIG_DEFAULT_TASK_STACKSIZE=4096
|
||||||
|
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_FILL_ALLOCATIONS=y
|
||||||
|
CONFIG_MM_KERNEL_HEAPSIZE=65535
|
||||||
|
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/mps3-an547/kernel"
|
||||||
|
CONFIG_PREALLOC_TIMERS=4
|
||||||
|
CONFIG_RAMLOG=y
|
||||||
|
CONFIG_RAM_SIZE=2097152
|
||||||
|
CONFIG_RAM_START=0x01000000
|
||||||
|
CONFIG_RAW_BINARY=y
|
||||||
|
CONFIG_READLINE_CMD_HISTORY=y
|
||||||
|
CONFIG_RR_INTERVAL=200
|
||||||
|
CONFIG_SCHED_BACKTRACE=y
|
||||||
|
CONFIG_SCHED_HPWORK=y
|
||||||
|
CONFIG_SCHED_HPWORKPRIORITY=192
|
||||||
|
CONFIG_SCHED_IRQMONITOR=y
|
||||||
|
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_MM=y
|
||||||
|
CONFIG_TESTING_OSTEST=y
|
||||||
|
CONFIG_TESTING_OSTEST_FPUTESTDISABLE=y
|
||||||
|
CONFIG_TIMER=y
|
||||||
|
CONFIG_TIMER_ARCH=y
|
||||||
|
CONFIG_USEC_PER_TICK=1000
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
############################################################################
|
||||||
|
# boards/arm/mps/mps3-an547/kernel/Makefile
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
# 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
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/mps/mps3-an547/kernel/mps_userspace.c
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* 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/arch.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__ */
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/mps/mps3-an547/scripts/memory.ld
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* 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);
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/mps/mps3-an547/scripts/user-space.ld
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* 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) }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user