diff options
author | Myles Watson <mylesgw@gmail.com> | 2010-06-09 22:41:35 +0000 |
---|---|---|
committer | Myles Watson <mylesgw@gmail.com> | 2010-06-09 22:41:35 +0000 |
commit | 894a34715f41f7c819a593dc3ff8e3033ffaa9fe (patch) | |
tree | 12ed2a5e10c6f181caa4c1add2ee8239abf82bfe /util | |
parent | 6507b390467591928f16aab68f247321ad3f2262 (diff) | |
download | coreboot-894a34715f41f7c819a593dc3ff8e3033ffaa9fe.tar.xz |
Same conversion as with resources from static arrays to lists, except
there is no free list.
Converting resource arrays to lists reduced the size of each device
struct from 1092 to 228 bytes.
Converting link arrays to lists reduced the size of each device struct
from 228 to 68 bytes.
Signed-off-by: Myles Watson <mylesgw@gmail.com>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5626 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util')
-rwxr-xr-x | util/sconfig/main.c | 68 |
1 files changed, 40 insertions, 28 deletions
diff --git a/util/sconfig/main.c b/util/sconfig/main.c index a8441111db..83b1c7ce3c 100755 --- a/util/sconfig/main.c +++ b/util/sconfig/main.c @@ -278,10 +278,14 @@ 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) + fprintf(fil, "struct bus %s_links[];\n", ptr->name); 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->children || ptr->multidev) + fprintf(fil, "struct bus %s_links[];\n", ptr->name); } if ((ptr->type == device) && (ptr->id != 0) && ptr->used) fprintf(fil, "struct device %s;\n", ptr->aliased_name); @@ -291,7 +295,7 @@ static void pass1(FILE *fil, struct device *ptr) { if (!ptr->used && (ptr->type == device)) { fprintf(fil, "struct device %s = {\n", ptr->name); fprintf(fil, "\t.ops = %s,\n", (ptr->ops)?(ptr->ops):"0"); - fprintf(fil, "\t.bus = &%s.link[%d],\n", ptr->bus->name, ptr->bus->link); + fprintf(fil, "\t.bus = &%s_links[%d],\n", ptr->bus->name, ptr->bus->link); fprintf(fil, "\t.path = {"); fprintf(fil, ptr->path, ptr->path_a, ptr->path_b); fprintf(fil, "},\n"); @@ -301,33 +305,10 @@ static void pass1(FILE *fil, struct device *ptr) { fprintf(fil, "\t.resource_list = &%s_res[0],\n", ptr->name); } int link = 0; - fprintf(fil, "\t.link = {\n"); - if (ptr->multidev) { - struct device *d = ptr; - while (d) { - if (device_match(d, ptr)) { - fprintf(fil, "\t\t[%d] = {\n", d->link); - fprintf(fil, "\t\t\t.link = %d,\n", d->link); - fprintf(fil, "\t\t\t.dev = &%s,\n", d->name); - if (d->children) - fprintf(fil, "\t\t\t.children = &%s,\n", d->children->name); - fprintf(fil, "\t\t},\n"); - link++; - } - d = d->next_sibling; - } - } else { - if (ptr->children) { - fprintf(fil, "\t\t[0] = {\n"); - fprintf(fil, "\t\t\t.link = 0,\n"); - fprintf(fil, "\t\t\t.dev = &%s,\n", ptr->name); - fprintf(fil, "\t\t\t.children = &%s,\n", ptr->children->name); - fprintf(fil, "\t\t},\n"); - link++; - } - } - fprintf(fil, "\t},\n"); - fprintf(fil, "\t.links = %d,\n", link); + if (ptr->children || ptr->multidev) + fprintf(fil, "\t.link_list = &%s_links[0],\n", ptr->name); + else + fprintf(fil, "\t.link_list = NULL,\n", ptr->name); if (ptr->sibling) fprintf(fil, "\t.sibling = &%s,\n", ptr->sibling->name); if (ptr->chip->chiph_exists) { @@ -356,6 +337,37 @@ static void pass1(FILE *fil, struct device *ptr) { } fprintf(fil, "\t };\n"); } + if (!ptr->used && ptr->type == device && (ptr->children || ptr->multidev)) { + fprintf(fil, "struct bus %s_links[] = {\n", ptr->name); + if (ptr->multidev) { + struct device *d = ptr; + while (d) { + if (device_match(d, ptr)) { + fprintf(fil, "\t\t[%d] = {\n", d->link); + fprintf(fil, "\t\t\t.link_num = %d,\n", d->link); + fprintf(fil, "\t\t\t.dev = &%s,\n", d->name); + if (d->children) + fprintf(fil, "\t\t\t.children = &%s,\n", d->children->name); + if (device_match(d->next_sibling, ptr)) + fprintf(fil, "\t\t\t.next=&%s_links[%d],\n", d->name, d->link+1); + else + fprintf(fil, "\t\t\t.next = NULL,\n"); + fprintf(fil, "\t\t},\n"); + } + d = d->next_sibling; + } + } else { + if (ptr->children) { + fprintf(fil, "\t\t[0] = {\n"); + fprintf(fil, "\t\t\t.link_num = 0,\n"); + fprintf(fil, "\t\t\t.dev = &%s,\n", ptr->name); + fprintf(fil, "\t\t\t.children = &%s,\n", ptr->children->name); + fprintf(fil, "\t\t\t.next = NULL,\n"); + fprintf(fil, "\t\t},\n"); + } + } + 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); |