summaryrefslogtreecommitdiff
path: root/util/sconfig/sconfig.h
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2018-05-30 15:09:09 -0700
committerFurquan Shaikh <furquan@google.com>2018-06-05 20:57:16 +0000
commit79e8412665567cfd2a18e144794f5b3d924b0cbc (patch)
tree51ccf491e1397f47e1784516e8960181e15cc793 /util/sconfig/sconfig.h
parenta51ff0712cd85ecd9f46ec7c928688b7d463ff28 (diff)
downloadcoreboot-79e8412665567cfd2a18e144794f5b3d924b0cbc.tar.xz
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>
Diffstat (limited to 'util/sconfig/sconfig.h')
-rw-r--r--util/sconfig/sconfig.h51
1 files changed, 39 insertions, 12 deletions
diff --git a/util/sconfig/sconfig.h b/util/sconfig/sconfig.h
index 119d7b5fbf..79d2da0d16 100644
--- a/util/sconfig/sconfig.h
+++ b/util/sconfig/sconfig.h
@@ -22,8 +22,6 @@
#include <unistd.h>
#include <errno.h>
-enum devtype { chip, device };
-
struct resource;
struct resource {
int type;
@@ -43,6 +41,30 @@ struct pci_irq_info {
int ioapic_irq_pin;
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 {
int id;
@@ -51,19 +73,17 @@ struct device {
int multidev;
int link;
int rescnt;
- int chiph_exists;
int subsystem_vendor;
int subsystem_device;
int inherit_subsystem;
char *ops;
char *name;
- char *name_underscore;
char *path;
int path_a;
int path_b;
int bustype;
struct pci_irq_info pci_irq_info[4];
- enum devtype type;
+
struct device *parent;
struct device *bus;
struct device *next;
@@ -72,12 +92,12 @@ struct device {
struct device *latestchild;
struct device *next_sibling;
struct device *sibling;
- struct device *chip;
struct resource *res;
- struct reg *reg;
+
+ struct chip *chip;
};
-struct device *head;
+extern struct device *head;
struct header;
struct header {
@@ -89,16 +109,23 @@ struct header {
void fold_in(struct device *parent);
void postprocess_devtree(void);
-struct device *new_chip(struct device *parent, struct device *bus, char *path);
-void add_header(struct device *dev);
+struct chip *new_chip(char *path);
+void add_header(struct chip *chip);
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 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,
int inherit);
void add_ioapic_info(struct device *dev, int apicid, const char *_srcpin,
int irqpin);
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);