Add detection/dump support for ServerEngines SE-SM 4210-P01.
[coreboot.git] / util / sconfig / sconfig.tab.c_shipped
index ac41d262f24596c8df688f01e3bb6c1c27c8341d..dbefe064058cac29b780e19b1ca0375b64a2ab22 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <errno.h>
-
-enum devtype { chip, device };
-
-struct resource;
-struct resource {
-       int type;
-       int index;
-       int base;
-       struct resource *next;
-};
-
-struct reg;
-struct reg {
-       char *key;
-       char *value;
-       struct reg *next;
-};
-
-struct device;
-struct device {
-       int id;
-       int enabled;
-       int used;
-       int multidev;
-       int link;
-       int rescnt;
-       int chiph_exists;
-       char *ops;
-       char *name;
-       char *aliased_name;
-       char *name_underscore;
-       char *path;
-       int path_a;
-       int path_b;
-       int bustype;
-       enum devtype type;
-       struct device *parent;
-       struct device *bus;
-       struct device *next;
-       struct device *nextdev;
-       struct device *children;
-       struct device *latestchild;
-       struct device *next_sibling;
-       struct device *sibling;
-       struct device *chip;
-       struct resource *res;
-       struct reg *reg;
-} *head, *lastdev, *cur_parent, *cur_bus, root;
-
-struct header;
-struct header {
-       char *name;
-       struct header *next;
-} headers;
-
-int devcount = 0;
-
-struct device *new_dev() {
-       struct device *dev = malloc(sizeof(struct device));
-       memset(dev, 0, sizeof(struct device));
-       dev->id = ++devcount;
-       dev->parent = cur_parent;
-       dev->bus = cur_bus;
-       head->next = dev;
-       head = dev;
-       return dev;
-}
-
-int device_match(struct device *a, struct device *b) {
-       if ((a->bustype == b->bustype) && (a->bus == b->bus) && (a->path_a == b->path_a) && (a->path_b == b->path_b))
-               return 1;
-       return 0;
-}
-
-void fold_in(struct device *parent) {
-       struct device *child = parent->children;
-       struct device *latest = 0;
-       while (child != latest) {
-               if (child->children) {
-                       if (!latest) latest = child->children;
-                       parent->latestchild->next_sibling = child->children;
-                       parent->latestchild = child->latestchild;
-               }
-               child = child->next_sibling;
-       }
-}
+#include "sconfig.h"
 
-int yywrap(void) {
-       return 1;
-}
+static struct device *cur_parent, *cur_bus;
 
-void yyerror (char const *str)
-{
-       fprintf (stderr, "%s\n", str);
-}
 
 
 
@@ -237,7 +139,9 @@ void yyerror (char const *str)
      IRQ = 274,
      DRQ = 275,
      IO = 276,
-     NUMBER = 277
+     NUMBER = 277,
+     SUBSYSTEMID = 278,
+     INHERIT = 279
    };
 #endif
 
@@ -476,22 +380,22 @@ union yyalloc
 #endif
 
 /* YYFINAL -- State number of the termination state.  */
-#define YYFINAL  9
+#define YYFINAL  3
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   23
+#define YYLAST   34
 
 /* YYNTOKENS -- Number of terminals.  */
-#define YYNTOKENS  23
+#define YYNTOKENS  25
 /* YYNNTS -- Number of nonterminals.  */
-#define YYNNTS  11
+#define YYNNTS  12
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  16
+#define YYNRULES  20
 /* YYNRULES -- Number of states.  */
-#define YYNSTATES  30
+#define YYNSTATES  36
 
 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
 #define YYUNDEFTOK  2
-#define YYMAXUTOK   277
+#define YYMAXUTOK   279
 
 #define YYTRANSLATE(YYX)                                               \
   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -526,7 +430,7 @@ static const yytype_uint8 yytranslate[] =
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
-      15,    16,    17,    18,    19,    20,    21,    22
+      15,    16,    17,    18,    19,    20,    21,    22,    23,    24
 };
 
 #if YYDEBUG
