nvo.h File Reference

Non-volatile stored options. More...

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

Go to the source code of this file.

Data Structures

struct  nvo_fragment
 A fragment of a non-volatile storage device used for stored options. More...
struct  nvo_block
 A block of non-volatile stored options. More...

Functions

 FILE_LICENCE (GPL2_OR_LATER)
void nvo_init (struct nvo_block *nvo, struct nvs_device *nvs, struct nvo_fragment *fragments, 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.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

void nvo_init ( struct nvo_block nvo,
struct nvs_device nvs,
struct nvo_fragment fragments,
struct refcnt refcnt 
)

Initialise non-volatile stored options.

Parameters:
nvo Non-volatile options block
nvs Underlying non-volatile storage device
fragments List of option-containing fragments
refcnt Containing object reference counter, or NULL

Definition at line 203 of file nvo.c.

References nvo_block::fragments, nvo_block::nvs, nvo_block::settings, and settings_init().

Referenced by falcon_probe_spi(), and rtl_init_eeprom().

00204                                                                         {
00205         nvo->nvs = nvs;
00206         nvo->fragments = fragments;
00207         settings_init ( &nvo->settings, &nvo_settings_operations, refcnt,
00208                         "nvo", 0 );
00209 }

int register_nvo ( struct nvo_block nvo,
struct settings parent 
)

Register non-volatile stored options.

Parameters:
nvo Non-volatile options block
parent Parent settings block, or NULL
Return values:
rc Return status code

Definition at line 218 of file nvo.c.

References nvo_block::data, DBGC, ENOMEM, nvo_block::fragments, free(), nvo_fragment::len, malloc(), NULL, nvo_init_dhcpopts(), nvo_load(), register_settings(), nvo_block::settings, and nvo_block::total_len.

Referenced by efab_probe(), and rtl_probe().

00218                                                                     {
00219         struct nvo_fragment *fragment = nvo->fragments;
00220         int rc;
00221 
00222         /* Calculate total length of all fragments */
00223         for ( fragment = nvo->fragments ; fragment->len ; fragment++ )
00224                 nvo->total_len += fragment->len;
00225 
00226         /* Allocate memory for options and read in from NVS */
00227         nvo->data = malloc ( nvo->total_len );
00228         if ( ! nvo->data ) {
00229                 DBGC ( nvo, "NVO %p could not allocate %zd bytes\n",
00230                        nvo, nvo->total_len );
00231                 rc = -ENOMEM;
00232                 goto err_malloc;
00233         }
00234         if ( ( rc = nvo_load ( nvo ) ) != 0 )
00235                 goto err_load;
00236 
00237         /* Verify and register options */
00238         nvo_init_dhcpopts ( nvo );
00239         if ( ( rc = register_settings ( &nvo->settings, parent ) ) != 0 )
00240                 goto err_register;
00241 
00242         DBGC ( nvo, "NVO %p registered\n", nvo );
00243         return 0;
00244         
00245  err_register:
00246  err_load:
00247         free ( nvo->data );
00248         nvo->data = NULL;
00249  err_malloc:
00250         return rc;
00251 }

void unregister_nvo ( struct nvo_block nvo  ) 

Unregister non-volatile stored options.

Parameters:
nvo Non-volatile options block

Definition at line 258 of file nvo.c.

References nvo_block::data, DBGC, free(), NULL, nvo_block::settings, and unregister_settings().

Referenced by efab_remove(), and rtl_remove().

00258                                               {
00259         unregister_settings ( &nvo->settings );
00260         free ( nvo->data );
00261         nvo->data = NULL;
00262         DBGC ( nvo, "NVO %p unregistered\n", nvo );
00263 }


Generated on Tue Apr 6 20:01:51 2010 for gPXE by  doxygen 1.5.7.1