drivers/wifi: Remove unnecessary data structure copy
[coreboot2.git] / util / sconfig / sconfig.h
blob5fc8b4fbfc7c8e23d674584283dfc621d8ce3047
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>
11 #include <stdbool.h>
13 struct resource;
14 struct resource {
15 int type;
16 int index;
17 int base;
18 struct resource *next;
21 struct reg;
22 struct reg {
23 char *key;
24 char *value;
25 struct reg *next;
28 struct fw_config_option;
29 struct fw_config_option {
30 const char *name;
31 uint64_t value;
32 struct fw_config_option *next;
35 struct fw_config_field_bits;
36 struct fw_config_field_bits {
37 unsigned int start_bit;
38 unsigned int end_bit;
39 struct fw_config_field_bits *next;
42 struct fw_config_field;
43 struct fw_config_field {
44 const char *name;
45 struct fw_config_field_bits *bits;
46 struct fw_config_field *next;
47 struct fw_config_option *options;
49 struct fw_config_probe;
50 struct fw_config_probe {
51 const char *field;
52 const char *option;
53 struct fw_config_probe *next;
56 struct identifier {
57 const char *id;
58 struct identifier *next;
61 struct chip;
62 struct chip_instance {
63 /* Monotonically increasing ID for each chip instance. */
64 int id;
66 /* Pointer to registers for this chip. */
67 struct reg *reg;
69 /* Pointer to references for this chip. */
70 struct reg *ref;
72 /* Pointer to chip of which this is instance. */
73 struct chip *chip;
75 /* Pointer to next instance of the same chip. */
76 struct chip_instance *next;
79 * Pointer to corresponding chip instance in base devicetree.
80 * a) If the chip instance belongs to the base devicetree, then this pointer is set to
81 * NULL.
82 * b) If the chip instance belongs to override tree, then this pointer is set to its
83 * corresponding chip instance in base devicetree (if it exists), else to NULL.
85 * This is useful when generating chip instances and chip_ops for a device to determine
86 * if this is the instance to emit or if there is a base chip instance to use instead.
88 struct chip_instance *base_chip_instance;
91 struct chip {
92 /* Indicates if chip header exists for this chip. */
93 int chiph_exists;
95 /* Name of current chip. */
96 char *name;
98 /* Name of current chip normalized to _. */
99 char *name_underscore;
101 /* Pointer to first instance of this chip. */
102 struct chip_instance *instance;
104 /* Pointer to next chip. */
105 struct chip *next;
108 struct device;
109 struct bus {
110 /* Pointer to device to which this bus belongs. */
111 struct device *dev;
113 /* Pointer to list of children. */
114 struct device *children;
117 struct device {
118 /* Indicates device status (enabled / hidden or not). */
119 int enabled;
120 int hidden;
121 /* non-zero if the device should be included in all cases */
122 int mandatory;
124 /* Subsystem IDs for the device. */
125 int subsystem_vendor;
126 int subsystem_device;
127 int inherit_subsystem;
129 /* Name of this device. */
130 char *name;
132 /* Alias of this device (for internal references) */
133 char *alias;
135 /* Path of this device. */
136 char *path;
137 int path_a;
138 int path_b;
140 /* Type of bus that exists under this device. */
141 int bustype;
143 /* Pointer to bus of parent on which this device resides. */
144 struct bus *parent;
146 /* Pointer to next child under the same parent. */
147 struct device *sibling;
149 /* Pointer to resources for this device. */
150 struct resource *res;
152 /* Pointer to chip instance for this device. */
153 struct chip_instance *chip_instance;
155 /* Pointer to the bus under this device. */
156 struct bus *bus;
158 /* Global identifier of the ops for this device. */
159 char *ops_id;
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 /* SMBIOS type41 fields */
174 int smbios_instance_id_valid;
175 unsigned int smbios_instance_id;
176 const char *smbios_refdes;
178 /* List of field+option to probe. */
179 struct fw_config_probe *probe;
180 bool enable_on_unprovisioned_fw_config;
183 extern struct bus *root_parent;
185 struct device *new_device_raw(struct bus *parent,
186 struct chip_instance *chip_instance,
187 const int bustype, const char *devnum,
188 char *alias, int status);
190 struct device *new_device_reference(struct bus *parent,
191 struct chip_instance *chip_instance,
192 const char *reference, int status);
194 void add_resource(struct bus *bus, int type, int index, int base);
196 void add_pci_subsystem_ids(struct bus *bus, int vendor, int device,
197 int inherit);
199 void add_slot_desc(struct bus *bus, char *type, char *length, char *designation,
200 char *data_width);
202 void add_smbios_dev_info(struct bus *bus, long instance_id, const char *refdes);
204 void yyrestart(FILE *input_file);
206 /* Add chip data to tail of queue. */
207 void chip_enqueue_tail(void *data);
209 /* Retrieve chip data from tail of queue. */
210 void *chip_dequeue_tail(void);
212 struct chip_instance *new_chip_instance(char *path);
213 void add_register(struct chip_instance *chip, char *name, char *val);
214 void add_reference(struct chip_instance *chip, char *name, char *alias);
216 struct fw_config_field *get_fw_config_field(const char *name);
218 void add_fw_config_field_bits(struct fw_config_field *field,
219 unsigned int start_bit, unsigned int end_bit);
221 struct fw_config_field *new_fw_config_field(const char *name, struct fw_config_field_bits *bits);
223 void add_fw_config_option(struct fw_config_field *field, const char *name,
224 uint64_t value);
226 void add_fw_config_probe(struct bus *bus, const char *field, const char *option);
228 void append_fw_config_bits(struct fw_config_field_bits **bits,
229 unsigned int start_bit, unsigned int end_bit);
231 void probe_unprovisioned_fw_config(struct bus *bus);
233 void add_device_ops(struct bus *, char *ops_id);