2015-04-11 07:44:37 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013-2014, Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2015-10-21 00:42:33 +08:00
|
|
|
* DESCRIPTION
|
|
|
|
* Platform independent, commonly used macros and defines related to linker
|
|
|
|
* script.
|
|
|
|
*
|
|
|
|
* This file may be included by:
|
|
|
|
* - Linker script files: for linker section declarations
|
|
|
|
* - C files: for external declaration of address or size of linker section
|
|
|
|
* - Assembly files: for external declaration of address or size of linker
|
|
|
|
* section
|
2015-07-02 05:22:39 +08:00
|
|
|
*/
|
2015-04-11 07:44:37 +08:00
|
|
|
|
|
|
|
#ifndef _LINKERDEFS_H
|
|
|
|
#define _LINKERDEFS_H
|
|
|
|
|
|
|
|
#include <toolchain.h>
|
|
|
|
#include <sections.h>
|
|
|
|
|
|
|
|
/* include platform dependent linker-defs */
|
2015-10-09 18:20:52 +08:00
|
|
|
#ifdef CONFIG_X86
|
2016-10-22 00:29:09 +08:00
|
|
|
/* Nothing yet to include */
|
2015-06-06 10:27:08 +08:00
|
|
|
#elif defined(CONFIG_ARM)
|
2015-04-11 07:44:37 +08:00
|
|
|
/* Nothing yet to include */
|
2015-06-06 10:27:49 +08:00
|
|
|
#elif defined(CONFIG_ARC)
|
2015-04-11 07:44:37 +08:00
|
|
|
/* Nothing yet to include */
|
2016-04-22 05:47:09 +08:00
|
|
|
#elif defined(CONFIG_NIOS2)
|
|
|
|
/* Nothing yet to include */
|
arch: added support for the riscv32 architecture
RISC-V is an open-source instruction set architecture.
Added support for the 32bit version of RISC-V to Zephyr.
1) exceptions/interrupts/faults are handled at the architecture
level via the __irq_wrapper handler. Context saving/restoring
of registers can be handled at both architecture and SOC levels.
If SOC-specific registers need to be saved, SOC level needs to
provide __soc_save_context and __soc_restore_context functions
that shall be accounted by the architecture level, when
corresponding config variable RISCV_SOC_CONTEXT_SAVE is set.
2) As RISC-V architecture does not provide a clear ISA specification
about interrupt handling, each RISC-V SOC handles it in its own
way. Hence, at the architecture level, the __irq_wrapper handler
expects the following functions to be provided by the SOC level:
__soc_is_irq: to check if the exception is the result of an
interrupt or not.
__soc_handle_irq: handle pending IRQ at SOC level (ex: clear
pending IRQ in SOC-specific IRQ register)
3) Thread/task scheduling, as well as IRQ offloading are handled via
the RISC-V system call ("ecall"), which is also handled via the
__irq_wrapper handler. The _Swap asm function just calls "ecall"
to generate an exception.
4) As there is no conventional way of handling CPU power save in
RISC-V, the default nano_cpu_idle and nano_cpu_atomic_idle
functions just unlock interrupts and return to the caller, without
issuing any CPU power saving instruction. Nonetheless, to allow
SOC-level to implement proper CPU power save, nano_cpu_idle and
nano_cpu_atomic_idle functions are defined as __weak
at the architecture level.
Change-Id: I980a161d0009f3f404ad22b226a6229fbb492389
Signed-off-by: Jean-Paul Etienne <fractalclone@gmail.com>
2017-01-11 07:24:30 +08:00
|
|
|
#elif defined(CONFIG_RISCV32)
|
|
|
|
/* Nothing yet to include */
|
2017-01-26 05:26:58 +08:00
|
|
|
#elif defined(CONFIG_XTENSA)
|
|
|
|
/* Nothing yet to include */
|
2015-04-11 07:44:37 +08:00
|
|
|
#else
|
|
|
|
#error Arch not supported.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef _LINKER
|
2015-10-14 23:17:20 +08:00
|
|
|
|
2016-04-09 03:38:57 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Space for storing per device busy bitmap. Since we do not know beforehand
|
|
|
|
* the number of devices, we go through the below mechanism to allocate the
|
|
|
|
* required space.
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT
|
2016-11-08 23:36:50 +08:00
|
|
|
#define DEVICE_COUNT \
|
|
|
|
((__device_init_end - __device_init_start) / _DEVICE_STRUCT_SIZE)
|
2016-04-09 03:38:57 +08:00
|
|
|
#define DEV_BUSY_SZ (((DEVICE_COUNT + 31) / 32) * 4)
|
|
|
|
#define DEVICE_BUSY_BITFIELD() \
|
|
|
|
FILL(0x00) ; \
|
|
|
|
__device_busy_start = .; \
|
|
|
|
. = . + DEV_BUSY_SZ; \
|
|
|
|
__device_busy_end = .;
|
|
|
|
#else
|
|
|
|
#define DEVICE_BUSY_BITFIELD()
|
|
|
|
#endif
|
|
|
|
|
2015-10-14 23:17:20 +08:00
|
|
|
/*
|
|
|
|
* generate a symbol to mark the start of the device initialization objects for
|
|
|
|
* the specified level, then link all of those objects (sorted by priority);
|
|
|
|
* ensure the objects aren't discarded if there is no direct reference to them
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DEVICE_INIT_LEVEL(level) \
|
|
|
|
__device_##level##_start = .; \
|
|
|
|
KEEP(*(SORT(.init_##level[0-9]))); \
|
|
|
|
KEEP(*(SORT(.init_##level[1-9][0-9]))); \
|
|
|
|
|
|
|
|
/*
|
|
|
|
* link in device initialization objects for all devices that are automatically
|
|
|
|
* initialized by the kernel; the objects are sorted in the order they will be
|
|
|
|
* initialized (i.e. ordered by level, sorted by priority within a level)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DEVICE_INIT_SECTIONS() \
|
2016-11-09 03:06:55 +08:00
|
|
|
__device_init_start = .; \
|
|
|
|
DEVICE_INIT_LEVEL(PRE_KERNEL_1) \
|
|
|
|
DEVICE_INIT_LEVEL(PRE_KERNEL_2) \
|
|
|
|
DEVICE_INIT_LEVEL(POST_KERNEL) \
|
|
|
|
DEVICE_INIT_LEVEL(APPLICATION) \
|
2016-04-09 03:38:57 +08:00
|
|
|
__device_init_end = .; \
|
|
|
|
DEVICE_BUSY_BITFIELD() \
|
2015-10-14 23:17:20 +08:00
|
|
|
|
2015-10-27 03:40:46 +08:00
|
|
|
|
|
|
|
/* define a section for undefined device initialization levels */
|
|
|
|
#define DEVICE_INIT_UNDEFINED_SECTION() \
|
|
|
|
KEEP(*(SORT(.init_[_A-Z0-9]*))) \
|
|
|
|
|
2016-07-31 21:16:29 +08:00
|
|
|
/*
|
|
|
|
* link in shell initialization objects for all modules that use shell and
|
|
|
|
* their shell commands are automatically initialized by the kernel.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define SHELL_INIT_SECTIONS() \
|
|
|
|
__shell_cmd_start = .; \
|
|
|
|
KEEP(*(".shell_*")); \
|
|
|
|
__shell_cmd_end = .;
|
|
|
|
|
|
|
|
|
2015-10-09 18:20:52 +08:00
|
|
|
#ifdef CONFIG_X86 /* LINKER FILES: defines used by linker script */
|
2015-04-11 07:44:37 +08:00
|
|
|
/* Should be moved to linker-common-defs.h */
|
|
|
|
#if defined(CONFIG_XIP)
|
|
|
|
#define ROMABLE_REGION ROM
|
|
|
|
#else
|
|
|
|
#define ROMABLE_REGION RAM
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If image is loaded via kexec Linux system call, then program
|
|
|
|
* headers need to be page aligned.
|
|
|
|
* This can be done by section page aligning.
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_BOOTLOADER_KEXEC
|
|
|
|
#define KEXEC_PGALIGN_PAD(x) . = ALIGN(x);
|
|
|
|
#else
|
|
|
|
#define KEXEC_PGALIGN_PAD(x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#elif defined(_ASMLANGUAGE)
|
2015-10-14 23:17:20 +08:00
|
|
|
|
2015-04-11 07:44:37 +08:00
|
|
|
/* Assembly FILES: declaration defined by the linker script */
|
|
|
|
GDATA(__bss_start)
|
|
|
|
GDATA(__bss_num_words)
|
|
|
|
#ifdef CONFIG_XIP
|
|
|
|
GDATA(__data_rom_start)
|
|
|
|
GDATA(__data_ram_start)
|
|
|
|
GDATA(__data_num_words)
|
|
|
|
#endif
|
|
|
|
|
2015-10-14 23:17:20 +08:00
|
|
|
#else /* ! _ASMLANGUAGE */
|
2015-04-11 07:44:37 +08:00
|
|
|
|
Introduce new sized integer typedefs
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t. This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.
We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.
We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.
Jira: ZEP-2051
Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-19 23:32:08 +08:00
|
|
|
#include <zephyr/types.h>
|
2015-04-11 07:44:37 +08:00
|
|
|
extern char __bss_start[];
|
2016-07-01 07:45:08 +08:00
|
|
|
extern char __bss_end[];
|
2015-04-11 07:44:37 +08:00
|
|
|
#ifdef CONFIG_XIP
|
|
|
|
extern char __data_rom_start[];
|
|
|
|
extern char __data_ram_start[];
|
2016-07-01 07:45:08 +08:00
|
|
|
extern char __data_ram_end[];
|
2015-04-11 07:44:37 +08:00
|
|
|
#endif
|
|
|
|
|
2015-09-17 07:14:40 +08:00
|
|
|
extern char _image_rom_start[];
|
|
|
|
extern char _image_rom_end[];
|
|
|
|
extern char _image_ram_start[];
|
|
|
|
extern char _image_ram_end[];
|
2015-09-22 05:57:39 +08:00
|
|
|
extern char _image_text_start[];
|
|
|
|
extern char _image_text_end[];
|
2015-09-17 07:14:40 +08:00
|
|
|
|
2015-04-11 07:44:37 +08:00
|
|
|
/* end address of image. */
|
|
|
|
extern char _end[];
|
|
|
|
|
|
|
|
#endif /* ! _ASMLANGUAGE */
|
|
|
|
|
|
|
|
#endif /* _LINKERDEFS_H */
|