coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
cbfs_mdata.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-or-later */
2
3
#ifndef _COMMONLIB_BSD_CBFS_MDATA_H_
4
#define _COMMONLIB_BSD_CBFS_MDATA_H_
5
6
#include <
commonlib/bsd/cbfs_serialized.h
>
7
#include <
stddef.h
>
8
#include <
stdint.h
>
9
10
/*
11
* Helper structure to allocate space for a blob of metadata on the stack. All functions using
12
* a cbfs_mdata should be getting it via cbfs_walk(), and can rely on the fact that cbfs_walk()
13
* has already fully validated the header (range checks for `len`, `attributes_offset` and
14
* `offset`, and null-termination for `filename`).
15
* NOTE: The fields in any union cbfs_mdata or any of its substructures from cbfs_serialized.h
16
* should always remain in the same byte order as they are stored on flash (= big endian). To
17
* avoid byte-order confusion, fields should always and only be converted to host byte order at
18
* exactly the time they are read from one of these structures into their own separate variable.
19
*/
20
union
cbfs_mdata
{
21
struct
cbfs_file
h
;
22
uint8_t
raw
[
CBFS_METADATA_MAX_SIZE
];
23
};
24
25
/* Finds a CBFS attribute in a metadata block. Attribute returned as-is (still big-endian).
26
If |size| is not 0, will check that it matches the length of the attribute (if found)...
27
else caller is responsible for checking the |len| field to avoid reading out-of-bounds. */
28
const
void
*
cbfs_find_attr
(
const
union
cbfs_mdata
*mdata,
uint32_t
attr_tag,
size_t
size_check);
29
30
/* Returns pointer to CBFS file hash structure in metadata attributes, or NULL if invalid. */
31
const
struct
vb2_hash *
cbfs_file_hash
(
const
union
cbfs_mdata
*mdata);
32
33
#endif
/* _COMMONLIB_BSD_CBFS_MDATA_H_ */
cbfs_file_hash
const struct vb2_hash * cbfs_file_hash(const union cbfs_mdata *mdata)
Definition:
cbfs_private.c:199
cbfs_find_attr
const void * cbfs_find_attr(const union cbfs_mdata *mdata, uint32_t attr_tag, size_t size_check)
Definition:
cbfs_private.c:167
cbfs_serialized.h
CBFS_METADATA_MAX_SIZE
#define CBFS_METADATA_MAX_SIZE
Definition:
cbfs_serialized.h:96
stddef.h
stdint.h
uint32_t
unsigned int uint32_t
Definition:
stdint.h:14
uint8_t
unsigned char uint8_t
Definition:
stdint.h:8
cbfs_file
Definition:
cbfs_serialized.h:98
cbfs_mdata
Definition:
cbfs_mdata.h:20
cbfs_mdata::h
struct cbfs_file h
Definition:
cbfs_mdata.h:21
cbfs_mdata::raw
uint8_t raw[CBFS_METADATA_MAX_SIZE]
Definition:
cbfs_mdata.h:22
src
commonlib
bsd
include
commonlib
bsd
cbfs_mdata.h
Generated by
1.9.1