aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorChris Kay <chris.kay@arm.com>2018-09-27 12:08:34 +0100
committerronald-cron-arm <39518861+ronald-cron-arm@users.noreply.github.com>2018-10-08 17:49:02 +0200
commit1298e848970ff6ae4662d3da3c05099fdc81f956 (patch)
tree3252466e6002047fcb8897ae5ae362c78bd6717d /arch
parent458ca4ec2ed2c646dde5706404c2098076c2e179 (diff)
arm: Move linker script configuration to independent header
This commit moves common linker script configuration options to an independent header file that is now included from both the Arm Compiler and LD linker scripts. Change-Id: I0ad252cfbbb28cc482a9612da0dac87bb8e9f471 Signed-off-by: Chris Kay <chris.kay@arm.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/src/armv7-m/ld.S79
-rw-r--r--arch/src/armv7-m/scatter.S75
-rw-r--r--arch/src/armv7-m/scatter.h76
3 files changed, 78 insertions, 152 deletions
diff --git a/arch/src/armv7-m/ld.S b/arch/src/armv7-m/ld.S
index 79a89296..7a36de0b 100644
--- a/arch/src/armv7-m/ld.S
+++ b/arch/src/armv7-m/ld.S
@@ -6,86 +6,9 @@
*
* Description:
* GNU LD linker script.
- *
- * There are three supported memory layouts for the ARMv7-M architecture:
- *
- * Layout 1 - Single region:
- * - All sections are placed in one contiguous region.
- * - This layout uses only the mem0 memory region.
- * - The memory is considered RXW by the linker, but the sections can be
- * configured later on with different attributes using the MPU.
- * - The main stack is placed at the end of mem0.
- * - This layout is mainly used by second-stage firmware that is loaded directly
- * into a single RAM.
- *
- * Layout 2 - Dual region with relocation:
- * - One region is used for .text and .data (storage).
- * - A second region is used for the remaining sections.
- * - This layout uses memory regions mem0 and mem1 as the first and second
- * regions, respectively.
- * - The main stack is placed at the end of mem1.
- * - This layout is mainly used by ROM firmware which uses part of the RAM for
- * the data sections.
- *
- * Layout 3 - Dual region without relocation
- * - One region is used only for the .text section.
- * - A second region is used for all data sections.
- * - This layout uses memory regions mem0 and mem1 as the first and second
- * regions, respectively.
- * - The main stack is placed at the end of mem1.
- * - The main difference from layout 2 is that there is no relocation of the
- * .data section.
- * - This layout is mainly used by second-stage firmware loaded directly into
- * two RAM regions. One of the RAM regions is attached to the instruction bus,
- * which improves the performance as data and instruction accesses are
- * independent.
- *
- */
-
-#define FWK_MEM_MODE_INVALID 0
-#define FWK_MEM_MODE_SINGLE_REGION 1
-#define FWK_MEM_MODE_DUAL_REGION_RELOCATION 2
-#define FWK_MEM_MODE_DUAL_REGION_NO_RELOCATION 3
-
-#include <fmw_memory.ld.S>
-
-/* Align the stack on an 8-byte boundary as CCR.STKALIGN is enabled */
-#define STACK_ALIGNMENT 8
-
-/* Align the heap on a 4-byte boundary to avoid unaligned accesses */
-#define HEAP_ALIGNMENT 4
-
-/*
- * Input validation
*/
-#ifndef FIRMWARE_MEM_MODE
- #error "FIRMWARE_MEM_MODE has not been configured"
-#endif
-
-#ifndef FIRMWARE_MEM0_BASE
- #error "FIRMWARE_MEM0_BASE has not been configured"
-#endif
-
-#ifndef FIRMWARE_MEM0_SIZE
- #error "FIRMWARE_MEM0_SIZE has not been configured"
-#endif
-
-#if ((FIRMWARE_MEM_MODE != FWK_MEM_MODE_SINGLE_REGION) && \
- (FIRMWARE_MEM_MODE != FWK_MEM_MODE_DUAL_REGION_RELOCATION) && \
- (FIRMWARE_MEM_MODE != FWK_MEM_MODE_DUAL_REGION_NO_RELOCATION))
- #error "FIRMWARE_MEM_MODE has been configured improperly"
-#endif
-
-#if FIRMWARE_MEM_MODE != FWK_MEM_MODE_SINGLE_REGION
- #ifndef FIRMWARE_MEM1_BASE
- #error "FIRMWARE_MEM1_BASE has not been configured"
- #endif
-
- #ifndef FIRMWARE_MEM1_SIZE
- #error "FIRMWARE_MEM1_SIZE has not been configured"
- #endif
-#endif
+#include "scatter.h"
ENTRY(arm_exception_reset)
diff --git a/arch/src/armv7-m/scatter.S b/arch/src/armv7-m/scatter.S
index 4c03e616..a484776d 100644
--- a/arch/src/armv7-m/scatter.S
+++ b/arch/src/armv7-m/scatter.S
@@ -6,82 +6,9 @@
*
* Description:
* Arm Compiler 6 scatter file.
- *
- * There are three supported memory layouts for the ARMv7-M architecture:
- *
- * Layout 1 - Single region:
- * - All sections are placed in one contiguous region.
- * - This layout uses only the mem0 memory region.
- * - The memory is considered RXW by the linker, but the sections can be
- * configured later on with different attributes using the MPU.
- * - The main stack is placed at the end of mem0.
- * - This layout is mainly used by second-stage firmware that is loaded directly
- * into a single RAM.
- *
- * Layout 2 - Dual region with relocation:
- * - One region is used for .text and .data (storage).
- * - A second region is used for the remaining sections.
- * - This layout uses memory regions mem0 and mem1 as the first and second
- * regions, respectively.
- * - The main stack is placed at the end of mem1.
- * - This layout is mainly used by ROM firmware which uses part of the RAM for
- * the data sections.
- *
- * Layout 3 - Dual region without relocation
- * - One region is used only for the .text section.
- * - A second region is used for all data sections.
- * - This layout uses memory regions mem0 and mem1 as the first and second
- * regions, respectively.
- * - The main stack is placed at the end of mem1.
- * - The main difference from layout 2 is that there is no relocation of the
- * .data section.
- * - This layout is mainly used by second-stage firmware loaded directly into
- * two RAM regions. One of the RAM regions is attached to the instruction bus,
- * which improves the performance as data and instruction accesses are
- * independent.
- *
*/
-#define FWK_MEM_MODE_INVALID 0
-#define FWK_MEM_MODE_SINGLE_REGION 1
-#define FWK_MEM_MODE_DUAL_REGION_RELOCATION 2
-#define FWK_MEM_MODE_DUAL_REGION_NO_RELOCATION 3
-
-#include <fmw_memory.ld.S>
-
-/*
- * Input validation
- */
-
-#ifndef FIRMWARE_MEM_MODE
- #error "FIRMWARE_MEM_MODE has not been configured"
-#endif
-
-#ifndef FIRMWARE_MEM0_BASE
- #error "FIRMWARE_MEM0_BASE has not been configured"
-#endif
-
-#ifndef FIRMWARE_MEM0_SIZE
- #error "FIRMWARE_MEM0_SIZE has not been configured"
-#endif
-
-#if ((FIRMWARE_MEM_MODE != FWK_MEM_MODE_SINGLE_REGION) && \
- (FIRMWARE_MEM_MODE != FWK_MEM_MODE_DUAL_REGION_RELOCATION) && \
- (FIRMWARE_MEM_MODE != FWK_MEM_MODE_DUAL_REGION_NO_RELOCATION))
- #error "FIRMWARE_MEM_MODE has been configured improperly"
-#endif
-
-#if FIRMWARE_MEM_MODE != FWK_MEM_MODE_SINGLE_REGION
- #ifndef FIRMWARE_MEM1_BASE
- #error "FIRMWARE_MEM1_BASE has not been configured"
- #endif
-
- #ifndef FIRMWARE_MEM1_SIZE
- #error "FIRMWARE_MEM1_SIZE has not been configured"
- #endif
-#endif
-
-#define FIRMWARE_MEM0_LIMIT (FIRMWARE_MEM0_BASE + FIRMWARE_MEM0_SIZE)
+#include "scatter.h"
#if FIRMWARE_MEM_MODE == FWK_MEM_MODE_SINGLE_REGION
#define FIRMWARE_MEM1_BASE +0
diff --git a/arch/src/armv7-m/scatter.h b/arch/src/armv7-m/scatter.h
new file mode 100644
index 00000000..e0cdaba2
--- /dev/null
+++ b/arch/src/armv7-m/scatter.h
@@ -0,0 +1,76 @@
+/*
+ * Arm SCP/MCP Software
+ * Copyright (c) 2015-2018, Arm Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Description:
+ * Common linker script configuration options.
+ *
+ * There are three supported memory layouts for the ARMv7-M architecture:
+ *
+ * Layout 1 - Single region:
+ * This layout uses a single read/write/execute memory region for all data.
+ * This is traditionally used by firmware running from a general-purpose
+ * RAM region. In this configuration MEM0 represents the RAM region, and
+ * MEM1 is unused.
+ *
+ * Layout 2 - Dual region with relocation:
+ * This layout uses a read/execute memory region for read-only and
+ * executable data, and a write memory region for writable data. This is
+ * traditionally used by firmware running from a ROM region. In this
+ * configuration MEM0 represents the ROM region and MEM1 represents the RAM
+ * region.
+ *
+ * Layout 3 - Dual region without relocation:
+ * This layout uses an execute memory region for executable data, and a
+ * read/write memory region for writable data. This is traditionally used
+ * by firmware running from a RAM region attached to the instruction bus.
+ * In this configuration MEM0 represents the RAM region attached to the
+ * instruction bus and MEM1 represents the RAM region attached to the data
+ * bus.
+ */
+
+#define FWK_MEM_MODE_SINGLE_REGION 0
+#define FWK_MEM_MODE_DUAL_REGION_RELOCATION 1
+#define FWK_MEM_MODE_DUAL_REGION_NO_RELOCATION 2
+
+#include <fmw_memory.ld.S>
+
+#ifndef FIRMWARE_MEM_MODE
+ #error "FIRMWARE_MEM_MODE has not been configured"
+#endif
+
+#if (FIRMWARE_MEM_MODE != FWK_MEM_MODE_SINGLE_REGION) && \
+ (FIRMWARE_MEM_MODE != FWK_MEM_MODE_DUAL_REGION_RELOCATION) && \
+ (FIRMWARE_MEM_MODE != FWK_MEM_MODE_DUAL_REGION_NO_RELOCATION)
+ #error "FIRMWARE_MEM_MODE has been configured improperly"
+#endif
+
+#ifndef FIRMWARE_MEM0_BASE
+ #error "FIRMWARE_MEM0_BASE has not been configured"
+#endif
+
+#ifndef FIRMWARE_MEM0_SIZE
+ #error "FIRMWARE_MEM0_SIZE has not been configured"
+#endif
+
+#define FIRMWARE_MEM0_LIMIT (FIRMWARE_MEM0_BASE + FIRMWARE_MEM0_SIZE)
+
+#if FIRMWARE_MEM_MODE != FWK_MEM_MODE_SINGLE_REGION
+ #ifndef FIRMWARE_MEM1_BASE
+ #error "FIRMWARE_MEM1_BASE has not been configured"
+ #endif
+
+ #ifndef FIRMWARE_MEM1_SIZE
+ #error "FIRMWARE_MEM1_SIZE has not been configured"
+ #endif
+
+ #define FIRMWARE_MEM1_LIMIT (FIRMWARE_MEM1_BASE + FIRMWARE_MEM1_SIZE)
+#endif
+
+/* Alignment of the heap */
+#define HEAP_ALIGNMENT 4
+
+/* Alignment of the stack (CCR.STKALIGN is enabled) */
+#define STACK_ALIGNMENT 8