hi, I could not understand the memsize.c, somebody help me?
Hi all,
I could not understand common/memsize.c, how it works?
maxsize / sizeof (long), what's meaning of it? why sizeof (long) is dividend?
just like stack, push every step mem addr to save:
save[i++] = *addr;
and then?
thanks
Signature · 4 lines
-- Sincerely, HaveF
Hi ya,
Quoted 1 line
I could not understand
common/memsize.c, how it works?
Like a charm ;)
Quoted 2 lines
maxsize / sizeof (long), what's meaning of it? why sizeof (long) is dividend?
As the comment in line 50 states, "cnt" is used in pointer arithmetic, so addr is increased in sizeof(long) bytes. maxsize however is considered to be in bytes only. Makes sense?
Quoted 4 lines
just like stack, push every step mem addr to save:
save[i++] = *addr;
and then?
Cannot parse the question.
The algorithm should be pretty clear however (take a paper and pencil and work out the values of addr as it proceeds) - we save the original content of the adressed cells and write our own pattern there (~cnt). Then we walk these cells upward and see where the previous write did not work like it was supposed to - voila.
Cheers
Detlev
Signature · 7 lines
The continental people think life is a game. The English think
cricket is a game.
-- George Mikes
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.dehi~
thanks for your reply.
sorry for my ability of writing and understanding the code =D
btw, How contribute my idea of this function, I means, it should be more
clean or easy just like this:
unsigned long get_ram_size(volatile long *base, long maxsize) {
unsigned long mem;
for (mem = (*base); mem < (maxsize); mem <<= 1)) {
if (*(unsigned long *)((unsigned long)(get_ram_size) + mem)
==
*(unsigned long *)(get_ram_size))
break;
}
}Quoted 38 lines · Detlev Zundel
Hi ya,
Quoted 1 line
I could not understand
common/memsize.c, how it works?Like a charm ;)
Quoted 2 lines
maxsize / sizeof (long), what's meaning of it? why sizeof (long) is dividend?
As the comment in line 50 states, "cnt" is used in pointer arithmetic, so addr is increased in sizeof(long) bytes. maxsize however is considered to be in bytes only. Makes sense?
Quoted 4 lines
just like stack, push every step mem addr to save:
save[i++] = *addr;
and then?Cannot parse the question.
The algorithm should be pretty clear however (take a paper and pencil and work out the values of addr as it proceeds) - we save the original content of the adressed cells and write our own pattern there (~cnt). Then we walk these cells upward and see where the previous write did not work like it was supposed to - voila.
Cheers
Detlev--
The continental people think life is a game. The English think cricket is a game.
-- George Mikes
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
Signature · 4 lines
-- Sincerely, HaveF
Hi,
Quoted 11 lines
thanks for your reply.
sorry for my ability of writing and understanding the code =Dbtw, How contribute my idea of this function, I means, it should be more ?clean or easy just like this:
unsigned long
get_ram_size(volatile long *base, long maxsize){
Quoted 7 lines
??????? unsigned long mem;
??????? for (mem = (*base); mem < (maxsize); mem <<= 1)) { ??????????????? if (*(unsigned long *)((unsigned long)(get_ram_size) + mem) == ??????????????????? *(unsigned long *)(get_ram_size)) ??????????????????????? break;
??????? }
}
This will not work at all, sorry . Before suggesting changes which should be "more clean or easy", at least test them on real hardware. You will find out that this code has lots of errors.
Some hints:
SW: What addresses is the original code accessing? What addresses are
you accessing? What values do you expect there?
HW: How does the algorithm in get_ram_size work at all? What
transactions does it produce on the CPU busses? What transactions will your code produce? Do you know what the CPU will do if it accesses RAM that is not available?
Please believe me, there is definitely *quite a bit* of understanding of hard- and software in the current code. If you do not know what the questions above mean, it is highly unlikely that you can improve the code.
Best wishes
Detlev
Signature · 7 lines
Thanks so much for Emacs. What a wondrous system -- one of the real seven wonders of the world. Forced to choose between Emacs and, say, any pyramid, I'd take Emacs. -- Robert Boyer -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
Hi
Detlev Zundel =D
Thanks for your patient explanation, I acquired a lot.
yes, you are right, I think a little about the compatibility of the code. yes, the compatibility!
I just find in linux, arch/mips/bcm47xx/prom.c, there is a segment code just like what I suggest above.
And move the code to my old box which bootloader is redboot, it works well. (Of course I also tryed memsize.c)so...
I'm lucky to have my new box which bootloader is u-boot =D
thanks for your warm-hearted hints again!
Quoted 53 lines · Detlev Zundel
Hi,
Quoted 8 lines
thanks for your reply.
sorry for my ability of writing and understanding the code =Dbtw, How contribute my idea of this function, I means, it should be more
clean or easy just like this:Quoted 6 lines
unsigned long
get_ram_size(volatile long *base, long maxsize){unsigned long mem; for (mem = (*base); mem < (maxsize); mem <<= 1)) { if (*(unsigned long *)((unsigned long)(get_ram_size) +mem) ==
Quoted 4 lines
*(unsigned long *)(get_ram_size)) break; } }This will not work at all, sorry . Before suggesting changes which should be "more clean or easy", at least test them on real hardware. You will find out that this code has lots of errors.
Some hints:
SW: What addresses is the original code accessing? What addresses are
you accessing? What values do you expect there?HW: How does the algorithm in
get_ram_sizework at all? What
transactions does it produce on the CPU busses? What transactions will your code produce? Do you know what the CPU will do if it accesses RAM that is not available?Please believe me, there is definitely *quite a bit* of understanding of hard- and software in the current code. If you do not know what the questions above mean, it is highly unlikely that you can improve the code.
Best wishes
Detlev--
Thanks so much for Emacs. What a wondrous system -- one of the real seven wonders of the world. Forced to choose between Emacs and, say,
any pyramid, I'd take Emacs. -- Robert Boyer
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
Signature · 4 lines
-- Sincerely, HaveF
Hi,
Quoted 1 line
Thanks for your patient explanation, I acquired a lot.
Glad if it helped.
Quoted 4 lines
I just find in linux,
arch/mips/bcm47xx/prom.c, there is a segment code just like what I suggest above.
And move the code to my old box which bootloader is redboot, it works well. (Of course I also tryed memsize.c)so...
Wow, you're right. To be honest, I do not understand the code, nor do I know why it should work.
Already in the first pointer arithmetic "mem" is obviously interpreted as sizeof(unsigned long) bytes and not in bytes as the constants suggest. Moreover they reference memory based on the address of a function and compare it to something dereferenced immediately afterwards - not taking "sticky values" on the bus into account. I don't even know why the dereferences should be similar at all as no known values are there - at least I don't see that.
Not understanding how or why this code should work, I would not dare to reuse it.
Quoted 1 line
I'm lucky to have my new box which bootloader is u-boot =D
Yes you are :)
Cheers
Detlev
Signature · 6 lines
I talk to planets baby
-- Dave Wyndorf (Monstermagnet)
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.deDear IaMaPlAyEr,
Quoted 2 lines · In message <[email protected]> you…
I could not understand
common/memsize.c, how it works?
It writes markers at specific memory locations and then reads these back. The algorithm is chosen to be fast but still to be able to detect mirrored address ranges and other memory errors.
Quoted 2 lines
maxsize / sizeof (long), what's meaning of it? why sizeof (long) is dividend?
Please read some boot about C programming, section pointer arithmetics.
Quoted 4 lines
just like stack, push every step mem addr to save:
save[i++] = *addr;
and then?
The test is intended to be a non-desctructive one.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "There are three principal ways to lose money: wine, women, and en- gineers. While the first two are more pleasant, the third is by far the more certain." -- Baron Rothschild, ca. 1800
Quoted 17 lines
-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Wolfgang Denk
Sent: Friday, July 24, 2009 11:41 AM
To: IaMaPlAyEr
Cc: u-boot at lists.denx.de
Subject: Re: [U-Boot] hi, I could not understand the memsize.c,somebody help me?Dear IaMaPlAyEr,
In message <[email protected]>
Quoted 1 line · you
Quoted 5 lines
Quoted 1 line
I could not understand
common/memsize.c, how it works?It writes markers at specific memory locations and then reads these back. The algorithm is chosen to be fast but still to be able to detect mirrored address ranges and other memory errors.
Suppose I configure MAX_MEM)SIZE as 1Gig and the actual memory on the board is 512M, is this function supposed to return 512M?
Quoted 31 lines
Quoted 3 lines
maxsize / sizeof (long), what's meaning of it? why sizeof (long) is dividend?
Please read some boot about C programming, section pointer arithmetics.
Quoted 4 lines
just like stack, push every step mem addr to save:
save[i++] = *addr;
and then?The test is intended to be a non-desctructive one.
Best regards,
Wolfgang Denk
Signature · 11 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "There are three principal ways to lose money: wine, women, and en- gineers. While the first two are more pleasant, the third is by far the more certain." -- Baron Rothschild, ca. 1800 _______________________________________________ U-Boot mailing list U-Boot at lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Hi Aggrwal,
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
I could not understand
common/memsize.c, how it works?It writes markers at specific memory locations and then reads these back. The algorithm is chosen to be fast but still to be able to detect mirrored address ranges and other memory errors.
Suppose I configure MAX_MEM)SIZE as 1Gig and the actual memory on the board is 512M, is this function supposed to return 512M?
That's the spirit, indeed.
Cheers
Detlev
Signature · 7 lines
(define Y (lambda (f) ((lambda (g) (f (lambda (x) ((g g) x)))) (lambda (g) (f (lambda (x) ((g g) x))))))) -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
Quoted 7 lines · On Fri, 2009-07-24 at 20:01 +0530, Aggrwal Poonam-B10812 wrote:
Quoted 5 lines
Quoted 1 line
I could not understand
common/memsize.c, how it works?It writes markers at specific memory locations and then reads these back. The algorithm is chosen to be fast but still to be able to detect mirrored address ranges and other memory errors.
Suppose I configure MAX_MEM)SIZE as 1Gig and the actual memory on the board is 512M, is this function supposed to return 512M?
Yes in this case but if you had 384M it would have returned 256M.