tree: More use accessor functions for struct region fields
Always use the high-level API region_offset() and region_sz() functions. This excludes the internal `region.c` code as well as unit tests. FIT payload support was also skipped, as it seems it never tried to use the API and would need a bigger overhaul. Change-Id: I18f1e37a06783aecde9024c15876b67bfeed70ee Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/79955 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Matt DeVillier <matt.devillier@amd.corp-partner.google.com> Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
		@@ -221,8 +221,8 @@ static int fch_spi_flash_protect(const struct spi_flash *flash, const struct reg
 | 
				
			|||||||
	size_t addr, len, gran_value, total_ranges, range;
 | 
						size_t addr, len, gran_value, total_ranges, range;
 | 
				
			||||||
	bool granularity_64k = true; /* assume 64k granularity */
 | 
						bool granularity_64k = true; /* assume 64k granularity */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	addr = region->offset;
 | 
						addr = region_offset(region);
 | 
				
			||||||
	len = region->size;
 | 
						len = region_sz(region);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	reg32 = pci_read_config32(SOC_LPC_DEV, ROM_ADDRESS_RANGE2_START);
 | 
						reg32 = pci_read_config32(SOC_LPC_DEV, ROM_ADDRESS_RANGE2_START);
 | 
				
			||||||
	rom_base = WORD_TO_DWORD_UPPER(reg32);
 | 
						rom_base = WORD_TO_DWORD_UPPER(reg32);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -85,13 +85,17 @@ static uint32_t update_boot_region(struct vb2_context *ctx)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if (vboot_is_firmware_slot_a(ctx)) {
 | 
						if (vboot_is_firmware_slot_a(ctx)) {
 | 
				
			||||||
		fname = "apu/amdfw_a";
 | 
							fname = "apu/amdfw_a";
 | 
				
			||||||
		if (!fmap_locate_area("FW_MAIN_A", &fw_slot))
 | 
							if (!fmap_locate_area("FW_MAIN_A", &fw_slot)) {
 | 
				
			||||||
			map_base = rdev_mmap(boot_device_ro(), fw_slot.offset, fw_slot.size);
 | 
								map_base = rdev_mmap(boot_device_ro(),
 | 
				
			||||||
 | 
										region_offset(&fw_slot), region_sz(&fw_slot));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		fname = "apu/amdfw_b";
 | 
							fname = "apu/amdfw_b";
 | 
				
			||||||
		if (!fmap_locate_area("FW_MAIN_B", &fw_slot))
 | 
							if (!fmap_locate_area("FW_MAIN_B", &fw_slot)) {
 | 
				
			||||||
			map_base = rdev_mmap(boot_device_ro(), fw_slot.offset, fw_slot.size);
 | 
								map_base = rdev_mmap(boot_device_ro(),
 | 
				
			||||||
 | 
										region_offset(&fw_slot), region_sz(&fw_slot));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!map_base) {
 | 
						if (!map_base) {
 | 
				
			||||||
@@ -118,7 +122,7 @@ static uint32_t update_boot_region(struct vb2_context *ctx)
 | 
				
			|||||||
	psp_dir_addr = ef_table->new_psp_directory;
 | 
						psp_dir_addr = ef_table->new_psp_directory;
 | 
				
			||||||
	bios_dir_addr = get_bios_dir_addr(ef_table);
 | 
						bios_dir_addr = get_bios_dir_addr(ef_table);
 | 
				
			||||||
	psp_dir_in_spi = (uint32_t *)((psp_dir_addr & SPI_ADDR_MASK) +
 | 
						psp_dir_in_spi = (uint32_t *)((psp_dir_addr & SPI_ADDR_MASK) +
 | 
				
			||||||
			(uint32_t)map_base - fw_slot.offset);
 | 
								(uint32_t)map_base - region_offset(&fw_slot));
 | 
				
			||||||
	if (*psp_dir_in_spi != PSP_COOKIE) {
 | 
						if (*psp_dir_in_spi != PSP_COOKIE) {
 | 
				
			||||||
		printk(BIOS_ERR, "PSP Directory address is not correct.\n");
 | 
							printk(BIOS_ERR, "PSP Directory address is not correct.\n");
 | 
				
			||||||
		cbfs_unmap(amdfw_location);
 | 
							cbfs_unmap(amdfw_location);
 | 
				
			||||||
@@ -129,7 +133,7 @@ static uint32_t update_boot_region(struct vb2_context *ctx)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if (bios_dir_addr) {
 | 
						if (bios_dir_addr) {
 | 
				
			||||||
		bios_dir_in_spi = (uint32_t *)((bios_dir_addr & SPI_ADDR_MASK) +
 | 
							bios_dir_in_spi = (uint32_t *)((bios_dir_addr & SPI_ADDR_MASK) +
 | 
				
			||||||
				(uint32_t)map_base - fw_slot.offset);
 | 
									(uint32_t)map_base - region_offset(&fw_slot));
 | 
				
			||||||
		if (*bios_dir_in_spi != BHD_COOKIE) {
 | 
							if (*bios_dir_in_spi != BHD_COOKIE) {
 | 
				
			||||||
			printk(BIOS_ERR, "BIOS Directory address is not correct.\n");
 | 
								printk(BIOS_ERR, "BIOS Directory address is not correct.\n");
 | 
				
			||||||
			cbfs_unmap(amdfw_location);
 | 
								cbfs_unmap(amdfw_location);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -106,8 +106,8 @@ static void write_ddr_information(struct qclib_cb_if_table_entry *te)
 | 
				
			|||||||
	ddr_region->size = ddr_size * MiB;
 | 
						ddr_region->size = ddr_size * MiB;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Use DDR info to configure MMU */
 | 
						/* Use DDR info to configure MMU */
 | 
				
			||||||
	qc_mmu_dram_config_post_dram_init((void *)ddr_region->offset,
 | 
						qc_mmu_dram_config_post_dram_init(
 | 
				
			||||||
		(size_t)ddr_region->size);
 | 
							(void *)(uintptr_t)region_offset(ddr_region), region_sz(ddr_region));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void write_qclib_log_to_cbmemc(struct qclib_cb_if_table_entry *te)
 | 
					static void write_qclib_log_to_cbmemc(struct qclib_cb_if_table_entry *te)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,7 +12,7 @@ static void soc_read_resources(struct device *dev)
 | 
				
			|||||||
	void *start = NULL;
 | 
						void *start = NULL;
 | 
				
			||||||
	void *end = NULL;
 | 
						void *end = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ram_range(dev, 0, (uintptr_t)ddr_region->offset, ddr_region->size);
 | 
						ram_range(dev, 0, (uintptr_t)region_offset(ddr_region), region_sz(ddr_region));
 | 
				
			||||||
	reserved_ram_range(dev, 1, (uintptr_t)_dram_aop, REGION_SIZE(dram_aop));
 | 
						reserved_ram_range(dev, 1, (uintptr_t)_dram_aop, REGION_SIZE(dram_aop));
 | 
				
			||||||
	reserved_ram_range(dev, 2, (uintptr_t)_dram_soc, REGION_SIZE(dram_soc));
 | 
						reserved_ram_range(dev, 2, (uintptr_t)_dram_soc, REGION_SIZE(dram_soc));
 | 
				
			||||||
	if (soc_modem_carve_out(&start, &end))
 | 
						if (soc_modem_carve_out(&start, &end))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,7 +19,7 @@ static void soc_read_resources(struct device *dev)
 | 
				
			|||||||
	void *start = NULL;
 | 
						void *start = NULL;
 | 
				
			||||||
	void *end = NULL;
 | 
						void *end = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ram_range(dev, 0, (uintptr_t)ddr_region->offset, ddr_region->size);
 | 
						ram_range(dev, 0, (uintptr_t)region_offset(ddr_region), region_sz(ddr_region));
 | 
				
			||||||
	reserved_ram_range(dev, 1, (uintptr_t)_dram_soc, REGION_SIZE(dram_soc));
 | 
						reserved_ram_range(dev, 1, (uintptr_t)_dram_soc, REGION_SIZE(dram_soc));
 | 
				
			||||||
	reserved_ram_range(dev, 2, (uintptr_t)_dram_wlan, REGION_SIZE(dram_wlan));
 | 
						reserved_ram_range(dev, 2, (uintptr_t)_dram_wlan, REGION_SIZE(dram_wlan));
 | 
				
			||||||
	reserved_ram_range(dev, 3, (uintptr_t)_dram_wpss, REGION_SIZE(dram_wpss));
 | 
						reserved_ram_range(dev, 3, (uintptr_t)_dram_wpss, REGION_SIZE(dram_wpss));
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user