iPXE
nvo.h File Reference

Non-volatile stored options. More...

#include <stdint.h>
#include <ipxe/dhcpopts.h>
#include <ipxe/settings.h>

Go to the source code of this file.

Data Structures

struct  nvo_block
 A block of non-volatile stored options. More...

Macros

#define NVO_SETTINGS_NAME   "nvo"
 Name of non-volatile options settings block.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
int nvo_applies (struct settings *settings, const struct setting *setting)
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.
int register_nvo (struct nvo_block *nvo, struct settings *parent)
 Register non-volatile stored options.
void unregister_nvo (struct nvo_block *nvo)
 Unregister non-volatile stored options.

Detailed Description

Non-volatile stored options.

Definition in file nvo.h.

Macro Definition Documentation

◆ NVO_SETTINGS_NAME

#define NVO_SETTINGS_NAME   "nvo"

Name of non-volatile options settings block.

Definition at line 47 of file nvo.h.

Referenced by efi_snp_hii_settings(), and register_nvo().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ nvo_applies()

int nvo_applies ( struct settings * settings,
const struct setting * setting )
extern

References address, and len.

◆ nvo_init()

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 )
extern

Initialise non-volatile stored options.

Parameters
nvoNon-volatile options block
nvsUnderlying non-volatile storage device
addressAddress within NVS device
lenLength of non-volatile options data
resizeResize method
refcntContaining object reference counter, or NULL

Definition at line 274 of file nvo.c.

277 {
278 nvo->nvs = nvs;
279 nvo->address = address;
280 nvo->len = len;
281 nvo->resize = resize;
284 refcnt, NULL );
285}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
void dhcpopt_init(struct dhcp_options *options, void *data, size_t alloc_len, int(*realloc)(struct dhcp_options *options, size_t len))
Initialise prepopulated block of DHCP options.
Definition dhcpopts.c:452
ring len
Length.
Definition dwmac.h:226
uint64_t address
Base address.
Definition ena.h:13
static void settings_init(struct settings *settings, struct settings_operations *op, struct refcnt *refcnt, const struct settings_scope *default_scope)
Initialise a settings block.
Definition settings.h:503
static int nvo_realloc_dhcpopt(struct dhcp_options *options, size_t len)
Reallocate non-volatile stored options DHCP option block.
Definition nvo.c:98
static struct settings_operations nvo_settings_operations
NVO settings operations.
Definition nvo.c:258
size_t len
Length of options data.
Definition nvo.h:31
int(* resize)(struct nvo_block *nvo, size_t len)
Resize non-volatile stored option block.
Definition nvo.h:41
struct settings settings
Settings block.
Definition nvo.h:25
unsigned int address
Address within NVS device.
Definition nvo.h:29
struct dhcp_options dhcpopts
DHCP options block.
Definition nvo.h:43
struct nvs_device * nvs
Underlying non-volatile storage device.
Definition nvo.h:27
A reference counter.
Definition refcnt.h:27

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_nvo()

int register_nvo ( struct nvo_block * nvo,
struct settings * parent )
extern

Register non-volatile stored options.

Parameters
nvoNon-volatile options block
parentParent settings block, or NULL
Return values
rcReturn status code

Definition at line 294 of file nvo.c.

294 {
295 int rc;
296
297 /* Allocate memory for options */
298 if ( ( rc = nvo_realloc ( nvo, nvo->len ) ) != 0 )
299 goto err_realloc;
300
301 /* Read data from NVS */
302 if ( ( rc = nvo_load ( nvo ) ) != 0 )
303 goto err_load;
304
305 /* Register settings */
306 if ( ( rc = register_settings ( &nvo->settings, parent,
307 NVO_SETTINGS_NAME ) ) != 0 )
308 goto err_register;
309
310 DBGC ( nvo, "NVO %p registered\n", nvo );
311 return 0;
312
313 err_register:
314 err_load:
315 nvo_realloc ( nvo, 0 );
316 err_realloc:
317 return rc;
318}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
#define DBGC(...)
Definition compiler.h:505
static int nvo_realloc(struct nvo_block *nvo, size_t len)
Reallocate non-volatile stored options block.
Definition nvo.c:65
static int nvo_load(struct nvo_block *nvo)
Load non-volatile stored options from non-volatile storage device.
Definition nvo.c:131
#define NVO_SETTINGS_NAME
Name of non-volatile options settings block.
Definition nvo.h:47
int register_settings(struct settings *settings, struct settings *parent, const char *name)
Register settings block.
Definition settings.c:476

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().

◆ unregister_nvo()

void unregister_nvo ( struct nvo_block * nvo)
extern

Unregister non-volatile stored options.

Parameters
nvoNon-volatile options block

Definition at line 325 of file nvo.c.

325 {
327 nvo_realloc ( nvo, 0 );
328 DBGC ( nvo, "NVO %p unregistered\n", nvo );
329}
void unregister_settings(struct settings *settings)
Unregister settings block.
Definition settings.c:515

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().