commproc.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * (C) Copyright 2000-2002
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <commproc.h>
  9. DECLARE_GLOBAL_DATA_PTR;
  10. #ifdef CONFIG_SYS_ALLOC_DPRAM
  11. int dpram_init (void)
  12. {
  13. /* Reclaim the DP memory for our use. */
  14. gd->arch.dp_alloc_base = CPM_DATAONLY_BASE;
  15. gd->arch.dp_alloc_top = CPM_DATAONLY_BASE + CPM_DATAONLY_SIZE;
  16. return (0);
  17. }
  18. /* Allocate some memory from the dual ported ram. We may want to
  19. * enforce alignment restrictions, but right now everyone is a good
  20. * citizen.
  21. */
  22. uint dpram_alloc (uint size)
  23. {
  24. uint addr = gd->arch.dp_alloc_base;
  25. if ((gd->arch.dp_alloc_base + size) >= gd->arch.dp_alloc_top)
  26. return (CPM_DP_NOSPACE);
  27. gd->arch.dp_alloc_base += size;
  28. return addr;
  29. }
  30. uint dpram_base (void)
  31. {
  32. return gd->arch.dp_alloc_base;
  33. }
  34. /* Allocate some memory from the dual ported ram. We may want to
  35. * enforce alignment restrictions, but right now everyone is a good
  36. * citizen.
  37. */
  38. uint dpram_alloc_align (uint size, uint align)
  39. {
  40. uint addr, mask = align - 1;
  41. addr = (gd->arch.dp_alloc_base + mask) & ~mask;
  42. if ((addr + size) >= gd->arch.dp_alloc_top)
  43. return (CPM_DP_NOSPACE);
  44. gd->arch.dp_alloc_base = addr + size;
  45. return addr;
  46. }
  47. uint dpram_base_align (uint align)
  48. {
  49. uint mask = align - 1;
  50. return (gd->arch.dp_alloc_base + mask) & ~mask;
  51. }
  52. #endif /* CONFIG_SYS_ALLOC_DPRAM */