iPXE
Data Structures | Functions
nvsvpd.h File Reference

Non-Volatile Storage using Vital Product Data. More...

#include <ipxe/nvs.h>
#include <ipxe/pcivpd.h>

Go to the source code of this file.

Data Structures

struct  nvs_vpd_device
 An NVS VPD device. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
int nvs_vpd_init (struct nvs_vpd_device *nvsvpd, struct pci_device *pci)
 Initialise NVS VPD device. More...
 
void nvs_vpd_nvo_init (struct nvs_vpd_device *nvsvpd, unsigned int field, struct nvo_block *nvo, struct refcnt *refcnt)
 Initialise non-volatile option storage within NVS VPD device. More...
 

Detailed Description

Non-Volatile Storage using Vital Product Data.

Definition in file nvsvpd.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ nvs_vpd_init()

int nvs_vpd_init ( struct nvs_vpd_device nvsvpd,
struct pci_device pci 
)

Initialise NVS VPD device.

Parameters
nvsvpdNVS VPD device
pciPCI device
Return values
rcReturn status code

Definition at line 178 of file nvsvpd.c.

178  {
179  int rc;
180 
181  /* Initialise VPD device */
182  if ( ( rc = pci_vpd_init ( &nvsvpd->vpd, pci ) ) != 0 ) {
183  DBGC ( pci, PCI_FMT " NVS could not initialise "
184  "VPD: %s\n", PCI_ARGS ( pci ), strerror ( rc ) );
185  return rc;
186  }
187 
188  /* Initialise NVS device */
189  nvsvpd->nvs.read = nvs_vpd_read;
190  nvsvpd->nvs.write = nvs_vpd_write;
191 
192  return 0;
193 }
int(* write)(struct nvs_device *nvs, unsigned int address, const void *data, size_t len)
Write data to device.
Definition: nvs.h:59
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
struct nvs_device nvs
NVS device.
Definition: nvsvpd.h:22
struct pci_vpd vpd
PCI VPD device.
Definition: nvsvpd.h:24
int(* read)(struct nvs_device *nvs, unsigned int address, void *data, size_t len)
Read data from device.
Definition: nvs.h:47
static int nvs_vpd_read(struct nvs_device *nvs, unsigned int field, void *data, size_t len)
Read from VPD field.
Definition: nvsvpd.c:49
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define PCI_FMT
PCI device debug message format.
Definition: pci.h:287
static int nvs_vpd_write(struct nvs_device *nvs, unsigned int field, const void *data, size_t len)
Write to VPD field.
Definition: nvsvpd.c:101
#define PCI_ARGS(pci)
PCI device debug message arguments.
Definition: pci.h:290
int pci_vpd_init(struct pci_vpd *vpd, struct pci_device *pci)
Initialise PCI Vital Product Data.
Definition: pcivpd.c:48

References DBGC, nvs_vpd_device::nvs, nvs_vpd_read(), nvs_vpd_write(), PCI_ARGS, PCI_FMT, pci_vpd_init(), rc, nvs_device::read, strerror(), nvs_vpd_device::vpd, and nvs_device::write.

Referenced by hermon_probe().

◆ nvs_vpd_nvo_init()

void nvs_vpd_nvo_init ( struct nvs_vpd_device nvsvpd,
unsigned int  field,
struct nvo_block nvo,
struct refcnt refcnt 
)

Initialise non-volatile option storage within NVS VPD device.

Parameters
nvsvpdNVS VPD device
fieldVPD field descriptor
nvoNon-volatile options block
refcntContaining object reference counter, or NULL

Definition at line 220 of file nvsvpd.c.

221  {
222  struct pci_device *pci = nvsvpd->vpd.pci;
223  unsigned int address;
224  size_t len;
225  int rc;
226 
227  /* Locate VPD field, if present */
228  if ( ( rc = pci_vpd_find ( &nvsvpd->vpd, field, &address,
229  &len ) ) != 0 ) {
230  DBGC ( pci, PCI_FMT " NVS VPD field " PCI_VPD_FIELD_FMT
231  " not present; assuming empty\n",
232  PCI_ARGS ( pci ), PCI_VPD_FIELD_ARGS ( field ) );
233  len = 0;
234  }
235 
236  /* Initialise non-volatile options block */
237  nvo_init ( nvo, &nvsvpd->nvs, field, len, nvs_vpd_nvo_resize, refcnt );
238 }
int pci_vpd_find(struct pci_vpd *vpd, unsigned int field, unsigned int *address, size_t *len)
Locate PCI VPD field.
Definition: pcivpd.c:353
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint64_t address
Base address.
Definition: ena.h:24
#define DBGC(...)
Definition: compiler.h:505
A reference counter.
Definition: refcnt.h:26
struct nvs_device nvs
NVS device.
Definition: nvsvpd.h:22
#define PCI_VPD_FIELD_FMT
PCI VPD field debug message format.
Definition: pcivpd.h:70
struct pci_vpd vpd
PCI VPD device.
Definition: nvsvpd.h:24
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.
Definition: nvo.c:273
#define PCI_FMT
PCI device debug message format.
Definition: pci.h:287
A PCI device.
Definition: pci.h:187
#define PCI_VPD_FIELD_ARGS(field)
PCI VPD field debug message arguments.
Definition: pcivpd.h:73
static int nvs_vpd_nvo_resize(struct nvo_block *nvo, size_t len)
Resize non-volatile option storage within NVS VPD device.
Definition: nvsvpd.c:202
uint32_t len
Length.
Definition: ena.h:14
struct pci_device * pci
PCI device.
Definition: pcivpd.h:132
#define PCI_ARGS(pci)
PCI device debug message arguments.
Definition: pci.h:290

References address, DBGC, len, nvo_init(), nvs_vpd_device::nvs, nvs_vpd_nvo_resize(), pci_vpd::pci, PCI_ARGS, PCI_FMT, PCI_VPD_FIELD_ARGS, PCI_VPD_FIELD_FMT, pci_vpd_find(), rc, and nvs_vpd_device::vpd.

Referenced by hermon_probe().