Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
EFI variables

EFI variables API for Soletta. More...

Macros

#define CREATE_BLOB(_val)
 Macro to create a struct sol_blob with value passed as argument. More...
 
#define CREATE_BUFFER(_val)
 Macro to create a struct sol_buffer with value passed as argument and flags SOL_BUFFER_FLAGS_MEMORY_NOT_OWNED and SOL_BUFFER_FLAGS_NO_NUL_BYTE. More...
 

Functions

static int sol_efivars_read_bool (const char *name, bool *value)
 Reads a boolean from the EFI given variable and set to value. More...
 
static int sol_efivars_read_double (const char *name, double *value)
 Reads a double from the EFI given variable and set to value. More...
 
static int sol_efivars_read_drange (const char *name, struct sol_drange *value)
 Reads a sol_drange from the EFI given variable and set to value. More...
 
static int sol_efivars_read_int32 (const char *name, int32_t *value)
 Reads an int32_t from the EFI given variable and set to value. More...
 
static int sol_efivars_read_irange (const char *name, struct sol_irange *value)
 Reads a sol_irange from the EFI given variable and set to value. More...
 
int sol_efivars_read_raw (const char *name, struct sol_buffer *buffer)
 Read stored contents and set to buffer. More...
 
static int sol_efivars_read_string (const char *name, char **value)
 Reads a string from the EFI given variable and set to value. More...
 
static int sol_efivars_read_uint8 (const char *name, uint8_t *value)
 Reads an uint8_t from the EFI given variable and set to value. More...
 
static int sol_efivars_write_bool (const char *name, bool value, void(*cb)(void *data, const char *name, struct sol_blob *blob, int status), const void *data)
 Writes a boolean into an EFI variable. More...
 
static int sol_efivars_write_double (const char *name, double value, void(*cb)(void *data, const char *name, struct sol_blob *blob, int status), const void *data)
 Writes a double into an EFI variable. More...
 
static int sol_efivars_write_drange (const char *name, struct sol_drange *value, void(*cb)(void *data, const char *name, struct sol_blob *blob, int status), const void *data)
 Writes a sol_drange into an EFI variable. More...
 
static int sol_efivars_write_int32 (const char *name, int32_t value, void(*cb)(void *data, const char *name, struct sol_blob *blob, int status), const void *data)
 Writes an int32_t into an EFI variable. More...
 
static int sol_efivars_write_irange (const char *name, struct sol_irange *value, void(*cb)(void *data, const char *name, struct sol_blob *blob, int status), const void *data)
 Writes a sol_irange into an EFI variable. More...
 
int sol_efivars_write_raw (const char *name, struct sol_blob *blob, void(*cb)(void *data, const char *name, struct sol_blob *blob, int status), const void *data)
 Writes buffer contents to storage. More...
 
static int sol_efivars_write_string (const char *name, const char *value, void(*cb)(void *data, const char *name, struct sol_blob *blob, int status), const void *data)
 Writes a string into an EFI variable. More...
 
static int sol_efivars_write_uint8 (const char *name, uint8_t value, void(*cb)(void *data, const char *name, struct sol_blob *blob, int status), const void *data)
 Writes an uint8_t into an EFI variable. More...
 

Detailed Description

EFI variables API for Soletta.

Macro Definition Documentation

#define CREATE_BLOB (   _val)
Value:
struct sol_blob *blob; \
size_t _s = sizeof(*_val); \
void *v = malloc(_s); \
SOL_NULL_CHECK(v, -ENOMEM); \
memcpy(v, _val, _s); \
blob = sol_blob_new(&SOL_BLOB_TYPE_DEFAULT, NULL, v, _s); \
if (!blob) { \
free(v); \
return -EINVAL; \
}
#define SOL_NULL_CHECK(ptr,...)
Convenience macro to check for NULL pointer.
Definition: sol-log.h:223
struct sol_blob * sol_blob_new(const struct sol_blob_type *type, struct sol_blob *parent, const void *mem, size_t size)
Creates a new blob instance of the given type type.
const struct sol_blob_type SOL_BLOB_TYPE_DEFAULT
Blob type object for the default implementation.
Data type describing the default blob implementation.
Definition: sol-types.h:468

Macro to create a struct sol_blob with value passed as argument.

Referenced by sol_efivars_write_bool(), sol_efivars_write_double(), sol_efivars_write_drange(), sol_efivars_write_int32(), sol_efivars_write_irange(), and sol_efivars_write_uint8().

