This patch adds the domain's resources and all links to the tree traversal for
constraining resources. Build and boot tested on qemu, serengeti, and alix2c3. Signed-off-by: Myles Watson <mylesgw@gmail.com> Acked-by: Ward Vandewege <ward@gnu.org> git-svn-id: svn://coreboot.org/repository/coreboot-v3@1112 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
parent
189fc2fa47
commit
7f6b02dcb1
1 changed files with 32 additions and 31 deletions
|
|
@ -705,41 +705,42 @@ static void constrain_resources(struct device *dev, struct constraints* limits)
|
|||
#define MEM_TYPE (IORESOURCE_MEM)
|
||||
#define IO_TYPE (IORESOURCE_IO)
|
||||
|
||||
/* Descend into every child and look for fixed resources. */
|
||||
for (child=dev->link[0].children; child; child = child->sibling) {
|
||||
constrain_resources(child, limits);
|
||||
for (i = 0; i<child->resources; i++) {
|
||||
res = &child->resource[i];
|
||||
if (!(res->flags & IORESOURCE_FIXED))
|
||||
continue;
|
||||
/* Constrain limits based on the fixed resources of this device. */
|
||||
for (i = 0; i<dev->resources; i++) {
|
||||
res = &dev->resource[i];
|
||||
if (!(res->flags & IORESOURCE_FIXED))
|
||||
continue;
|
||||
|
||||
/* PREFETCH, MEM, or I/O - skip any others. */
|
||||
if ((res->flags & MEM_MASK) == PREF_TYPE)
|
||||
lim = &limits->pref;
|
||||
else if ((res->flags & MEM_MASK) == MEM_TYPE)
|
||||
lim = &limits->mem;
|
||||
else if ((res->flags & IO_MASK) == IO_TYPE)
|
||||
lim = &limits->io;
|
||||
else
|
||||
continue;
|
||||
/* PREFETCH, MEM, or I/O - skip any others. */
|
||||
if ((res->flags & MEM_MASK) == PREF_TYPE)
|
||||
lim = &limits->pref;
|
||||
else if ((res->flags & MEM_MASK) == MEM_TYPE)
|
||||
lim = &limits->mem;
|
||||
else if ((res->flags & IO_MASK) == IO_TYPE)
|
||||
lim = &limits->io;
|
||||
else
|
||||
continue;
|
||||
|
||||
/* Is it already outside the limits? */
|
||||
if (res->size &&
|
||||
(((res->base + res->size -1) < lim->base) ||
|
||||
(res->base > lim->limit)))
|
||||
continue;
|
||||
/* Is it already outside the limits? */
|
||||
if (res->size && (((res->base + res->size -1) < lim->base) ||
|
||||
(res->base > lim->limit)))
|
||||
continue;
|
||||
|
||||
/* Choose to be above or below fixed resources. This
|
||||
* check is signed so that "negative" amounts of space
|
||||
* are handled correctly.
|
||||
*/
|
||||
if ((s64)(lim->limit - (res->base + res->size -1)) >
|
||||
(s64)(res->base - lim->base))
|
||||
lim->base = res->base + res->size;
|
||||
else
|
||||
lim->limit = res->base -1;
|
||||
}
|
||||
/* Choose to be above or below fixed resources. This
|
||||
* check is signed so that "negative" amounts of space
|
||||
* are handled correctly.
|
||||
*/
|
||||
if ((s64)(lim->limit - (res->base + res->size -1)) >
|
||||
(s64)(res->base - lim->base))
|
||||
lim->base = res->base + res->size;
|
||||
else
|
||||
lim->limit = res->base -1;
|
||||
}
|
||||
|
||||
/* Descend into every child and look for fixed resources. */
|
||||
for (i = 0; i< dev->links; i++)
|
||||
for (child=dev->link[i].children; child; child = child->sibling)
|
||||
constrain_resources(child, limits);
|
||||
}
|
||||
|
||||
static void avoid_fixed_resources(struct device *dev)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue