File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -29,4 +29,8 @@ zephyr_library_sources(
29
29
thread.c
30
30
)
31
31
32
+ if (CONFIG_MINIMAL_LIBC )
33
+ zephyr_library_sources (sbrk.c )
34
+ endif ()
35
+
32
36
zephyr_library_sources_ifdef (CONFIG_IRQ_OFFLOAD irq_offload.c )
Original file line number Diff line number Diff line change
1
+
2
+ #include <zephyr/devicetree.h>
3
+ #include <zephyr/linker/linker-defs.h>
4
+
5
+ #define _DDR_NODE DT_CHOSEN(zephyr_sram)
6
+ #define _LAYOUT_DDR_LOC DT_REG_ADDR(_DDR_NODE)
7
+ #define _LAYOUT_DDR_SIZE DT_REG_SIZE(_DDR_NODE)
8
+
9
+ /* Current offset from HEAP_BASE of unused memory */
10
+ __attribute__((section (".bss" ), used )) static size_t heap_sz ;
11
+
12
+ #define HEAP_BASE ((uintptr_t) (&_end))
13
+ #define MAX_HEAP_SIZE (_LAYOUT_DDR_LOC + _LAYOUT_DDR_SIZE - HEAP_BASE)
14
+
15
+ /* Implementation stolen from newlib/libc-hooks.c */
16
+ void * _sbrk (intptr_t count )
17
+ {
18
+ void * ret , * ptr ;
19
+
20
+ ptr = ((char * )HEAP_BASE ) + heap_sz ;
21
+
22
+ if ((heap_sz + count ) < MAX_HEAP_SIZE ) {
23
+ heap_sz += count ;
24
+ ret = ptr ;
25
+
26
+ } else {
27
+ ret = (void * )-1 ;
28
+ }
29
+
30
+ return ret ;
31
+ }
32
+ __weak FUNC_ALIAS (_sbrk , sbrk , void * );
You can’t perform that action at this time.
0 commit comments