smbios_settings.c File Reference

#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <gpxe/settings.h>
#include <gpxe/init.h>
#include <gpxe/uuid.h>
#include <gpxe/smbios.h>

Go to the source code of this file.

Defines

#define SMBIOS_TAG_MAGIC   0x5B
 SMBIOS settings tag magic number.
#define SMBIOS_EMPTY_TAG   ( SMBIOS_TAG_MAGIC << 24 )
 Construct SMBIOS empty tag.
#define SMBIOS_RAW_TAG(_type, _structure, _field)
 Construct SMBIOS raw-data tag.
#define SMBIOS_STRING_TAG(_type, _structure, _field)
 Construct SMBIOS string tag.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
static int smbios_fetch (struct settings *settings __unused, struct setting *setting, void *data, size_t len)
 Fetch value of SMBIOS setting.
static void smbios_init (void)
 Initialise SMBIOS settings.
struct init_fn smbios_init_fn __init_fn (INIT_NORMAL)
 SMBIOS settings initialiser.

Variables

static struct settings_operations smbios_settings_operations
 SMBIOS settings operations.
static struct settings smbios_settings
 SMBIOS settings.
struct setting uuid_setting __setting
 UUID setting obtained via SMBIOS.


Define Documentation

#define SMBIOS_TAG_MAGIC   0x5B

SMBIOS settings tag magic number.

Definition at line 30 of file smbios_settings.c.

Referenced by smbios_fetch().

#define SMBIOS_EMPTY_TAG   ( SMBIOS_TAG_MAGIC << 24 )

Construct SMBIOS empty tag.

Return values:
tag SMBIOS setting tag

Definition at line 37 of file smbios_settings.c.

#define SMBIOS_RAW_TAG ( _type,
_structure,
_field   ) 

Value:

( ( SMBIOS_TAG_MAGIC << 24 ) |                          \
          ( (_type) << 16 ) |                                   \
          ( offsetof ( _structure, _field ) << 8 ) |            \
          ( sizeof ( ( ( _structure * ) 0 )->_field ) ) )
Construct SMBIOS raw-data tag.

Parameters:
_type SMBIOS structure type number
_structure SMBIOS structure data type
_field Field within SMBIOS structure data type
Return values:
tag SMBIOS setting tag

Definition at line 47 of file smbios_settings.c.

#define SMBIOS_STRING_TAG ( _type,
_structure,
_field   ) 

Value:

( ( SMBIOS_TAG_MAGIC << 24 ) |                          \
          ( (_type) << 16 ) |                                   \
          ( offsetof ( _structure, _field ) << 8 ) )
Construct SMBIOS string tag.

Parameters:
_type SMBIOS structure type number
_structure SMBIOS structure data type
_field Field within SMBIOS structure data type
Return values:
tag SMBIOS setting tag

Definition at line 61 of file smbios_settings.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

static int smbios_fetch ( struct settings *settings  __unused,
struct setting setting,
void *  data,
size_t  len 
) [static]

Fetch value of SMBIOS setting.

Parameters:
settings Settings block, or NULL to search all blocks
setting Setting to fetch
data Buffer to fill with setting data
len Length of buffer
Return values:
len Length of setting data, or negative error

Definition at line 75 of file smbios_settings.c.

References ENOENT, find_smbios_structure(), smbios_structure::header, smbios_header::len, memcpy, read_smbios_string(), read_smbios_structure(), SMBIOS_TAG_MAGIC, and setting::tag.

00077                                                    {
00078         struct smbios_structure structure;
00079         unsigned int tag_magic;
00080         unsigned int tag_type;
00081         unsigned int tag_offset;
00082         unsigned int tag_len;
00083         int rc;
00084 
00085         /* Split tag into type, offset and length */
00086         tag_magic = ( setting->tag >> 24 );
00087         tag_type = ( ( setting->tag >> 16 ) & 0xff );
00088         tag_offset = ( ( setting->tag >> 8 ) & 0xff );
00089         tag_len = ( setting->tag & 0xff );
00090         if ( tag_magic != SMBIOS_TAG_MAGIC )
00091                 return -ENOENT;
00092 
00093         /* Find SMBIOS structure */
00094         if ( ( rc = find_smbios_structure ( tag_type, &structure ) ) != 0 )
00095                 return rc;
00096 
00097         {
00098                 uint8_t buf[structure.header.len];
00099 
00100                 /* Read SMBIOS structure */
00101                 if ( ( rc = read_smbios_structure ( &structure, buf,
00102                                                     sizeof ( buf ) ) ) != 0 )
00103                         return rc;
00104 
00105                 if ( tag_len == 0 ) {
00106                         /* String */
00107                         return read_smbios_string ( &structure,
00108                                                     buf[tag_offset],
00109                                                     data, len );
00110                 } else {
00111                         /* Raw data */
00112                         if ( len > tag_len )
00113                                 len = tag_len;
00114                         memcpy ( data, &buf[tag_offset], len );
00115                         return tag_len;
00116                 }
00117         }
00118 }

static void smbios_init ( void   )  [static]

Initialise SMBIOS settings.

Definition at line 136 of file smbios_settings.c.

References DBG, NULL, register_settings(), and strerror().

00136                                  {
00137         int rc;
00138 
00139         if ( ( rc = register_settings ( &smbios_settings, NULL ) ) != 0 ) {
00140                 DBG ( "SMBIOS could not register settings: %s\n",
00141                       strerror ( rc ) );
00142                 return;
00143         }
00144 }

struct init_fn smbios_init_fn __init_fn ( INIT_NORMAL   )  [read]

SMBIOS settings initialiser.


Variable Documentation

Initial value:

 {
        .fetch = smbios_fetch,
}
SMBIOS settings operations.

Definition at line 121 of file smbios_settings.c.

struct settings smbios_settings [static]

Initial value:

 {
        .refcnt = NULL,
        .name = "smbios",
        .tag_magic = SMBIOS_EMPTY_TAG,
        .siblings = LIST_HEAD_INIT ( smbios_settings.siblings ),
        .children = LIST_HEAD_INIT ( smbios_settings.children ),
        .op = &smbios_settings_operations,
}
SMBIOS settings.

Definition at line 126 of file smbios_settings.c.


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