@@ -534,25 +438,29 @@ static const yytype_uint8 yytranslate[] =
    YYRHS.  */
 static const yytype_uint8 yyprhs[] =
 {
-       0,     0,     3,     5,     7,     9,    12,    15,    16,    19,
-      22,    23,    24,    30,    31,    39,    44
+       0,     0,     3,     4,     7,    10,    13,    16,    17,    20,
+      23,    26,    29,    30,    31,    37,    38,    46,    51,    56,
+      60
 };
 
 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
 static const yytype_int8 yyrhs[] =
 {
-      24,     0,    -1,    25,    -1,    28,    -1,    30,    -1,    26,
-      25,    -1,    26,    33,    -1,    -1,    27,    25,    -1,    27,
-      32,    -1,    -1,    -1,     3,    12,    29,    26,     9,    -1,
-      -1,     4,     7,    22,     6,    31,    27,     9,    -1,     8,
-      22,    10,    22,    -1,     5,    12,    10,    12,    -1
+      26,     0,    -1,    -1,    27,    30,    -1,    28,    32,    -1,
+      28,    30,    -1,    28,    35,    -1,    -1,    29,    32,    -1,
+      29,    30,    -1,    29,    34,    -1,    29,    36,    -1,    -1,
+      -1,     3,    12,    31,    28,     9,    -1,    -1,     4,     7,
+      22,     6,    33,    29,     9,    -1,     8,    22,    10,    22,
+      -1,     5,    12,    10,    12,    -1,    23,    22,    22,    -1,
+      23,    22,    22,    24,    -1
 };
 
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
-static const yytype_uint16 yyrline[] =
+static const yytype_uint8 yyrline[] =
 {
-       0,   132,   132,   152,   152,   154,   154,   154,   156,   156,
-     156,   158,   158,   215,   215,   294,   312
+       0,    35,    35,    35,    37,    37,    37,    37,    39,    39,
+      39,    39,    39,    41,    41,    51,    51,    63,    66,    69,
+      72
 };
 #endif
 
@@ -564,8 +472,9 @@ static const char *const yytname[] =
   "$end", "error", "$undefined", "CHIP", "DEVICE", "REGISTER", "BOOL",
   "BUS", "RESOURCE", "END", "EQUALS", "HEX", "STRING", "PCI", "PNP", "I2C",
   "APIC", "APIC_CLUSTER", "PCI_DOMAIN", "IRQ", "DRQ", "IO", "NUMBER",
-  "$accept", "devtree", "devchip", "devices", "devicesorresources", "chip",
-  "@1", "device", "@2", "resource", "registers", 0
+  "SUBSYSTEMID", "INHERIT", "$accept", "devtree", "$@1", "chipchildren",
+  "devicechildren", "chip", "@2", "device", "@3", "resource", "registers",
+  "subsystemid", 0
 };
 #endif
 
@@ -576,22 +485,24 @@ static const yytype_uint16 yytoknum[] =
 {
        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
-     275,   276,   277
+     275,   276,   277,   278,   279
 };
 # endif
 
 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 static const yytype_uint8 yyr1[] =
 {
-       0,    23,    24,    25,    25,    26,    26,    26,    27,    27,
-      27,    29,    28,    31,    30,    32,    33
+       0,    25,    27,    26,    28,    28,    28,    28,    29,    29,
+      29,    29,    29,    31,    30,    33,    32,    34,    35,    36,
+      36
 };
 
 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
 static const yytype_uint8 yyr2[] =
 {
-       0,     2,     1,     1,     1,     2,     2,     0,     2,     2,
-       0,     0,     5,     0,     7,     4,     4
+       0,     2,     0,     2,     2,     2,     2,     0,     2,     2,
+       2,     2,     0,     0,     5,     0,     7,     4,     4,     3,
+       4
 };
 
 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -599,33 +510,35 @@ static const yytype_uint8 yyr2[] =
    means the default is an error.  */
 static const yytype_uint8 yydefact[] =
 {
-       0,     0,     0,     0,     2,     3,     4,    11,     0,     1,
-       7,     0,     0,    13,     0,    12,     5,     6,    10,     0,
-       0,     0,     0,    14,     8,     9,    16,     0,     0,    15
+       2,     0,     0,     1,     0,     3,    13,     7,     0,     0,
+       0,    14,     5,     4,     6,     0,     0,     0,     0,    15,
+      18,    12,     0,     0,    16,     0,     9,     8,    10,    11,
+       0,     0,     0,    19,    17,    20
 };
 
 /* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int8 yydefgoto[] =
 {
-      -1,     3,     4,    12,    20,     5,    10,     6,    18,    25,
-      17
+      -1,     1,     2,     8,    22,     5,     7,    13,    21,    28,
+      14,    29
 };
 
 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
    STATE-NUM.  */
