Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/36561 )
Change subject: lib/imd: Use uintptr_t over void * ......................................................................
lib/imd: Use uintptr_t over void *
This reduces the number of casts.
Change-Id: I3c41963202e5912da7c96ed8236e80e8bc27a4ed Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M src/include/cbmem.h M src/include/imd.h M src/lib/fit_payload.c M src/lib/imd.c M src/lib/imd_cbmem.c 5 files changed, 11 insertions(+), 11 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/61/36561/1
diff --git a/src/include/cbmem.h b/src/include/cbmem.h index 4767c80..c5d8d58 100644 --- a/src/include/cbmem.h +++ b/src/include/cbmem.h @@ -110,7 +110,7 @@ /* Add the cbmem memory used to the memory map at boot. */ void cbmem_add_bootmem(void); /* Return the cbmem memory used */ -void cbmem_get_region(void **baseptr, size_t *size); +void cbmem_get_region(uintptr_t *baseptr, size_t *size); void cbmem_list(void); void cbmem_add_records_to_cbtable(struct lb_header *header);
diff --git a/src/include/imd.h b/src/include/imd.h index cd2d297..09db1d9 100644 --- a/src/include/imd.h +++ b/src/include/imd.h @@ -101,7 +101,7 @@ int imd_lockdown(struct imd *imd);
/* Fill in base address and size of region used by imd. */ -int imd_region_used(struct imd *imd, void **base, size_t *size); +int imd_region_used(struct imd *imd, uintptr_t *base, size_t *size);
/* Add an entry to the imd. If id already exists NULL is returned. */ const struct imd_entry *imd_entry_add(const struct imd *imd, uint32_t id, diff --git a/src/lib/fit_payload.c b/src/lib/fit_payload.c index 1b6c986..f719352 100644 --- a/src/lib/fit_payload.c +++ b/src/lib/fit_payload.c @@ -127,7 +127,7 @@ { u32 addr_cells = 1, size_cells = 1; u64 reg_addrs[2], reg_sizes[2]; - void *baseptr = NULL; + uintptr_t baseptr = 0; size_t size = 0;
static const char *firmware_path[] = {"firmware", NULL}; @@ -163,7 +163,7 @@ return; }
- reg_addrs[1] = (uintptr_t)baseptr; + reg_addrs[1] = baseptr; reg_sizes[1] = size;
dt_add_reg_prop(coreboot_node, reg_addrs, reg_sizes, 2, addr_cells, diff --git a/src/lib/imd.c b/src/lib/imd.c index bedcfa8..b24a6f5 100644 --- a/src/lib/imd.c +++ b/src/lib/imd.c @@ -524,11 +524,11 @@ return 0; }
-int imd_region_used(struct imd *imd, void **base, size_t *size) +int imd_region_used(struct imd *imd, uintptr_t *base, size_t *size) { struct imd_root *r; struct imd_entry *e; - void *low_addr; + uintptr_t low_addr; size_t sz_used;
if (!imd->lg.limit) @@ -542,10 +542,10 @@ /* Use last entry to obtain lowest address. */ e = root_last_entry(r);
- low_addr = relative_pointer(r, e->start_offset); + low_addr = (uintptr_t)r + e->start_offset;
/* Total size used is the last entry's base up to the limit. */ - sz_used = imd->lg.limit - (uintptr_t)low_addr; + sz_used = imd->lg.limit - low_addr;
*base = low_addr; *size = sz_used; diff --git a/src/lib/imd_cbmem.c b/src/lib/imd_cbmem.c index be135c2..3d5f653 100644 --- a/src/lib/imd_cbmem.c +++ b/src/lib/imd_cbmem.c @@ -295,14 +295,14 @@
void cbmem_add_bootmem(void) { - void *baseptr = NULL; + uintptr_t baseptr = 0; size_t size = 0;
cbmem_get_region(&baseptr, &size); - bootmem_add_range((uintptr_t)baseptr, size, BM_MEM_TABLE); + bootmem_add_range(baseptr, size, BM_MEM_TABLE); }
-void cbmem_get_region(void **baseptr, size_t *size) +void cbmem_get_region(uintptr_t *baseptr, size_t *size) { imd_region_used(cbmem_get_imd(), baseptr, size); }