iPXE
blob.c File Reference

Openable data blobs. More...

#include <string.h>
#include <errno.h>
#include <ipxe/malloc.h>
#include <ipxe/xfer.h>
#include <ipxe/process.h>
#include <ipxe/blob.h>

Go to the source code of this file.

Data Structures

struct  blob
 An openable data blob. More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
static void blob_close (struct blob *blob, int rc)
 Close data blob.
static void blob_step (struct blob *blob)
 Process data blob.
int blob_open (struct interface *xfer, const void *data, size_t len)
 Open data blob.

Variables

static struct interface_operation blob_xfer_op []
 Data blob interface operations.
static struct interface_descriptor blob_xfer_desc
 Data blob interface descriptor.
static struct process_descriptor blob_process_desc
 Data blob process descriptor.

Detailed Description

Openable data blobs.

Within the iPXE data transfer interface model, openers are fully asynchronous and may not deliver any data until after the opener has returned. An openable data blob provides a way to open an interface that will then simply return a single fixed blob of data.

Definition in file blob.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ blob_close()

void blob_close ( struct blob * blob,
int rc )
static

Close data blob.

Parameters
blobData blob
rcReason for close

Definition at line 64 of file blob.c.

64 {
65
66 /* Stop process */
68
69 /* Shut down interface */
71}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
Definition interface.c:279
void process_del(struct process *process)
Remove process from process list.
Definition process.c:80
An openable data blob.
Definition blob.c:45
struct interface xfer
Data transfer interface.
Definition blob.c:49
struct process process
Download process.
Definition blob.c:51

References intf_shutdown(), blob::process, process_del(), rc, and blob::xfer.

Referenced by blob_step().

◆ blob_step()

void blob_step ( struct blob * blob)
static

Process data blob.

Parameters
blobData blob

Definition at line 78 of file blob.c.

78 {
79 int rc;
80
81 /* Deliver data when window opens */
82 if ( xfer_window ( &blob->xfer ) ) {
84 blob_close ( blob, rc );
85 }
86}
static void blob_close(struct blob *blob, int rc)
Close data blob.
Definition blob.c:64
const void * data
Data.
Definition blob.c:53
size_t len
Length of data.
Definition blob.c:55
size_t xfer_window(struct interface *intf)
Check flow control window.
Definition xfer.c:117
int xfer_deliver_raw(struct interface *intf, const void *data, size_t len)
Deliver datagram as raw data without metadata.
Definition xfer.c:289

References blob_close(), blob::data, blob::len, rc, blob::xfer, xfer_deliver_raw(), and xfer_window().

◆ blob_open()

int blob_open ( struct interface * xfer,
const void * data,
size_t len )

Open data blob.

Parameters
xferData transfer interface
dataData
lenLength of data
Return values
rcReturn status code

Definition at line 110 of file blob.c.

110 {
111 struct blob *blob;
112 void *copy;
113
114 /* Allocate and initialise structure */
115 blob = zalloc ( sizeof ( *blob ) + len );
116 if ( ! blob )
117 return -ENOMEM;
118 ref_init ( &blob->refcnt, NULL );
121 copy = ( ( ( void * ) blob ) + sizeof ( *blob ) );
122 blob->data = copy;
123 blob->len = len;
124 memcpy ( copy, data, len );
125
126 /* Attach parent interface, mortalise self, and return */
128 ref_put ( &blob->refcnt );
129 return 0;
130}
#define NULL
NULL pointer (VOID *).
Definition Base.h:321
static struct process_descriptor blob_process_desc
Data blob process descriptor.
Definition blob.c:99
static struct interface_descriptor blob_xfer_desc
Data blob interface descriptor.
Definition blob.c:95
ring len
Length.
Definition dwmac.h:226
uint8_t data[48]
Additional event data.
Definition ena.h:11
#define ENOMEM
Not enough space.
Definition errno.h:535
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
Definition interface.c:108
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition interface.h:204
void * zalloc(size_t size)
Allocate cleared memory.
Definition malloc.c:662
static void process_init(struct process *process, struct process_descriptor *desc, struct refcnt *refcnt)
Initialise process and add to process list.
Definition process.h:162
#define ref_put(refcnt)
Drop reference to object.
Definition refcnt.h:107
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition refcnt.h:65
struct refcnt refcnt
Reference count.
Definition blob.c:47

References blob_process_desc, blob_xfer_desc, blob::data, data, ENOMEM, intf_init(), intf_plug_plug(), blob::len, len, memcpy(), NULL, blob::process, process_init(), ref_init, ref_put, blob::refcnt, blob::xfer, and zalloc().

Referenced by datauri_open().

Variable Documentation

◆ blob_xfer_op

struct interface_operation blob_xfer_op[]
static
Initial value:
= {
}
static void blob_step(struct blob *blob)
Process data blob.
Definition blob.c:78
void intf_close(struct interface *intf, int rc)
Close an object interface.
Definition interface.c:250
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
Definition interface.h:33
void xfer_window_changed(struct interface *intf)
Report change of flow control window.
Definition xfer.c:147

Data blob interface operations.

Definition at line 89 of file blob.c.

89 {
91 INTF_OP ( intf_close, struct blob *, blob_close ),
92};

◆ blob_xfer_desc

struct interface_descriptor blob_xfer_desc
static
Initial value:
=
INTF_DESC ( struct blob, xfer, blob_xfer_op )
static struct interface_operation blob_xfer_op[]
Data blob interface operations.
Definition blob.c:89
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
Definition interface.h:81

Data blob interface descriptor.

Definition at line 95 of file blob.c.

Referenced by blob_open().

◆ blob_process_desc

struct process_descriptor blob_process_desc
static
Initial value:
=
#define PROC_DESC_ONCE(object_type, process, _step)
Define a process descriptor for a process that runs only once.
Definition process.h:98
A process.
Definition process.h:18

Data blob process descriptor.

Definition at line 99 of file blob.c.

Referenced by blob_open().