abuf: Add a way to set up an abuf with a given address
In some cases it is convenient to provide an address when initing an abuf, instead of a pointer. Add a function for this. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -68,6 +68,28 @@ static int lib_test_abuf_init_const(struct unit_test_state *uts)
|
||||
}
|
||||
LIB_TEST(lib_test_abuf_init_const, 0);
|
||||
|
||||
/* Test abuf_init_const_addr() */
|
||||
static int lib_test_abuf_init_const_addr(struct unit_test_state *uts)
|
||||
{
|
||||
struct abuf buf;
|
||||
ulong start;
|
||||
void *ptr;
|
||||
|
||||
start = ut_check_free();
|
||||
|
||||
ptr = map_sysmem(0x100, 0);
|
||||
|
||||
abuf_init_const_addr(&buf, 0x100, 10);
|
||||
ut_asserteq_ptr(ptr, buf.data);
|
||||
ut_asserteq(10, buf.size);
|
||||
|
||||
/* No memory should have been allocated */
|
||||
ut_assertok(ut_check_delta(start));
|
||||
|
||||
return 0;
|
||||
}
|
||||
LIB_TEST(lib_test_abuf_init_const_addr, 0);
|
||||
|
||||
/* Test abuf_map_sysmem() and abuf_addr() */
|
||||
static int lib_test_abuf_map_sysmem(struct unit_test_state *uts)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user