From c25cc11ae32e10a7d0c9f04c29bfb7eca4d9c210 Mon Sep 17 00:00:00 2001 From: Myles Watson Date: Fri, 21 May 2010 14:33:48 +0000 Subject: Use lists instead of arrays for resources in devices to reduce memory usage. Signed-off-by: Myles Watson Acked-by: Patrick Georgi git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5576 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- util/sconfig/main.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'util/sconfig/main.c') diff --git a/util/sconfig/main.c b/util/sconfig/main.c index 9c7938617b..a8441111db 100755 --- a/util/sconfig/main.c +++ b/util/sconfig/main.c @@ -278,8 +278,11 @@ void add_register(struct device *dev, char *name, char *val) { } static void pass0(FILE *fil, struct device *ptr) { - if ((ptr->type == device) && (ptr->id != 0) && (!ptr->used)) + if ((ptr->type == device) && (ptr->id != 0) && (!ptr->used)) { fprintf(fil, "struct device %s;\n", ptr->name); + if (ptr->rescnt > 0) + fprintf(fil, "struct resource %s_res[];\n", ptr->name); + } if ((ptr->type == device) && (ptr->id != 0) && ptr->used) fprintf(fil, "struct device %s;\n", ptr->aliased_name); } @@ -295,18 +298,7 @@ static void pass1(FILE *fil, struct device *ptr) { fprintf(fil, "\t.enabled = %d,\n", ptr->enabled); fprintf(fil, "\t.on_mainboard = 1,\n"); if (ptr->rescnt > 0) { - fprintf(fil, "\t.resources = %d,\n", ptr->rescnt); - fprintf(fil, "\t.resource = {\n"); - struct resource *r = ptr->res; - while (r) { - fprintf(fil, "\t\t{ .flags=IORESOURCE_FIXED | IORESOURCE_ASSIGNED | IORESOURCE_"); - if (r->type == IRQ) fprintf(fil, "IRQ"); - if (r->type == DRQ) fprintf(fil, "DRQ"); - if (r->type == IO) fprintf(fil, "IO"); - fprintf(fil, ", .index=0x%x, .base=0x%x},\n", r->index, r->base); - r = r->next; - } - fprintf(fil, "\t },\n"); + fprintf(fil, "\t.resource_list = &%s_res[0],\n", ptr->name); } int link = 0; fprintf(fil, "\t.link = {\n"); @@ -346,6 +338,24 @@ static void pass1(FILE *fil, struct device *ptr) { fprintf(fil, "\t.next=&%s\n", ptr->nextdev->name); fprintf(fil, "};\n"); } + if (ptr->rescnt > 0) { + int i=1; + fprintf(fil, "struct resource %s_res[] = {\n", ptr->name); + struct resource *r = ptr->res; + while (r) { + fprintf(fil, "\t\t{ .flags=IORESOURCE_FIXED | IORESOURCE_ASSIGNED | IORESOURCE_"); + if (r->type == IRQ) fprintf(fil, "IRQ"); + if (r->type == DRQ) fprintf(fil, "DRQ"); + if (r->type == IO) fprintf(fil, "IO"); + fprintf(fil, ", .index=0x%x, .base=0x%x,", r->index, r->base); + if (r->next) + fprintf(fil, ".next=&%s_res[%d]},\n", ptr->name, i++); + else + fprintf(fil, ".next=NULL },\n"); + r = r->next; + } + fprintf(fil, "\t };\n"); + } if ((ptr->type == chip) && (ptr->chiph_exists)) { if (ptr->reg) { fprintf(fil, "struct %s_config %s_info_%d\t= {\n", ptr->name_underscore, ptr->name_underscore, ptr->id); -- cgit v1.2.3