coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
iobuf.h File Reference
#include <stdint.h>
#include <sys/types.h>
Include dependency graph for iobuf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ibuf
 
struct  obuf
 

Functions

static size_t ibuf_capacity (const struct ibuf *ib)
 
static size_t ibuf_nr_read (const struct ibuf *ib)
 
static size_t ibuf_remaining (const struct ibuf *ib)
 
static size_t obuf_capacity (const struct obuf *ob)
 
static size_t obuf_nr_written (const struct obuf *ob)
 
static size_t obuf_remaining (const struct obuf *ob)
 
void ibuf_init (struct ibuf *ib, const void *b, size_t sz)
 
int ibuf_splice (const struct ibuf *src, struct ibuf *dst, size_t off, size_t sz)
 
int ibuf_splice_current (const struct ibuf *src, struct ibuf *dst, size_t sz)
 
int ibuf_split (const struct ibuf *src, struct ibuf *a, struct ibuf *b, size_t boundary)
 
const voidibuf_oob_drain (struct ibuf *ib, size_t sz)
 
int ibuf_read (struct ibuf *ib, void *data, size_t sz)
 
int ibuf_read_be8 (struct ibuf *ib, uint8_t *v)
 
int ibuf_read_be16 (struct ibuf *ib, uint16_t *v)
 
int ibuf_read_be32 (struct ibuf *ib, uint32_t *v)
 
int ibuf_read_be64 (struct ibuf *ib, uint64_t *v)
 
int ibuf_read_le8 (struct ibuf *ib, uint8_t *v)
 
int ibuf_read_le16 (struct ibuf *ib, uint16_t *v)
 
int ibuf_read_le32 (struct ibuf *ib, uint32_t *v)
 
int ibuf_read_le64 (struct ibuf *ib, uint64_t *v)
 
int ibuf_read_n8 (struct ibuf *ib, uint8_t *v)
 
int ibuf_read_n16 (struct ibuf *ib, uint16_t *v)
 
int ibuf_read_n32 (struct ibuf *ib, uint32_t *v)
 
int ibuf_read_n64 (struct ibuf *ib, uint64_t *v)
 
void ibuf_from_obuf (struct ibuf *ib, const struct obuf *ob)
 
void obuf_init (struct obuf *ob, void *b, size_t sz)
 
const voidobuf_contents (const struct obuf *ob, size_t *sz)
 
int obuf_splice (const struct obuf *src, struct obuf *dst, size_t off, size_t sz)
 
int obuf_splice_current (const struct obuf *src, struct obuf *dst, size_t sz)
 
int obuf_split (const struct obuf *src, struct obuf *a, struct obuf *b, size_t boundary)
 
voidobuf_oob_fill (struct obuf *ob, size_t sz)
 
int obuf_write (struct obuf *ob, const void *data, size_t sz)
 
int obuf_write_be8 (struct obuf *ob, uint8_t v)
 
int obuf_write_be16 (struct obuf *ob, uint16_t v)
 
int obuf_write_be32 (struct obuf *ob, uint32_t v)
 
int obuf_write_be64 (struct obuf *ob, uint64_t v)
 
int obuf_write_le8 (struct obuf *ob, uint8_t v)
 
int obuf_write_le16 (struct obuf *ob, uint16_t v)
 
int obuf_write_le32 (struct obuf *ob, uint32_t v)
 
int obuf_write_le64 (struct obuf *ob, uint64_t v)
 
int obuf_write_n8 (struct obuf *ob, uint8_t v)
 
int obuf_write_n16 (struct obuf *ob, uint16_t v)
 
int obuf_write_n32 (struct obuf *ob, uint32_t v)
 
int obuf_write_n64 (struct obuf *ob, uint64_t v)
 

Function Documentation

◆ ibuf_capacity()

static size_t ibuf_capacity ( const struct ibuf ib)
inlinestatic

Definition at line 37 of file iobuf.h.

References ibuf::capacity.

Referenced by ibuf_remaining(), ibuf_splice(), ibuf_split(), and tpm_unmarshal_response().

Here is the caller graph for this function:

◆ ibuf_from_obuf()

