util/gitconfig/pre-commit: Use clang-format to sanitise commits
[coreboot.git] / util / sconfig / sconfig.h
blob389d697a33289931e075cc59d51cb031a7401992
1 /*
2 * sconfig, coreboot device tree compiler
4 * Copyright (C) 2010 coresystems GmbH
5 * written by Patrick Georgi <patrick@georgi-clan.de>
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.
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.
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <string.h>
20 #include <sys/types.h>
21 #include <sys/stat.h>
22 #include <unistd.h>
23 #include <errno.h>
25 struct resource;
26 struct resource {
27 int type;
28 int index;
29 int base;
30 struct resource *next;
33 struct reg;
34 struct reg {
35 char *key;
36 char *value;
37 struct reg *next;
40 struct pci_irq_info {
41 int ioapic_irq_pin;
42 int ioapic_dst_id;
45 struct chip;
46 struct chip_instance {
48 * Monotonically increasing ID for each newly allocated
49 * node(chip/device).
51 int id;
53 /* Pointer to registers for this chip. */
54 struct reg *reg;
56 /* Pointer to chip of which this is instance. */
57 struct chip *chip;
59 /* Pointer to next instance of the same chip. */
60 struct chip_instance *next;
63 * Reference count - Indicates how many devices hold pointer to this
64 * chip instance.
66 int ref_count;
69 struct chip {
70 /* Indicates if chip header exists for this chip. */
71 int chiph_exists;
73 /* Name of current chip. */
74 char *name;
76 /* Name of current chip normalized to _. */
77 char *name_underscore;
79 /* Pointer to first instance of this chip. */
80 struct chip_instance *instance;
82 /* Pointer to next chip. */
83 struct chip *next;
86 struct device;
87 struct bus {
88 /* Instance/ID of the bus under the device. */
89 int id;
91 /* Pointer to device to which this bus belongs. */
92 struct device *dev;
94 /* Pointer to list of children. */
95 struct device *children;
97 /* Pointer to next bus for the device. */
98 struct bus *next_bus;
101 struct device {
102 /* Monotonically increasing ID for the device. */
103 int id;
105 /* Indicates device status (enabled / hidden or not). */
106 int enabled;
107 int hidden;
109 /* Subsystem IDs for the device. */
110 int subsystem_vendor;
111 int subsystem_device;
112 int inherit_subsystem;
114 /* Name of this device. */
115 char *name;
117 /* Path of this device. */
118 char *path;
119 int path_a;
120 int path_b;
122 /* Type of bus that exists under this device. */
123 int bustype;
125 /* PCI IRQ info. */
126 struct pci_irq_info pci_irq_info[4];
128 /* Pointer to bus of parent on which this device resides. */
129 struct bus *parent;
131 /* Pointer to next child under the same parent. */
132 struct device *sibling;
134 /* Pointer to resources for this device. */
135 struct resource *res;
137 /* Pointer to chip instance for this device. */
138 struct chip_instance *chip_instance;
140 /* Pointer to list of buses under this device. */
141 struct bus *bus;
142 /* Pointer to last bus under this device. */
143 struct bus *last_bus;
146 extern struct bus *root_parent;
148 struct device *new_device(struct bus *parent,
149 struct chip_instance *chip_instance,
150 const int bustype, const char *devnum,
151 int status);
153 void add_resource(struct bus *bus, int type, int index, int base);
155 void add_pci_subsystem_ids(struct bus *bus, int vendor, int device,
156 int inherit);
158 void add_ioapic_info(struct bus *bus, int apicid, const char *_srcpin,
159 int irqpin);
161 void yyrestart(FILE *input_file);
163 /* Add chip data to tail of queue. */
164 void chip_enqueue_tail(void *data);
166 /* Retrieve chip data from tail of queue. */
167 void *chip_dequeue_tail(void);
169 struct chip_instance *new_chip_instance(char *path);
170 void add_register(struct chip_instance *chip, char *name, char *val);