Split C code in sconfig's parser into a separate file.
[coreboot.git] / util / sconfig / sconfig.h
1 /*
2  * sconfig, coreboot device tree compiler
3  *
4  * Copyright (C) 2010 coresystems GmbH
5  *                 written by Patrick Georgi <patrick.georgi@coresystems.de>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; version 2 of the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
19  */
20
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 #include <unistd.h>
27 #include <errno.h>
28
29 enum devtype { chip, device };
30
31 struct resource;
32 struct resource {
33         int type;
34         int index;
35         int base;
36         struct resource *next;
37 };
38
39 struct reg;
40 struct reg {
41         char *key;
42         char *value;
43         struct reg *next;
44 };
45
46 struct device;
47 struct device {
48         int id;
49         int enabled;
50         int used;
51         int multidev;
52         int link;
53         int rescnt;
54         int chiph_exists;
55         char *ops;
56         char *name;
57         char *aliased_name;
58         char *name_underscore;
59         char *path;
60         int path_a;
61         int path_b;
62         int bustype;
63         enum devtype type;
64         struct device *parent;
65         struct device *bus;
66         struct device *next;
67         struct device *nextdev;
68         struct device *children;
69         struct device *latestchild;
70         struct device *next_sibling;
71         struct device *sibling;
72         struct device *chip;
73         struct resource *res;
74         struct reg *reg;
75 };
76
77 extern struct device *cur_parent, *cur_bus;
78
79 struct header;
80 struct header {
81         char *name;
82         struct header *next;
83 };
84
85 void fold_in(struct device *parent);
86
87 void postprocess_devtree(void);
88 struct device *new_chip(char *path);
89 void add_header(struct device *dev);
90 struct device *new_device(const int bus, const char *devnum, int enabled);
91 void alias_siblings(struct device *d);
92 void add_resource(int type, int index, int base);
93 void add_register(char *name, char *val);