util/sconfig: Re-factor sconfig to not assume chip as device

This change adds a new structure "struct chip" to identify elements of
type chip rather than re-using the structure for device. Until now
chip was treated as a device while generating the parse tree and then
device tree postprocessing skipped over all the chip entries in
children and sibling pointers of device nodes.

With this change, the device tree will only contain struct device in
the parsed tree. It helps by avoiding unnecessary pointers to chip
structure as children or next_sibling and then skipping those elements
in post processing. Every device can then hold a pointer to its chip.

When generating static.c, chip structure is emitted before device
structure to ensure that the device structure has chip within its
scope. Externally, the only visible change in static.c should be the
order in which chip/device elements are emitted i.e. previously all
chips under a particular device were emitted to static.c and then the
devices using those chips. Now, all chips are emitted before all the
devices in static.c

BUG=b:80081934
TEST=Verified that abuild is successful for all boards. Also, verified
that static.c generated for eve, kahlee, scarlet, asrock imb_a180 is
unchanged from before in node definitions.

Change-Id: I255092f527c8eecb144385eb681df20e54caf8f5
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://review.coreboot.org/26720
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Furquan Shaikh 2018-05-30 15:09:09 -07:00
parent a51ff0712c
commit 79e8412665
5 changed files with 199 additions and 112 deletions

View File