void ibuf_from_obuf ( struct ibuf ib,
const struct obuf ob 
)

Definition at line 22 of file iobuf.c.

References obuf::b, ibuf_init(), and obuf::n_written.

Here is the call graph for this function:

◆ ibuf_init()

void ibuf_init ( struct ibuf ib,
const void b,
size_t  sz 
)

Definition at line 15 of file iobuf.c.

References ibuf::b, ibuf::capacity, and ibuf::n_read.

Referenced by ibuf_from_obuf(), ibuf_splice(), and tpm_process_command().

Here is the caller graph for this function:

◆ ibuf_nr_read()

static size_t ibuf_nr_read ( const struct ibuf ib)
inlinestatic

Definition at line 42 of file iobuf.h.

References ibuf::n_read.

Referenced by ibuf_remaining(), ibuf_splice(), and ibuf_splice_current().

Here is the caller graph for this function:

◆ ibuf_oob_drain()

const void* ibuf_oob_drain ( struct ibuf ib,
size_t  sz 
)

Definition at line 59 of file iobuf.c.

References ibuf::b, ibuf_check_size(), ibuf::n_read, and NULL.

Referenced by ibuf_read(), tpm_unmarshal_response(), unmarshal_nv_read(), and unmarshal_TPM2B_MAX_NV_BUFFER().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ibuf_read()

int ibuf_read ( struct ibuf ib,
void data,
size_t  sz 
)

Definition at line 72 of file iobuf.c.

References ibuf_oob_drain(), memcpy(), and NULL.

Referenced by ibuf_read_n16(), ibuf_read_n32(), ibuf_read_n64(), ibuf_read_n8(), and unmarshal_get_capability().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ibuf_read_be16()

int ibuf_read_be16 ( struct ibuf ib,
uint16_t v 
)

Definition at line 97 of file iobuf.c.

References ibuf::b, ibuf_check_size(), ibuf::n_read, and read_at_be16().

Referenced by tpm_unmarshal_response(), unmarshal_TPM2B_MAX_NV_BUFFER(), and unmarshal_vendor_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ibuf_read_be32()

int ibuf_read_be32 ( struct ibuf ib,
uint32_t v 
)

Definition at line 110 of file iobuf.c.

References ibuf::b, ibuf_check_size(), ibuf::n_read, and read_at_be32().

Referenced by tpm_unmarshal_response(), unmarshal_get_capability(), and unmarshal_nv_read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ibuf_read_be64()

int ibuf_read_be64 ( struct ibuf ib,
uint64_t v 
)

Definition at line 123 of file iobuf.c.

References ibuf::b, ibuf_check_size(), ibuf::n_read, and read_at_be64().

Here is the call graph for this function:

◆ ibuf_read_be8()

int ibuf_read_be8 ( struct ibuf ib,
uint8_t v 
)

Definition at line 84 of file iobuf.c.

References ibuf::b, ibuf_check_size(), ibuf::n_read, and read_at_be8().

Referenced by unmarshal_get_capability(), and unmarshal_vendor_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ibuf_read_le16()

int ibuf_read_le16 ( struct ibuf ib,
uint16_t v 
)

Definition at line 149 of file iobuf.c.

References ibuf::b, ibuf_check_size(), ibuf::n_read, and read_at_le16().

Here is the call graph for this function:

◆ ibuf_read_le32()

int ibuf_read_le32 ( struct ibuf ib,
uint32_t v 
)

Definition at line 162 of file iobuf.c.

References ibuf::b, ibuf_check_size(), ibuf::n_read, and read_at_le32().

Here is the call graph for this function:

◆ ibuf_read_le64()

int ibuf_read_le64 ( struct ibuf ib,
uint64_t v 
)

Definition at line 175 of file iobuf.c.

References ibuf::b, ibuf_check_size(), ibuf::n_read, and read_at_le64().

Here is the call graph for this function:

◆ ibuf_read_le8()

int ibuf_read_le8 ( struct ibuf ib,
uint8_t v 
)

Definition at line 136 of file iobuf.c.

References ibuf::b, ibuf_check_size(), ibuf::n_read, and read_at_le8().

Here is the call graph for this function:

