iPXE
Data Structures | Defines | 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...

Defines

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

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


Define Documentation

#define NVO_SETTINGS_NAME   "nvo"

Name of non-volatile options settings block.

Definition at line 46 of file nvo.h.

Referenced by efi_snp_hii_settings(), and register_nvo().


Function Documentation

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

References nvo_block::address, address, dhcpopt_init(), nvo_block::dhcpopts, nvo_block::len, len, NULL, nvo_realloc_dhcpopt(), 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().

                                        {
        nvo->nvs = nvs;
        nvo->address = address;
        nvo->len = len;
        nvo->resize = resize;
        dhcpopt_init ( &nvo->dhcpopts, NULL, 0, nvo_realloc_dhcpopt );
        settings_init ( &nvo->settings, &nvo_settings_operations,
                        refcnt, NULL );
}
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.

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

                                                                    {
        int rc;

        /* Allocate memory for options */
        if ( ( rc = nvo_realloc ( nvo, nvo->len ) ) != 0 )
                goto err_realloc;

        /* Read data from NVS */
        if ( ( rc = nvo_load ( nvo ) ) != 0 )
                goto err_load;

        /* Register settings */
        if ( ( rc = register_settings ( &nvo->settings, parent,
                                        NVO_SETTINGS_NAME ) ) != 0 )
                goto err_register;

        DBGC ( nvo, "NVO %p registered\n", nvo );
        return 0;
        
 err_register:
 err_load:
        nvo_realloc ( nvo, 0 );
 err_realloc:
        return rc;
}
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.

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

                                              {
        unregister_settings ( &nvo->settings );
        nvo_realloc ( nvo, 0 );
        DBGC ( nvo, "NVO %p unregistered\n", nvo );
}