mb/lenovo/t530: Convert to ASL 2.0 syntax
[coreboot.git] / util / sconfig / sconfig.y
blob8e0379183c3a7bfb9c31defcdfd557a35ab0d2e3
1 %{
2 /* sconfig, coreboot device tree compiler */
3 /* SPDX-License-Identifier: GPL-2.0-only */
5 #include <stdint.h>
6 #include "sconfig.h"
8 int yylex();
9 void yyerror(const char *s);
11 static struct bus *cur_parent;
12 static struct chip_instance *cur_chip_instance;
13 static struct fw_config_field *cur_field;
16 %union {
17 struct device *dev;
18 struct chip_instance *chip_instance;
19 char *string;
20 uint64_t number;
23 %token CHIP DEVICE REGISTER ALIAS REFERENCE ASSOCIATION BOOL STATUS MANDATORY BUS RESOURCE END EQUALS HEX STRING PCI PNP I2C APIC CPU_CLUSTER CPU DOMAIN IRQ DRQ SLOT_DESC IO NUMBER SUBSYSTEMID INHERIT IOAPIC_IRQ IOAPIC PCIINT GENERIC SPI USB MMIO LPC ESPI GPIO FW_CONFIG_TABLE FW_CONFIG_FIELD FW_CONFIG_OPTION FW_CONFIG_PROBE
25 devtree: { cur_parent = root_parent; } | devtree chip | devtree fw_config_table;
27 chipchildren: chipchildren device | chipchildren chip | chipchildren registers | chipchildren reference | /* empty */ ;
29 devicechildren: devicechildren device | devicechildren chip | devicechildren resource | devicechildren subsystemid | devicechildren ioapic_irq | devicechildren smbios_slot_desc | devicechildren registers | devicechildren fw_config_probe | /* empty */ ;
31 chip: CHIP STRING /* == path */ {
32 $<chip_instance>$ = new_chip_instance($<string>2);
33 chip_enqueue_tail(cur_chip_instance);
34 cur_chip_instance = $<chip_instance>$;
36 chipchildren END {
37 cur_chip_instance = chip_dequeue_tail();
40 device: DEVICE BUS NUMBER /* == devnum */ alias status {
41 $<dev>$ = new_device_raw(cur_parent, cur_chip_instance, $<number>2, $<string>3, $<string>4, $<number>5);
42 cur_parent = $<dev>$->last_bus;
44 devicechildren END {
45 cur_parent = $<dev>6->parent;
48 device: DEVICE REFERENCE STRING status {
49 $<dev>$ = new_device_reference(cur_parent, cur_chip_instance, $<string>3, $<number>4);
50 cur_parent = $<dev>$->last_bus;
52 devicechildren END {
53 cur_parent = $<dev>5->parent;
56 alias: /* empty */ {
57 $<string>$ = NULL;
58 } | ALIAS STRING {
59 $<string>$ = $<string>2;
62 status: BOOL | STATUS ;
64 resource: RESOURCE NUMBER /* == resnum */ EQUALS NUMBER /* == resval */
65 { add_resource(cur_parent, $<number>1, strtol($<string>2, NULL, 0), strtol($<string>4, NULL, 0)); } ;
67 reference: REFERENCE STRING /* == alias */ ASSOCIATION STRING /* == field in chip config */
68 { add_reference(cur_chip_instance, $<string>4, $<string>2); } ;
70 registers: REGISTER STRING /* == regname */ EQUALS STRING /* == regval */
71 { add_register(cur_chip_instance, $<string>2, $<string>4); } ;
73 subsystemid: SUBSYSTEMID NUMBER NUMBER
74 { add_pci_subsystem_ids(cur_parent, strtol($<string>2, NULL, 16), strtol($<string>3, NULL, 16), 0); };
76 subsystemid: SUBSYSTEMID NUMBER NUMBER INHERIT
77 { add_pci_subsystem_ids(cur_parent, strtol($<string>2, NULL, 16), strtol($<string>3, NULL, 16), 1); };
79 ioapic_irq: IOAPIC_IRQ NUMBER PCIINT NUMBER
80 { add_ioapic_info(cur_parent, strtol($<string>2, NULL, 16), $<string>3, strtol($<string>4, NULL, 16)); };
82 smbios_slot_desc: SLOT_DESC STRING STRING STRING STRING
83 { add_slot_desc(cur_parent, $<string>2, $<string>3, $<string>4, $<string>5); };
85 smbios_slot_desc: SLOT_DESC STRING STRING STRING
86 { add_slot_desc(cur_parent, $<string>2, $<string>3, $<string>4, NULL); };
88 smbios_slot_desc: SLOT_DESC STRING STRING
89 { add_slot_desc(cur_parent, $<string>2, $<string>3, NULL, NULL); };
91 /* fw_config: firmware configuration table */
92 fw_config_table: FW_CONFIG_TABLE fw_config_table_children END { };
94 /* fw_config -> field */
95 fw_config_table_children: fw_config_table_children fw_config_field | /* empty */ ;
97 /* field -> option */
98 fw_config_field_children: fw_config_field_children fw_config_option | /* empty */ ;
100 /* field <start-bit> <end-bit> */
101 fw_config_field: FW_CONFIG_FIELD STRING NUMBER /* == start bit */ NUMBER /* == end bit */ {
102 cur_field = new_fw_config_field($<string>2, strtoul($<string>3, NULL, 0), strtoul($<string>4, NULL, 0));
104 fw_config_field_children END { };
106 /* field <bit> (for single-bit fields) */
107 fw_config_field: FW_CONFIG_FIELD STRING NUMBER /* == bit */ {
108 cur_field = new_fw_config_field($<string>2, strtoul($<string>3, NULL, 0), strtoul($<string>3, NULL, 0));
110 fw_config_field_children END { };
112 /* field (for adding options to an existing field) */
113 fw_config_field: FW_CONFIG_FIELD STRING {
114 cur_field = get_fw_config_field($<string>2);
116 fw_config_field_children END { };
118 /* option <value> */
119 fw_config_option: FW_CONFIG_OPTION STRING NUMBER /* == field value */
120 { add_fw_config_option(cur_field, $<string>2, strtoull($<string>3, NULL, 0)); };
122 /* probe <field> <option> */
123 fw_config_probe: FW_CONFIG_PROBE STRING /* == field */ STRING /* == option */
124 { add_fw_config_probe(cur_parent, $<string>2, $<string>3); }