soc/intel/xeon_sp: Do resource transition

Replace xx_resource() calls with calls that take the base
and size arguments as-is, without dividing by KiB (or >> 10).

With replacement of the allocator/constructor function
caller can use log_resource() instead.

Change-Id: I7e4e1e5a779c418f369dd2dab8c811f67ad1399f
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/55477
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Kyösti Mälkki 2021-06-14 00:40:22 +03:00
parent d0525d4248
commit 6f9c3577ea
1 changed files with 25 additions and 54 deletions

View File

@ -166,10 +166,8 @@ static void configure_dpr(struct device *dev)
static void mc_add_dram_resources(struct device *dev, int *res_count) static void mc_add_dram_resources(struct device *dev, int *res_count)
{ {
uint64_t base_kb; const struct resource *res;
uint64_t size_kb;
uint64_t mc_values[NUM_MAP_ENTRIES]; uint64_t mc_values[NUM_MAP_ENTRIES];
struct resource *resource;
int index = *res_count; int index = *res_count;
/* Only add dram resources once. */ /* Only add dram resources once. */
@ -181,67 +179,44 @@ static void mc_add_dram_resources(struct device *dev, int *res_count)
mc_report_map_entries(dev, &mc_values[0]); mc_report_map_entries(dev, &mc_values[0]);
/* Conventional Memory (DOS region, 0x0 to 0x9FFFF) */ /* Conventional Memory (DOS region, 0x0 to 0x9FFFF) */
base_kb = 0; res = ram_from_to(dev, index++, 0, 0xa0000);
size_kb = (0xa0000 >> 10); LOG_RESOURCE("legacy_ram", dev, res);
LOG_MEM_RESOURCE("legacy_ram", dev, index, base_kb, size_kb);
ram_resource_kb(dev, index++, base_kb, size_kb);
/* 1MB -> top_of_ram i.e., cbmem_top */ /* 1MB -> top_of_ram i.e., cbmem_top */
base_kb = (0x100000 >> 10); res = ram_from_to(dev, index++, 1 * MiB, (uintptr_t)cbmem_top());
size_kb = ((uintptr_t)cbmem_top() - 1 * MiB) >> 10; LOG_RESOURCE("low_ram", dev, res);
LOG_MEM_RESOURCE("low_ram", dev, index, base_kb, size_kb);
ram_resource_kb(dev, index++, base_kb, size_kb);
/* Mark TSEG/SMM region as reserved */ /* Mark TSEG/SMM region as reserved */
base_kb = (mc_values[TSEG_BASE_REG] >> 10); res = reserved_ram_from_to(dev, index++, mc_values[TSEG_BASE_REG],
size_kb = (mc_values[TSEG_LIMIT_REG] - mc_values[TSEG_BASE_REG] + 1) >> 10; mc_values[TSEG_LIMIT_REG] + 1);
LOG_MEM_RESOURCE("mmio_tseg", dev, index, base_kb, size_kb); LOG_RESOURCE("mmio_tseg", dev, res);
reserved_ram_resource_kb(dev, index++, base_kb, size_kb);
/* Reserve and set up DPR */ /* Reserve and set up DPR */
configure_dpr(dev); configure_dpr(dev);
union dpr_register dpr = { .raw = pci_read_config32(dev, VTD_LTDPR) }; union dpr_register dpr = { .raw = pci_read_config32(dev, VTD_LTDPR) };
if (dpr.size) { if (dpr.size) {
uint64_t dpr_base_k = (dpr.top - dpr.size) << 10; res = reserved_ram_from_to(dev, index++, (dpr.top - dpr.size) * MiB,
uint64_t dpr_size_k = dpr.size << 10; dpr.top * MiB);
reserved_ram_resource_kb(dev, index++, dpr_base_k, dpr_size_k); LOG_RESOURCE("dpr", dev, res);
LOG_MEM_RESOURCE("dpr", dev, index, dpr_base_k, dpr_size_k);
} }
/* Mark region between TSEG - TOLM (eg. MESEG) as reserved */ /* Mark region between TSEG - TOLM (eg. MESEG) as reserved */
if (mc_values[TSEG_LIMIT_REG] < mc_values[TOLM_REG]) { res = reserved_ram_from_to(dev, index++, mc_values[TSEG_LIMIT_REG] + 1,
base_kb = ((mc_values[TSEG_LIMIT_REG] + 1) >> 10); mc_values[TOLM_REG]);
size_kb = (mc_values[TOLM_REG] - mc_values[TSEG_LIMIT_REG]) >> 10; LOG_RESOURCE("mmio_tolm", dev, res);
LOG_MEM_RESOURCE("mmio_tolm", dev, index, base_kb, size_kb);
reserved_ram_resource_kb(dev, index++, base_kb, size_kb);
}
/* 4GiB -> TOHM */ /* 4GiB -> TOHM */
if (mc_values[TOHM_REG] > 0x100000000) { res = upper_ram_end(dev, index++, mc_values[TOHM_REG] + 1);
base_kb = (0x100000000 >> 10); LOG_RESOURCE("high_ram", dev, res);
size_kb = (mc_values[TOHM_REG] - 0x100000000 + 1) >> 10;
LOG_MEM_RESOURCE("high_ram", dev, index, base_kb, size_kb);
ram_resource_kb(dev, index++, base_kb, size_kb);
}
/* add MMIO CFG resource */ /* add MMIO CFG resource */
resource = new_resource(dev, index++); res = mmio_from_to(dev, index++, mc_values[MMCFG_BASE_REG],
resource->base = (resource_t) mc_values[MMCFG_BASE_REG]; mc_values[MMCFG_LIMIT_REG] + 1);
resource->size = (resource_t) (mc_values[MMCFG_LIMIT_REG] - LOG_RESOURCE("mmiocfg_res", dev, res);
mc_values[MMCFG_BASE_REG] + 1);
resource->flags = IORESOURCE_MEM | IORESOURCE_RESERVE |
IORESOURCE_FIXED | IORESOURCE_STORED | IORESOURCE_ASSIGNED;
LOG_MEM_RESOURCE("mmiocfg_res", dev, index-1, (resource->base >> 10),
(resource->size >> 10));
/* add Local APIC resource */ /* add Local APIC resource */
resource = new_resource(dev, index++); res = mmio_range(dev, index++, LAPIC_DEFAULT_BASE, 0x00001000);
resource->base = LAPIC_DEFAULT_BASE; LOG_RESOURCE("apic_res", dev, res);
resource->size = 0x00001000;
resource->flags = IORESOURCE_MEM | IORESOURCE_RESERVE |
IORESOURCE_FIXED | IORESOURCE_STORED | IORESOURCE_ASSIGNED;
LOG_MEM_RESOURCE("apic_res", dev, index-1, (resource->base >> 10),
(resource->size >> 10));
/* /*
* Add legacy region as reserved - 0xa000 - 1MB * Add legacy region as reserved - 0xa000 - 1MB
@ -250,15 +225,11 @@ static void mc_add_dram_resources(struct device *dev, int *res_count)
* 0xa0000 - 0xbffff: legacy VGA * 0xa0000 - 0xbffff: legacy VGA
* 0xc0000 - 0xfffff: RAM * 0xc0000 - 0xfffff: RAM
*/ */
base_kb = VGA_BASE_ADDRESS >> 10; res = mmio_range(dev, index++, VGA_BASE_ADDRESS, VGA_BASE_SIZE);
size_kb = VGA_BASE_SIZE >> 10; LOG_RESOURCE("legacy_mmio", dev, res);
LOG_MEM_RESOURCE("legacy_mmio", dev, index, base_kb, size_kb);
mmio_resource_kb(dev, index++, base_kb, size_kb);
base_kb = (0xc0000 >> 10); res = reserved_ram_from_to(dev, index++, 0xc0000, 1 * MiB);
size_kb = (0x100000 - 0xc0000) >> 10; LOG_RESOURCE("legacy_write_protect", dev, res);
LOG_MEM_RESOURCE("legacy_write_protect", dev, index, base_kb, size_kb);
reserved_ram_resource_kb(dev, index++, base_kb, size_kb);
*res_count = index; *res_count = index;
} }