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
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user