summaryrefslogtreecommitdiff
path: root/util/sconfig
diff options
context:
space:
mode:
authorMyles Watson <mylesgw@gmail.com>2010-05-21 14:33:48 +0000
committerMyles Watson <mylesgw@gmail.com>2010-05-21 14:33:48 +0000
commitc25cc11ae32e10a7d0c9f04c29bfb7eca4d9c210 (patch)
treefb5ada475647efc61ee1f51f50e3adad4ac74b6e /util/sconfig
parentc5b87c8f895502b235e1619a23bd89dda955000e (diff)
downloadcoreboot-c25cc11ae32e10a7d0c9f04c29bfb7eca4d9c210.tar.xz
Use lists instead of arrays for resources in devices to reduce memory usage.
Signed-off-by: Myles Watson <mylesgw@gmail.com> Acked-by: Patrick Georgi <patrick.georgi@coresystems.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5576 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/sconfig')
-rwxr-xr-xutil/sconfig/main.c36
1 files changed, 23 insertions, 13 deletions
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);