aboutsummaryrefslogtreecommitdiff
path: root/arch/src/armv7-m/scatter.h
blob: 157ded166a03f383f60f81cd5ad27eb504fe0948 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
 * Arm SCP/MCP Software
 * Copyright (c) 2015-2020, 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.
 */

#ifndef ARCH_SCATTER_H
#define ARCH_SCATTER_H

#define ARCH_MEM_MODE_SINGLE_REGION 0
#define ARCH_MEM_MODE_DUAL_REGION_RELOCATION 1
#define ARCH_MEM_MODE_DUAL_REGION_NO_RELOCATION 2

#include <fmw_memory.h>

#ifndef FMW_MEM_MODE
#    error "FMW_MEM_MODE has not been configured"
#endif

#if (FMW_MEM_MODE != ARCH_MEM_MODE_SINGLE_REGION) && \
    (FMW_MEM_MODE != ARCH_MEM_MODE_DUAL_REGION_RELOCATION) && \
    (FMW_MEM_MODE != ARCH_MEM_MODE_DUAL_REGION_NO_RELOCATION)
#    error "FMW_MEM_MODE has been configured improperly"
#endif

#ifndef FMW_MEM0_BASE
#    error "FMW_MEM0_BASE has not been configured"
#endif

#ifndef FMW_MEM0_SIZE
#    error "FMW_MEM0_SIZE has not been configured"
#endif

#define ARCH_MEM0_LIMIT (FMW_MEM0_BASE + FMW_MEM0_SIZE)

#if FMW_MEM_MODE != ARCH_MEM_MODE_SINGLE_REGION
#    ifndef FMW_MEM1_BASE
#        error "FMW_MEM1_BASE has not been configured"
#    endif

#    ifndef FMW_MEM1_SIZE
#        error "FMW_MEM1_SIZE has not been configured"
#    endif

#    define ARCH_MEM1_LIMIT (FMW_MEM1_BASE + FMW_MEM1_SIZE)
#endif

#endif /* ARCH_SCATTER_H */