#define CREATE_BUFFER (   _val)
Value:
struct sol_buffer buf = SOL_BUFFER_INIT_FLAGS(_val, \
Buffers where the buf->data is not owned by sol_buffer, that is, it can't be resized and free() should...
Definition: sol-buffer.h:88
#define SOL_BUFFER_INIT_FLAGS(data_, size_, flags_)
Helper macro to initialize an buffer with the given data and flags.
Definition: sol-buffer.h:164
A sol_buffer is a dynamic array, that can be resized if needed.
Definition: sol-buffer.h:130
Do not reserve space for the NUL byte.
Definition: sol-buffer.h:92

Macro to create a struct sol_buffer with value passed as argument and flags SOL_BUFFER_FLAGS_MEMORY_NOT_OWNED and SOL_BUFFER_FLAGS_NO_NUL_BYTE.

Referenced by sol_efivars_read_bool(), sol_efivars_read_double(), sol_efivars_read_drange(), sol_efivars_read_int32(), sol_efivars_read_irange(), and sol_efivars_read_uint8().

Function Documentation

static int sol_efivars_read_bool ( const char *  name,
bool *  value 
)
inlinestatic

Reads a boolean from the EFI given variable and set to value.

This function will read the contents of the EFI variable name into the variable value.

Parameters
namename of property. It will look for an EFI variable with this name.
valueThe variable that will be set with read contents.

return 0 on success, a negative number on failure

References CREATE_BUFFER, and sol_efivars_read_raw().

static int sol_efivars_read_double ( const char *  name,
double *  value 
)
inlinestatic

Reads a double from the EFI given variable and set to value.

This function will read the contents of the EFI variable name into the variable value.

Parameters
namename of property. It will look for an EFI variable with this name.
valueThe variable that will be set with read contents.

return 0 on success, a negative number on failure

References CREATE_BUFFER, and sol_efivars_read_raw().

static int sol_efivars_read_drange ( const char *  name,
struct sol_drange value 
)
inlinestatic

Reads a sol_drange from the EFI given variable and set to value.

This function will read the contents of the EFI variable name into the variable value.

Parameters
namename of property. It will look for an EFI variable with this name.
valueThe variable that will be set with read contents.

return 0 on success, a negative number on failure

References CREATE_BUFFER, and sol_efivars_read_raw().

static int sol_efivars_read_int32 ( const char *  name,
int32_t *  value 
)
inlinestatic

Reads an int32_t from the EFI given variable and set to value.

This function will read the contents of the EFI variable name into the variable value.

Parameters
namename of property. It will look for an EFI variable with this name.
valueThe variable that will be set with read contents.

return 0 on success, a negative number on failure

References CREATE_BUFFER, and sol_efivars_read_raw().

static int sol_efivars_read_irange ( const char *  name,
struct sol_irange value 
)
inlinestatic

Reads a sol_irange from the EFI given variable and set to value.

This function will read the contents of the EFI variable name into the variable value.

Parameters
namename of property. It will look for an EFI variable with this name.
valueThe variable that will be set with read contents.

return 0 on success, a negative number on failure

References CREATE_BUFFER, and sol_efivars_read_raw().

int sol_efivars_read_raw ( const char *  name,
struct sol_buffer buffer 
)

Read stored contents and set to buffer.

This function will read the contents of the EFI variable name into the buffer buffer. It will try to resize the buffer if needed.

Parameters
namename of property. It will look for an EFI variable with this name.
bufferbuffer that will be set with read contents.

return 0 on success, a negative number on failure

Referenced by sol_efivars_read_bool(), sol_efivars_read_double(), sol_efivars_read_drange(), sol_efivars_read_int32(), sol_efivars_read_irange(), sol_efivars_read_string(), and sol_efivars_read_uint8().

static int sol_efivars_read_string ( const char *  name,
char **  value 
)
inlinestatic

Reads a string from the EFI given variable and set to value.

This function will read the contents of the EFI variable name into the variable value.

Parameters
namename of property. It will look for an EFI variable with this name.
valueThe variable that will be set with read contents.

return 0 on success, a negative number on failure

References sol_buffer_fini(), SOL_BUFFER_INIT_EMPTY, sol_buffer_steal(), and sol_efivars_read_raw().

static int sol_efivars_read_uint8 ( const char *  name,
uint8_t *  value 
)
inlinestatic

Reads an uint8_t from the EFI given variable and set to value.

This function will read the contents of the EFI variable name into the variable value.

Parameters
namename of property. It will look for an EFI variable with this name.
valueThe variable that will be set with read contents.

return 0 on success, a negative number on failure

References CREATE_BUFFER, and sol_efivars_read_raw().

static int sol_efivars_write_bool ( const char *  name,
bool  value,
void(*)(void *data, const char *name, struct sol_blob *blob, int status)  cb,
const void *  data 
)
inlinestatic

Writes a boolean into an EFI variable.

This function uses sol_efivars_write_raw() internally, the same behaviour should be considered.

Parameters
namename of property. It will create a new EFI variable with this name.
valueThe value to be written.
cbcallback to be called when writing finishes. It contains status of writing: if failed, is lesser than zero.
datauser data to be sent to callback cb

return 0 on success, a negative number on failure

References CREATE_BLOB, sol_blob_unref(), and sol_efivars_write_raw().

static int sol_efivars_write_double ( const char *  name,
double  value,
void(*)(void *data, const char *name, struct sol_blob *blob, int status)  cb,
const void *  data 
)
inlinestatic

Writes a double into an EFI variable.

This function uses sol_efivars_write_raw() internally, the same behaviour should be considered.

Parameters
namename of property. It will create a new EFI variable with this name.
valueThe value to be written.
cbcallback to be called when writing finishes. It contains status of writing: if failed, is lesser than zero.
datauser data to be sent to callback cb

return 0 on success, a negative number on failure

References CREATE_BLOB, sol_blob_unref(), and sol_efivars_write_raw().

static int sol_efivars_write_drange ( const char *  name,
struct sol_drange value,
void(*)(void *data, const char *name, struct sol_blob *blob, int status)  cb,
const void *  data 
)
inlinestatic

Writes a sol_drange into an EFI variable.

This function uses sol_efivars_write_raw() internally, the same behaviour should be considered.

Parameters
namename of property. It will create a new EFI variable with this name.
valueThe value to be written.
cbcallback to be called when writing finishes. It contains status of writing: if failed, is lesser than zero.
datauser data to be sent to callback cb

return 0 on success, a negative number on failure

References CREATE_BLOB, sol_blob_unref(), and sol_efivars_write_raw().

static int sol_efivars_write_int32 ( const char *  name,
int32_t  value,
void(*)(void *data, const char *name, struct sol_blob *blob, int status)  cb,
const void *  data 
)
inlinestatic

Writes an int32_t into an EFI variable.

This function uses sol_efivars_write_raw() internally, the same behaviour should be considered.

Parameters
namename of property. It will create a new EFI variable with this name.
valueThe value to be written.
cbcallback to be called when writing finishes. It contains status of writing: if failed, is lesser than zero.
datauser data to be sent to callback cb

return 0 on success, a negative number on failure

References CREATE_BLOB, sol_blob_unref(), and sol_efivars_write_raw().

static int sol_efivars_write_irange ( const char *  name,
struct sol_irange value,
void(*)(void *data, const char *name, struct sol_blob *blob, int status)  cb,
const void *  data 
)
inlinestatic

Writes a sol_irange into an EFI variable.

This function uses sol_efivars_write_raw() internally, the same behaviour should be considered.

Parameters
namename of property. It will create a new EFI variable with this name.
valueThe value to be written.
cbcallback to be called when writing finishes. It contains status of writing: if failed, is lesser than zero.
datauser data to be sent to callback cb

return 0 on success, a negative number on failure

References CREATE_BLOB, sol_blob_unref(), and sol_efivars_write_raw().

int sol_efivars_write_raw ( const char *  name,
struct sol_blob blob,
void(*)(void *data, const char *name, struct sol_blob *blob, int status)  cb,
const void *  data 
)

Writes buffer contents to storage.

Note that as writing operations are asynchronous, to check if it completely succeeded, one needs to register a callback that will inform writing result.

Parameters
namename of property. It will create a new EFI variable with this name.
blobblob that will be written
cbcallback to be called when writing finishes. It contains status of writing: if failed, is lesser than zero.
datauser data to be sent to callback cb

return 0 on success, a negative number on failure

Referenced by sol_efivars_write_bool(), sol_efivars_write_double(), sol_efivars_write_drange(), sol_efivars_write_int32(), sol_efivars_write_irange(), sol_efivars_write_string(), and sol_efivars_write_uint8().

static int sol_efivars_write_string ( const char *  name,
const char *  value,
void(*)(void *data, const char *name, struct sol_blob *blob, int status)  cb,
const void *  data 
)
inlinestatic

Writes a string into an EFI variable.

This function uses sol_efivars_write_raw() internally, the same behaviour should be considered.

Parameters
namename of property. It will create a new EFI variable with this name.
valueThe value to be written.
cbcallback to be called when writing finishes. It contains status of writing: if failed, is lesser than zero.
datauser data to be sent to callback cb

return 0 on success, a negative number on failure

References sol_blob_new(), SOL_BLOB_TYPE_DEFAULT, sol_blob_unref(), sol_efivars_write_raw(), SOL_NULL_CHECK, and SOL_NULL_CHECK_GOTO.

static int sol_efivars_write_uint8 ( const char *  name,
uint8_t  value,
void(*)(void *data, const char *name, struct sol_blob *blob, int status)  cb,
const void *  data 
)
inlinestatic

Writes an uint8_t into an EFI variable.

This function uses sol_efivars_write_raw() internally, the same behaviour should be considered.

Parameters
namename of property. It will create a new EFI variable with this name.
valueThe value to be written.
cbcallback to be called when writing finishes. It contains status of writing: if failed, is lesser than zero.
datauser data to be sent to callback cb

return 0 on success, a negative number on failure

References CREATE_BLOB, sol_blob_unref(), and sol_efivars_write_raw().