@ -24,7 +24,13 @@ struct device *head, *lastdev;
struct header headers; struct header headers;
static int devcount = 0; static struct chip *chip_head;
/*
* This is intentionally shared between chip and device structure ids because it
* is easier to track the order of parsing for chip and device.
*/
static int count = 0;
typedef enum { typedef enum {
UNSLASH, UNSLASH,
@ -34,22 +40,15 @@ typedef enum {
} translate_t; } translate_t;
static struct device root; static struct device root;
static struct device mainboard = { static struct chip mainboard = {
.name = "mainboard", .name = "mainboard",
.name_underscore = "mainboard", .name_underscore = "mainboard",
.id = 0,
.chip = &mainboard,
.type = chip,
.chiph_exists = 0,
.children = &root
}; };
static struct device root = { static struct device root = {
.name = "dev_root", .name = "dev_root",
.name_underscore = "dev_root",
.id = 0, .id = 0,
.chip = &mainboard, .chip = &mainboard,
.type = device,
.path = " .type = DEVICE_PATH_ROOT ", .path = " .type = DEVICE_PATH_ROOT ",
.ops = "&default_dev_ops_root", .ops = "&default_dev_ops_root",
.parent = &root, .parent = &root,
@ -57,11 +56,64 @@ static struct device root = {
.enabled = 1 .enabled = 1
}; };
static struct queue {
void *data;
struct queue *next;
struct queue *prev;
} *q;
struct queue *new_queue_entry(void *data)
{
struct queue *e = malloc(sizeof(*e));
if (!e) {
fprintf(stderr, "%s: malloc failure!\n", __func__);
exit(1);
}
e->data = data;
e->next = e->prev = e;
return e;
}
void chip_enqueue_tail(void *data)
{
struct queue *tmp = new_queue_entry(data);
if (!q) {
q = tmp;
return;
}
q->prev->next = tmp;
tmp->prev = q->prev;
q->prev = tmp;
tmp->next = q;
}
void *chip_dequeue_tail(void)
{
struct queue *tmp = q->prev;
void *data;
if (tmp == q)
q = NULL;
else {
tmp->prev->next = q;
q->prev = tmp->prev;
}
data = tmp->data;
free(tmp);
return data;
}
static struct device *new_dev(struct device *parent, struct device *bus) static struct device *new_dev(struct device *parent, struct device *bus)
{ {
struct device *dev = malloc(sizeof(struct device)); struct device *dev = malloc(sizeof(struct device));
memset(dev, 0, sizeof(struct device)); memset(dev, 0, sizeof(struct device));
dev->id = ++devcount; dev->id = ++count;
dev->parent = parent; dev->parent = parent;
dev->bus = bus; dev->bus = bus;
dev->subsystem_vendor = -1; dev->subsystem_vendor = -1;
@ -109,22 +161,18 @@ void yyerror(char const *str)
void postprocess_devtree(void) void postprocess_devtree(void)
{ {
root.next_sibling = root.children; root.next_sibling = root.children;
root.next_sibling->next_sibling = root.next_sibling->children;
/*
* Since root is statically created we need to call fold_in explicitly
* here to have the next_sibling and latestchild setup correctly.
*/
fold_in(&root);
struct device *dev = &root; struct device *dev = &root;
while (dev) { while (dev) {
/* skip "chip" elements in children chain */ /* skip functions of the same device in sibling chain */
while (dev->children && (dev->children->type == chip))
dev->children = dev->children->children;
/* skip "chip" elements and functions of the same device in sibling chain */
while (dev->sibling && dev->sibling->used) while (dev->sibling && dev->sibling->used)
dev->sibling = dev->sibling->sibling; dev->sibling = dev->sibling->sibling;
/* If end of chain, and parent is a chip, move on */
if (!dev->sibling && (dev->parent->type == chip))
dev->sibling = dev->parent->sibling;
/* skip chips */
while (dev->sibling && dev->sibling->type == chip)
dev->sibling = dev->sibling->children;
/* skip duplicate function elements in nextdev chain */ /* skip duplicate function elements in nextdev chain */
while (dev->nextdev && dev->nextdev->used) while (dev->nextdev && dev->nextdev->used)
dev->nextdev = dev->nextdev->nextdev; dev->nextdev = dev->nextdev->nextdev;
@ -154,14 +202,20 @@ char *translate_name(const char *str, translate_t mode)
return b; return b;
} }
struct device *new_chip(struct device *parent, struct device *bus, char *path) struct chip *new_chip(char *path)
{ {
struct device *new_chip = new_dev(parent, bus); struct chip *new_chip = malloc(sizeof(*new_chip));
if (!new_chip) {
fprintf(stderr, "%s: malloc failure!\n", __func__);
exit(1);
}
memset(new_chip, 0, sizeof(*new_chip));
new_chip->id = ++count;
new_chip->chiph_exists = 1; new_chip->chiph_exists = 1;
new_chip->name = path; new_chip->name = path;
new_chip->name_underscore = translate_name(new_chip->name, UNSLASH); new_chip->name_underscore = translate_name(new_chip->name, UNSLASH);
new_chip->type = chip;
new_chip->chip = new_chip;
struct stat st; struct stat st;
char *chip_h = malloc(strlen(path) + 18); char *chip_h = malloc(strlen(path) + 18);
@ -182,23 +236,20 @@ struct device *new_chip(struct device *parent, struct device *bus, char *path)
if ((stat(chip_h, &st) == -1) && (errno == ENOENT)) if ((stat(chip_h, &st) == -1) && (errno == ENOENT))
new_chip->chiph_exists = 0; new_chip->chiph_exists = 0;
if (parent->latestchild) {
parent->latestchild->next_sibling = new_chip;
parent->latestchild->sibling = new_chip;
}
parent->latestchild = new_chip;
if (!parent->children)
parent->children = new_chip;
free(chip_h); free(chip_h);
new_chip->next = chip_head;
chip_head = new_chip;
return new_chip; return new_chip;
} }
void add_header(struct device *dev) void add_header(struct chip *chip)
{ {
int include_exists = 0; int include_exists = 0;
struct header *h = &headers; struct header *h = &headers;
while (h->next) { while (h->next) {
int result = strcmp(dev->name, h->next->name); int result = strcmp(chip->name, h->next->name);
if (result == 0) { if (result == 0) {
include_exists = 1; include_exists = 1;
break; break;
@ -211,14 +262,15 @@ void add_header(struct device *dev)
struct header *tmp = h->next; struct header *tmp = h->next;
h->next = malloc(sizeof(struct header)); h->next = malloc(sizeof(struct header));
memset(h->next, 0, sizeof(struct header)); memset(h->next, 0, sizeof(struct header));
h->next->chiph_exists = dev->chiph_exists; h->next->chiph_exists = chip->chiph_exists;
h->next->name = dev->name; h->next->name = chip->name;
h->next->next = tmp; h->next->next = tmp;
} }
} }
struct device *new_device(struct device *parent, struct device *busdev, struct device *new_device(struct device *parent, struct device *busdev,
const int bus, const char *devnum, int enabled) struct chip *chip, const int bus, const char *devnum,
int enabled)
{ {
struct device *new_d = new_dev(parent, busdev); struct device *new_d = new_dev(parent, busdev);
new_d->bustype = bus; new_d->bustype = bus;
@ -233,10 +285,9 @@ struct device *new_device(struct device *parent, struct device *busdev,
char *name = malloc(10); char *name = malloc(10);
sprintf(name, "_dev%d", new_d->id); sprintf(name, "_dev%d", new_d->id);
new_d->name = name; new_d->name = name;
new_d->name_underscore = name; // shouldn't be necessary, but avoid 0-ptr
new_d->type = device;
new_d->enabled = enabled; new_d->enabled = enabled;
new_d->chip = new_d->parent->chip; new_d->chip = chip;
if (parent->latestchild) { if (parent->latestchild) {
parent->latestchild->next_sibling = new_d; parent->latestchild->next_sibling = new_d;
@ -309,7 +360,7 @@ void alias_siblings(struct device *d)
struct device *cmp = d->next_sibling; struct device *cmp = d->next_sibling;
while (cmp && (cmp->bus == d->bus) && (cmp->path_a == d->path_a) while (cmp && (cmp->bus == d->bus) && (cmp->path_a == d->path_a)
&& (cmp->path_b == d->path_b)) { && (cmp->path_b == d->path_b)) {
if (cmp->type == device && !cmp->used) { if (!cmp->used) {
if (device_match(d, cmp)) { if (device_match(d, cmp)) {
d->multidev = 1; d->multidev = 1;
@ -343,14 +394,14 @@ void add_resource(struct device *dev, int type, int index, int base)
dev->rescnt++; dev->rescnt++;
} }
void add_register(struct device *dev, char *name, char *val) void add_register(struct chip *chip, char *name, char *val)
{ {
struct reg *r = malloc(sizeof(struct reg)); struct reg *r = malloc(sizeof(struct reg));
memset(r, 0, sizeof(struct reg)); memset(r, 0, sizeof(struct reg));
r->key = name; r->key = name;
r->value = val; r->value = val;
if (dev->reg) { if (chip->reg) {
struct reg *head = dev->reg; struct reg *head = chip->reg;
// sorting to be equal to sconfig's behaviour // sorting to be equal to sconfig's behaviour
int sort = strcmp(r->key, head->key); int sort = strcmp(r->key, head->key);
if (sort == 0) { if (sort == 0) {
@ -359,7 +410,7 @@ void add_register(struct device *dev, char *name, char *val)
} }
if (sort < 0) { if (sort < 0) {
r->next = head; r->next = head;
dev->reg = r; chip->reg = r;
} else { } else {
while ((head->next) while ((head->next)
&& (strcmp(head->next->key, r->key) < 0)) && (strcmp(head->next->key, r->key) < 0))
@ -368,7 +419,7 @@ void add_register(struct device *dev, char *name, char *val)
head->next = r; head->next = r;
} }
} else { } else {
dev->reg = r; chip->reg = r;
} }
} }
@ -412,13 +463,13 @@ void add_ioapic_info(struct device *dev, int apicid, const char *_srcpin,
dev->pci_irq_info[srcpin].ioapic_dst_id = apicid; dev->pci_irq_info[srcpin].ioapic_dst_id = apicid;
} }
static void pass0(FILE * fil, struct device *ptr) static void pass0(FILE *fil, struct device *ptr)
{ {
if (ptr->type == device && ptr->id == 0) if (ptr->id == 0)
fprintf(fil, "DEVTREE_CONST struct bus %s_links[];\n", fprintf(fil, "DEVTREE_CONST struct bus %s_links[];\n",
ptr->name); ptr->name);
if ((ptr->type == device) && (ptr->id != 0) && (!ptr->used)) { if ((ptr->id != 0) && (!ptr->used)) {
fprintf(fil, "DEVTREE_CONST static struct device %s;\n", fprintf(fil, "DEVTREE_CONST static struct device %s;\n",
ptr->name); ptr->name);
if (ptr->rescnt > 0) if (ptr->rescnt > 0)
@ -431,10 +482,11 @@ static void pass0(FILE * fil, struct device *ptr)
} }
} }
static void pass1(FILE * fil, struct device *ptr) static void pass1(FILE *fil, struct device *ptr)
{ {
int pin; int pin;
if (!ptr->used && (ptr->type == device)) {
if (!ptr->used) {
if (ptr->id != 0) if (ptr->id != 0)
fprintf(fil, "static "); fprintf(fil, "static ");
fprintf(fil, "DEVTREE_CONST struct device %s = {\n", fprintf(fil, "DEVTREE_CONST struct device %s = {\n",
@ -481,7 +533,7 @@ static void pass1(FILE * fil, struct device *ptr)
fprintf(fil, "#if !DEVTREE_EARLY\n"); fprintf(fil, "#if !DEVTREE_EARLY\n");
fprintf(fil, "\t.chip_ops = &%s_ops,\n", fprintf(fil, "\t.chip_ops = &%s_ops,\n",
ptr->chip->name_underscore); ptr->chip->name_underscore);
if (ptr->chip->chip == &mainboard) if (ptr->chip == &mainboard)
fprintf(fil, "\t.name = mainboard_name,\n"); fprintf(fil, "\t.name = mainboard_name,\n");
fprintf(fil, "#endif\n"); fprintf(fil, "#endif\n");
if (ptr->chip->chiph_exists) if (ptr->chip->chiph_exists)
@ -516,8 +568,7 @@ static void pass1(FILE * fil, struct device *ptr)
} }
fprintf(fil, "\t };\n"); fprintf(fil, "\t };\n");
} }
if (!ptr->used && ptr->type == device if (!ptr->used && (ptr->children || ptr->multidev)) {
&& (ptr->children || ptr->multidev)) {
fprintf(fil, "DEVTREE_CONST struct bus %s_links[] = {\n", fprintf(fil, "DEVTREE_CONST struct bus %s_links[] = {\n",
ptr->name); ptr->name);
if (ptr->multidev) { if (ptr->multidev) {
@ -559,29 +610,10 @@ static void pass1(FILE * fil, struct device *ptr)
} }
fprintf(fil, "\t};\n"); fprintf(fil, "\t};\n");
} }
if ((ptr->type == chip) && (ptr->chiph_exists)) {
if (ptr->reg) {
fprintf(fil,
"DEVTREE_CONST struct %s_config %s_info_%d = {\n",
ptr->name_underscore, ptr->name_underscore,
ptr->id);
struct reg *r = ptr->reg;
while (r) {
fprintf(fil, "\t.%s = %s,\n", r->key, r->value);
r = r->next;
}
fprintf(fil, "};\n\n");
} else {
fprintf(fil,
"DEVTREE_CONST struct %s_config %s_info_%d = { };\n",
ptr->name_underscore, ptr->name_underscore,
ptr->id);
}
}
} }
static void walk_device_tree(FILE * fil, struct device *ptr, static void walk_device_tree(FILE *fil, struct device *ptr,
void (*func) (FILE *, struct device *), void (*func)(FILE *, struct device *),
struct device *chips) struct device *chips)
{ {
do { do {
@ -590,7 +622,35 @@ static void walk_device_tree(FILE * fil, struct device *ptr,
} while (ptr); } while (ptr);
} }
static void inherit_subsystem_ids(FILE * file, struct device *dev) static void emit_chips(FILE *fil)
{
struct chip *chip;
for (chip = chip_head; chip; chip = chip->next) {
if (!chip->chiph_exists)
continue;
if (chip->reg) {
fprintf(fil,
"DEVTREE_CONST struct %s_config %s_info_%d = {\n",
chip->name_underscore, chip->name_underscore,
chip->id);
struct reg *r = chip->reg;
while (r) {
fprintf(fil, "\t.%s = %s,\n", r->key, r->value);
r = r->next;
}
fprintf(fil, "};\n\n");
} else {
fprintf(fil,
"DEVTREE_CONST struct %s_config %s_info_%d = { };\n",
chip->name_underscore, chip->name_underscore,
chip->id);
}
}
}
static void inherit_subsystem_ids(FILE *file, struct device *dev)
{ {
struct device *p; struct device *p;
@ -649,13 +709,6 @@ int main(int argc, char **argv)
fclose(filec); fclose(filec);
if ((head->type == chip) && (!head->chiph_exists)) {
struct device *tmp = head;
head = &root;
while (head->next != tmp)
head = head->next;
}
FILE *autogen = fopen(outputc, "w"); FILE *autogen = fopen(outputc, "w");
if (!autogen) { if (!autogen) {
fprintf(stderr, "Could not open file '%s' for writing: ", fprintf(stderr, "Could not open file '%s' for writing: ",
@ -687,6 +740,8 @@ int main(int argc, char **argv)
} }
fprintf(autogen, "#endif\n"); fprintf(autogen, "#endif\n");
emit_chips(autogen);
walk_device_tree(autogen, &root, inherit_subsystem_ids, NULL); walk_device_tree(autogen, &root, inherit_subsystem_ids, NULL);
fprintf(autogen, "\n/* pass 0 */\n"); fprintf(autogen, "\n/* pass 0 */\n");
walk_device_tree(autogen, &root, pass0, NULL); walk_device_tree(autogen, &root, pass0, NULL);

View File

@ -22,8 +22,6 @@
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
enum devtype { chip, device };
struct resource; struct resource;
struct resource { struct resource {
int type; int type;
@ -43,6 +41,30 @@ struct pci_irq_info {
int ioapic_irq_pin; int ioapic_irq_pin;
int ioapic_dst_id; int ioapic_dst_id;
}; };
struct chip {
/*
* Monotonically increasing ID for each newly allocated
* node(chip/device).
*/
int id;
/* Indicates if chip header exists for this chip. */
int chiph_exists;
/* Name of current chip. */
char *name;
/* Name of current chip normalized to _. */
char *name_underscore;
/* Pointer to registers for this chip. */
struct reg *reg;
/* Pointer to next chip. */
struct chip *next;
};
struct device; struct device;
struct device { struct device {
int id; int id;
@ -51,19 +73,17 @@ struct device {
int multidev; int multidev;
int link; int link;
int rescnt; int rescnt;
int chiph_exists;
int subsystem_vendor; int subsystem_vendor;
int subsystem_device; int subsystem_device;
int inherit_subsystem; int inherit_subsystem;
char *ops; char *ops;
char *name; char *name;
char *name_underscore;
char *path; char *path;
int path_a; int path_a;
int path_b; int path_b;
int bustype; int bustype;
struct pci_irq_info pci_irq_info[4]; struct pci_irq_info pci_irq_info[4];
enum devtype type;
struct device *parent; struct device *parent;
struct device *bus; struct device *bus;
struct device *next; struct device *next;
@ -72,12 +92,12 @@ struct device {
struct device *latestchild; struct device *latestchild;
struct device *next_sibling; struct device *next_sibling;
struct device *sibling; struct device *sibling;
struct device *chip;
struct resource *res; struct resource *res;
struct reg *reg;
struct chip *chip;
}; };
struct device *head; extern struct device *head;
struct header; struct header;
struct header { struct header {
@ -89,16 +109,23 @@ struct header {
void fold_in(struct device *parent); void fold_in(struct device *parent);
void postprocess_devtree(void); void postprocess_devtree(void);
struct device *new_chip(struct device *parent, struct device *bus, char *path); struct chip *new_chip(char *path);
void add_header(struct device *dev); void add_header(struct chip *chip);
struct device *new_device(struct device *parent, struct device *busdev, struct device *new_device(struct device *parent, struct device *busdev,
const int bus, const char *devnum, int enabled); struct chip *chip, const int bus, const char *devnum,
int enabled);
void alias_siblings(struct device *d); void alias_siblings(struct device *d);
void add_resource(struct device *dev, int type, int index, int base); void add_resource(struct device *dev, int type, int index, int base);
void add_register(struct device *dev, char *name, char *val); void add_register(struct chip *chip, char *name, char *val);
void add_pci_subsystem_ids(struct device *dev, int vendor, int device, void add_pci_subsystem_ids(struct device *dev, int vendor, int device,
int inherit); int inherit);
void add_ioapic_info(struct device *dev, int apicid, const char *_srcpin, void add_ioapic_info(struct device *dev, int apicid, const char *_srcpin,
int irqpin); int irqpin);
void yyrestart(FILE *input_file); void yyrestart(FILE *input_file);
/* Add chip data to tail of queue. */
void chip_enqueue_tail(void *data);
/* Retrieve chip data from tail of queue. */
void *chip_dequeue_tail(void);

View File

@ -86,6 +86,7 @@ int yylex();
void yyerror(const char *s); void yyerror(const char *s);
static struct device *cur_parent, *cur_bus; static struct device *cur_parent, *cur_bus;
static struct chip *cur_chip;
@ -164,6 +165,7 @@ union YYSTYPE
struct device *device; struct device *device;
struct chip *chip;
char *string; char *string;
int number; int number;
@ -484,9 +486,9 @@ static const yytype_uint8 yytranslate[] =
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] = static const yytype_uint8 yyrline[] =
{ {
0, 34, 34, 34, 36, 36, 36, 36, 38, 38, 0, 36, 36, 36, 38, 38, 38, 38, 40, 40,
38, 38, 38, 38, 40, 40, 50, 50, 62, 65, 40, 40, 40, 40, 42, 42, 52, 52, 64, 67,
68, 71, 74 70, 73, 76
}; };
#endif #endif
@ -1298,8 +1300,9 @@ yyreduce:
case 14: case 14:
{ {
(yyval.device) = new_chip(cur_parent, cur_bus, (yyvsp[0].string)); (yyval.chip) = new_chip((yyvsp[0].string));
cur_parent = (yyval.device); chip_enqueue_tail(cur_chip);
cur_chip = (yyval.chip);
} }
break; break;
@ -1307,9 +1310,8 @@ yyreduce:
case 15: case 15:
{ {
cur_parent = (yyvsp[-2].device)->parent; cur_chip = chip_dequeue_tail();
fold_in((yyvsp[-2].device)); add_header((yyvsp[-2].chip));
add_header((yyvsp[-2].device));
} }
break; break;
@ -1317,7 +1319,7 @@ yyreduce:
case 16: case 16:
{ {
(yyval.device) = new_device(cur_parent, cur_bus, (yyvsp[-2].number), (yyvsp[-1].string), (yyvsp[0].number)); (yyval.device) = new_device(cur_parent, cur_bus, cur_chip, (yyvsp[-2].number), (yyvsp[-1].string), (yyvsp[0].number));
cur_parent = (yyval.device); cur_parent = (yyval.device);
cur_bus = (yyval.device); cur_bus = (yyval.device);
} }
@ -1343,7 +1345,7 @@ yyreduce:
case 19: case 19:
{ add_register(cur_parent, (yyvsp[-2].string), (yyvsp[0].string)); } { add_register(cur_chip, (yyvsp[-2].string), (yyvsp[0].string)); }
break; break;

View File

@ -86,6 +86,7 @@ union YYSTYPE
struct device *device; struct device *device;
struct chip *chip;
char *string; char *string;
int number; int number;

View File

@ -21,10 +21,12 @@ int yylex();
void yyerror(const char *s); void yyerror(const char *s);
static struct device *cur_parent, *cur_bus; static struct device *cur_parent, *cur_bus;
static struct chip *cur_chip;
%} %}
%union { %union {
struct device *device; struct device *device;
struct chip *chip;
char *string; char *string;
int number; int number;
} }
@ -38,17 +40,17 @@ chipchildren: chipchildren device | chipchildren chip | chipchildren registers |
devicechildren: devicechildren device | devicechildren chip | devicechildren resource | devicechildren subsystemid | devicechildren ioapic_irq | /* empty */ ; devicechildren: devicechildren device | devicechildren chip | devicechildren resource | devicechildren subsystemid | devicechildren ioapic_irq | /* empty */ ;
chip: CHIP STRING /* == path */ { chip: CHIP STRING /* == path */ {
$<device>$ = new_chip(cur_parent, cur_bus, $<string>2); $<chip>$ = new_chip($<string>2);
cur_parent = $<device>$; chip_enqueue_tail(cur_chip);
cur_chip = $<chip>$;
} }
chipchildren END { chipchildren END {
cur_parent = $<device>3->parent; cur_chip = chip_dequeue_tail();
fold_in($<device>3); add_header($<chip>3);
add_header($<device>3);
}; };
device: DEVICE BUS NUMBER /* == devnum */ BOOL { device: DEVICE BUS NUMBER /* == devnum */ BOOL {
$<device>$ = new_device(cur_parent, cur_bus, $<number>2, $<string>3, $<number>4); $<device>$ = new_device(cur_parent, cur_bus, cur_chip, $<number>2, $<string>3, $<number>4);
cur_parent = $<device>$; cur_parent = $<device>$;
cur_bus = $<device>$; cur_bus = $<device>$;
} }
@ -63,7 +65,7 @@ resource: RESOURCE NUMBER /* == resnum */ EQUALS NUMBER /* == resval */
{ add_resource(cur_parent, $<number>1, strtol($<string>2, NULL, 0), strtol($<string>4, NULL, 0)); } ; { add_resource(cur_parent, $<number>1, strtol($<string>2, NULL, 0), strtol($<string>4, NULL, 0)); } ;
registers: REGISTER STRING /* == regname */ EQUALS STRING /* == regval */ registers: REGISTER STRING /* == regname */ EQUALS STRING /* == regval */
{ add_register(cur_parent, $<string>2, $<string>4); } ; { add_register(cur_chip, $<string>2, $<string>4); } ;
subsystemid: SUBSYSTEMID NUMBER NUMBER subsystemid: SUBSYSTEMID NUMBER NUMBER
{ add_pci_subsystem_ids(cur_parent, strtol($<string>2, NULL, 16), strtol($<string>3, NULL, 16), 0); }; { add_pci_subsystem_ids(cur_parent, strtol($<string>2, NULL, 16), strtol($<string>3, NULL, 16), 0); };