Skip to content

Commit

Permalink
bloblist: Add functions to obtain base address and size
Browse files Browse the repository at this point in the history
Add a few convenience functions to obtain useful information about the
bloblist.

Signed-off-by: Simon Glass <[email protected]>
  • Loading branch information
sjg20 committed Jan 13, 2022
1 parent 99047f5 commit e50a24a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions common/bloblist.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,18 @@ int bloblist_finish(void)
return 0;
}

ulong bloblist_get_base(void)
{
return map_to_sysmem(gd->bloblist);
}

ulong bloblist_get_size(void)
{
struct bloblist_hdr *hdr = gd->bloblist;

return hdr->size;
}

void bloblist_get_stats(ulong *basep, ulong *sizep, ulong *allocedp)
{
struct bloblist_hdr *hdr = gd->bloblist;
Expand Down
14 changes: 14 additions & 0 deletions include/bloblist.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,20 @@ int bloblist_finish(void);
*/
void bloblist_get_stats(ulong *basep, ulong *sizep, ulong *allocedp);

/**
* bloblist_get_base() - Get the base address of the bloblist
*
* @returns base address of bloblist
*/
ulong bloblist_get_base(void);

/**
* bloblist_get_size() - Get the size of the bloblist
*
* @returns the size in bytes
*/
ulong bloblist_get_size(void);

/**
* bloblist_show_stats() - Show information about the bloblist
*
Expand Down
2 changes: 2 additions & 0 deletions test/bloblist.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ static int bloblist_test_blob(struct unit_test_state *uts)
hdr = clear_bloblist();
ut_assertnull(bloblist_find(TEST_TAG, TEST_BLOBLIST_SIZE));
ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0));
ut_asserteq(TEST_BLOBLIST_SIZE, bloblist_get_size());
ut_asserteq(TEST_ADDR, bloblist_get_base());
ut_asserteq(map_to_sysmem(hdr), TEST_ADDR);

/* Add a record and check that we can find it */
Expand Down

0 comments on commit e50a24a

Please sign in to comment.