cbfs: Make `mdata` argument to cbfs_allocator_t const
Right before CB:49334 was submitted, I changed the signature of cbfs_allocator_t function pointers to include another argument passing in the already loaded CBFS metadata (to allow for the rare edge case of allocators needing to read CBFS attributes). This interface is not meant to be able to modify the passed-in metadata, so to clarify that and prevent potential errors, we should declare the argument const. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I7e3756490b9ad7ded91268c61797cef36c4118ee Reviewed-on: https://review.coreboot.org/c/coreboot/+/52081 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
parent
d9c02cdc98
commit
4676ec52c2
|
@ -67,7 +67,7 @@
|
||||||
* attributes). Must return a pointer to space of the requested size where the file data should
|
* attributes). Must return a pointer to space of the requested size where the file data should
|
||||||
* be loaded, or NULL to make the operation fail.
|
* be loaded, or NULL to make the operation fail.
|
||||||
*/
|
*/
|
||||||
typedef void *(*cbfs_allocator_t)(void *arg, size_t size, union cbfs_mdata *mdata);
|
typedef void *(*cbfs_allocator_t)(void *arg, size_t size, const union cbfs_mdata *mdata);
|
||||||
|
|
||||||
static inline size_t cbfs_load(const char *name, void *buf, size_t size);
|
static inline size_t cbfs_load(const char *name, void *buf, size_t size);
|
||||||
static inline size_t cbfs_ro_load(const char *name, void *buf, size_t size);
|
static inline size_t cbfs_ro_load(const char *name, void *buf, size_t size);
|
||||||
|
@ -183,9 +183,9 @@ struct _cbfs_default_allocator_arg {
|
||||||
void *buf;
|
void *buf;
|
||||||
size_t buf_size;
|
size_t buf_size;
|
||||||
};
|
};
|
||||||
void *_cbfs_default_allocator(void *arg, size_t size, union cbfs_mdata *unused);
|
void *_cbfs_default_allocator(void *arg, size_t size, const union cbfs_mdata *unused);
|
||||||
|
|
||||||
void *_cbfs_cbmem_allocator(void *arg, size_t size, union cbfs_mdata *unused);
|
void *_cbfs_cbmem_allocator(void *arg, size_t size, const union cbfs_mdata *unused);
|
||||||
|
|
||||||
/**********************************************************************************************
|
/**********************************************************************************************
|
||||||
* INLINE IMPLEMENTATIONS *
|
* INLINE IMPLEMENTATIONS *
|
||||||
|
|
|
@ -369,7 +369,7 @@ void *_cbfs_alloc(const char *name, cbfs_allocator_t allocator, void *arg,
|
||||||
return loc;
|
return loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *_cbfs_default_allocator(void *arg, size_t size, union cbfs_mdata *unused)
|
void *_cbfs_default_allocator(void *arg, size_t size, const union cbfs_mdata *unused)
|
||||||
{
|
{
|
||||||
struct _cbfs_default_allocator_arg *darg = arg;
|
struct _cbfs_default_allocator_arg *darg = arg;
|
||||||
if (size > darg->buf_size)
|
if (size > darg->buf_size)
|
||||||
|
@ -377,7 +377,7 @@ void *_cbfs_default_allocator(void *arg, size_t size, union cbfs_mdata *unused)
|
||||||
return darg->buf;
|
return darg->buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *_cbfs_cbmem_allocator(void *arg, size_t size, union cbfs_mdata *unused)
|
void *_cbfs_cbmem_allocator(void *arg, size_t size, const union cbfs_mdata *unused)
|
||||||
{
|
{
|
||||||
return cbmem_add((uintptr_t)arg, size);
|
return cbmem_add((uintptr_t)arg, size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,7 @@ int rmodule_load(void *base, struct rmodule *module)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *rmodule_cbfs_allocator(void *rsl_arg, size_t unused,
|
static void *rmodule_cbfs_allocator(void *rsl_arg, size_t unused,
|
||||||
union cbfs_mdata *mdata)
|
const union cbfs_mdata *mdata)
|
||||||
{
|
{
|
||||||
struct rmod_stage_load *rsl = rsl_arg;
|
struct rmod_stage_load *rsl = rsl_arg;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue