From 7f6b02dcb19abc5fc17886afc092fe22a56301af Mon Sep 17 00:00:00 2001 From: Myles Watson Date: Fri, 9 Jan 2009 14:17:06 +0000 Subject: [PATCH] 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 Acked-by: Ward Vandewege git-svn-id: svn://coreboot.org/repository/coreboot-v3@1112 f3766cd6-281f-0410-b1cd-43a5c92072e9 --- device/device.c | 63 +++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/device/device.c b/device/device.c index 0099321001..41b548674e 100644 --- a/device/device.c +++ b/device/device.c @@ -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; iresources; i++) { - res = &child->resource[i]; - if (!(res->flags & IORESOURCE_FIXED)) - continue; + /* Constrain limits based on the fixed resources of this device. */ + for (i = 0; iresources; 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)