]>
git.ipfire.org Git - people/ms/u-boot.git/blob - cpu/mpc8xx/commproc.c
75740e07f2bd00ef78071c6d5568bf7e89748f13
2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #ifdef CFG_ALLOC_DPRAM
31 DECLARE_GLOBAL_DATA_PTR
;
33 /* Reclaim the DP memory for our use. */
34 gd
->dp_alloc_base
= CPM_DATAONLY_BASE
;
35 gd
->dp_alloc_top
= CPM_DATAONLY_BASE
+ CPM_DATAONLY_SIZE
;
40 /* Allocate some memory from the dual ported ram. We may want to
41 * enforce alignment restrictions, but right now everyone is a good
44 uint
dpram_alloc (uint size
)
46 DECLARE_GLOBAL_DATA_PTR
;
47 uint addr
= gd
->dp_alloc_base
;
49 if ((gd
->dp_alloc_base
+ size
) >= gd
->dp_alloc_top
)
50 return (CPM_DP_NOSPACE
);
52 gd
->dp_alloc_base
+= size
;
57 uint
dpram_base (void)
59 DECLARE_GLOBAL_DATA_PTR
;
61 return gd
->dp_alloc_base
;
64 /* Allocate some memory from the dual ported ram. We may want to
65 * enforce alignment restrictions, but right now everyone is a good
68 uint
dpram_alloc_align (uint size
, uint align
)
70 DECLARE_GLOBAL_DATA_PTR
;
72 uint addr
, mask
= align
- 1;
74 addr
= (gd
->dp_alloc_base
+ mask
) & ~mask
;
76 if ((addr
+ size
) >= gd
->dp_alloc_top
)
77 return (CPM_DP_NOSPACE
);
79 gd
->dp_alloc_base
= addr
+ size
;
84 uint
dpram_base_align (uint align
)
86 DECLARE_GLOBAL_DATA_PTR
;
88 uint mask
= align
- 1;
90 return (gd
->dp_alloc_base
+ mask
) & ~mask
;
92 #endif /* CFG_ALLOC_DPRAM */
94 #if defined(CONFIG_POST) || defined(CONFIG_LOGBUFFER)
96 void post_word_store (ulong a
)
98 volatile void *save_addr
=
99 ((immap_t
*) CFG_IMMR
)->im_cpm
.cp_dpmem
+ CPM_POST_WORD_ADDR
;
101 *(volatile ulong
*) save_addr
= a
;
104 ulong
post_word_load (void)
106 volatile void *save_addr
=
107 ((immap_t
*) CFG_IMMR
)->im_cpm
.cp_dpmem
+ CPM_POST_WORD_ADDR
;
109 return *(volatile ulong
*) save_addr
;
112 #endif /* CONFIG_POST || CONFIG_LOGBUFFER*/
114 #ifdef CONFIG_BOOTCOUNT_LIMIT
116 void bootcount_store (ulong a
)
118 volatile ulong
*save_addr
=
119 (volatile ulong
*)( ((immap_t
*) CFG_IMMR
)->im_cpm
.cp_dpmem
+
120 CPM_BOOTCOUNT_ADDR
);
123 save_addr
[1] = BOOTCOUNT_MAGIC
;
126 ulong
bootcount_load (void)
128 volatile ulong
*save_addr
=
129 (volatile ulong
*)( ((immap_t
*) CFG_IMMR
)->im_cpm
.cp_dpmem
+
130 CPM_BOOTCOUNT_ADDR
);
132 if (save_addr
[1] != BOOTCOUNT_MAGIC
)
138 #endif /* CONFIG_BOOTCOUNT_LIMIT */