◆ ibuf_read_n16()

int ibuf_read_n16 ( struct ibuf ib,
uint16_t v 
)

Definition at line 193 of file iobuf.c.

References ibuf_read().

Here is the call graph for this function:

◆ ibuf_read_n32()

int ibuf_read_n32 ( struct ibuf ib,
uint32_t v 
)

Definition at line 198 of file iobuf.c.

References ibuf_read().

Here is the call graph for this function:

◆ ibuf_read_n64()

int ibuf_read_n64 ( struct ibuf ib,
uint64_t v 
)

Definition at line 203 of file iobuf.c.

References ibuf_read().

Here is the call graph for this function:

◆ ibuf_read_n8()

int ibuf_read_n8 ( struct ibuf ib,
uint8_t v 
)

Definition at line 188 of file iobuf.c.

References ibuf_read().

Here is the call graph for this function:

◆ ibuf_remaining()

static size_t ibuf_remaining ( const struct ibuf ib)
inlinestatic

Definition at line 47 of file iobuf.h.

References ibuf_capacity(), and ibuf_nr_read().

Referenced by ibuf_check_size(), tpm_unmarshal_response(), unmarshal_nv_read(), and unmarshal_TPM2B_MAX_NV_BUFFER().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ibuf_splice()

int ibuf_splice ( const struct ibuf src,
struct ibuf dst,
size_t  off,
size_t  sz 
)

Definition at line 27 of file iobuf.c.

References ibuf::b, ibuf_capacity(), ibuf_init(), ibuf_nr_read(), and ibuf::n_read.

Referenced by ibuf_splice_current(), and ibuf_split().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ibuf_splice_current()

int ibuf_splice_current ( const struct ibuf src,
struct ibuf dst,
size_t  sz 
)

Definition at line 45 of file iobuf.c.

References ibuf_nr_read(), and ibuf_splice().

Here is the call graph for this function:

◆ ibuf_split()

int ibuf_split ( const struct ibuf src,
struct ibuf a,
struct ibuf b,
size_t  boundary 
)

Definition at line 50 of file iobuf.c.

References ibuf_capacity(), and ibuf_splice().

Here is the call graph for this function:

◆ obuf_capacity()

static size_t obuf_capacity ( const struct obuf ob)
inlinestatic

Definition at line 52 of file iobuf.h.

References obuf::capacity.

Referenced by obuf_remaining(), obuf_splice(), and obuf_split().

Here is the caller graph for this function:

◆ obuf_contents()

const void* obuf_contents ( const struct obuf ob,
size_t sz 
)

Definition at line 405 of file iobuf.c.

References obuf::b, and obuf_nr_written().

Referenced by tpm_process_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ obuf_init()

void obuf_init ( struct obuf ob,
void b,
size_t  sz 
)

Definition at line 216 of file iobuf.c.

References obuf::b, obuf::capacity, and obuf::n_written.

Referenced by obuf_splice(), and tpm_process_command().

Here is the caller graph for this function:

◆ obuf_nr_written()

static size_t obuf_nr_written ( const struct obuf ob)
inlinestatic

Definition at line 57 of file iobuf.h.

References obuf::n_written.

Referenced by marshal_nv_define_space(), marshal_session_header(), obuf_contents(), obuf_remaining(), obuf_splice(), obuf_splice_current(), and tpm_marshal_command().

Here is the caller graph for this function:

◆ obuf_oob_fill()

void* obuf_oob_fill ( struct obuf ob,
size_t  sz 
)

Definition at line 255 of file iobuf.c.

References obuf::b, obuf::n_written, NULL, and obuf_check_size().

Referenced by obuf_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ obuf_remaining()

static size_t obuf_remaining ( const struct obuf ob)
inlinestatic

Definition at line 62 of file iobuf.h.

References obuf_capacity(), and obuf_nr_written().

Referenced by obuf_check_size().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ obuf_splice()

int obuf_splice ( const struct obuf src,
struct obuf dst,
size_t  off,
size_t  sz 
)

Definition at line 223 of file iobuf.c.

References obuf::b, obuf::n_written, obuf_capacity(), obuf_init(), and obuf_nr_written().

