iPXE
|
Non-volatile stored options. More...
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ipxe/dhcp.h>
#include <ipxe/nvs.h>
#include <ipxe/nvo.h>
Go to the source code of this file.
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static unsigned int | nvo_checksum (struct nvo_block *nvo) |
Calculate checksum over non-volatile stored options. More... | |
static int | nvo_realloc (struct nvo_block *nvo, size_t len) |
Reallocate non-volatile stored options block. More... | |
static int | nvo_realloc_dhcpopt (struct dhcp_options *options, size_t len) |
Reallocate non-volatile stored options DHCP option block. More... | |
static int | nvo_load (struct nvo_block *nvo) |
Load non-volatile stored options from non-volatile storage device. More... | |
static int | nvo_save (struct nvo_block *nvo) |
Save non-volatile stored options back to non-volatile storage device. More... | |
int | nvo_applies (struct settings *settings __unused, const struct setting *setting) |
Check applicability of NVO setting. More... | |
static int | nvo_store (struct settings *settings, const struct setting *setting, const void *data, size_t len) |
Store value of NVO setting. More... | |
static int | nvo_fetch (struct settings *settings, struct setting *setting, void *data, size_t len) |
Fetch value of NVO setting. More... | |
void | nvo_init (struct nvo_block *nvo, struct nvs_device *nvs, size_t address, size_t len, int(*resize)(struct nvo_block *nvo, size_t len), struct refcnt *refcnt) |
Initialise non-volatile stored options. More... | |
int | register_nvo (struct nvo_block *nvo, struct settings *parent) |
Register non-volatile stored options. More... | |
void | unregister_nvo (struct nvo_block *nvo) |
Unregister non-volatile stored options. More... | |
Variables | |
static struct settings_operations | nvo_settings_operations |
NVO settings operations. More... | |
Non-volatile stored options.
Definition in file nvo.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Calculate checksum over non-volatile stored options.
nvo | Non-volatile options block |
sum | Checksum |
Definition at line 46 of file nvo.c.
References data, nvo_block::data, and nvo_block::len.
Referenced by nvo_load(), and nvo_save().
Reallocate non-volatile stored options block.
nvo | Non-volatile options block |
len | New length |
rc | Return status code |
Definition at line 64 of file nvo.c.
References dhcp_options::alloc_len, dhcp_options::data, nvo_block::data, DBGC, nvo_block::dhcpopts, ENOMEM, len, nvo_block::len, NULL, realloc(), and dhcp_options::used_len.
Referenced by nvo_realloc_dhcpopt(), register_nvo(), and unregister_nvo().
|
static |
Reallocate non-volatile stored options DHCP option block.
options | DHCP option block |
len | New length |
rc | Return status code |
Definition at line 97 of file nvo.c.
References container_of, DBGC, dhcpopt_no_realloc(), nvo_block::dhcpopts, len, nvo_realloc(), options, rc, nvo_block::resize, and strerror().
Referenced by nvo_init().
|
static |
Load non-volatile stored options from non-volatile storage device.
nvo | Non-volatile options block |
rc | Return status code |
Definition at line 130 of file nvo.c.
References nvo_block::address, dhcp_options::data, nvo_block::data, DBGC, dhcpopt_update_used_len(), nvo_block::dhcpopts, nvo_block::len, memset(), nvo_checksum(), nvo_block::nvs, nvs_read(), rc, and strerror().
Referenced by register_nvo().
|
static |
Save non-volatile stored options back to non-volatile storage device.
nvo | Non-volatile options block |
rc | Return status code |
Definition at line 172 of file nvo.c.
References nvo_block::address, checksum, nvo_block::data, DBGC, nvo_block::len, nvo_checksum(), nvo_block::nvs, nvs_write(), rc, and strerror().
Referenced by nvo_store().
Check applicability of NVO setting.
settings | Settings block |
setting | Setting |
applies | Setting applies within this settings block |
Definition at line 199 of file nvo.c.
References dhcpopt_applies(), NULL, setting::scope, and setting::tag.
Referenced by efi_snp_hii_setting_applies().
|
static |
Store value of NVO setting.
settings | Settings block |
setting | Setting to store |
data | Setting data, or NULL to clear setting |
len | Length of setting data |
rc | Return status code |
Definition at line 215 of file nvo.c.
References container_of, data, DBGC, dhcpopt_store(), nvo_block::dhcpopts, len, nvo_save(), rc, strerror(), and setting::tag.
|
static |
Fetch value of NVO setting.
settings | Settings block |
setting | Setting to fetch |
data | Buffer to fill with setting data |
len | Length of buffer |
len | Length of setting data, or negative error |
The actual length of the setting will be returned even if the buffer was too small.
Definition at line 248 of file nvo.c.
References container_of, data, dhcpopt_fetch(), nvo_block::dhcpopts, len, and setting::tag.
void nvo_init | ( | struct nvo_block * | nvo, |
struct nvs_device * | nvs, | ||
size_t | address, | ||
size_t | len, | ||
int(*)(struct nvo_block *nvo, size_t len) | resize, | ||
struct refcnt * | refcnt | ||
) |
Initialise non-volatile stored options.
nvo | Non-volatile options block |
nvs | Underlying non-volatile storage device |
address | Address within NVS device |
len | Length of non-volatile options data |
resize | Resize method |
refcnt | Containing object reference counter, or NULL |
Definition at line 273 of file nvo.c.
References address, nvo_block::address, dhcpopt_init(), nvo_block::dhcpopts, len, nvo_block::len, NULL, nvo_realloc_dhcpopt(), nvo_settings_operations, nvo_block::nvs, nvo_block::resize, nvo_block::settings, and settings_init().
Referenced by falcon_probe_spi(), myri10ge_nv_init(), nvs_vpd_nvo_init(), and realtek_init_eeprom().
Register non-volatile stored options.
nvo | Non-volatile options block |
parent | Parent settings block, or NULL |
rc | Return status code |
Definition at line 293 of file nvo.c.
References DBGC, nvo_block::len, nvo_load(), nvo_realloc(), NVO_SETTINGS_NAME, rc, register_settings(), and nvo_block::settings.
Referenced by efab_probe(), hermon_register_netdev(), myri10ge_nv_init(), and realtek_probe().
void unregister_nvo | ( | struct nvo_block * | nvo | ) |
Unregister non-volatile stored options.
nvo | Non-volatile options block |
Definition at line 324 of file nvo.c.
References DBGC, nvo_realloc(), nvo_block::settings, and unregister_settings().
Referenced by efab_remove(), hermon_register_netdev(), hermon_unregister_netdev(), myri10ge_nv_fini(), and realtek_remove().
|
static |
NVO settings operations.
Definition at line 257 of file nvo.c.
Referenced by nvo_init().