iPXE
Data Structures | Macros | Functions
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. More...
 

Functions

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

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 46 of file nvo.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ nvo_applies()

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

◆ nvo_init()

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.

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 273 of file nvo.c.

276  {
277  nvo->nvs = nvs;
278  nvo->address = address;
279  nvo->len = len;
280  nvo->resize = resize;
283  refcnt, NULL );
284 }
struct dhcp_options dhcpopts
DHCP options block.
Definition: nvo.h:42
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:451
uint64_t address
Base address.
Definition: ena.h:24
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:498
A reference counter.
Definition: refcnt.h:26
static int nvo_realloc_dhcpopt(struct dhcp_options *options, size_t len)
Reallocate non-volatile stored options DHCP option block.
Definition: nvo.c:97
struct nvs_device * nvs
Underlying non-volatile storage device.
Definition: nvo.h:26
int(* resize)(struct nvo_block *nvo, size_t len)
Resize non-volatile stored option block.
Definition: nvo.h:40
struct settings settings
Settings block.
Definition: nvo.h:24
unsigned int address
Address within NVS device.
Definition: nvo.h:28
uint32_t len
Length.
Definition: ena.h:14
static struct settings_operations nvo_settings_operations
NVO settings operations.
Definition: nvo.c:257
size_t len
Length of options data.
Definition: nvo.h:30
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

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 
)

Register non-volatile stored options.

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

Definition at line 293 of file nvo.c.

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

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)

Unregister non-volatile stored options.

Parameters
nvoNon-volatile options block

Definition at line 324 of file nvo.c.

324  {
325  unregister_settings ( &nvo->settings );
326  nvo_realloc ( nvo, 0 );
327  DBGC ( nvo, "NVO %p unregistered\n", nvo );
328 }
void unregister_settings(struct settings *settings)
Unregister settings block.
Definition: settings.c:514
#define DBGC(...)
Definition: compiler.h:505
struct settings settings
Settings block.
Definition: nvo.h:24
static int nvo_realloc(struct nvo_block *nvo, size_t len)
Reallocate non-volatile stored options block.
Definition: nvo.c:64

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