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. More...
 
static int pci_settings_fetch (struct settings *settings __unused, struct setting *setting, void *data, size_t len)
 Fetch value of PCI device setting. More...
 
static void pci_settings_init (void)
 Initialise PCI device settings. More...
 
struct init_fn pci_settings_init_fn __init_fn (INIT_NORMAL)
 PCI device settings initialiser. More...
 

Variables

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

Detailed Description

PCI device settings.

Definition in file pci_settings.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ pci_settings_applies()

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.

49  {
50 
51  return ( setting->scope == &pci_settings_scope );
52 }
static const struct settings_scope pci_settings_scope
PCI device settings scope.
Definition: pci_settings.c:39
A setting.
Definition: settings.h:23
const struct settings_scope * scope
Setting scope (or NULL)
Definition: settings.h:49

References pci_settings_scope, and setting::scope.

◆ pci_settings_fetch()

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.

65  {
66  struct pci_device pci;
67  unsigned int tag_busdevfn;
68  unsigned int tag_offset;
69  unsigned int tag_len;
70  unsigned int i;
71 
72  /* Extract busdevfn, offset, and length from tag */
73  tag_busdevfn = ( setting->tag >> 16 );
74  tag_offset = ( ( setting->tag >> 8 ) & 0xff );
75  tag_len = ( ( setting->tag >> 0 ) & 0xff );
76 
77  /* Locate PCI device */
78  memset ( &pci, 0, sizeof ( pci ) );
79  pci_init ( &pci, tag_busdevfn );
80  DBG ( PCI_FMT " reading %#02x+%#x\n", PCI_ARGS ( &pci ),
81  tag_offset, tag_len );
82 
83  /* Read data one byte at a time, in reverse order (since PCI
84  * is little-endian and iPXE settings are essentially
85  * big-endian).
86  */
87  tag_offset += tag_len;
88  for ( i = 0 ; ( ( i < tag_len ) && ( i < len ) ); i++ ) {
89  pci_read_config_byte ( &pci, --tag_offset, data++ );
90  }
91 
92  /* Set type to ":hexraw" if not already specified */
93  if ( ! setting->type )
94  setting->type = &setting_type_hexraw;
95 
96  return tag_len;
97 }
uint64_t tag
Setting tag, if applicable.
Definition: settings.h:43
const struct setting_type * type
Setting type.
Definition: settings.h:36
#define PCI_FMT
PCI device debug message format.
Definition: pci.h:307
A PCI device.
Definition: pci.h:206
A setting.
Definition: settings.h:23
uint32_t len
Length.
Definition: ena.h:14
#define PCI_ARGS(pci)
PCI device debug message arguments.
Definition: pci.h:310
uint8_t data[48]
Additional event data.
Definition: ena.h:22
static void pci_init(struct pci_device *pci, unsigned int busdevfn)
Initialise PCI device.
Definition: pci.h:334
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
void * memset(void *dest, int character, size_t len) __nonnull
int pci_read_config_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.

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

◆ pci_settings_init()

static void pci_settings_init ( void  )
static

Initialise PCI device settings.

Definition at line 115 of file pci_settings.c.

115  {
116  int rc;
117 
118  if ( ( rc = register_settings ( &pci_settings, NULL, "pci" ) ) != 0 ) {
119  DBG ( "PCI could not register settings: %s\n",
120  strerror ( rc ) );
121  return;
122  }
123 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static struct settings pci_settings
PCI device settings.
Definition: pci_settings.c:106
int register_settings(struct settings *settings, struct settings *parent, const char *name)
Register settings block.
Definition: settings.c:475
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

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

◆ __init_fn()

struct init_fn pci_settings_init_fn __init_fn ( INIT_NORMAL  )

PCI device settings initialiser.

Variable Documentation

◆ pci_settings_scope

const struct settings_scope pci_settings_scope
static

PCI device settings scope.

Definition at line 39 of file pci_settings.c.

Referenced by pci_settings_applies().

◆ pci_settings_operations

struct settings_operations pci_settings_operations
static
Initial value:
= {
}
static int pci_settings_applies(struct settings *settings __unused, const struct setting *setting)
Check applicability of PCI device setting.
Definition: pci_settings.c:48
static int pci_settings_fetch(struct settings *settings __unused, struct setting *setting, void *data, size_t len)
Fetch value of PCI device setting.
Definition: pci_settings.c:63

PCI device settings operations.

Definition at line 100 of file pci_settings.c.

◆ pci_settings

struct settings pci_settings
static
Initial value:
= {
.refcnt = NULL,
.default_scope = &pci_settings_scope,
}
static struct settings_operations pci_settings_operations
PCI device settings operations.
Definition: pci_settings.c:100
static const struct settings_scope pci_settings_scope
PCI device settings scope.
Definition: pci_settings.c:39
static struct settings pci_settings
PCI device settings.
Definition: pci_settings.c:106
struct list_head siblings
Sibling settings blocks.
Definition: settings.h:140
struct list_head children
Child settings blocks.
Definition: settings.h:142
#define LIST_HEAD_INIT(list)
Initialise a static list head.
Definition: list.h:30
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

PCI device settings.

Definition at line 106 of file pci_settings.c.

Referenced by pci_settings_init().