mb/google/{guybrush,mancomb}: Add VBOOT_VBNV_OFFSET
[coreboot.git] / util / sconfig / sconfig.h
blob0db1ce59c997417418d37298139fb98ef9f7cd9d
1 /* sconfig, coreboot device tree compiler */
2 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <stdint.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <sys/types.h>
9 #include <unistd.h>
10 #include <errno.h>
12 struct resource;
13 struct resource {
14 int type;
15 int index;
16 int base;
17 struct resource *next;
20 struct reg;
21 struct reg {
22 char *key;
23 char *value;
24 struct reg *next;
27 struct pci_irq_info {
28 int ioapic_irq_pin;
29 int ioapic_dst_id;
32 struct fw_config_option;
33 struct fw_config_option {
34 const char *name;
35 uint64_t value;
36 struct fw_config_option *next;
38 struct fw_config_field;
39 struct fw_config_field {
40 const char *name;
41 unsigned int start_bit;
42 unsigned int end_bit;
43 struct fw_config_field *next;
44 struct fw_config_option *options;
46 struct fw_config_probe;
47 struct fw_config_probe {
48 const char *field;
49 const char *option;
50 struct fw_config_probe *next;
53 struct chip;
54 struct chip_instance {
55 /* Monotonically increasing ID for each chip instance. */
56 int id;
58 /* Pointer to registers for this chip. */
59 struct reg *reg;
61 /* Pointer to references for this chip. */
62 struct reg *ref;
64 /* Pointer to chip of which this is instance. */
65 struct chip *chip;
67 /* Pointer to next instance of the same chip. */
68 struct chip_instance *next;
71 * Pointer to corresponding chip instance in base devicetree.
72 * a) If the chip instance belongs to the base devicetree, then this pointer is set to
73 * NULL.
74 * b) If the chip instance belongs to override tree, then this pointer is set to its
75 * corresponding chip instance in base devicetree (if it exists), else to NULL.
77 * This is useful when generating chip instances and chip_ops for a device to determine
78 * if this is the instance to emit or if there is a base chip instance to use instead.
80 struct chip_instance *base_chip_instance;
83 struct chip {
84 /* Indicates if chip header exists for this chip. */
85 int chiph_exists;
87 /* Name of current chip. */
88 char *name;
90 /* Name of current chip normalized to _. */
91 char *name_underscore;
93 /* Pointer to first instance of this chip. */
94 struct chip_instance *instance;
96 /* Pointer to next chip. */
97 struct chip *next;
100 struct device;
101 struct bus {
102 /* Instance/ID of the bus under the device. */
103 int id;
105 /* Pointer to device to which this bus belongs. */
106 struct device *dev;
108 /* Pointer to list of children. */
109 struct device *children;
111 /* Pointer to next bus for the device. */
112 struct bus *next_bus;
115 struct device {
116 /* Indicates device status (enabled / hidden or not). */
117 int enabled;
118 int hidden;
119 /* non-zero if the device should be included in all cases */
120 int mandatory;
122 /* Subsystem IDs for the device. */
123 int subsystem_vendor;
124 int subsystem_device;
125 int inherit_subsystem;
127 /* Name of this device. */
128 char *name;
130 /* Alias of this device (for internal references) */
131 char *alias;
133 /* Path of this device. */
134 char *path;
135 int path_a;
136 int path_b;
138 /* Type of bus that exists under this device. */
139 int bustype;
141 /* PCI IRQ info. */
142 struct pci_irq_info pci_irq_info[4];
144 /* Pointer to bus of parent on which this device resides. */
145 struct bus *parent;
147 /* Pointer to next child under the same parent. */
148 struct device *sibling;
150 /* Pointer to resources for this device. */
151 struct resource *res;
153 /* Pointer to chip instance for this device. */
154 struct chip_instance *chip_instance;
156 /* Pointer to list of buses under this device. */
157 struct bus *bus;
158 /* Pointer to last bus under this device. */
159 struct bus *last_bus;
161 /* SMBIOS slot type */
162 char *smbios_slot_type;
164 /* SMBIOS slot data width */
165 char *smbios_slot_data_width;
167 /* SMBIOS slot description for reference designation */
168 char *smbios_slot_designation;
170 /* SMBIOS slot length */
171 char *smbios_slot_length;
173 /* List of field+option to probe. */
174 struct fw_config_probe *probe;
177 extern struct bus *root_parent;
179 struct device *new_device_raw(struct bus *parent,
180 struct chip_instance *chip_instance,
181 const int bustype, const char *devnum,
182 char *alias, int status);
184 struct device *new_device_reference(struct bus *parent,
185 struct chip_instance *chip_instance,
186 const char *reference, int status);
188 void add_resource(struct bus *bus, int type, int index, int base);
190 void add_pci_subsystem_ids(struct bus *bus, int vendor, int device,
191 int inherit);
193 void add_ioapic_info(struct bus *bus, int apicid, const char *_srcpin,
194 int irqpin);
196 void add_slot_desc(struct bus *bus, char *type, char *length, char *designation,
197 char *data_width);
199 void yyrestart(FILE *input_file);
201 /* Add chip data to tail of queue. */
202 void chip_enqueue_tail(void *data);
204 /* Retrieve chip data from tail of queue. */
205 void *chip_dequeue_tail(void);
207 struct chip_instance *new_chip_instance(char *path);
208 void add_register(struct chip_instance *chip, char *name, char *val);
209 void add_reference(struct chip_instance *chip, char *name, char *alias);
211 struct fw_config_field *get_fw_config_field(const char *name);
213 struct fw_config_field *new_fw_config_field(const char *name,
214 unsigned int start_bit, unsigned int end_bit);
216 void add_fw_config_option(struct fw_config_field *field, const char *name,
217 uint64_t value);
219 void add_fw_config_probe(struct bus *bus, const char *field, const char *option);