-#define YYPACT_NINF -13
+#define YYPACT_NINF -9
 static const yytype_int8 yypact[] =
 {
-       8,    -6,     6,    14,   -13,   -13,   -13,   -13,    -7,   -13,
-     -13,    10,    -2,   -13,     5,   -13,   -13,   -13,   -13,     9,
-       1,    11,    -4,   -13,   -13,   -13,   -13,    12,    -1,   -13
+      -9,     3,     1,    -9,    -2,    -9,    -9,    -9,     4,     5,
+      -1,    -9,    -9,    -9,    -9,    -8,     7,     9,     6,    -9,
+      -9,    -9,    -3,     0,    -9,     2,    -9,    -9,    -9,    -9,
+      11,     8,    10,    -5,    -9,    -9
 };
 
 /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int8 yypgoto[] =
 {
-     -13,   -13,   -12,   -13,   -13,   -13,   -13,   -13,   -13,   -13,
-     -13
+      -9,    -9,    -9,    -9,    -9,    -6,    -9,    12,    -9,    -9,
+      -9,    -9
 };
 
 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
@@ -635,25 +548,28 @@ static const yytype_int8 yypgoto[] =
 #define YYTABLE_NINF -1
 static const yytype_uint8 yytable[] =
 {
-      16,     1,     2,    14,     1,     2,     7,    15,    24,    22,
-      23,     1,     2,     8,     9,    11,    13,    19,    27,    21,
-       0,    29,    28,    26
+       4,     9,    12,     3,     4,    23,    24,     4,     9,    10,
+       6,    16,    15,    11,    17,    19,    26,    18,    20,    35,
+      25,    32,    30,     0,    31,     0,     0,     0,     0,     0,
+      33,     0,    34,     0,    27
 };
 
 static const yytype_int8 yycheck[] =
 {
-      12,     3,     4,     5,     3,     4,    12,     9,    20,     8,
-       9,     3,     4,     7,     0,    22,     6,    12,    22,    10,
-      -1,    22,    10,    12
+       3,     4,     8,     0,     3,     8,     9,     3,     4,     5,
+      12,    12,     7,     9,    22,     6,    22,    10,    12,    24,
+      23,    10,    22,    -1,    22,    -1,    -1,    -1,    -1,    -1,
+      22,    -1,    22,    -1,    22
 };
 
 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
    symbol of state STATE-NUM.  */
 static const yytype_uint8 yystos[] =
 {
-       0,     3,     4,    24,    25,    28,    30,    12,     7,     0,
-      29,    22,    26,     6,     5,     9,    25,    33,    31,    12,
-      27,    10,     8,     9,    25,    32,    12,    22,    10,    22
+       0,    26,    27,     0,     3,    30,    12,    31,    28,     4,
+       5,     9,    30,    32,    35,     7,    12,    22,    10,     6,
+      12,    33,    29,     8,     9,    23,    30,    32,    34,    36,
+      22,    22,    10,    22,    22,    24
 };
 
 #define yyerrok                (yyerrstatus = 0)
