=?gb2312?b?tPC4tA==?=: Prefmem of bus 3
Eric W. Biederman
ebiederman at lnxi.com
Wed Mar 10 20:14:00 CET 2004
ron minnich <rminnich at lanl.gov> writes:
> On Tue, 9 Mar 2004, YhLu wrote:
>
> > I mean
> >
> > /* Get the base address */
> > base = resource->base;
> > /* Get the resource alignment */
> > align = 1UL << resource->align;
> >
> > /* Get the limit (rounded up) */
> > limit = base + ((resource->size + align - 1UL) & ~(align - 1UL))
> > -1UL;
>
> I am thinking now about what you said. Granularity is the units of
> allocation. Alignment is the alignment of the data.
>
> Examples: 64 byte granularity, 32-byte alignment, you can see that
> addresses of 32, 64, 96, etc. are acceptable.
> 64 byte granularity, 64 byte alignment, only addresses of
> 64, 128, ... are acceptable.
>
> If memory serves, behind a bridge, the memory space granularity is 16 bits
> (or is it 20? memory fails). Alignment is more or less the size of the
> resource.
>
> Looking at quadrics, the resource is 28 bits, so that will have to be the
> alignment, and granularity is 20 bits.
>
> So the expression above is wrong, I think you are correct. It will work in
> many cases but fail in some. I think it should be this:
>
> limit = base + ((resource->size + gran - 1UL) & ~(gran - 1UL)) -1UL
>
> as you already said.
>
> I.e. take the base, add a size rounded up to gran, and add it to base.
That is right. I feel quite silly that is the code that is sitting in
my tree and I feel for not getting it pushed out earlier. I'm going
to many directions at once or something like that.
It has the additional comment:
/* Get the resource granularity */
gran = 1UL << resource->gran;
/* For a non bridge resource granularity and alignment are the same.
* For a bridge resource align is the largest needed alignment below
* the bridge. While the granularity is simply how many low bits of the
* address cannot be set.
*/
/* Get the limit (rounded up) */
limit = base + ((resource->size + gran - 1UL) & ~(gran - 1UL)) -1UL;
I will get this committed shortly. At least I chose sane names so this
could be reasoned out.
Eric
More information about the coreboot
mailing list