drv_sram.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * File : sram.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009-2013 RT-Thread Develop Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2013-05-19 Bernard The first version for LPC40xx
  13. */
  14. #include "board.h"
  15. #include "drv_sram.h"
  16. #include <rtthread.h>
  17. #ifdef BSP_DRV_SDRAM
  18. struct rt_memheap system_heap;
  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. void *sram_malloc(unsigned long size)
  29. {
  30. return rt_memheap_alloc(&system_heap, size);
  31. }
  32. RTM_EXPORT(sram_malloc);
  33. void sram_free(void *ptr)
  34. {
  35. rt_memheap_free(ptr);
  36. }
  37. RTM_EXPORT(sram_free);
  38. void *sram_realloc(void *ptr, unsigned long size)
  39. {
  40. return rt_memheap_realloc(&system_heap, ptr, size);
  41. }
  42. RTM_EXPORT(sram_realloc);
  43. #endif