mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 02:05:01 +00:00
bdb: Add functions to get attributes of BDB components
These APIs return size and offsets of BDB components. They help code look more descriptive. BUG=none BRANCH=none TEST=make runtests Change-Id: I29326e249d9f2b88d5716f878f8415703f63360c Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/388813 Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
626e0b034d
commit
3b44f30597
@@ -5,7 +5,8 @@
|
||||
* Boot descriptor block firmware functions
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "2sysincludes.h"
|
||||
#include "2common.h"
|
||||
#include "2sha.h"
|
||||
#include "bdb.h"
|
||||
|
||||
@@ -196,6 +197,11 @@ const struct bdb_header *bdb_get_header(const void *buf)
|
||||
return buf;
|
||||
}
|
||||
|
||||
uint32_t bdb_size_of(const void *buf)
|
||||
{
|
||||
return bdb_get_header(buf)->bdb_size;
|
||||
}
|
||||
|
||||
const struct bdb_key *bdb_get_bdbkey(const void *buf)
|
||||
{
|
||||
const struct bdb_header *h = bdb_get_header(buf);
|
||||
@@ -223,6 +229,11 @@ const struct bdb_key *bdb_get_datakey(const void *buf)
|
||||
return (const struct bdb_key *)(b8 + h->oem_area_0_size);
|
||||
}
|
||||
|
||||
ptrdiff_t bdb_offset_of_datakey(const void *buf)
|
||||
{
|
||||
return vb2_offset_of(buf, bdb_get_datakey(buf));
|
||||
}
|
||||
|
||||
const struct bdb_sig *bdb_get_header_sig(const void *buf)
|
||||
{
|
||||
const struct bdb_header *h = bdb_get_header(buf);
|
||||
@@ -232,6 +243,11 @@ const struct bdb_sig *bdb_get_header_sig(const void *buf)
|
||||
return (const struct bdb_sig *)(b8 + h->signed_size);
|
||||
}
|
||||
|
||||
ptrdiff_t bdb_offset_of_header_sig(const void *buf)
|
||||
{
|
||||
return vb2_offset_of(buf, bdb_get_header_sig(buf));
|
||||
}
|
||||
|
||||
const struct bdb_data *bdb_get_data(const void *buf)
|
||||
{
|
||||
const struct bdb_sig *s = bdb_get_header_sig(buf);
|
||||
@@ -241,6 +257,11 @@ const struct bdb_data *bdb_get_data(const void *buf)
|
||||
return (const struct bdb_data *)(b8 + s->struct_size);
|
||||
}
|
||||
|
||||
ptrdiff_t bdb_offset_of_data(const void *buf)
|
||||
{
|
||||
return vb2_offset_of(buf, bdb_get_data(buf));
|
||||
}
|
||||
|
||||
const void *bdb_get_oem_area_1(const void *buf)
|
||||
{
|
||||
const struct bdb_data *p = bdb_get_data(buf);
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#define VBOOT_REFERENCE_BDB_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "bdb_struct.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -153,6 +155,24 @@ const void *bdb_get_oem_area_1(const void *buf);
|
||||
const struct bdb_hash *bdb_get_hash(const void *buf, enum bdb_data_type type);
|
||||
const struct bdb_sig *bdb_get_data_sig(const void *buf);
|
||||
|
||||
/**
|
||||
* Functions to calculate size of BDB components
|
||||
*
|
||||
* @param buf Pointer to BDB buffer
|
||||
* @return Size of the component
|
||||
*/
|
||||
uint32_t bdb_size_of(const void *buf);
|
||||
|
||||
/**
|
||||
* Functions to calculate offset of BDB components
|
||||
*
|
||||
* @param buf Pointer to BDB buffer
|
||||
* @return Offset of the component
|
||||
*/
|
||||
ptrdiff_t bdb_offset_of_datakey(const void *buf);
|
||||
ptrdiff_t bdb_offset_of_header_sig(const void *buf);
|
||||
ptrdiff_t bdb_offset_of_data(const void *buf);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Functions probably provided by the caller */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user