1 /*
2 * Copyright (c) 2006-2021, RT-Thread Development Team
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date Author Notes
8 * 2013-05-19 Bernard The first version for LPC40xx
9 */
10
11 #include "board.h"
12 #include "drv_sram.h"
13
14 #include <rtthread.h>
15
16 #ifdef BSP_DRV_SDRAM
17 struct rt_memheap system_heap;
18
sram_init(void)19 void sram_init(void)
20 {
21 rt_kprintf("system ram: [0x%08x - 0x%08x]\n", HEAP_BEGIN, HEAP_END);
22 /* initialize the built-in SRAM as a memory heap */
23 rt_memheap_init(&system_heap,
24 "system",
25 (void *)HEAP_BEGIN,
26 (rt_uint32_t)HEAP_END - (rt_uint32_t)HEAP_BEGIN);
27 }
28
sram_malloc(unsigned long size)29 void *sram_malloc(unsigned long size)
30 {
31 return rt_memheap_alloc(&system_heap, size);
32 }
33 RTM_EXPORT(sram_malloc);
34
sram_free(void * ptr)35 void sram_free(void *ptr)
36 {
37 rt_memheap_free(ptr);
38 }
39 RTM_EXPORT(sram_free);
40
sram_realloc(void * ptr,unsigned long size)41 void *sram_realloc(void *ptr, unsigned long size)
42 {
43 return rt_memheap_realloc(&system_heap, ptr, size);
44 }
45 RTM_EXPORT(sram_realloc);
46
47 #endif
48