Zephyr API Documentation
4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
linker-devnull.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2023 Nordic Semiconductor ASA
3
*
4
* SPDX-License-Identifier: Apache-2.0
5
*/
6
7
/*
8
* DESCRIPTION
9
* Platform independent set of macros for creating a memory segment for
10
* aggregating data that shall be kept in the elf file but not in the binary.
11
*/
12
13
#ifndef ZEPHYR_INCLUDE_LINKER_LINKER_DEVNULL_H_
14
#define ZEPHYR_INCLUDE_LINKER_LINKER_DEVNULL_H_
15
16
#if defined(CONFIG_LINKER_DEVNULL_MEMORY)
17
18
#if defined(CONFIG_XIP)
19
#if (!defined(ROM_ADDR) && !defined(ROM_BASE)) || !defined(ROM_SIZE)
20
#error "ROM_SIZE, ROM_ADDR or ROM_BASE not defined"
21
#endif
22
#endif
/* CONFIG_XIP */
23
24
#if (!defined(RAM_ADDR) && !defined(RAM_BASE)) || !defined(RAM_SIZE)
25
#error "RAM_SIZE, RAM_ADDR or RAM_BASE not defined"
26
#endif
27
28
#if defined(CONFIG_XIP) && !defined(ROM_ADDR)
29
#define ROM_ADDR ROM_BASE
30
#endif
31
32
#if !defined(RAM_ADDR)
33
#define RAM_ADDR RAM_BASE
34
#endif
35
36
#define ROM_END_ADDR (ROM_ADDR + ROM_SIZE)
37
#define DEVNULL_SIZE CONFIG_LINKER_DEVNULL_MEMORY_SIZE
38
#define ROM_DEVNULL_END_ADDR (ROM_END_ADDR + DEVNULL_SIZE)
39
#define MAX_ADDR UINT32_MAX
40
41
/* Determine where to put the devnull region. It should be adjacent to the ROM
42
* region. If ROM starts after RAM or the distance between ROM and RAM is big
43
* enough to fit the devnull region then devnull region is placed just after
44
* the ROM region. If it cannot be done then the devnull region is placed before
45
* the ROM region. It is possible that the devnull region cannot be placed
46
* adjacent to the ROM (e.g. ROM starts at 0 and RAM follows ROM). In that
47
* case compilation fails and the devnull region is not supported in that
48
* configuration.
49
*/
50
#if !defined(CONFIG_XIP)
51
52
#if RAM_ADDR >= DEVNULL_SIZE
53
#define DEVNULL_ADDR (RAM_ADDR - DEVNULL_SIZE)
54
#else
55
#define DEVNULL_ADDR (RAM_ADDR + RAM_SIZE)
56
#endif
57
58
#else
/* CONFIG_XIP */
59
60
#if ((ROM_ADDR > RAM_ADDR) && ((MAX_ADDR - ROM_END_ADDR) >= DEVNULL_SIZE)) || \
61
((ROM_END_ADDR + DEVNULL_SIZE) <= RAM_ADDR)
62
#define DEVNULL_ADDR ROM_END_ADDR
63
#elif ROM_ADDR > DEVNULL_SIZE
64
#define DEVNULL_ADDR (ROM_ADDR - DEVNULL_SIZE)
65
#else
66
#error "Cannot place devnull segment adjacent to ROM region."
67
#endif
68
69
#endif
/* CONFIG_XIP */
70
71
#define DEVNULL_REGION DEVNULL_ROM
72
73
#endif
/* CONFIG_LINKER_DEVNULL_MEMORY */
74
75
#endif
/* ZEPHYR_INCLUDE_LINKER_LINKER_DEVNULL_H_ */
zephyr
linker
linker-devnull.h
Generated on Thu Dec 19 2024 18:02:34 for Zephyr API Documentation by
1.12.0