
Dear Wolfgang,
2009/11/18 Minkyu Kang mk7.kang@samsung.com:
In some case, saved address and compared address are different. (e.g: 80M) So, it can be get wrong memory size. This patch fix the such problem, and fix style problems also.
Signed-off-by: Minkyu Kang mk7.kang@samsung.com
common/memsize.c | 77 +++++++++++++++++++++++++++++++++--------------------- 1 files changed, 47 insertions(+), 30 deletions(-)
diff --git a/common/memsize.c b/common/memsize.c index 6c275c9..57c3cd7 100644 --- a/common/memsize.c +++ b/common/memsize.c @@ -44,51 +44,68 @@ long get_ram_size(volatile long *base, long maxsize) long cnt; long val; long size;
- long max = maxsize / sizeof(long);
int i = 0;
- for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
- for (cnt = 1; cnt < max; cnt <<= 1) {
addr = base + cnt; /* pointer arith! */
- sync ();
- save[i++] = *addr;
- sync ();
- sync();
- save[++i] = *addr;
- sync();
*addr = ~cnt; }
- addr = base + max - 1;
- sync();
- save[++i] = *addr;
- sync();
- *addr = ~max;
addr = base;
- sync ();
- save[i] = *addr;
- sync ();
- sync();
- save[0] = *addr;
- sync();
*addr = 0;
- sync();
- sync ();
- if ((val = *addr) != 0) {
- /* Restore the original data before leaving the function.
- */
- sync ();
- *addr = save[i];
- for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
- addr = base + cnt;
- sync ();
- *addr = save[--i];
- }
- return (0);
- val = *addr;
- if (val != 0) {
- i = 0;
- cnt = 1;
- size = 0;
- goto restore;
}
- for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
- i = 0;
- for (cnt = 1; cnt < max; cnt <<= 1) {
addr = base + cnt; /* pointer arith! */ val = *addr;
- *addr = save[--i];
- *addr = save[++i];
if (val != ~cnt) {
- size = cnt * sizeof (long);
- /* Restore the original data before leaving the function.
- */
- for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
- addr = base + cnt;
- *addr = save[--i];
- }
- return (size);
- size = cnt * sizeof(long);
- cnt <<= 1;
- goto restore;
} }
- return (maxsize);
- addr = base + max - 1;
- val = *addr;
- *addr = save[++i];
- if (val != ~max)
- maxsize = (cnt >> 1) * sizeof(long);
- return maxsize;
+restore:
- /* Restore the original data before leaving the function. */
- for (; cnt < max; cnt <<= 1) {
- addr = base + cnt;
- sync();
- *addr = save[++i];
- }
- addr = base;
- sync();
- *addr = save[0];
- return size;
}
1.5.4.3 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Any comments?
Thanks Minkyu Kang