2015-09-10 10:54:09 -07:00
|
|
|
/*
|
2015-11-30 15:29:39 -05:00
|
|
|
* Copyright (c) 2014-2015 Wind River Systems, Inc.
|
2015-09-10 10:54:09 -07:00
|
|
|
*
|
2017-01-18 17:01:01 -08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-09-10 10:54:09 -07:00
|
|
|
*/
|
|
|
|
|
2015-11-30 15:29:39 -05:00
|
|
|
/**
|
|
|
|
* @brief Common parts of the linker scripts for the ARCv2/EM targets.
|
|
|
|
*/
|
2015-09-10 10:54:09 -07:00
|
|
|
|
|
|
|
#define _LINKER
|
|
|
|
#define _ASMLANGUAGE
|
|
|
|
|
|
|
|
#include <autoconf.h>
|
2017-06-17 11:30:47 -04:00
|
|
|
#include <linker/sections.h>
|
2015-09-10 10:54:09 -07:00
|
|
|
|
2018-05-24 13:28:10 +02:00
|
|
|
#if defined(CONFIG_UART_NSIM)
|
2015-09-10 10:54:09 -07:00
|
|
|
EXTERN(_VectorTable)
|
|
|
|
#endif
|
|
|
|
|
2017-06-17 11:30:47 -04:00
|
|
|
#include <linker/linker-defs.h>
|
|
|
|
#include <linker/linker-tool.h>
|
2015-09-10 10:54:09 -07:00
|
|
|
|
2017-12-20 16:48:45 +08:00
|
|
|
#define KOBJECT_TEXT_AREA 256
|
|
|
|
|
2015-09-10 10:54:09 -07:00
|
|
|
/* physical address of RAM */
|
2016-08-09 11:45:23 -07:00
|
|
|
#ifdef CONFIG_HARVARD
|
|
|
|
#define ROMABLE_REGION ICCM
|
|
|
|
#define RAMABLE_REGION DCCM
|
2015-09-10 10:54:09 -07:00
|
|
|
#else
|
2016-08-09 11:45:23 -07:00
|
|
|
#if defined(CONFIG_XIP) && (FLASH_SIZE != 0)
|
|
|
|
#define ROMABLE_REGION FLASH
|
|
|
|
#define RAMABLE_REGION SRAM
|
|
|
|
#else
|
|
|
|
#define ROMABLE_REGION SRAM
|
|
|
|
#define RAMABLE_REGION SRAM
|
|
|
|
#endif
|
2015-09-10 10:54:09 -07:00
|
|
|
#endif
|
|
|
|
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
#ifdef CONFIG_ARC_MPU_ENABLE
|
|
|
|
#if CONFIG_ARC_MPU_VER == 2
|
2018-02-12 19:20:22 +08:00
|
|
|
#define MPU_MIN_SIZE 2048
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
#elif CONFIG_ARC_MPU_VER == 3
|
2018-02-12 19:20:22 +08:00
|
|
|
#define MPU_MIN_SIZE 32
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
#endif
|
2018-02-12 19:20:22 +08:00
|
|
|
#define MPU_MIN_SIZE_ALIGN . = ALIGN(MPU_MIN_SIZE );
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
#else
|
2018-02-12 19:20:22 +08:00
|
|
|
#define MPU_MIN_SIZE_ALIGN
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
#endif
|
|
|
|
|
2015-09-10 10:54:09 -07:00
|
|
|
#if defined(CONFIG_XIP)
|
|
|
|
#define _DATA_IN_ROM __data_rom_start
|
|
|
|
#else
|
|
|
|
#define _DATA_IN_ROM
|
|
|
|
#endif
|
|
|
|
|
2016-08-09 11:45:23 -07:00
|
|
|
OUTPUT_ARCH(arc)
|
2018-06-22 16:07:36 +02:00
|
|
|
ENTRY(CONFIG_KERNEL_ENTRY)
|
2016-08-09 11:45:23 -07:00
|
|
|
|
2015-09-10 10:54:09 -07:00
|
|
|
MEMORY {
|
2016-08-09 11:45:23 -07:00
|
|
|
#ifdef FLASH_START
|
|
|
|
FLASH (rx) : ORIGIN = FLASH_START, LENGTH = FLASH_SIZE*1k
|
|
|
|
#endif
|
|
|
|
#ifdef ICCM_START
|
2017-01-09 14:50:00 -08:00
|
|
|
ICCM (rwx) : ORIGIN = ICCM_START, LENGTH = ICCM_SIZE*1k
|
2016-08-09 11:45:23 -07:00
|
|
|
#endif
|
|
|
|
#ifdef SRAM_START
|
2016-05-20 21:35:34 -07:00
|
|
|
SRAM (rwx) : ORIGIN = SRAM_START, LENGTH = SRAM_SIZE*1k
|
2016-08-09 11:45:23 -07:00
|
|
|
#endif
|
|
|
|
#ifdef DCCM_START
|
2016-05-20 21:35:34 -07:00
|
|
|
DCCM (rw) : ORIGIN = DCCM_START, LENGTH = DCCM_SIZE*1k
|
|
|
|
#endif
|
2017-02-13 09:36:32 -08:00
|
|
|
/* Used by and documented in include/linker/intlist.ld */
|
|
|
|
IDT_LIST (wx) : ORIGIN = 0xFFFFF7FF, LENGTH = 2K
|
2015-09-10 10:54:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
SECTIONS {
|
|
|
|
GROUP_START(ROMABLE_REGION)
|
|
|
|
|
|
|
|
SECTION_PROLOGUE(_TEXT_SECTION_NAME,,ALIGN(1024)) {
|
2015-10-30 12:50:11 -04:00
|
|
|
_image_rom_start = .;
|
2015-10-30 12:36:06 -04:00
|
|
|
_image_text_start = .;
|
2015-09-10 10:54:09 -07:00
|
|
|
|
|
|
|
/* when !XIP, .text is in RAM, and vector table must be at its very start */
|
|
|
|
|
|
|
|
KEEP(*(.exc_vector_table))
|
|
|
|
KEEP(*(".exc_vector_table.*"))
|
2017-02-08 17:40:50 -08:00
|
|
|
KEEP(*(IRQ_VECTOR_TABLE))
|
2015-09-10 10:54:09 -07:00
|
|
|
|
2017-02-13 09:36:32 -08:00
|
|
|
#ifdef CONFIG_GEN_SW_ISR_TABLE
|
|
|
|
KEEP(*(SW_ISR_TABLE))
|
|
|
|
#endif
|
2015-09-10 10:54:09 -07:00
|
|
|
*(.text)
|
|
|
|
*(".text.*")
|
2016-01-13 13:02:56 -05:00
|
|
|
*(.gnu.linkonce.t.*)
|
2015-09-10 10:54:09 -07:00
|
|
|
|
2017-12-20 16:48:45 +08:00
|
|
|
#include <linker/kobject-text.ld>
|
2015-09-10 10:54:09 -07:00
|
|
|
} GROUP_LINK_IN(ROMABLE_REGION)
|
|
|
|
|
2017-12-20 16:48:45 +08:00
|
|
|
_image_text_end = .;
|
|
|
|
_image_rodata_start = .;
|
|
|
|
|
2016-10-20 08:09:32 -07:00
|
|
|
#include <linker/common-rom.ld>
|
2016-01-13 13:02:56 -05:00
|
|
|
|
2015-09-10 10:54:09 -07:00
|
|
|
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,) {
|
2017-02-13 15:40:08 -08:00
|
|
|
KEEP(*(.openocd_dbg))
|
|
|
|
KEEP(*(".openocd_dbg.*"))
|
2015-09-10 10:54:09 -07:00
|
|
|
*(.rodata)
|
|
|
|
*(".rodata.*")
|
2016-01-13 13:02:56 -05:00
|
|
|
*(.gnu.linkonce.r.*)
|
2016-11-21 14:16:11 -08:00
|
|
|
|
|
|
|
#ifdef CONFIG_CUSTOM_RODATA_LD
|
|
|
|
/* Located in project source directory */
|
|
|
|
#include <custom-rodata.ld>
|
|
|
|
#endif
|
|
|
|
|
2017-12-20 16:48:45 +08:00
|
|
|
#include <linker/kobject-rom.ld>
|
|
|
|
|
2015-09-10 10:54:09 -07:00
|
|
|
} GROUP_LINK_IN(ROMABLE_REGION)
|
|
|
|
|
2017-12-20 16:48:45 +08:00
|
|
|
_image_rodata_end = .;
|
2018-02-12 19:20:22 +08:00
|
|
|
MPU_MIN_SIZE_ALIGN
|
2015-10-30 12:50:11 -04:00
|
|
|
_image_rom_end = .;
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
_image_rom_size = _image_rom_end - _image_rom_start;
|
2015-09-10 10:54:09 -07:00
|
|
|
|
|
|
|
GROUP_END(ROMABLE_REGION)
|
|
|
|
|
|
|
|
GROUP_START(RAMABLE_REGION)
|
|
|
|
|
userspace: compartmentalized app memory organization
Summary: revised attempt at addressing issue 6290. The
following provides an alternative to using
CONFIG_APPLICATION_MEMORY by compartmentalizing data into
Memory Domains. Dependent on MPU limitations, supports
compartmentalized Memory Domains for 1...N logical
applications. This is considered an initial attempt at
designing flexible compartmentalized Memory Domains for
multiple logical applications and, with the provided python
script and edited CMakeLists.txt, provides support for power
of 2 aligned MPU architectures.
Overview: The current patch uses qualifiers to group data into
subsections. The qualifier usage allows for dynamic subsection
creation and affords the developer a large amount of flexibility
in the grouping, naming, and size of the resulting partitions and
domains that are built on these subsections. By additional macro
calls, functions are created that help calculate the size,
address, and permissions for the subsections and enable the
developer to control application data in specified partitions and
memory domains.
Background: Initial attempts focused on creating a single
section in the linker script that then contained internally
grouped variables/data to allow MPU/MMU alignment and protection.
This did not provide additional functionality beyond
CONFIG_APPLICATION_MEMORY as we were unable to reliably group
data or determine their grouping via exported linker symbols.
Thus, the resulting decision was made to dynamically create
subsections using the current qualifier method. An attempt to
group the data by object file was tested, but found that this
broke applications such as ztest where two object files are
created: ztest and main. This also creates an issue of grouping
the two object files together in the same memory domain while
also allowing for compartmenting other data among threads.
Because it is not possible to know a) the name of the partition
and thus the symbol in the linker, b) the size of all the data
in the subsection, nor c) the overall number of partitions
created by the developer, it was not feasible to align the
subsections at compile time without using dynamically generated
linker script for MPU architectures requiring power of 2
alignment.
In order to provide support for MPU architectures that require a
power of 2 alignment, a python script is run at build prior to
when linker_priv_stacks.cmd is generated. This script scans the
built object files for all possible partitions and the names given
to them. It then generates a linker file (app_smem.ld) that is
included in the main linker.ld file. This app_smem.ld allows the
compiler and linker to then create each subsection and align to
the next power of 2.
Usage:
- Requires: app_memory/app_memdomain.h .
- _app_dmem(id) marks a variable to be placed into a data
section for memory partition id.
- _app_bmem(id) marks a variable to be placed into a bss
section for memory partition id.
- These are seen in the linker.map as "data_smem_id" and
"data_smem_idb".
- To create a k_mem_partition, call the macro
app_mem_partition(part0) where "part0" is the name then used to
refer to that partition. This macro only creates a function and
necessary data structures for the later "initialization".
- To create a memory domain for the partition, the macro
app_mem_domain(dom0) is called where "dom0" is the name then
used for the memory domain.
- To initialize the partition (effectively adding the partition
to a linked list), init_part_part0() is called. This is followed
by init_app_memory(), which walks all partitions in the linked
list and calculates the sizes for each partition.
- Once the partition is initialized, the domain can be
initialized with init_domain_dom0(part0) which initializes the
domain with partition part0.
- After the domain has been initialized, the current thread
can be added using add_thread_dom0(k_current_get()).
- The code used in ztests ans kernel/init has been added under
a conditional #ifdef to isolate the code from other tests.
The userspace test CMakeLists.txt file has commands to insert
the CONFIG_APP_SHARED_MEM definition into the required build
targets.
Example:
/* create partition at top of file outside functions */
app_mem_partition(part0);
/* create domain */
app_mem_domain(dom0);
_app_dmem(dom0) int var1;
_app_bmem(dom0) static volatile int var2;
int main()
{
init_part_part0();
init_app_memory();
init_domain_dom0(part0);
add_thread_dom0(k_current_get());
...
}
- If multiple partitions are being created, a variadic
preprocessor macro can be used as provided in
app_macro_support.h:
FOR_EACH(app_mem_partition, part0, part1, part2);
or, for multiple domains, similarly:
FOR_EACH(app_mem_domain, dom0, dom1);
Similarly, the init_part_* can also be used in the macro:
FOR_EACH(init_part, part0, part1, part2);
Testing:
- This has been successfully tested on qemu_x86 and the
ARM frdm_k64f board. It compiles and builds power of 2
aligned subsections for the linker script on the 96b_carbon
boards. These power of 2 alignments have been checked by
hand and are viewable in the zephyr.map file that is
produced during build. However, due to a shortage of
available MPU regions on the 96b_carbon board, we are unable
to test this.
- When run on the 96b_carbon board, the test suite will
enter execution, but each individaul test will fail due to
an MPU FAULT. This is expected as the required number of
MPU regions exceeds the number allowed due to the static
allocation. As the MPU driver does not detect this issue,
the fault occurs because the data being accessed has been
placed outside the active MPU region.
- This now compiles successfully for the ARC boards
em_starterkit_em7d and em_starterkit_em7d_v22. However,
as we lack ARC hardware to run this build on, we are unable
to test this build.
Current known issues:
1) While the script and edited CMakeLists.txt creates the
ability to align to the next power of 2, this does not
address the shortage of available MPU regions on certain
devices (e.g. 96b_carbon). In testing the APB and PPB
regions were commented out.
2) checkpatch.pl lists several issues regarding the
following:
a) Complex macros. The FOR_EACH macros as defined in
app_macro_support.h are listed as complex macros needing
parentheses. Adding parentheses breaks their
functionality, and we have otherwise been unable to
resolve the reported error.
b) __aligned() preferred. The _app_dmem_pad() and
_app_bmem_pad() macros give warnings that __aligned()
is preferred. Prior iterations had this implementation,
which resulted in errors due to "complex macros".
c) Trailing semicolon. The macro init_part(name) has
a trailing semicolon as the semicolon is needed for the
inlined macro call that is generated when this macro
expands.
Update: updated to alternative CONFIG_APPLCATION_MEMORY.
Added config option CONFIG_APP_SHARED_MEM to enable a new section
app_smem to contain the shared memory component. This commit
seperates the Kconfig definition from the definition used for the
conditional code. The change is in response to changes in the
way the build system treats definitions. The python script used
to generate a linker script for app_smem was also midified to
simplify the alignment directives. A default linker script
app_smem.ld was added to remove the conditional includes dependency
on CONFIG_APP_SHARED_MEM. By addining the default linker script
the prebuild stages link properly prior to the python script running
Signed-off-by: Joshua Domagalski <jedomag@tycho.nsa.gov>
Signed-off-by: Shawn Mosley <smmosle@tycho.nsa.gov>
2018-04-26 10:14:02 -04:00
|
|
|
#include <app_data_alignment.ld>
|
|
|
|
SECTION_PROLOGUE(_APP_SMEM_SECTION_NAME, (OPTIONAL),)
|
|
|
|
{
|
|
|
|
MPU_MIN_SIZE_ALIGN
|
|
|
|
_image_ram_start = .;
|
|
|
|
_app_smem_start = .;
|
|
|
|
#if defined(CONFIG_MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT)
|
|
|
|
#include <app_smem.ld>
|
|
|
|
#else
|
|
|
|
APP_SMEM_SECTION()
|
|
|
|
#endif
|
|
|
|
MPU_MIN_SIZE_ALIGN
|
|
|
|
_app_smem_end = .;
|
|
|
|
} GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
|
|
|
|
|
|
|
|
_app_smem_size = _app_smem_end - _app_smem_start;
|
|
|
|
_app_smem_rom_start = LOADADDR(_APP_SMEM_SECTION_NAME);
|
2017-12-20 16:48:45 +08:00
|
|
|
#ifdef CONFIG_APPLICATION_MEMORY
|
|
|
|
SECTION_DATA_PROLOGUE(_APP_DATA_SECTION_NAME, (OPTIONAL),)
|
|
|
|
{
|
2018-02-12 19:20:22 +08:00
|
|
|
MPU_MIN_SIZE_ALIGN
|
|
|
|
#include <app_data_alignment.ld>
|
|
|
|
|
2017-12-20 16:48:45 +08:00
|
|
|
__app_ram_start = .;
|
|
|
|
__app_data_ram_start = .;
|
2015-10-30 12:50:11 -04:00
|
|
|
_image_ram_start = .;
|
2017-12-20 16:48:45 +08:00
|
|
|
APP_INPUT_SECTION(.data)
|
|
|
|
APP_INPUT_SECTION(".data.*")
|
|
|
|
__app_data_ram_end = .;
|
|
|
|
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
2016-01-20 15:13:38 -08:00
|
|
|
|
2017-12-20 16:48:45 +08:00
|
|
|
__app_data_rom_start = LOADADDR(_APP_DATA_SECTION_NAME);
|
2016-11-21 14:16:11 -08:00
|
|
|
|
2017-12-20 16:48:45 +08:00
|
|
|
SECTION_PROLOGUE(_APP_BSS_SECTION_NAME, (NOLOAD OPTIONAL),)
|
|
|
|
{
|
|
|
|
__app_bss_start = .;
|
|
|
|
APP_INPUT_SECTION(.bss)
|
|
|
|
APP_INPUT_SECTION(".bss.*")
|
|
|
|
APP_INPUT_SECTION(COMMON)
|
|
|
|
__app_bss_end = .;
|
|
|
|
} GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
|
2015-09-10 10:54:09 -07:00
|
|
|
|
2017-12-20 16:48:45 +08:00
|
|
|
__app_bss_num_words = (__app_bss_end - __app_bss_start) >> 2;
|
2016-05-20 21:35:34 -07:00
|
|
|
|
2017-12-20 16:48:45 +08:00
|
|
|
SECTION_PROLOGUE(_APP_NOINIT_SECTION_NAME, (NOLOAD OPTIONAL),)
|
|
|
|
{
|
|
|
|
APP_INPUT_SECTION(.noinit)
|
|
|
|
APP_INPUT_SECTION(".noinit.*")
|
2018-02-12 19:20:22 +08:00
|
|
|
|
2017-12-20 16:48:45 +08:00
|
|
|
} GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
|
|
|
|
|
2018-02-12 19:20:22 +08:00
|
|
|
__app_last_address_used = .;
|
|
|
|
|
|
|
|
/* Pad out application ram area to make MPU friendly */
|
|
|
|
SECTION_PROLOGUE(app_pad, (NOLOAD OPTIONAL),)
|
|
|
|
{
|
|
|
|
. = ALIGN(_app_data_align);
|
|
|
|
MPU_MIN_SIZE_ALIGN
|
|
|
|
} GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
|
2017-12-20 16:48:45 +08:00
|
|
|
__app_ram_end = .;
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
__app_ram_size = __app_ram_end - __app_ram_start;
|
2017-12-20 16:48:45 +08:00
|
|
|
#endif /* CONFIG_APPLICATION_MEMORY */
|
2015-09-10 10:54:09 -07:00
|
|
|
|
2017-02-13 09:52:07 -08:00
|
|
|
SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),) {
|
2018-02-12 19:20:22 +08:00
|
|
|
MPU_MIN_SIZE_ALIGN
|
2015-09-10 10:54:09 -07:00
|
|
|
/*
|
|
|
|
* For performance, BSS section is assumed to be 4 byte aligned and
|
|
|
|
* a multiple of 4 bytes
|
|
|
|
*/
|
|
|
|
. = ALIGN(4);
|
|
|
|
__bss_start = .;
|
2017-12-20 16:48:45 +08:00
|
|
|
|
|
|
|
#ifndef CONFIG_APPLICATION_MEMORY
|
|
|
|
_image_ram_start = .;
|
|
|
|
#endif
|
|
|
|
__kernel_ram_start = .;
|
|
|
|
KERNEL_INPUT_SECTION(.bss)
|
|
|
|
KERNEL_INPUT_SECTION(".bss.*")
|
|
|
|
KERNEL_INPUT_SECTION(COMMON)
|
|
|
|
*(".kernel_bss.*")
|
|
|
|
|
2015-09-10 10:54:09 -07:00
|
|
|
/*
|
|
|
|
* BSP clears this memory in words only and doesn't clear any
|
|
|
|
* potential left over bytes.
|
|
|
|
*/
|
|
|
|
__bss_end = ALIGN(4);
|
2017-02-13 09:52:07 -08:00
|
|
|
} GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
|
2015-09-10 10:54:09 -07:00
|
|
|
|
|
|
|
SECTION_PROLOGUE(_NOINIT_SECTION_NAME,(NOLOAD),) {
|
|
|
|
/*
|
|
|
|
* This section is used for non-initialized objects that
|
|
|
|
* will not be cleared during the boot process.
|
|
|
|
*/
|
2017-12-20 16:48:45 +08:00
|
|
|
KERNEL_INPUT_SECTION(.noinit)
|
|
|
|
KERNEL_INPUT_SECTION(".noinit.*")
|
|
|
|
*(".kernel_noinit.*")
|
2015-09-10 10:54:09 -07:00
|
|
|
|
|
|
|
} GROUP_LINK_IN(RAMABLE_REGION)
|
|
|
|
|
2017-12-20 16:48:45 +08:00
|
|
|
SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,) {
|
|
|
|
|
|
|
|
/* when XIP, .text is in ROM, but vector table must be at start of .data */
|
|
|
|
__data_ram_start = .;
|
|
|
|
KERNEL_INPUT_SECTION(.data)
|
|
|
|
KERNEL_INPUT_SECTION(".data.*")
|
|
|
|
*(".kernel.*")
|
|
|
|
|
|
|
|
#ifdef CONFIG_CUSTOM_RWDATA_LD
|
|
|
|
/* Located in project source directory */
|
|
|
|
#include <custom-rwdata.ld>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
|
|
|
|
|
|
|
__data_rom_start = LOADADDR(_DATA_SECTION_NAME);
|
|
|
|
|
|
|
|
#include <linker/common-ram.ld>
|
|
|
|
#include <linker/kobject.ld>
|
|
|
|
|
|
|
|
__data_ram_end = .;
|
|
|
|
|
2018-02-12 19:20:22 +08:00
|
|
|
MPU_MIN_SIZE_ALIGN
|
arch: arc: add user space support for arc
* add the implementation of syscall
* based on 'trap_s' intruction, id = 3
* add the privilege stack
* the privilege stack is allocted with thread stack
* for the kernel thread, the privilege stack is also a
part of thread stack, the start of stack can be configured
as stack guard
* for the user thread, no stack guard, when the user stack is
overflow, it will fall into kernel memory area which requires
kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
specific
* the above codes have been tested through tests/kernel/mem_protect/
userspace for MPU version 2
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-01-23 17:13:09 +08:00
|
|
|
|
2015-09-10 10:54:09 -07:00
|
|
|
/* Define linker symbols */
|
2015-10-30 12:50:11 -04:00
|
|
|
_image_ram_end = .;
|
2015-09-10 10:54:09 -07:00
|
|
|
_end = .; /* end of image */
|
|
|
|
|
2017-12-20 16:48:45 +08:00
|
|
|
__kernel_ram_end = .;
|
|
|
|
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
|
2015-09-10 10:54:09 -07:00
|
|
|
|
2017-12-20 16:48:45 +08:00
|
|
|
GROUP_END(RAMABLE_REGION)
|
2015-11-30 15:43:12 -05:00
|
|
|
|
2016-11-21 14:16:11 -08:00
|
|
|
#ifdef CONFIG_CUSTOM_SECTIONS_LD
|
|
|
|
/* Located in project source directory */
|
|
|
|
#include <custom-sections.ld>
|
|
|
|
#endif
|
|
|
|
|
2017-02-13 09:36:32 -08:00
|
|
|
#ifdef CONFIG_GEN_ISR_TABLES
|
|
|
|
#include <linker/intlist.ld>
|
|
|
|
#endif
|
2015-09-10 10:54:09 -07:00
|
|
|
}
|