iPXE
Functions | Variables
pci_settings.c File Reference

PCI device settings. More...

#include <stdio.h>
#include <errno.h>
#include <ipxe/pci.h>
#include <ipxe/settings.h>
#include <ipxe/init.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static int pci_settings_applies (struct settings *settings __unused, const struct setting *setting)
 Check applicability of PCI device setting.
static int pci_settings_fetch (struct settings *settings __unused, struct setting *setting, void *data, size_t len)
 Fetch value of PCI device setting.
static void pci_settings_init (void)
 Initialise PCI device settings.
struct init_fn pci_settings_init_fn __init_fn (INIT_NORMAL)
 PCI device settings initialiser.

Variables

static struct settings_scope pci_settings_scope
 PCI device settings scope.
static struct settings_operations pci_settings_operations
 PCI device settings operations.
static struct settings pci_settings
 PCI device settings.

Detailed Description

PCI device settings.

Definition in file pci_settings.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static int pci_settings_applies ( struct settings *settings  __unused,
const struct setting setting 
) [static]

Check applicability of PCI device setting.

Parameters:
settingsSettings block
settingSetting
Return values:
appliesSetting applies within this settings block

Definition at line 48 of file pci_settings.c.

References pci_settings_scope, and setting::scope.

                                                                  {

        return ( setting->scope == &pci_settings_scope );
}
static int pci_settings_fetch ( struct settings *settings  __unused,
struct setting setting,
void *  data,
size_t  len 
) [static]

Fetch value of PCI device setting.

Parameters:
settingsSettings block
settingSetting to fetch
dataBuffer to fill with setting data
lenLength of buffer
Return values:
lenLength of setting data, or negative error

Definition at line 63 of file pci_settings.c.

References DBG, memset(), PCI_ARGS, PCI_FMT, pci_init(), pci_read_config_byte(), setting::tag, and setting::type.

                                                         {
        struct pci_device pci;
        unsigned int tag_busdevfn;
        unsigned int tag_offset;
        unsigned int tag_len;
        unsigned int i;

        /* Extract busdevfn, offset, and length from tag */
        tag_busdevfn = ( setting->tag >> 16 );
        tag_offset = ( ( setting->tag >> 8 ) & 0xff );
        tag_len = ( ( setting->tag >> 0 ) & 0xff );

        /* Locate PCI device */
        memset ( &pci, 0, sizeof ( pci ) );
        pci_init ( &pci, tag_busdevfn );
        DBG ( PCI_FMT " reading %#02x+%#x\n", PCI_ARGS ( &pci ),
              tag_offset, tag_len );

        /* Read data one byte at a time, in reverse order (since PCI
         * is little-endian and iPXE settings are essentially
         * big-endian).
         */
        tag_offset += tag_len;
        for ( i = 0 ; ( ( i < tag_len ) && ( i < len ) ); i++ ) {
                pci_read_config_byte ( &pci, --tag_offset, data++ );
        }

        /* Set type to ":hexraw" if not already specified */
        if ( ! setting->type )
                setting->type = &setting_type_hexraw;

        return tag_len;
}
static void pci_settings_init ( void  ) [static]

Initialise PCI device settings.

Definition at line 115 of file pci_settings.c.

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

                                       {
        int rc;

        if ( ( rc = register_settings ( &pci_settings, NULL, "pci" ) ) != 0 ) {
                DBG ( "PCI could not register settings: %s\n",
                      strerror ( rc ) );
                return;
        }
}
struct init_fn pci_settings_init_fn __init_fn ( INIT_NORMAL  ) [read]

PCI device settings initialiser.


Variable Documentation

PCI device settings scope.

Definition at line 39 of file pci_settings.c.

Referenced by pci_settings_applies().

Initial value:
 {
        .applies = pci_settings_applies,
        .fetch = pci_settings_fetch,
}

PCI device settings operations.

Definition at line 100 of file pci_settings.c.

struct settings pci_settings [static]
Initial value:
 {
        .refcnt = NULL,
        .siblings = LIST_HEAD_INIT ( pci_settings.siblings ),
        .children = LIST_HEAD_INIT ( pci_settings.children ),
        .op = &pci_settings_operations,
        .default_scope = &pci_settings_scope,
}

PCI device settings.

Definition at line 106 of file pci_settings.c.