答复: Prefmem of bus 3
rminnich at lanl.gov
Wed Mar 10 17:20:00 CET 2004
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))
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
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.
More information about the coreboot