Referenced by obuf_splice_current(), and obuf_split().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ obuf_splice_current()

int obuf_splice_current ( const struct obuf src,
struct obuf dst,
size_t  sz 
)

Definition at line 241 of file iobuf.c.

References obuf_nr_written(), and obuf_splice().

Referenced by marshal_nv_define_space(), marshal_session_header(), and tpm_marshal_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ obuf_split()

int obuf_split ( const struct obuf src,
struct obuf a,
struct obuf b,
size_t  boundary 
)

Definition at line 246 of file iobuf.c.

References obuf_capacity(), and obuf_splice().

Here is the call graph for this function:

◆ obuf_write()

int obuf_write ( struct obuf ob,
const void data,
size_t  sz 
)

Definition at line 268 of file iobuf.c.

References memcpy(), NULL, and obuf_oob_fill().

Referenced by marshal_session_header(), marshal_TPM2B(), marshal_TPMT_HA(), obuf_write_n16(), obuf_write_n32(), obuf_write_n64(), and obuf_write_n8().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ obuf_write_be16()

int obuf_write_be16 ( struct obuf ob,
uint16_t  v 
)

◆ obuf_write_be32()

int obuf_write_be32 ( struct obuf ob,
uint32_t  v 
)

Definition at line 307 of file iobuf.c.

References obuf::b, obuf::n_written, obuf_check_size(), and write_at_be32().

Referenced by marshal_get_capability(), marshal_session_header(), marshal_TPMA_NV(), marshal_TPML_DIGEST_VALUES(), and tpm_marshal_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ obuf_write_be64()

int obuf_write_be64 ( struct obuf ob,
uint64_t  v 
)

Definition at line 320 of file iobuf.c.

References obuf::b, obuf::n_written, obuf_check_size(), and write_at_be64().

Referenced by marshal_nv_setbits().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ obuf_write_be8()

int obuf_write_be8 ( struct obuf ob,
uint8_t  v 
)

Definition at line 281 of file iobuf.c.

References obuf::b, obuf::n_written, obuf_check_size(), and write_at_be8().

Referenced by marshal_clear_control(), marshal_hierarchy_control(), marshal_selftest(), and marshal_session_header().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ obuf_write_le16()

int obuf_write_le16 ( struct obuf ob,
uint16_t  v 
)

Definition at line 346 of file iobuf.c.

References obuf::b, obuf::n_written, obuf_check_size(), and write_at_le16().

Here is the call graph for this function:

◆ obuf_write_le32()

int obuf_write_le32 ( struct obuf ob,
uint32_t  v 
)

Definition at line 359 of file iobuf.c.

References obuf::b, obuf::n_written, obuf_check_size(), and write_at_le32().

Here is the call graph for this function:

◆ obuf_write_le64()

int obuf_write_le64 ( struct obuf ob,
uint64_t  v 
)

Definition at line 372 of file iobuf.c.

References obuf::b, obuf::n_written, obuf_check_size(), and write_at_le64().

Here is the call graph for this function:

◆ obuf_write_le8()

int obuf_write_le8 ( struct obuf ob,
uint8_t  v 
)

Definition at line 333 of file iobuf.c.

References obuf::b, obuf::n_written, obuf_check_size(), and write_at_le8().

Here is the call graph for this function:

◆ obuf_write_n16()

int obuf_write_n16 ( struct obuf ob,
uint16_t  v 
)

Definition at line 390 of file iobuf.c.

References obuf_write().

Here is the call graph for this function:

◆ obuf_write_n32()

int obuf_write_n32 ( struct obuf ob,
uint32_t  v 
)

Definition at line 395 of file iobuf.c.

References obuf_write().

Here is the call graph for this function:

◆ obuf_write_n64()

int obuf_write_n64 ( struct obuf ob,
uint64_t  v 
)

Definition at line 400 of file iobuf.c.

References obuf_write().

Here is the call graph for this function:

◆ obuf_write_n8()

int obuf_write_n8 ( struct obuf ob,
uint8_t  v 
)

Definition at line 385 of file iobuf.c.

References obuf_write().

Here is the call graph for this function: