diff options
author | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2021-06-14 00:40:22 +0300 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2022-05-24 13:08:00 +0000 |
commit | 68e6dc983223ead50362af45d9465045ae2b2d2f (patch) | |
tree | 71e624e8dc03519ceb147a1f04d1d97ee55be0e9 | |
parent | 0c78f4c05a220cd7475ce2430ef28d31ef2922b3 (diff) |
device: Add log_resource()
This will replace LOG_{MEM/IO}_RESOURCE macros once
the new resource constructors are available.
Change-Id: I21b030dc42dcb8e462b29f49499be5fd31ea38f5
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/55476
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
-rw-r--r-- | src/device/device_util.c | 9 | ||||
-rw-r--r-- | src/include/device/resource.h | 9 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/device/device_util.c b/src/device/device_util.c index 039e562b43..32f57ac0f3 100644 --- a/src/device/device_util.c +++ b/src/device/device_util.c @@ -932,3 +932,12 @@ const char *dev_path_name(enum device_path_type type) type_name = type_names[type]; return type_name; } + +void log_resource(const char *type, const struct device *dev, const struct resource *res, + const char *srcfile, const int line) +{ + printk(BIOS_SPEW, "%s:%d res: %s, dev: %s, index: 0x%lx, base: 0x%llx, " + "end: 0x%llx, size_kb: 0x%llx\n", + srcfile, line, type, dev_path(dev), res->index, res->base, + resource_end(res), res->size / KiB); +} diff --git a/src/include/device/resource.h b/src/include/device/resource.h index fb1f691190..6f16c03818 100644 --- a/src/include/device/resource.h +++ b/src/include/device/resource.h @@ -90,6 +90,15 @@ static inline void *res2mmio(const struct resource *res, unsigned long offset, return (void *)(uintptr_t)((res->base + offset) & ~mask); } +void log_resource(const char *type, const struct device *dev, const struct resource *res, + const char *srcfile, const int line); + +#define LOG_RESOURCE(type, dev, res) \ + do { \ + if (CONFIG(DEBUG_RESOURCES) && (dev) && (res)) \ + log_resource(type, (dev), (res), __func__, __LINE__); \ + } while (0) + /* * Pick largest resource on the bus using the given mask and type. * Params: |