diff options
author | Furquan Shaikh <furquan@google.com> | 2018-05-30 15:09:09 -0700 |
---|---|---|
committer | Furquan Shaikh <furquan@google.com> | 2018-06-05 20:57:16 +0000 |
commit | 79e8412665567cfd2a18e144794f5b3d924b0cbc (patch) | |
tree | 51ccf491e1397f47e1784516e8960181e15cc793 /util/sconfig/sconfig.y | |
parent | a51ff0712cd85ecd9f46ec7c928688b7d463ff28 (diff) | |
download | coreboot-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.y')
-rwxr-xr-x | util/sconfig/sconfig.y | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/util/sconfig/sconfig.y b/util/sconfig/sconfig.y index 5cecbbace6..651aa87d50 100755 --- a/util/sconfig/sconfig.y +++ b/util/sconfig/sconfig.y @@ -21,10 +21,12 @@ int yylex(); void yyerror(const char *s); static struct device *cur_parent, *cur_bus; +static struct chip *cur_chip; %} %union { struct device *device; + struct chip *chip; char *string; int number; } @@ -38,17 +40,17 @@ chipchildren: chipchildren device | chipchildren chip | chipchildren registers | devicechildren: devicechildren device | devicechildren chip | devicechildren resource | devicechildren subsystemid | devicechildren ioapic_irq | /* empty */ ; chip: CHIP STRING /* == path */ { - $<device>$ = new_chip(cur_parent, cur_bus, $<string>2); - cur_parent = $<device>$; + $<chip>$ = new_chip($<string>2); + chip_enqueue_tail(cur_chip); + cur_chip = $<chip>$; } chipchildren END { - cur_parent = $<device>3->parent; - fold_in($<device>3); - add_header($<device>3); + cur_chip = chip_dequeue_tail(); + add_header($<chip>3); }; device: DEVICE BUS NUMBER /* == devnum */ BOOL { - $<device>$ = new_device(cur_parent, cur_bus, $<number>2, $<string>3, $<number>4); + $<device>$ = new_device(cur_parent, cur_bus, cur_chip, $<number>2, $<string>3, $<number>4); cur_parent = $<device>$; cur_bus = $<device>$; } @@ -63,7 +65,7 @@ resource: RESOURCE NUMBER /* == resnum */ EQUALS NUMBER /* == resval */ { add_resource(cur_parent, $<number>1, strtol($<string>2, NULL, 0), strtol($<string>4, NULL, 0)); } ; registers: REGISTER STRING /* == regname */ EQUALS STRING /* == regval */ - { add_register(cur_parent, $<string>2, $<string>4); } ; + { add_register(cur_chip, $<string>2, $<string>4); } ; subsystemid: SUBSYSTEMID NUMBER NUMBER { add_pci_subsystem_ids(cur_parent, strtol($<string>2, NULL, 16), strtol($<string>3, NULL, 16), 0); }; |