summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu-Ping Wu <yupingso@chromium.org>2024-11-26 10:03:27 +0800
committerYu-Ping Wu <yupingso@google.com>2024-11-27 07:41:35 +0000
commitd2deb14fb00f71fca4897e44b4d61d8027d2bdf3 (patch)
treee09b027ef3290bd470c99e56cddddc48c2fcff1c
parent80caf690d01165e1e395b281b2c14c1057c3598e (diff)
commonlib/bsd/mem_chip_info: Add mem_chip_info_entry_density_bytes
Add a helper function to get the mem_chip_info entry size. Change-Id: Ibf2a2006fb3e7772688b80807589e8f2d64d1147 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/85312 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yidi Lin <yidilin@google.com>
-rw-r--r--src/commonlib/bsd/include/commonlib/bsd/mem_chip_info.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/commonlib/bsd/include/commonlib/bsd/mem_chip_info.h b/src/commonlib/bsd/include/commonlib/bsd/mem_chip_info.h
index f191cc7642..2813651b31 100644
--- a/src/commonlib/bsd/include/commonlib/bsd/mem_chip_info.h
+++ b/src/commonlib/bsd/include/commonlib/bsd/mem_chip_info.h
@@ -98,16 +98,19 @@ static inline size_t mem_chip_info_size(int entries)
return sizeof(struct mem_chip_info) + sizeof(struct mem_chip_entry) * entries;
};
+static inline uint64_t mem_chip_info_entry_density_bytes(const struct mem_chip_entry *entry)
+{
+ return (uint64_t)entry->density_mbits * (entry->channel_io_width / entry->io_width)
+ * (MiB / 8);
+}
+
static inline uint64_t mem_chip_info_total_density_bytes(const struct mem_chip_info *info)
{
uint64_t bytes = 0;
int i;
- for (i = 0; i < info->num_entries; i++) {
- const struct mem_chip_entry *e = &info->entries[i];
- bytes += (uint64_t)e->density_mbits * (e->channel_io_width / e->io_width)
- * (MiB / 8);
- }
+ for (i = 0; i < info->num_entries; i++)
+ bytes += mem_chip_info_entry_density_bytes(&info->entries[i]);
return bytes;
}