util/sconfig: Declare the repeated devicetree storage
With DEVTREE_EARLY we could create incomplete device objects with topology links removed to reduce footprint for bootblock. Declare everything with 'static __unused DEVTREE_CONST' to avoid compiler errors and to not expose unusable device object names to global scope. Change-Id: Ie4cb9e75f179f44edf4f8256ad8320bc2d4ae71a Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/31931 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
		
				
					committed by
					
						
						Patrick Georgi
					
				
			
			
				
	
			
			
			
						parent
						
							975a7e3ba3
						
					
				
				
					commit
					5ccce7cdc7
				
			@@ -696,17 +696,17 @@ static int dev_has_children(struct device *dev)
 | 
			
		||||
static void pass0(FILE *fil, struct device *ptr, struct device *next)
 | 
			
		||||
{
 | 
			
		||||
	if (ptr == &base_root_dev) {
 | 
			
		||||
		fprintf(fil, "DEVTREE_CONST struct bus %s_links[];\n",
 | 
			
		||||
		fprintf(fil, "STORAGE struct bus %s_links[];\n",
 | 
			
		||||
			ptr->name);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	fprintf(fil, "static DEVTREE_CONST struct device %s;\n", ptr->name);
 | 
			
		||||
	fprintf(fil, "STORAGE struct device %s;\n", ptr->name);
 | 
			
		||||
	if (ptr->res)
 | 
			
		||||
		fprintf(fil, "DEVTREE_CONST struct resource %s_res[];\n",
 | 
			
		||||
		fprintf(fil, "STORAGE struct resource %s_res[];\n",
 | 
			
		||||
			ptr->name);
 | 
			
		||||
	if (dev_has_children(ptr))
 | 
			
		||||
		fprintf(fil, "DEVTREE_CONST struct bus %s_links[];\n",
 | 
			
		||||
		fprintf(fil, "STORAGE struct bus %s_links[];\n",
 | 
			
		||||
			ptr->name);
 | 
			
		||||
 | 
			
		||||
	if (next)
 | 
			
		||||
@@ -723,7 +723,7 @@ static void emit_resources(FILE *fil, struct device *ptr)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	int i = 1;
 | 
			
		||||
	fprintf(fil, "DEVTREE_CONST struct resource %s_res[] = {\n", ptr->name);
 | 
			
		||||
	fprintf(fil, "STORAGE struct resource %s_res[] = {\n", ptr->name);
 | 
			
		||||
	struct resource *r = ptr->res;
 | 
			
		||||
	while (r) {
 | 
			
		||||
		fprintf(fil,
 | 
			
		||||
@@ -765,7 +765,7 @@ static void emit_bus(FILE *fil, struct bus *bus)
 | 
			
		||||
 | 
			
		||||
static void emit_dev_links(FILE *fil, struct device *ptr)
 | 
			
		||||
{
 | 
			
		||||
	fprintf(fil, "DEVTREE_CONST struct bus %s_links[] = {\n",
 | 
			
		||||
	fprintf(fil, "STORAGE struct bus %s_links[] = {\n",
 | 
			
		||||
		ptr->name);
 | 
			
		||||
 | 
			
		||||
	struct bus *bus = ptr->bus;
 | 
			
		||||
@@ -784,9 +784,11 @@ static void pass1(FILE *fil, struct device *ptr, struct device *next)
 | 
			
		||||
	struct chip_instance *chip_ins = ptr->chip_instance;
 | 
			
		||||
	int has_children = dev_has_children(ptr);
 | 
			
		||||
 | 
			
		||||
	if (ptr != &base_root_dev)
 | 
			
		||||
		fprintf(fil, "static ");
 | 
			
		||||
	fprintf(fil, "DEVTREE_CONST struct device %s = {\n", ptr->name);
 | 
			
		||||
	if (ptr == &base_root_dev)
 | 
			
		||||
		fprintf(fil, "DEVTREE_CONST struct device %s = {\n", ptr->name);
 | 
			
		||||
	else
 | 
			
		||||
		fprintf(fil, "STORAGE struct device %s = {\n", ptr->name);
 | 
			
		||||
 | 
			
		||||
	fprintf(fil, "#if !DEVTREE_EARLY\n");
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
@@ -942,7 +944,7 @@ static void emit_chip_headers(FILE *fil, struct chip *chip)
 | 
			
		||||
 | 
			
		||||
static void emit_chip_instance(FILE *fil, struct chip_instance *instance)
 | 
			
		||||
{
 | 
			
		||||
	fprintf(fil, "DEVTREE_CONST struct %s_config %s_info_%d = {",
 | 
			
		||||
	fprintf(fil, "STORAGE struct %s_config %s_info_%d = {",
 | 
			
		||||
		instance->chip->name_underscore,
 | 
			
		||||
		instance->chip->name_underscore,
 | 
			
		||||
		instance->id);
 | 
			
		||||
@@ -965,6 +967,8 @@ static void emit_chips(FILE *fil)
 | 
			
		||||
 | 
			
		||||
	emit_chip_headers(fil, chip);
 | 
			
		||||
 | 
			
		||||
	fprintf(fil, "\n#define STORAGE static __unused DEVTREE_CONST\n\n");
 | 
			
		||||
 | 
			
		||||
	for (; chip; chip = chip->next) {
 | 
			
		||||
		if (!chip->chiph_exists)
 | 
			
		||||
			continue;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user