summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorShuo Liu <shuo.liu@intel.com>2022-08-06 02:30:47 +0800
committerMartin L Roth <gaumless@gmail.com>2022-08-13 16:40:26 +0000
commitd9142921429ec34dd64de9372242bfdd301969c8 (patch)
tree8243b39553bbccbae56e6c322810915984a2b658 /tests
parent0640c281c3efb870ffac1631d6562df4aa115810 (diff)
downloadcoreboot-d9142921429ec34dd64de9372242bfdd301969c8.tar.gz
coreboot-d9142921429ec34dd64de9372242bfdd301969c8.tar.bz2
coreboot-d9142921429ec34dd64de9372242bfdd301969c8.zip
tests/lib: Do not pick up unassigned resources
Unassigned tag is defined to emulate an unmapped PCI BAR resource. This resource is not mapped into host physical address and hence should not be picked up by memranges_add_resources(). Change-Id: If7a5c437d486b80d798496b985efd80526f13c63 Signed-off-by: Shuo Liu <shuo.liu@intel.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/66451 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jan Dabros <jsd@semihalf.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/memrange-test.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/tests/lib/memrange-test.c b/tests/lib/memrange-test.c
index f99673df5d68..e812c74e2457 100644
--- a/tests/lib/memrange-test.c
+++ b/tests/lib/memrange-test.c
@@ -17,11 +17,16 @@ enum mem_types {
READONLY_TAG,
INSERTED_TAG,
HOLE_TAG,
+ UNASSIGNED_TAG,
END_OF_RESOURCES
};
/* Indices of entries matters, since it must reflect mem_types enum */
struct resource res_mock_1[] = {
+ [UNASSIGNED_TAG] = {.base = 0x0,
+ .size = 0x8000,
+ .next = &res_mock_1[CACHEABLE_TAG],
+ .flags = IORESOURCE_MEM | IORESOURCE_PREFETCH},
[CACHEABLE_TAG] = {.base = 0xE000,
.size = 0xF2000,
.next = &res_mock_1[RESERVED_TAG],
@@ -86,7 +91,7 @@ struct device *all_devices = &mock_device;
int setup_test_1(void **state)
{
*state = res_mock_1;
- mock_device.resource_list = &res_mock_1[CACHEABLE_TAG];
+ mock_device.resource_list = &res_mock_1[UNASSIGNED_TAG];
return 0;
}
@@ -128,6 +133,12 @@ resource_t get_aligned_end(struct resource *res, struct range_entry *entry)
* Example memory ranges (res_mock1) for test_memrange_basic.
* Ranges marked with asterisks (***) are not added to the test_memrange.
*
+ * +-------UNASSIGNED_TAG--------+ <-0x0
+ * | |
+ * +-----------------------------+ <-0x8000
+ *
+ *
+ *
* +--------CACHEABLE_TAG--------+ <-0xE000
* | |
* | |
@@ -152,16 +163,22 @@ static void test_memrange_basic(void **state)
int counter = 0;
const unsigned long cacheable = IORESOURCE_CACHEABLE;
const unsigned long reserved = IORESOURCE_RESERVE;
+ const unsigned long prefetchable = IORESOURCE_PREFETCH;
struct range_entry *ptr;
struct memranges test_memrange;
struct resource *res_mock = *state;
resource_t prev_base = 0;
- memranges_init(&test_memrange, cacheable, cacheable, CACHEABLE_TAG);
+ memranges_init_empty(&test_memrange, NULL, 0);
+ memranges_add_resources(&test_memrange, prefetchable, prefetchable, UNASSIGNED_TAG);
+ memranges_add_resources(&test_memrange, cacheable, cacheable, CACHEABLE_TAG);
memranges_add_resources(&test_memrange, reserved, reserved, RESERVED_TAG);
- /* There should be two entries, since cacheable and
- reserved regions are not neighbors */
+ /* There should be two entries, since cacheable and reserved regions are not neighbors.
+ Besides these two, a region with an unassigned tag is defined, to emulate an unmapped
+ PCI BAR resource. This resource is not mapped into host physical address and hence
+ should not be picked up by memranges_add_resources().*/
+
memranges_each_entry(ptr, &test_memrange)
{
assert_in_range(range_entry_tag(ptr), CACHEABLE_TAG, RESERVED_TAG);