From: Detlev Zundel <dzu@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] hi, I could not understand the memsize.c, somebody help me?
Date: Thu, 25 Jun 2009 14:56:49 +0200 [thread overview]
Message-ID: <m2my7wcvzi.fsf@ohwell.denx.de> (raw)
In-Reply-To: <2ae8403e0906242014k7e37b8f0tebaffaeeaea3f6bc@mail.gmail.com> (iamaplayer@gmail.com's message of "Thu, 25 Jun 2009 11:14:13 +0800")
Hi ya,
> I could not understand common/memsize.c, how it works?
Like a charm ;)
> 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?
> 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
next prev parent reply other threads:[~2009-06-25 12:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-25 3:14 [U-Boot] hi, I could not understand the memsize.c, somebody help me? IaMaPlAyEr
2009-06-25 12:56 ` Detlev Zundel [this message]
2009-06-29 8:54 ` IaMaPlAyEr
2009-06-29 11:54 ` Detlev Zundel
2009-06-30 2:53 ` IaMaPlAyEr
2009-06-30 13:50 ` Detlev Zundel
2009-07-24 6:11 ` Wolfgang Denk
2009-07-24 14:31 ` Aggrwal Poonam-B10812
2009-07-24 15:13 ` Detlev Zundel
2009-07-24 15:21 ` Kenneth Johansson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2my7wcvzi.fsf@ohwell.denx.de \
--to=dzu@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox