2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
11 DECLARE_GLOBAL_DATA_PTR;
13 #ifdef CONFIG_SYS_ALLOC_DPRAM
17 /* Reclaim the DP memory for our use. */
18 gd->arch.dp_alloc_base = CPM_DATAONLY_BASE;
19 gd->arch.dp_alloc_top = CPM_DATAONLY_BASE + CPM_DATAONLY_SIZE;
24 /* Allocate some memory from the dual ported ram. We may want to
25 * enforce alignment restrictions, but right now everyone is a good
28 uint dpram_alloc (uint size)
30 uint addr = gd->arch.dp_alloc_base;
32 if ((gd->arch.dp_alloc_base + size) >= gd->arch.dp_alloc_top)
33 return (CPM_DP_NOSPACE);
35 gd->arch.dp_alloc_base += size;
40 uint dpram_base (void)
42 return gd->arch.dp_alloc_base;
45 /* Allocate some memory from the dual ported ram. We may want to
46 * enforce alignment restrictions, but right now everyone is a good
49 uint dpram_alloc_align (uint size, uint align)
51 uint addr, mask = align - 1;
53 addr = (gd->arch.dp_alloc_base + mask) & ~mask;
55 if ((addr + size) >= gd->arch.dp_alloc_top)
56 return (CPM_DP_NOSPACE);
58 gd->arch.dp_alloc_base = addr + size;
63 uint dpram_base_align (uint align)
65 uint mask = align - 1;
67 return (gd->arch.dp_alloc_base + mask) & ~mask;
69 #endif /* CONFIG_SYS_ALLOC_DPRAM */