@@ -1466,223 +1382,68 @@ yyreduce:
     {
         case 2:
 
-    {
-       root.next_sibling = root.children;
-       root.next_sibling->next_sibling = root.next_sibling->children;
-
-       struct device *dev = &root;
-       while (dev) {
-               /* skip "chip" elements in children 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) 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 */
-               while (dev->nextdev && dev->nextdev->used) dev->nextdev = dev->nextdev->nextdev;
-               dev = dev->next_sibling;
-       }
-       ;}
+    { cur_parent = cur_bus = head; ;}
     break;
 
-  case 11:
+  case 3:
 
-    {
-       (yyval.device) = new_dev();
-       (yyval.device)->chiph_exists = 1;
-       (yyval.device)->name = (yyvsp[(2) - (2)].string);
-       (yyval.device)->name_underscore = strdup((yyval.device)->name);
-       char *c;
-       for (c = (yyval.device)->name_underscore; *c; c++) {
-               if (*c == '/') *c = '_';
-               if (*c == '-') *c = '_';
-       }
-       (yyval.device)->type = chip;
-       (yyval.device)->chip = (yyval.device);
-
-       struct stat st;
-       char *chip_h = malloc(strlen((yyvsp[(2) - (2)].string))+12);
-       sprintf(chip_h, "src/%s/chip.h", (yyvsp[(2) - (2)].string));
-       if ((stat(chip_h, &st) == -1) && (errno == ENOENT))
-               (yyval.device)->chiph_exists = 0;
-
-       if (cur_parent->latestchild) {
-               cur_parent->latestchild->next_sibling = (yyval.device);
-               cur_parent->latestchild->sibling = (yyval.device);
-       }
-       cur_parent->latestchild = (yyval.device);
-       if (!cur_parent->children)
-               cur_parent->children = (yyval.device);
+    { postprocess_devtree(); ;}
+    break;
 
+  case 13:
+
+    {
+       (yyval.device) = new_chip(cur_parent, cur_bus, (yyvsp[(2) - (2)].string));
        cur_parent = (yyval.device);
 ;}
     break;
 
-  case 12:
+  case 14:
 
     {
        cur_parent = (yyvsp[(3) - (5)].device)->parent;
-
        fold_in((yyvsp[(3) - (5)].device));
-
-       if ((yyvsp[(3) - (5)].device)->chiph_exists) {
-               int include_exists = 0;
-               struct header *h = &headers;
-               while (h->next) {
-                       int result = strcmp((yyvsp[(3) - (5)].device)->name, h->next->name);
-                       if (result == 0) {
-                               include_exists = 1;
-                               break;
-                       }
-                       if (result < 0) break;
-                       h = h->next;
-               }
-               if (!include_exists) {
-                       struct header *tmp = h->next;
-                       h->next = malloc(sizeof(struct header));
-                       memset(h->next, 0, sizeof(struct header));
-                       h->next->name = (yyvsp[(3) - (5)].device)->name;
-                       h->next->next = tmp;
-                       break;
-               }
-       }
+       add_header((yyvsp[(3) - (5)].device));
 ;}
     break;
 
-  case 13:
+  case 15:
 
     {
-       (yyval.device) = new_dev();
-       (yyval.device)->bustype = (yyvsp[(2) - (4)].number);
-
-       char *tmp;
-       (yyval.device)->path_a = strtol(strdup((yyvsp[(3) - (4)].string)), &tmp, 16);
-       if (*tmp == '.') {
-               tmp++;
-               (yyval.device)->path_b = strtol(tmp, NULL, 16);
-       }
-
-       char *name = malloc(10);
-       sprintf(name, "_dev%d", (yyval.device)->id);
-       (yyval.device)->name = name;
-       (yyval.device)->name_underscore = name; // shouldn't be necessary, but avoid 0-ptr
-       (yyval.device)->type = device;
-       (yyval.device)->enabled = (yyvsp[(4) - (4)].number);
-       (yyval.device)->chip = (yyval.device)->parent->chip;
-
-       if (cur_parent->latestchild) {
-               cur_parent->latestchild->next_sibling = (yyval.device);
-               cur_parent->latestchild->sibling = (yyval.device);
-       }
-       cur_parent->latestchild = (yyval.device);
-       if (!cur_parent->children)
-               cur_parent->children = (yyval.device);
-
-       lastdev->nextdev = (yyval.device);
-       lastdev = (yyval.device);
-       if ((yyvsp[(2) - (4)].number) == PCI) {
-               (yyval.device)->path = ".type=DEVICE_PATH_PCI,{.pci={ .devfn = PCI_DEVFN(0x%x,%d)}}";
-       }
-       if ((yyvsp[(2) - (4)].number) == PNP) {
-               (yyval.device)->path = ".type=DEVICE_PATH_PNP,{.pnp={ .port = 0x%x, .device = 0x%x }}";
-       }
-       if ((yyvsp[(2) - (4)].number) == I2C) {
-               (yyval.device)->path = ".type=DEVICE_PATH_I2C,{.i2c={ .device = 0x%x }}";
-       }
-       if ((yyvsp[(2) - (4)].number) == APIC) {
-               (yyval.device)->path = ".type=DEVICE_PATH_APIC,{.apic={ .apic_id = 0x%x }}";
-       }
-       if ((yyvsp[(2) - (4)].number) == APIC_CLUSTER) {
-               (yyval.device)->path = ".type=DEVICE_PATH_APIC_CLUSTER,{.apic_cluster={ .cluster = 0x%x }}";
-       }
-       if ((yyvsp[(2) - (4)].number) == PCI_DOMAIN) {
-               (yyval.device)->path = ".type=DEVICE_PATH_PCI_DOMAIN,{.pci_domain={ .domain = 0x%x }}";
-       }
+       (yyval.device) = new_device(cur_parent, cur_bus, (yyvsp[(2) - (4)].number), (yyvsp[(3) - (4)].string), (yyvsp[(4) - (4)].number));
        cur_parent = (yyval.device);
        cur_bus = (yyval.device);
 ;}
     break;
 
-  case 14:
+  case 16:
 
     {
        cur_parent = (yyvsp[(5) - (7)].device)->parent;
        cur_bus = (yyvsp[(5) - (7)].device)->bus;
-
        fold_in((yyvsp[(5) - (7)].device));
-
-       struct device *d = (yyvsp[(5) - (7)].device)->children;
-       while (d) {
-               int link = 0;
-               struct device *cmp = d->next_sibling;
-               while (cmp && (cmp->bus == d->bus) && (cmp->path_a == d->path_a) && (cmp->path_b == d->path_b)) {
-                       if (cmp->type==device && !cmp->used) {
-                               if (device_match(d, cmp)) {
-                                       d->multidev = 1;
-
-                                       cmp->aliased_name = malloc(12);
-                                       sprintf(cmp->aliased_name, "_dev%d", cmp->id);
-                                       cmp->id = d->id;
-                                       cmp->name = d->name;
-                                       cmp->used = 1;
-                                       cmp->link = ++link;
-                               }
-                       }
-                       cmp = cmp->next_sibling;
-               }
-               d = d->next_sibling;
-       }
+       alias_siblings((yyvsp[(5) - (7)].device)->children);
 ;}
     break;
 
-  case 15:
+  case 17:
 
-    {
-               struct resource *r = malloc(sizeof(struct resource));
-               memset (r, 0, sizeof(struct resource));
-               r->type = (yyvsp[(1) - (4)].number);
-               r->index = strtol((yyvsp[(2) - (4)].string), NULL, 0);
-               r->base = strtol((yyvsp[(4) - (4)].string), NULL, 0);
-               if (cur_parent->res) {
-                       struct resource *head = cur_parent->res;
-                       while (head->next) head = head->next;
-                       head->next = r;
-               } else {
-                       cur_parent->res = r;
-               }
-               cur_parent->rescnt++;
-       ;}
+    { add_resource(cur_parent, (yyvsp[(1) - (4)].number), strtol((yyvsp[(2) - (4)].string), NULL, 0), strtol((yyvsp[(4) - (4)].string), NULL, 0)); ;}
     break;
 
-  case 16:
+  case 18:
 
-    {
-               struct reg *r = malloc(sizeof(struct reg));
-               memset (r, 0, sizeof(struct reg));
-               r->key = (yyvsp[(2) - (4)].string);
-               r->value = (yyvsp[(4) - (4)].string);
-               if (cur_parent->reg) {
-                       struct reg *head = cur_parent->reg;
-                       // sorting to be equal to sconfig's behaviour
-                       int sort = strcmp(r->key, head->key);
-                       if (sort == 0) {
-                               printf("ERROR: duplicate 'register' key.\n");
-                               exit(1);
-                       }
-                       if (sort<0) {
-                               r->next = head;
-                               cur_parent->reg = r;
-                       } else {
-                               while ((head->next) && (strcmp(head->next->key, r->key)<0)) head = head->next;
-                               r->next = head->next;
-                               head->next = r;
-                       }
-               } else {
-                       cur_parent->reg = r;
-               }
-       ;}
+    { add_register(cur_parent, (yyvsp[(2) - (4)].string), (yyvsp[(4) - (4)].string)); ;}
+    break;
+
+  case 19:
+
+    { add_pci_subsystem_ids(cur_parent, strtol((yyvsp[(2) - (3)].string), NULL, 16), strtol((yyvsp[(3) - (3)].string), NULL, 16), 0); ;}
+    break;
+
+  case 20:
+
+    { add_pci_subsystem_ids(cur_parent, strtol((yyvsp[(2) - (4)].string), NULL, 16), strtol((yyvsp[(3) - (4)].string), NULL, 16), 1); ;}
     break;
 
 
@@ -1898,165 +1659,4 @@ yyreturn:
 
 
 
-void pass0(FILE *fil, struct device *ptr) {
-       if ((ptr->type == device) && (ptr->id != 0) && (!ptr->used))
-               fprintf(fil, "struct device %s;\n", ptr->name);
-       if ((ptr->type == device) && (ptr->id != 0) && ptr->used)
-               fprintf(fil, "struct device %s;\n", ptr->aliased_name);
-}
-
-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.path = {");
-               fprintf(fil, ptr->path, ptr->path_a, ptr->path_b);
-               fprintf(fil, "},\n");
-               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");
-               }
-               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->sibling)
-                       fprintf(fil, "\t.sibling = &%s,\n", ptr->sibling->name);
-               if (ptr->chip->chiph_exists) {
-                       fprintf(fil, "\t.chip_ops = &%s_ops,\n", ptr->chip->name_underscore);
-                       fprintf(fil, "\t.chip_info = &%s_info_%d,\n", ptr->chip->name_underscore, ptr->chip->id);
-               }
-               if (ptr->nextdev)
-                       fprintf(fil, "\t.next=&%s\n", ptr->nextdev->name);
-               fprintf(fil, "};\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);
-                       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, "struct %s_config %s_info_%d;\n", ptr->name_underscore, ptr->name_underscore, ptr->id);
-               }
-       }
-}
-
-void walk_device_tree(FILE *fil, struct device *ptr, void (*func)(FILE *, struct device*), struct device *chips) {
-       do {
-               func(fil, ptr);
-               ptr = ptr->next_sibling;
-       } while (ptr);
-}
-
-struct device mainboard = {
-       .name = "mainboard",
-       .name_underscore = "mainboard",
-       .id = 0,
-       .chip = &mainboard,
-       .type = chip,
-       .chiph_exists = 1,
-       .children = &root
-};
-
-struct device root = {
-       .name = "dev_root",
-       .name_underscore = "dev_root",
-       .id = 0,
-       .chip = &mainboard,
-       .type = device,
-       .path = " .type = DEVICE_PATH_ROOT ",
-       .ops = "&default_dev_ops_root",
-       .parent = &root,
-       .bus = &root,
-       .enabled = 1
-};
-
-int main(int argc, char** argv) {
-       if (argc != 3) {
-               printf("usage: sconfig vendor/mainboard outputdir\n");
-               return 1;
-       }
-       char *mainboard=argv[1];
-       char *outputdir=argv[2];
-       char *devtree=malloc(strlen(mainboard)+30);
-       char *outputc=malloc(strlen(outputdir)+10);
-       sprintf(devtree, "src/mainboard/%s/devicetree.cb", mainboard);
-       sprintf(outputc, "%s/static.c", outputdir);
-
-       headers.next = malloc(sizeof(struct header));
-       headers.next->name = malloc(strlen(mainboard)+12);
-       headers.next->next = 0;
-       sprintf(headers.next->name, "mainboard/%s", mainboard);
-
-       FILE *filec = fopen(devtree, "r");
-       yyrestart(filec);
-
-       FILE *staticc = fopen(outputc, "w");
-
-       cur_bus = cur_parent = lastdev = head = &root;
-       yyparse();
-       fclose(filec);
-
-       if ((head->type == chip) && (!head->chiph_exists)) {
-               struct device *tmp = head;
-               head = &root;
-               while (head->next != tmp) head = head->next;
-       }
-
-       fprintf(staticc, "#include <device/device.h>\n");
-       fprintf(staticc, "#include <device/pci.h>\n");
-       struct header *h = &headers;
-       while (h->next) {
-               h = h->next;
-               fprintf(staticc, "#include \"%s/chip.h\"\n", h->name);
-       }
-       fprintf(staticc, "\n/* pass 0 */\n");
-       walk_device_tree(staticc, &root, pass0, NULL);
-       fprintf(staticc, "\n/* pass 1 */\nstruct mainboard_config mainboard_info_0;\nstruct device **last_dev_p = &%s.next;\n", lastdev->name);
-       walk_device_tree(staticc, &root, pass1, NULL);
-
-       fclose(staticc);
-       return 0;
-}